/* Епізод-чат (chat_episode) і голосове повідомлення (voiceMessage) — js/trainers9.js, 17.10.2026.
   Лише токени з css/theme.css — працює у світлій і темній темі та з будь-яким кольором кабінету.
   Класи: ce-* — телефон і чат, vm-* — голосове. */

/* ---------------- сцена й кнопки ---------------- */
.ce-stage { display: flex; justify-content: center; gap: 22px; margin: 16px 0 6px; }
.ce-stage.ce-two { display: grid; grid-template-columns: repeat(2, minmax(0, 340px)); justify-content: center; }
.ce-col { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; width: 100%; max-width: 360px; }
.ce-owner { font-size: 13px; color: var(--ink-soft); }
.ce-owner b { color: var(--ink); font-weight: 800; }
.ce-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 12px; }
.ce-tip { margin-right: auto; font-size: 13.5px; color: var(--ink-soft); }
.ce-count { font-size: 12px; font-weight: 800; letter-spacing: .06em; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
@media (max-width: 699px) {
  .ce-stage.ce-two { grid-template-columns: minmax(0, 360px); }
  .ce-tip { flex-basis: 100%; }
}

/* ---------------- телефон ---------------- */
.ce-phone { width: 100%; padding: 9px; border-radius: 42px; background: var(--surface-2);
  border: 1.5px solid var(--line-strong); box-shadow: var(--shadow-2), inset 0 0 0 1px var(--line); }
.ce-screen { position: relative; height: min(600px, 76vh); min-height: 440px; border-radius: 33px; overflow: hidden;
  display: flex; flex-direction: column; background: var(--page); border: 1px solid var(--line); }
.ce-status { display: flex; align-items: center; justify-content: space-between; padding: 10px 22px 4px; font: 800 13px var(--font);
  color: var(--ink); font-variant-numeric: tabular-nums; position: relative; z-index: 3; }
.ce-sicons { display: inline-flex; gap: 5px; align-items: center; }
.ce-sicons svg { height: 11px; width: auto; fill: currentColor; }
.ce-head { display: flex; align-items: center; gap: 9px; padding: 8px 12px 10px; background: var(--surface);
  border-bottom: 1px solid var(--line); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }
.ce-back svg { width: 20px; height: 20px; color: var(--mag); display: block; }
.ce-ava { width: 36px; height: 36px; flex: none; border-radius: 50%; display: grid; place-items: center; overflow: hidden;
  background: var(--mag-soft); color: var(--mag); border: 1px solid var(--mag-line); font: 800 15px var(--font); }
.ce-ava img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ce-who { min-width: 0; flex: 1; }
.ce-who > b { display: block; font-size: 15px; font-weight: 800; color: var(--ink); line-height: 1.2; }
.ce-zones { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.ce-zone { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px 2px 5px; border-radius: 999px; font-size: 11px;
  color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.ce-zone svg { width: 11px; height: 11px; }
.ce-zone b { color: var(--ink); font-weight: 800; font-variant-numeric: tabular-nums; }
.ce-zone-me { background: var(--mag-soft); border-color: var(--mag-line); }
.ce-zone-me b { color: var(--mag); }

/* ---------------- стрічка ---------------- */
.ce-feed { flex: 1; overflow-y: auto; padding: 14px 12px 10px; display: flex; flex-direction: column; gap: 6px; scrollbar-width: thin; }
.ce-day { align-self: center; margin: 10px 0 4px; animation: ce-in .28s ease both; }
.ce-day span { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line, transparent); }
.ce-row { display: flex; flex-direction: column; max-width: 82%; animation: ce-in .28s cubic-bezier(.2, .9, .3, 1.3) both; }
.ce-mine { align-self: flex-end; align-items: flex-end; }
.ce-them { align-self: flex-start; align-items: flex-start; }
.ce-b { position: relative; padding: 8px 12px 6px; border-radius: 20px; font-size: 15px; line-height: 1.4; overflow-wrap: anywhere; }
.ce-them .ce-b { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 6px; box-shadow: var(--shadow-1); }
.ce-mine .ce-b { background: var(--mag); color: var(--on-mag); border-bottom-right-radius: 6px; box-shadow: var(--shadow-mag); }
.ce-b .tf-text { white-space: pre-wrap; }
.ce-time { display: block; text-align: right; font-size: 10.5px; margin-top: 2px; opacity: .62; font-variant-numeric: tabular-nums; }
.ce-big { background: transparent !important; border: 0 !important; box-shadow: none !important; padding: 0 2px; font-size: 40px; line-height: 1.1; }
.ce-big .ce-time { font-size: 10.5px; color: var(--ink-faint); opacity: 1; }
.ce-seen { align-self: flex-end; font-size: 11px; font-weight: 700; color: var(--ink-faint); margin: -2px 4px 4px; animation: ce-fade .3s both; }

/* «typing…» */
.ce-typing .ce-b { padding: 11px 14px; }
.ce-dots { display: inline-flex; gap: 4px; }
.ce-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-soft); animation: ce-dot 1.1s infinite ease-in-out; }
.ce-dots i:nth-child(2) { animation-delay: .15s; }
.ce-dots i:nth-child(3) { animation-delay: .3s; }
.ce-tlabel { font-size: 11px; color: var(--ink-faint); margin: 3px 6px 0; font-style: italic; }

/* фото */
.ce-pic { padding: 4px !important; }
.ce-img { display: block; width: 100%; max-width: 230px; min-height: 80px; border-radius: 16px; object-fit: cover; background: var(--surface-2); }
.ce-img.ce-broken { min-height: 60px; }
.ce-cap { padding: 4px 8px 2px; font-size: 14.5px; }
.ce-cap:empty { display: none; }

/* відео-посилання */
.ce-vid { padding: 4px !important; width: 236px; max-width: 100%; }
.ce-vlink { display: block; text-decoration: none; color: inherit; border-radius: 16px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.ce-mine .ce-vlink { background: color-mix(in srgb, var(--on-mag) 16%, transparent); border-color: color-mix(in srgb, var(--on-mag) 25%, transparent); }
.ce-thumb { position: relative; display: block; aspect-ratio: 16 / 9; background: var(--solid); }
.ce-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ce-vplay { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px; border-radius: 50%;
  display: grid; place-items: center; background: var(--mag); box-shadow: var(--shadow-mag); transition: transform .15s; }
.ce-vplay svg { width: 22px; height: 22px; fill: var(--on-mag); margin-left: 2px; }
.ce-vlink:hover .ce-vplay { transform: scale(1.1); }
.ce-vtext { display: block; padding: 8px 10px; }
.ce-vtext b { display: block; font-size: 14px; font-weight: 800; line-height: 1.3; }
.ce-vtext small { display: block; font-size: 11px; opacity: .7; margin-top: 2px; }

/* поле вводу — декорація */
.ce-input { display: flex; align-items: center; gap: 8px; margin: 6px 10px 12px; padding: 9px 9px 9px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink-faint); font-size: 14px; }
.ce-input span { flex: 1; }
.ce-input i { width: 28px; height: 28px; border-radius: 50%; background: var(--mag-soft); border: 1px solid var(--mag-line); }

/* ---------------- заблокований екран ---------------- */
.ce-lock { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; padding: 64px 14px 18px; cursor: pointer;
  /* суцільний фон: у темній темі --surface-2 напівпрозорий, і крізь нього просвічувала шапка чату */
  background: radial-gradient(420px 320px at 50% 18%, var(--mag-soft), transparent 70%), linear-gradient(var(--surface-2), var(--surface-2)), var(--page);
  transition: transform .42s cubic-bezier(.6, 0, .3, 1), opacity .42s; }
.ce-lock[hidden] { display: none; }
.ce-lock.ce-unlock { transform: translateY(-100%); opacity: .4; pointer-events: none; }
.ce-lclock { font: 300 64px/1 var(--font); letter-spacing: -2px; color: var(--ink); font-variant-numeric: tabular-nums; }
.ce-lcity { font-size: 13px; font-weight: 700; color: var(--ink-soft); margin-top: 8px; letter-spacing: .04em; }
.ce-notif { margin-top: 34px; width: 100%; text-align: left; border: 1px solid var(--line); border-radius: 22px; padding: 11px 13px 12px;
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2); cursor: pointer; font: inherit;
  animation: ce-drop .55s .25s cubic-bezier(.2, .9, .3, 1.3) both; transition: transform .15s, box-shadow .15s; }
.ce-notif:hover { transform: translateY(-2px); box-shadow: var(--shadow-2), var(--glow); }
.ce-notif:focus-visible { outline: 2px solid var(--mag); outline-offset: 2px; }
.ce-nhead { display: flex; align-items: center; gap: 8px; }
.ce-nhead .ce-ava { width: 26px; height: 26px; font-size: 12px; }
.ce-nhead b { font-size: 14px; font-weight: 800; }
.ce-nhead small { margin-left: auto; font-size: 11px; color: var(--ink-faint); }
.ce-ntext { display: block; margin-top: 5px; font-size: 14.5px; line-height: 1.4; }
.ce-swipe { margin-top: auto; width: 120px; height: 5px; border-radius: 999px; background: var(--ink); opacity: .35; }

/* =====================================================================
   Голосове повідомлення
   ===================================================================== */
.vm { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.ce-mine .vm { align-items: flex-end; }
.vm-bubble { display: flex; align-items: center; gap: 10px; width: 250px; max-width: 100%; padding: 9px 10px 8px 9px; border-radius: 22px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-1); }
.ce-them .vm-bubble { border-bottom-left-radius: 6px; }
.vm-mine .vm-bubble { background: var(--mag); color: var(--on-mag); border-color: transparent; box-shadow: var(--shadow-mag); border-bottom-right-radius: 6px; }
.vm-play { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 0; padding: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--mag); color: var(--on-mag); box-shadow: 0 3px 0 var(--depth-mag, var(--mag-line)); transition: transform .12s; }
.vm-play svg { width: 20px; height: 20px; fill: currentColor; }
.vm-play:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--depth-mag, var(--mag-line)); }
.vm-mine .vm-play { background: var(--on-mag); color: var(--mag); box-shadow: 0 3px 0 color-mix(in srgb, var(--on-mag) 45%, transparent); }
.vm-on .vm-play { animation: ec-pulse-vm 1.4s infinite; }
.vm-mid { flex: 1; min-width: 0; }
.vm-wave { display: flex; align-items: center; gap: 2px; height: 30px; }
.vm-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .28; transition: opacity .12s, transform .12s; }
.vm-wave i.on { opacity: 1; }
.vm-them .vm-wave i.on, .vm:not(.vm-mine) .vm-wave i.on { background: var(--mag); }
.vm-on .vm-wave i.on:last-of-type { transform: scaleY(1.15); }
.vm-meta { display: flex; justify-content: space-between; font-size: 11px; opacity: .7; margin-top: 2px; font-variant-numeric: tabular-nums; }
.vm-speed { flex: none; min-width: 44px; height: 28px; padding: 0 8px; border-radius: 999px; cursor: pointer; font: 800 12px var(--font);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--line-strong); box-shadow: none; }
.vm-mine .vm-speed { background: color-mix(in srgb, var(--on-mag) 18%, transparent); color: var(--on-mag); border-color: color-mix(in srgb, var(--on-mag) 40%, transparent); }
.vm-speed:focus-visible, .vm-play:focus-visible, .vm-opt:focus-visible, .vm-show:focus-visible { outline: 2px solid var(--mag); outline-offset: 2px; }

.vm-tr { width: 250px; max-width: 100%; padding: 9px 12px; border-radius: 16px; font-size: 14.5px; line-height: 1.45; color: var(--ink);
  background: var(--surface-2); border: 1px dashed var(--line-strong); }
.vm-tr[hidden] { display: none; }
.vm-tr.vm-open { animation: ce-in .3s both; }

.vm-show { align-self: inherit; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-soft); border-radius: 999px;
  padding: 5px 12px; font: 700 12px var(--font); cursor: pointer; box-shadow: none; }
.vm-show:hover { color: var(--mag); border-color: var(--mag); }

.vm-q { width: 270px; max-width: 100%; padding: 11px 12px 10px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--mag-line);
  box-shadow: var(--shadow-1); text-align: left; }
.vm-qh { font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--mag); }
.vm-qq { font-size: 14.5px; font-weight: 700; color: var(--ink); margin: 4px 0 8px; line-height: 1.35; }
.vm-opts { display: flex; flex-direction: column; gap: 7px; }
.vm-opt { text-align: left; padding: 9px 12px; border-radius: 14px; cursor: pointer; font: 700 14px var(--font); color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line-strong); box-shadow: 0 3px 0 var(--depth, var(--line-strong));
  transition: transform .1s, box-shadow .1s, background .15s; }
.vm-opt:hover:not(:disabled) { border-color: var(--mag); }
.vm-opt:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--depth, var(--line-strong)); }
.vm-opt:disabled { cursor: default; }
.vm-opt.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); box-shadow: 0 3px 0 var(--depth-ok, var(--ok-line)); animation: tr-pop .35s; }
.vm-opt.wrong { background: var(--bad-soft); border-color: var(--bad-line); color: var(--bad); box-shadow: none; animation: tr-shake .4s; opacity: .8; }
.vm-opt:disabled:not(.right):not(.wrong) { opacity: .55; }
.vm-fb { font-size: 12.5px; color: var(--ink-soft); margin-top: 8px; min-height: 1em; }

/* ---------------- рух ---------------- */
@keyframes ce-in { from { opacity: 0; transform: translateY(10px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes ce-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ce-drop { from { opacity: 0; transform: translateY(-24px) scale(.95); } to { opacity: 1; transform: none; } }
@keyframes ce-dot { 0%, 80%, 100% { opacity: .3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@keyframes ec-pulse-vm { 0% { box-shadow: 0 0 0 0 var(--mag-line); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) {
  .ce-row, .ce-notif, .vm-tr.vm-open, .ce-seen, .ce-day { animation: none; }
  .ce-dots i, .vm-on .vm-play { animation: none; }
  .ce-lock { transition: none; }
}

/* переписка в застосунку для знайомств (chat_episode.app) */
.ce-appname { display: block; font-size: 11px; font-weight: 700; color: var(--mag); letter-spacing: .02em; }
.ce-appic { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--mag); color: var(--on-mag); font-size: 12px; font-weight: 800; }
.ce-nmatch { display: block; margin-top: 6px; font-size: 13px; font-weight: 800; color: var(--mag); }
.ce-ntext b { font-weight: 800; }
.ce-match { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding: 10px 12px 14px; margin-bottom: 6px; }
.ce-match b { font-size: 17px; font-weight: 800; color: var(--mag); }
.ce-match small { font-size: 12px; color: var(--ink-soft); }
.ce-mavas { display: flex; margin-bottom: 4px; }
.ce-mavas .ce-ava { width: 52px; height: 52px; font-size: 20px; box-shadow: 0 0 0 3px var(--surface), var(--glow); }
.ce-mavas .ce-ava + .ce-ava { margin-left: -12px; }
