/* AI conversation: the voice screen (templates/ai/_talk.html, static/js/talk.js) and the text chat's finishing touches.
   Soft Precision tokens only (app.css :root), logical properties (RTL first), motion on transform/opacity (plus a
   background-color fade on the small core); html[data-motion="0"] and prefers-reduced-motion stop every loop. */

.tutor-home, .talk-chat, .talk {
  --voice-night: #172345;
  --voice-white: #f7fffd;
  --voice-mint: #bef3e1;
  --voice-frost: rgb(190 243 225 / .24);
  --voice-accent: var(--indigo);
}

/* ---------------------------------------------------------------- text chat (the bar, composer and sheet are in tools.css) */
.talk-chat .msg.fresh, .talk-chat .msg.learner:last-child { animation: talk-rise .32s var(--ease-out) both; }
@keyframes talk-rise { from { opacity: 0; transform: translateY(6px); } }
.talk-chat .play-btn.mine { justify-self: start; display: inline-flex; gap: 4px; align-items: center; min-block-size: 30px;
  padding-inline: 8px 10px; border-radius: 999px; font-size: var(--fs-xs); }
.talk-chat .fix-card { border-inline-start: 3px solid var(--saffron); }
.talk-chat .fix del { text-decoration-color: var(--bad); }
.talk-chat .fix ins { text-decoration: none; color: var(--ok); font-weight: 600; }
.voice-start { display: inline-flex; gap: 6px; align-items: center; }

.talk-chat .chat-bar .wrap { max-inline-size: 760px; }
.talk-chat .cb-in { gap: 8px; min-block-size: 64px; }
.talk-chat .cb-actions { gap: 6px; }
.talk-chat .cb-actions > button, .talk-chat .cb-in > a { background: var(--fill-q); }
.talk-chat .cb-title-btn { gap: 4px; }
.talk-chat .cb-t { font-size: clamp(.93rem, 2vw + .55rem, 1.15rem); }
.chat-context {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 9px;
  margin-block: 3px 0; padding: 9px 12px; background: var(--accent-soft); color: var(--accent-ink); border-radius: var(--r-ctl);
}
.chat-context .ic { inline-size: 18px; block-size: 18px; }
.chat-context .chat-scene { margin: 0; color: var(--ink); text-align: start; font-size: var(--fs-sm); line-height: 1.4; }
.talk-chat .composer-wrap {
  border-inline: 1px solid var(--hair); border-block-start: 1px solid var(--hair);
  border-start-start-radius: var(--r-card); border-start-end-radius: var(--r-card);
}
.chat-voice-action {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 9px;
  min-block-size: 48px; inline-size: 100%; padding: 8px 13px; border: 1px solid transparent; border-radius: var(--r-ctl);
  background: var(--voice-accent); color: var(--on-accent); font: inherit; font-weight: 700; line-height: 1.4;
  text-align: start; text-decoration: none; cursor: pointer; touch-action: manipulation;
  transition: transform var(--dur-1) var(--ease-out);
}
.chat-voice-action[hidden], .talk-chat .cs-row[hidden], .talk-chat .mic-btn[hidden], .talk-go[hidden] { display: none; }
.chat-voice-action .ic { inline-size: 20px; block-size: 20px; }
.chat-voice-action :last-child { opacity: .8; }
.chat-voice-action:active { transform: var(--press); }
.chat-voice-action:focus-visible { outline: var(--ring-w) solid var(--ring); outline-offset: 2px; }
.talk-chat .composer input[type="text"] { border-radius: var(--r-ctl); }
.talk-chat .mic-btn { color: var(--accent-ink); background: var(--accent-soft); }
.talk-chat .mic-btn.on { color: var(--on-accent); background: var(--bad); }

@media (min-width: 760px) {
  .talk-chat .composer-wrap { margin-inline: 0; padding-inline: 12px; }
}

/* streamed turn: the partner's words land in a bubble as they are written; the typing dots show before the first */
.typing.on { display: grid; }
.msg.streaming .bubble p::after { content: ""; display: inline-block; inline-size: .45em; block-size: 1em; margin-inline-start: 2px; vertical-align: -2px;
  background: var(--ink-2); opacity: .5; border-radius: 2px; animation: zs-dot 1s infinite ease-in-out; }
html[data-motion="0"] .msg.streaming .bubble p::after { animation: none; }
.chat-err { margin: 0; padding: 8px 12px; border-radius: var(--r-md); background: color-mix(in srgb, var(--saffron) 16%, var(--card)); font-size: var(--fs-sm); }
.chat-err[hidden] { display: none; }

/* instant feedback: a calm mark beside each learner bubble, an inline card under it (never a red "wrong" state); the
   «تصحیح فوری» switch itself is a row of the options sheet (tools.css .cs-row) */
.l-row { display: flex; align-items: flex-end; gap: 4px; max-inline-size: 100%; }
.l-row .bubble { min-inline-size: 0; }
.fb-mark { position: relative; flex: none; display: grid; place-items: center; inline-size: 28px; block-size: 28px; padding: 0; border: 0; border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 6%, transparent); color: var(--ok); cursor: pointer; transition: background-color .2s, transform .2s var(--ease-out); }
.fb-mark::after { content: ""; position: absolute; inset: -8px; }  /* a 44px touch target around the small mark */
.fb-mark .ic { inline-size: 16px; block-size: 16px; }
.fb-mark.fix i { display: block; inline-size: 10px; block-size: 10px; border-radius: 50%; background: var(--saffron); box-shadow: 0 0 0 3px color-mix(in srgb, var(--saffron) 25%, transparent); }
.fb-mark[aria-expanded="true"] { background: color-mix(in srgb, var(--ink) 12%, transparent); }
.fb-mark:focus-visible { outline: var(--ring-w) solid var(--ring); outline-offset: 2px; }
.msg.fresh .fb-mark, .fb-mark.fresh { animation: talk-rise .3s var(--ease-out) both; }
.fb-card { display: grid; gap: 6px; inline-size: min(100%, 34rem); padding: 10px 12px; border-radius: var(--r-md); background: var(--card); border: 1px solid var(--hair);
  border-inline-start: 3px solid var(--saffron); font-size: var(--fs-sm); line-height: 1.7; box-shadow: var(--e1); animation: talk-rise .28s var(--ease-out) both; }
.fb-card[hidden] { display: none; }
.msg[data-status="ok"] .fb-card { border-inline-start-color: var(--ok); }
.fb-k { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--ink-2); font-size: var(--fs-xs); font-weight: 700; }
.fb-k .ic { inline-size: 14px; block-size: 14px; }
.fb-you, .fb-fix, .fb-more > span { direction: ltr; text-align: left; margin: 0; font-family: var(--f-display); font-size: var(--fs-base); }
.fb-you { color: var(--ink-2); }
.fb-q { background: none; color: inherit; text-decoration: underline wavy color-mix(in srgb, var(--saffron) 85%, var(--ink)); text-decoration-thickness: 2px; text-underline-offset: 3px; }
.fb-fix { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.fb-fix ins { text-decoration: none; color: var(--ok); font-weight: 700; background: color-mix(in srgb, var(--ok) 10%, transparent); border-radius: 4px; padding-inline: 3px; }
.fb-fix .play-btn { min-block-size: 32px; min-inline-size: 32px; padding-inline: 8px; font-size: var(--fs-xs); }
.fb-why { margin: 0; }
.fb-more { margin: 0; color: var(--ink-2); }
.fb-more del { color: var(--ink-2); } .fb-more ins { text-decoration: none; color: var(--ok); font-weight: 600; }
.fb-retry { display: grid; gap: 4px; margin-block-start: 2px; }
.fb-retry-row { display: flex; gap: 6px; align-items: center; }
.fb-retry-row input { flex: 1; min-inline-size: 0; min-block-size: var(--ctl); border-radius: 999px; padding-inline: 14px; }
.fb-retry-row .btn { white-space: nowrap; }
.fb-mic { inline-size: var(--ctl); flex: none; }
.fb-mic.on { background: var(--bad); color: #fff; }
.fb-result { margin: 0; min-block-size: 1.4em; color: var(--ink-2); }
.fb-result.ok { color: var(--ok); font-weight: 700; }
.fb-retry.done input { border-color: var(--ok); }
.fb-better summary { cursor: pointer; min-block-size: 44px; display: flex; align-items: center; color: var(--accent-ink); font-weight: 600; }
.word-chip { margin-block-start: 6px; direction: rtl; }
.word-chip[hidden] { display: none; }
.word-chip .btn { min-block-size: 36px; }
.bubble.partner p[data-words] { cursor: text; }

/* the hint ladder: a starter, then full replies with their meaning, then «فارسی بگو» */
.hint-ladder .rung { display: grid; gap: 6px; }
.hint-ladder .rung[hidden] { display: none; }
.hint-ladder .sugg { display: grid; gap: 2px; }
.sugg-fa { display: block; direction: rtl; text-align: start; color: var(--ink-2); font-size: var(--fs-xs); }
.fa-box { display: grid; gap: 4px; }
.fa-box input { min-block-size: var(--ctl); border-radius: 999px; padding-inline: 14px; }
.sum-corrected { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.sum-corrected ins { text-decoration: none; color: var(--ok); font-weight: 600; }
.sum-corrected .play-btn { min-block-size: 32px; padding-inline: 8px; font-size: var(--fs-xs); }
@media (max-width: 420px) { .fb-retry-row { flex-wrap: wrap; } .fb-retry-row input { flex-basis: 100%; } }

/* ================================================================ the voice screen
   One focal element (the presence) over a quiet ground; the state is told by colour (indigo = the partner's turn,
   teal = yours, grey = off), by one line of text, and by motion that morphs rather than cuts. The microphone level
   moves the rings through inline transforms written by talk.js (no CSS variable animation). */
body.talk-open { overflow: hidden; }
.talk { --pc: var(--indigo); --yc: var(--teal); --talk-c: var(--pc); --sz: min(54vw, 30vh, 220px);
  position: fixed; inset: 0; z-index: 80; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto auto; row-gap: 4px;
  color: var(--ink); background: var(--paper);
  padding: max(8px, var(--safe-t)) max(var(--gutter), var(--safe-r)) max(12px, var(--safe-b)) max(var(--gutter), var(--safe-l));
  opacity: 0; transform: translateY(16px) scale(.985); transform-origin: 50% 85%;
  transition: opacity .3s var(--ease-out), transform .5s var(--spring); overscroll-behavior: contain; }
.talk[hidden] { display: none; }
.talk.in { opacity: 1; transform: none; }
.talk.out { opacity: 0; pointer-events: none; transform: translateY(16px) scale(.985); transition: opacity .22s var(--ease-std), transform .26s var(--ease-std); }
.talk[data-state="listening"], .talk[data-state="hearing"] { --talk-c: var(--yc); }
.talk[data-state="muted"], .talk[data-state="paused"] { --talk-c: var(--line); }
.talk-bg { position: absolute; inset: 0; z-index: 0; pointer-events: none; opacity: 0; transition: opacity .7s var(--ease-std); }
.talk-bg-partner { background: radial-gradient(72% 46% at 50% 34%, color-mix(in srgb, var(--indigo) 15%, transparent), transparent 72%); opacity: 1; }
.talk-bg-you { background: radial-gradient(72% 46% at 50% 34%, color-mix(in srgb, var(--teal) 13%, transparent), transparent 72%); }
.talk[data-state="listening"] .talk-bg-you, .talk[data-state="hearing"] .talk-bg-you { opacity: 1; }
.talk[data-state="listening"] .talk-bg-partner, .talk[data-state="hearing"] .talk-bg-partner,
.talk[data-state="muted"] .talk-bg-partner, .talk[data-state="paused"] .talk-bg-partner { opacity: 0; }
.talk-top, .talk-stage, .talk-cap, .talk-help, .talk-dock-wrap { position: relative; z-index: 1; }  /* the in-flow rows sit over the tints */
.talk :is(button, input):focus-visible { outline: var(--ring-w) solid var(--ring); outline-offset: 2px; }

/* top bar: back to the text chat, the scenario, the clock, settings */
.talk-top { display: flex; align-items: center; gap: 8px; min-block-size: 48px; }
.talk-who { flex: 1; min-inline-size: 0; text-align: center; }
.talk-who h2 { margin: 0; font-size: var(--fs-base); font-weight: 700; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.talk-who p { margin: 0; display: inline-flex; gap: 6px; align-items: center; color: var(--ink-2); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; }
.talk-dot { inline-size: 3px; block-size: 3px; border-radius: 50%; background: currentColor; opacity: .6; }
.talk-ic { display: grid; place-items: center; inline-size: 44px; block-size: 44px; border: 0; border-radius: 50%; padding: 0; flex: none;
  background: var(--fill-q); color: var(--ink); cursor: pointer; touch-action: manipulation; transition: background-color .2s, transform .15s var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .talk-ic:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); } }
.talk-ic:active { transform: var(--press); }
.talk-ic .ic { inline-size: 20px; block-size: 20px; }

/* settings: an inset grouped list that drops from the gear (anchored to its trigger) */
.talk-opts { position: absolute; z-index: 5; inset-block-start: calc(max(8px, var(--safe-t)) + 52px); inset-inline-end: max(var(--gutter), var(--safe-r));
  inline-size: min(100% - 2 * var(--gutter), 24rem); display: grid; padding: 4px; border-radius: var(--r-pop); background: var(--card); box-shadow: var(--e2);
  max-block-size: calc(100dvh - 120px - var(--safe-t) - var(--safe-b)); overflow-y: auto; overscroll-behavior: contain;
  transform-origin: 90% 0; animation: talk-pop .28s var(--ease-out) both; }
[dir="ltr"] .talk-opts { transform-origin: 10% 0; }
.talk-opts[hidden] { display: none; }
@keyframes talk-pop { from { opacity: 0; transform: scale(.94) translateY(-6px); } }
.talk-switch { display: flex; justify-content: space-between; gap: 14px; align-items: center; min-block-size: 48px; padding: 10px 12px; border-radius: var(--r-sm); cursor: pointer; }
.talk-switch + .talk-switch { position: relative; }
.talk-switch + .talk-switch::before { content: ""; position: absolute; inset-block-start: 0; inset-inline: 12px; block-size: 1px; background: var(--hair); }
@media (hover: hover) and (pointer: fine) { .talk-switch:hover { background: var(--fill-q); } }
.talk-switch > span { display: grid; gap: 2px; min-inline-size: 0; }
.talk-switch b { font-size: var(--fs-sm); }
.talk-switch small { color: var(--ink-2); font-size: var(--fs-xs); line-height: 1.6; }
.talk-switch input { appearance: none; -webkit-appearance: none; flex: none; position: relative; inline-size: 51px; block-size: 31px; margin: 0;
  border-radius: 999px; background: color-mix(in srgb, var(--ink) 16%, transparent); cursor: pointer; transition: background-color .25s var(--ease-std); }
.talk-switch input::after { content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px; inline-size: 27px; block-size: 27px;
  border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgb(0 0 0 / .18), 0 0 0 .5px rgb(0 0 0 / .06); transition: transform .3s var(--spring); }
.talk-switch input:checked { background: var(--ok); }
.talk-switch input:checked::after { transform: translateX(-20px); }
[dir="ltr"] .talk-switch input:checked::after { transform: translateX(20px); }
.talk-switch input:disabled { opacity: .45; }

/* the presence: a halo, two rings and a core. Colour follows --talk-c; rings follow the microphone (inline transforms). */
.talk-stage { display: grid; place-items: center; align-content: center; gap: 22px; min-block-size: 0; padding-block: 8px; }
.presence { position: relative; display: grid; place-items: center; inline-size: var(--sz); aspect-ratio: 1; border: 0; padding: 0; background: none;
  border-radius: 50%; cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; transition: transform .2s var(--ease-out); }
.presence:active { transform: scale(.97); }
.presence > * { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; }
.pr-halo { background: radial-gradient(circle, color-mix(in srgb, var(--talk-c) 34%, transparent), transparent 66%); opacity: .6; transform: scale(1.3);
  transition: opacity .6s var(--ease-std); will-change: transform; }
.pr-ring { border: 1.5px solid color-mix(in srgb, var(--talk-c) 60%, transparent); opacity: 0; transform: scale(1.02); transition: opacity .35s var(--ease-std); will-change: transform, opacity; }
.pr-ring-2 { border-width: 1px; }
/* the base is deepened on purpose: dark mode's accents are pale, and white light on a pale disc reads as flat */
.pr-core { inset: 15%; overflow: hidden; background-color: color-mix(in srgb, var(--talk-c) 72%, #141a4a);
  box-shadow: inset 0 -22px 40px rgb(8 10 40 / .4), inset 0 2px 8px rgb(255 255 255 / .42), 0 22px 44px -14px color-mix(in srgb, var(--talk-c) 70%, transparent);
  transition: background-color .5s var(--ease-std), box-shadow .5s var(--ease-std), opacity .4s; }
.pr-core > .ic { position: absolute; inset: 24%; inline-size: 52%; block-size: 52%; color: var(--voice-white); }
.pr-light, .pr-sheen { position: absolute; pointer-events: none; }  /* children of the core, so .presence > * does not place them */
.pr-light { inset: 0; background: radial-gradient(circle at 32% 24%, rgb(255 255 255 / .62), rgb(255 255 255 / 0) 50%),
  radial-gradient(circle at 70% 84%, color-mix(in srgb, var(--talk-c) 50%, #fff), transparent 44%); }
.pr-sheen { inset: -30%; background: conic-gradient(from 0deg, transparent 0 55%, rgb(255 255 255 / .38) 72%, transparent 88%); opacity: 0; transition: opacity .4s; }
/* idle / ready: a slow breath */
.presence[data-state="idle"] .pr-halo, .presence[data-state="ready"] .pr-halo { animation: pr-breathe 4.4s var(--ease-std) infinite alternate; }
@keyframes pr-breathe { from { transform: scale(1.22); opacity: .4; } to { transform: scale(1.42); opacity: .65; } }
/* listening / hearing: the rings wake and follow your voice (talk.js) */
.presence[data-state="listening"] .pr-ring, .presence[data-state="hearing"] .pr-ring { opacity: .85; }
.presence[data-state="listening"] .pr-ring-2 { opacity: .35; }
.presence[data-state="hearing"] .pr-ring-2 { opacity: .55; }
/* thinking: a sheen circles the core */
.presence[data-state="thinking"] .pr-sheen { opacity: 1; animation: pr-spin 1.5s linear infinite; }
@keyframes pr-spin { to { transform: rotate(1turn); } }
.presence[data-state="thinking"] .pr-core { animation: pr-pulse 1.3s var(--ease-std) infinite alternate; }
@keyframes pr-pulse { from { transform: scale(.985); } to { transform: scale(1.02); } }
/* speaking: the core breathes in cadence, the halo swells, a soft ripple leaves it */
.presence[data-state="speaking"] .pr-core { animation: pr-talk 1.1s var(--ease-std) infinite alternate; }
@keyframes pr-talk { from { transform: scale(.975); } 45% { transform: scale(1.035); } to { transform: scale(.995); } }
.presence[data-state="speaking"] .pr-halo { animation: pr-swell 1.1s var(--ease-std) infinite alternate; }
@keyframes pr-swell { from { transform: scale(1.28); opacity: .5; } to { transform: scale(1.5); opacity: .8; } }
.presence[data-state="speaking"] .pr-ring { animation: pr-ripple 2.4s var(--ease-out) infinite; }
.presence[data-state="speaking"] .pr-ring-2 { animation-delay: -1.2s; }
@keyframes pr-ripple { 0% { transform: scale(1.02); opacity: .55; } 100% { transform: scale(1.48); opacity: 0; } }
/* muted / paused: still and grey */
.presence[data-state="muted"] .pr-halo, .presence[data-state="paused"] .pr-halo { opacity: .22; transform: scale(1.2); }
.presence[data-state="muted"] .pr-core, .presence[data-state="paused"] .pr-core { opacity: .75; box-shadow: inset 0 -18px 32px rgb(0 0 0 / .14), 0 10px 24px -14px rgb(0 0 0 / .3); }
.talk-state { margin: 0; min-block-size: 1.6em; color: var(--ink-2); font-size: var(--fs-md); font-weight: 600; text-align: center; line-height: 1.5;
  max-inline-size: 28rem; text-wrap: balance; transition: opacity .25s; }

/* captions: the partner's line large, yours under it, the correction card when there is one */
.talk-cap { display: grid; gap: 10px; justify-items: center; align-content: end; inline-size: min(100%, 38rem); justify-self: center;
  max-block-size: 36dvh; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; padding-block: 4px 8px; }
.talk-cap::-webkit-scrollbar { display: none; }
.cap-partner { margin: 0; text-align: center; font-family: var(--f-display); font-size: clamp(1.25rem, 1.4vw + 1rem, 1.625rem); font-weight: 600;
  line-height: 1.4; letter-spacing: -.012em; text-wrap: balance; transition: filter .3s, opacity .3s; }
.cap-partner:empty { display: none; }
.cap-partner span { transition: color .35s var(--ease-std), opacity .35s; }
.cap-partner span.cap-said { color: var(--ink-2); opacity: .8; }
.cap-partner span.cap-now { color: var(--ink); }
.cap-partner.cap-live { color: var(--ink-2); }
.talk.no-text .cap-partner:not(.peek) { filter: blur(7px); opacity: .5; cursor: pointer; user-select: none; }
.cap-you { display: grid; gap: 1px; justify-items: center; text-align: center; animation: talk-rise .3s var(--ease-out) both; }
.cap-you[hidden], .cap-fix[hidden] { display: none; }
.cap-k { color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; }
.cap-you p { margin: 0; color: var(--ink-2); font-family: var(--f-display); font-size: var(--fs-base); line-height: 1.5; }
.cap-fix { display: grid; gap: 3px; inline-size: min(100%, 30rem); padding: 10px 14px; border-radius: var(--r-md); background: var(--card); box-shadow: var(--e1);
  border-inline-start: 3px solid var(--saffron); font-size: var(--fs-sm); text-align: start; animation: talk-rise .32s var(--ease-out) both; }
.cap-fix strong { font-size: var(--fs-xs); color: var(--ink-2); }
.cap-fix p { margin: 0; }
.cap-fix .fix { font-family: var(--f-display); font-size: var(--fs-md); text-align: left; }
.cap-fix del { text-decoration-color: var(--bad); color: var(--ink-2); }
.cap-fix ins { text-decoration: none; color: var(--ok); font-weight: 700; }
.cap-tip { color: var(--ink-2); font-size: var(--fs-xs); }

/* helpers: quiet capsules in one row (it scrolls on the narrowest phones) */
.talk-help { display: flex; justify-content: safe center; gap: 8px; padding-block: 6px 8px; overflow-x: auto; scrollbar-width: none; }
.talk-help::-webkit-scrollbar { display: none; }
.talk-help button { flex: none; display: inline-flex; align-items: center; gap: 6px; min-block-size: 44px; padding-inline: 12px 14px; border: 0; border-radius: 999px;
  background: var(--fill-q); color: var(--ink); font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; touch-action: manipulation;
  transition: transform .15s var(--ease-out), background-color .2s, color .2s; }
.talk-help button .ic { inline-size: 18px; block-size: 18px; color: var(--ink-2); }
@media (max-width: 430px) {  /* all four helpers in one row on a phone: a call screen does not scroll sideways */
  .talk-help { gap: 6px; }
  .talk-help button { gap: 4px; padding-inline: 10px; font-size: var(--fs-xs); }
  .talk-help button .ic { inline-size: 16px; block-size: 16px; }
}
@media (hover: hover) and (pointer: fine) { .talk-help button:hover { background: color-mix(in srgb, var(--ink) 12%, transparent); } }
.talk-help button:active { transform: scale(.96); }
.talk-help button:disabled { opacity: .4; cursor: default; }
.talk-help button[aria-pressed="false"] { background: transparent; box-shadow: inset 0 0 0 1px var(--hair); color: var(--ink-2); }

/* the dock: a floating material capsule with the microphone in the middle */
.talk-dock-wrap { display: grid; justify-items: center; gap: 6px; }
.talk-dock { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; justify-items: center; gap: 16px; inline-size: min(100%, 22rem);
  padding: 10px 16px; border-radius: 999px; background: var(--mat-card); backdrop-filter: var(--mat-blur); -webkit-backdrop-filter: var(--mat-blur); box-shadow: var(--e2); }
.talk-key, .talk-end, .talk-mic { display: grid; place-items: center; border: 0; padding: 0; border-radius: 50%; cursor: pointer; touch-action: manipulation;
  transition: transform .15s var(--ease-out), background-color .3s var(--ease-std); }
.talk-key, .talk-end { inline-size: 52px; block-size: 52px; }
.talk-key { background: var(--fill-q); color: var(--ink); }
.talk-end { background: var(--bad); color: #fff; }
.talk-key .ic, .talk-end .ic { inline-size: 22px; block-size: 22px; }
.talk-mic { position: relative; inline-size: 72px; block-size: 72px; background: var(--voice-accent); color: var(--on-accent); touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  box-shadow: 0 14px 30px -12px color-mix(in srgb, var(--talk-c) 80%, transparent); }
.talk-mic .ic { inline-size: 30px; block-size: 30px; }
.talk-mic-ring { position: absolute; inset: -7px; border-radius: 50%; border: 2px solid var(--talk-c); opacity: 0; transform: scale(.92); transition: opacity .25s, transform .25s var(--ease-out); }
.talk-mic.on { background: var(--voice-night); color: var(--voice-mint); }
.talk-mic.on .talk-mic-ring { opacity: .55; transform: scale(1); animation: pr-ripple 1.9s var(--ease-out) infinite; }
.talk-mic.off { background: var(--fill-q); color: var(--ink); box-shadow: none; }
.talk-mic:disabled { cursor: default; opacity: .7; }
.talk-mic:active, .talk-key:active, .talk-end:active { transform: scale(.94); }
.talk-mic-l { margin: 0; min-block-size: 1.5em; font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); text-align: center; }

/* sheets: hint / translation over the dock; the start and end cards rise from the bottom like a system sheet */
.talk-sheet { position: absolute; z-index: 4; inset-inline: max(var(--gutter), var(--safe-l)) max(var(--gutter), var(--safe-r)); inset-block-end: calc(136px + var(--safe-b));
  max-inline-size: 32rem; margin-inline: auto; max-block-size: 46dvh; overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px; padding-inline-end: 52px;
  border-radius: var(--r-pop); background: var(--card); box-shadow: var(--e2); animation: talk-pop .28s var(--ease-out) both; transform-origin: 50% 100%; }
.talk-sheet[hidden] { display: none; }
.talk-sheet-x { position: absolute; inset-block-start: 8px; inset-inline-end: 8px; inline-size: 36px; block-size: 36px; }
.talk-sheet .hint-box { display: grid; gap: 8px; background: none; border: 0; padding: 0; max-block-size: none; }
.talk-sheet .suggs { display: grid; gap: 6px; }
.talk-sheet .sugg { text-align: left; padding: 8px 12px; border-radius: var(--r-md); border: 1px solid var(--hair); background: var(--paper);
  font-family: var(--f-display); font-size: var(--fs-base); color: var(--ink); cursor: default; }
.talk-sheet .hint-close { display: none; }
.talk-sheet .tr-fa { margin: 0 0 6px; font-size: var(--fs-md); }
.talk-sheet .hint-box > p .muted { display: none; }  /* "tap to copy into the message box" is for the typed chat */

.talk-modal { position: absolute; inset: 0; z-index: 6; display: grid; align-items: end; justify-items: center; background: var(--scrim); animation: talk-fade .25s var(--ease-out) both; }
.talk-modal[hidden] { display: none; }
@keyframes talk-fade { from { opacity: 0; } }
.talk-card { position: relative; display: grid; gap: 10px; justify-items: center; inline-size: 100%; max-inline-size: 30rem; max-block-size: 100%; overflow-y: auto;
  padding: 8px 22px calc(16px + var(--safe-b));
  border-radius: var(--r-xl) var(--r-xl) 0 0; background: var(--card); box-shadow: var(--e3); text-align: center; animation: talk-sheet-up .55s var(--spring) both; }
@keyframes talk-sheet-up { from { transform: translateY(48px); opacity: 0; } }
.talk-grab { inline-size: 36px; block-size: 5px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 18%, transparent); }
.talk-badge { display: grid; place-items: center; inline-size: 56px; block-size: 56px; border-radius: 18px; margin-block-start: 4px;
  background: var(--voice-night); color: var(--voice-mint); box-shadow: var(--sh-card); }
.talk-badge .ic { inline-size: 28px; block-size: 28px; }
.talk-card h3 { margin: 0; font-size: var(--fs-xl); line-height: 1.3; letter-spacing: -.01em; text-wrap: balance; }
.talk-sub { margin: 0; color: var(--ink-2); font-size: var(--fs-base); }
.talk-tips { list-style: none; margin: 0; padding: 2px 0 0; display: grid; gap: 8px; justify-self: stretch; text-align: start; font-size: var(--fs-sm); line-height: 1.7; }
.talk-tips li { display: flex; gap: 10px; align-items: flex-start; }
.talk-tips li[hidden] { display: none; }
.talk-tips .ic { flex: none; inline-size: 18px; block-size: 18px; color: var(--accent-ink); margin-block-start: .25em; }
.talk-consent { margin: 0; color: var(--ink-2); font-size: var(--fs-xs); line-height: 1.8; }
.talk-go { inline-size: 100%; min-block-size: var(--ctl-lg); justify-content: center; border-radius: 999px; font-size: var(--fs-md); }
.talk-enable.btn { border-color: transparent; background: var(--voice-accent); color: var(--on-accent); }
.talk-alt { min-block-size: 44px; font-size: var(--fs-sm); }
.talk-err { margin: 0; color: var(--bad); font-size: var(--fs-sm); }
.talk-err[hidden] { display: none; }

@media (min-width: 760px) {
  .talk-modal { align-items: center; padding: var(--gutter); }
  .talk-card { border-radius: var(--r-xl); padding-block: 26px 24px; }
  .talk-grab { display: none; }
}
@media (min-width: 900px) {
  .talk { --sz: min(30vh, 250px); padding-block: 20px 26px; row-gap: 8px; }
  .talk-sheet { inset-block-end: 150px; }
  .cap-partner { font-size: clamp(1.5rem, 1.2vw + 1rem, 1.75rem); }
}
@media (max-height: 640px) {
  .talk { --sz: min(44vw, 22vh, 150px); row-gap: 0; }
  .talk-stage { gap: 12px; padding-block: 2px; }
  .talk-cap { max-block-size: 30dvh; }
  .talk-help { padding-block: 4px 6px; }
  .talk-mic { inline-size: 64px; block-size: 64px; }
  .talk-mic .ic { inline-size: 26px; block-size: 26px; }
  .talk-dock { padding-block: 8px; }
}
/* a correction card needs the room: the presence steps back so the partner's line stays readable under it */
.talk:has(.cap-fix:not([hidden])) { --sz: min(30vw, 16vh, 120px); }
.talk:has(.cap-fix:not([hidden])) .talk-cap { max-block-size: 50dvh; }

/* motion tiers: tier 0 and reduced motion keep the colour changes and lose every loop and slide (talk.js then moves
   the rings by opacity only) */
html[data-motion="0"] .talk, html[data-motion="0"] .talk *, html[data-motion="0"] .talk-chat .msg, html[data-motion="0"] .chat-voice-action,
html[data-motion="0"] .fb-card, html[data-motion="0"] .fb-mark {
  animation: none !important; transition: none !important; }
html[data-motion="0"] .talk, html[data-motion="0"] .talk.out { opacity: 1; transform: none; }
html[data-motion="0"] .talk[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) {
  .talk, .talk *, .talk-chat .msg, .chat-voice-action, .talk-chat .mic-btn.on, .fb-card, .fb-mark { animation: none !important; transition: none !important; }
  .talk, .talk.out { opacity: 1; transform: none; }
  .talk[hidden] { display: none; }
}
@media (prefers-reduced-transparency: reduce) { .talk-dock { background: var(--card); backdrop-filter: none; -webkit-backdrop-filter: none; } }
@media (forced-colors: active) { .pr-core, .talk-mic { forced-color-adjust: none; border: 2px solid CanvasText; } .pr-halo { display: none; } }
