/* Shared foundation: warm paper by default, a warm dark set that follows the device (or the header switch). Classes and tokens the page-by-page work relies on:
     .note, .note.warn, .note.error   a short message in a tinted rounded box (15px, not monospace)
     .note-slot                       wrapper that reserves one line, so a note appearing pushes nothing
     .btn.danger                      outlined in --danger, for destructive actions
     .btn.quiet                       text-weight secondary action
     --focus                          colour of the one :focus-visible ring
     --control                        outline colour for controls (3:1 or better on --panel)
   Minimums: body 16px, labels and counters 14px, controls 44px tall.
   Contrast (checked): --text 15:1, --muted 7.1:1, --dim 4.8:1 (worst: on --panel-2), white on
   --accent 5.0:1, --control 3.6:1 and --focus 6.0:1 on --panel.
   Dark (checked): --text 13.8:1, --muted 8.1:1, --dim 5.3:1 (worst: on --panel-2), --on-accent on
   --accent 6.9:1, --control 3.3:1 (worst: on --panel-2) and --focus 7.1:1. */
:root {
  --bg: #f6f1e9;
  --bg-glow: #fbe9dc;
  --panel: #fffdf9;
  --panel-2: #f7f0e6;
  --border: #e3d7c6;
  --border-soft: #ece3d6;
  --text: #2b2420;
  --muted: #5f554c;
  --dim: #74685d;
  --control: #948371;
  --accent: #b8502c;
  --accent-strong: #9a3f1f;
  --accent-soft: #f7e1d5;
  --other: #2d6a6e;
  --other-soft: #dcecea;
  --rec: #d1382a;
  --danger: #b42318;
  --danger-soft: #fde4e1;
  --ok: #2a7045;
  --ok-soft: #e1f1e6;
  --warn: #8a5300;
  --warn-soft: #fbedcf;
  --focus: #1f5fbf;
  --on-accent: #fff;
  --field: #fff;
  --danger-line: #f1b8b1;
  --other-line: #b9d6d3;
  --accent-line: #ebc5b2;
  --glow: rgba(154,63,31,.28);
  --bar-shadow: rgba(70,45,20,.10);
  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(70,45,20,.06), 0 10px 30px rgba(70,45,20,.08);
  --serif: "Fraunces", ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "PingFang SC", "Hiragino Sans", "Noto Sans JP", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

/* Dark: follows the device unless the switch (web/theme.js) has chosen. The same set is written
   twice because CSS cannot share one block between a media query and an attribute selector. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1613;
    --bg-glow: #2b1d15;
    --panel: #241f1b;
    --panel-2: #2e2823;
    --border: #43392f;
    --border-soft: #362e27;
    --text: #f3ebe1;
    --muted: #cdbfb0;
    --dim: #a99a8a;
    --control: #857668;
    --accent: #e3895f;
    --accent-strong: #f2a580;
    --accent-soft: #4a2c1f;
    --on-accent: #1a1613;
    --other: #73bfc2;
    --other-soft: #1e3a3c;
    --rec: #ef5b4b;
    --danger: #f2897c;
    --danger-soft: #3e211d;
    --ok: #84d19f;
    --ok-soft: #1d3527;
    --warn: #f0c362;
    --warn-soft: #3b2f16;
    --focus: #8db6ff;
    --field: #1d1814;
    --danger-line: #6a3a33;
    --other-line: #2f5a5c;
    --accent-line: #7a4a35;
    --glow: rgba(0,0,0,.45);
    --bar-shadow: rgba(0,0,0,.4);
    --shadow: 0 1px 2px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1613;
  --bg-glow: #2b1d15;
  --panel: #241f1b;
  --panel-2: #2e2823;
  --border: #43392f;
  --border-soft: #362e27;
  --text: #f3ebe1;
  --muted: #cdbfb0;
  --dim: #a99a8a;
  --control: #857668;
  --accent: #e3895f;
  --accent-strong: #f2a580;
  --accent-soft: #4a2c1f;
  --on-accent: #1a1613;
  --other: #73bfc2;
  --other-soft: #1e3a3c;
  --rec: #ef5b4b;
  --danger: #f2897c;
  --danger-soft: #3e211d;
  --ok: #84d19f;
  --ok-soft: #1d3527;
  --warn: #f0c362;
  --warn-soft: #3b2f16;
  --focus: #8db6ff;
  --field: #1d1814;
  --danger-line: #6a3a33;
  --other-line: #2f5a5c;
  --accent-line: #7a4a35;
  --glow: rgba(0,0,0,.45);
  --bar-shadow: rgba(0,0,0,.4);
  --shadow: 0 1px 2px rgba(0,0,0,.45), 0 10px 30px rgba(0,0,0,.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* The room page asks to reach under the phone's own bars (viewport-fit=cover); the insets keep
     the content out of a notch and the home bar. They are 0 on every page that does not ask. */
  padding: max(32px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(64px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  min-height: 100vh;
  background: var(--bg) radial-gradient(ellipse 90% 380px at 50% 0, var(--bg-glow), transparent) no-repeat;
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* The brand typeface (soft, Latin; OFL licence beside it). Korean, Chinese and Japanese headings keep the sans stack. */
@font-face { font-family: "Fraunces"; src: url("/static/fonts/fraunces-soft-latin.woff2") format("woff2"); font-weight: 400 700; font-style: normal; font-display: swap; }
h1 .word, h2, h3, .login h1 .lang, .avatar, .who-name { font-variation-settings: "SOFT" 100; }

.wrap { max-width: 760px; margin: 0 auto; }
.wrap.guest { max-width: 680px; }

header { display: flex; align-items: center; gap: 8px 16px; margin-bottom: 24px; flex-wrap: wrap; }
h1 { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 400; margin: 0; line-height: 1.2; }
h1 .mark { flex: none; display: block; }
.mark .a { fill: var(--accent); }
.mark .b { fill: var(--other); stroke: var(--bg); stroke-width: 1.5; stroke-linejoin: round; }
h1 .word { font-family: var(--serif); font-size: 24px; font-weight: 600; letter-spacing: -0.01em; color: var(--text); }
h1 .lang, .field .lang { color: var(--muted); font-family: var(--sans); font-size: 16px; font-weight: 400; }
.field .lang { color: var(--accent-strong); }

nav { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 15px; }
nav a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border-radius: 999px; } /* the four tabs fit one row at 390px */
nav a:hover { color: var(--text); background: color-mix(in srgb, var(--panel) 60%, transparent); }
nav a[aria-current="page"] { color: var(--text); font-weight: 600; background: var(--panel); box-shadow: var(--shadow); }
/* Beside the brand: the tabs. At the far right, the switch and Sign out, together and not among the tabs. */
header h1 { order: 0; }
header nav { order: 1; margin-left: 8px; }
header .theme-toggle { order: 2; margin-left: auto; }
header #sign-out { order: 3; margin-left: 0; }

/* The light/dark switch theme.js puts in the header: the moon while the page is light, the sun while
   it is dark. The icon follows the same rules as the tokens, so it is right before the script runs. */
.theme-toggle { flex: none; width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--muted); display: inline-grid; place-items: center; cursor: pointer; }
.theme-toggle:hover { color: var(--text); background: color-mix(in srgb, var(--panel) 60%, transparent); }
.theme-toggle .sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .moon { display: none; }
}
:root[data-theme="dark"] .theme-toggle .sun { display: block; }
:root[data-theme="dark"] .theme-toggle .moon { display: none; }
@media (max-width: 640px) {
  /* The brand, the switch and Sign out share the first row; the tabs take the second. */
  header nav { order: 4; flex-basis: 100%; margin-left: 0; }
}
header { position: relative; }
.login header { position: relative; }
.login .theme-toggle { position: absolute; top: -8px; right: 0; margin: 0; }

/* Sign in: a centred card with the brand mark above it. */
.wrap.login { max-width: 440px; padding-top: 4vh; }
.login header { justify-content: center; margin-bottom: 20px; }
.login h1 { flex-direction: column; gap: 12px; text-align: center; }
.login h1 .mark { width: 56px; height: 56px; }
.login h1 .lang { font-family: var(--serif); font-size: 26px; font-weight: 600; color: var(--text); }

.card {
  background: var(--panel);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
@media (max-width: 560px) { .card { padding: 20px; } }
h1, h2, h3 { text-wrap: balance; }
h2:lang(ko), h2:lang(zh), h2:lang(ja) { font-family: var(--sans); font-weight: 700; }

.btn-pair { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-pair .btn { white-space: nowrap; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

/* ---- record button ---- */
.record-area { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 12px 0 4px; }

.recbtn {
  width: 104px; height: 104px; border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: var(--on-accent);
  display: grid; place-items: center;
  cursor: pointer;
  transition: transform .12s ease, background-color .2s ease, box-shadow .2s ease;
  box-shadow: 0 8px 22px var(--glow);
}
.recbtn:hover:not(:disabled) { transform: translateY(-1px); background: var(--accent-strong); }
.recbtn:disabled { opacity: .45; box-shadow: none; cursor: not-allowed; }
.recbtn .dot { width: 28px; height: 28px; border-radius: 50%; background: var(--on-accent); transition: all .2s ease; }
.recbtn.is-recording { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 35%, transparent), 0 8px 22px var(--glow); animation: ring 2.4s ease-out infinite; }
.recbtn.is-recording .dot { width: 22px; height: 22px; border-radius: 5px; }
.recbtn.is-busy .dot { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; transform: scale(1);} 50% { opacity: .35; transform: scale(.8);} }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--rec) 38%, transparent), 0 8px 22px var(--glow); } 70%,100% { box-shadow: 0 0 0 22px color-mix(in srgb, var(--rec) 0%, transparent), 0 8px 22px var(--glow); } }
@media (prefers-reduced-motion: reduce) {
  .recbtn.is-recording { animation: none; box-shadow: 0 0 0 6px color-mix(in srgb, var(--rec) 22%, transparent), 0 8px 22px var(--glow); }
  .recbtn.is-busy .dot { animation: none; opacity: .6; }
}

.rec-label { font-size: 16px; color: var(--muted); letter-spacing: .01em; }
.record-area .recbtn.is-recording + .rec-label { font-size: 20px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.rec-label b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }

.meter { width: 220px; height: 6px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .06s linear; }
.meter.wide { width: 100%; height: 8px; margin-bottom: 8px; }
.target { margin-top: 16px; }

/* ---- toggles ---- */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 6px; max-width: 100%; }
.segmented button {
  appearance: none; border: 1px solid var(--control); background: var(--panel); color: var(--muted);
  min-height: 44px; padding: 0 18px; font-size: 16px; cursor: pointer; font-family: inherit;
  /* inline-block, not flex: a flex box drops the space between the language's word and the
     English gloss ("존댓말 · polite"), which are separate spans. 42px = 44 less the border. */
  border-radius: 999px; white-space: nowrap; display: inline-block; line-height: 42px; text-align: center;
}
.segmented button:hover:not(:disabled) { color: var(--text); border-color: var(--accent); }
/* The check exists only on the selected chip, so an unselected label sits in the middle. */
.segmented button[aria-pressed="true"]::before { content: "\2713"; margin-right: 8px; }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); font-weight: 600; border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* A country's flag before a language's name: a hairline outline keeps a white field visible. */
.flag { width: 20px; height: 15px; border-radius: 3px; box-shadow: 0 0 0 1px var(--border); vertical-align: middle; margin-right: 8px; position: relative; top: -1px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field[hidden] { display: none; }
.field > span, .field > label { font-size: 14px; color: var(--muted); letter-spacing: .02em; }
.field > .help { letter-spacing: 0; font-size: 16px; } /* a help line is a sentence to read, not a label */

/* ---- text panes ---- */
.panes { display: flex; flex-direction: column; gap: 14px; }
.pane { border-left: 2px solid var(--border); padding-left: 14px; }
.pane.ko { border-left-color: var(--accent); }
.pane .tag { font-size: 16px; letter-spacing: .04em; color: var(--muted); display: block; margin-bottom: 3px; }
.pane .body { font-size: 16px; }
.pane.ko .body { font-size: 19px; line-height: 1.55; font-weight: 500; }
.pane .body.placeholder { color: var(--dim); font-style: italic; }

/* ---- notes ---- */
.note { font-size: 15px; line-height: 1.5; color: var(--text); background: var(--panel-2); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 10px; font-family: inherit; }
.note.warn { background: var(--warn-soft); }
.note.error { background: var(--danger-soft); }
.note[hidden] { display: none; }
.guests { margin: 0 0 16px; }
.guests > p { margin: 0 0 10px; font-size: 15px; line-height: 1.5; }
.guests > .note { margin-top: 0; }
.note-slot { min-height: calc(15px * 1.5 + 20px); margin-top: 10px; }
.note-slot > .note { margin-top: 0; }

/* ---- player ---- */
.player { display: flex; align-items: center; gap: 14px; margin-top: 4px; flex-wrap: wrap; }
audio { flex: 1; min-width: 240px; height: 44px; accent-color: var(--accent); }
.dl { display: inline-flex; align-items: center; min-height: 44px; font-size: 15px; color: var(--muted); text-decoration: none; border: 1px solid var(--control); background: var(--panel); padding: 0 18px; border-radius: 999px; }
.dl:hover { color: var(--text); border-color: var(--accent); }

/* ---- timings ---- */
.timings { display: flex; flex-direction: column; gap: 7px; margin-top: 4px; }
.timing { display: grid; grid-template-columns: 92px 1fr 64px; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }
.timing .bar { height: 5px; background: var(--border-soft); border-radius: 3px; overflow: hidden; }
.timing .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.timing .ms { text-align: right; font-family: var(--mono); font-size: 14px; color: var(--muted); }
.timing.total { color: var(--text); }
.timing.total .bar i { background: linear-gradient(90deg, var(--accent), var(--ok)); }

/* ---- status chip ---- */
.chip { display: inline-flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); background: var(--panel); border: 1px solid var(--border-soft); padding: 6px 12px; border-radius: 999px; margin-bottom: 16px; }
.chip .pip { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.chip.ok .pip { background: var(--ok); }
.chip.checking .pip { background: var(--dim); }
.chip.warn { border-color: var(--warn); background: var(--warn-soft); }
.chip.warn .pip { background: var(--warn); width: 12px; height: 11px; border-radius: 0; clip-path: polygon(50% 0, 100% 100%, 0 100%); } /* a triangle, so a warning is not only a colour */
.chip a { color: var(--accent-strong); display: inline-flex; align-items: center; min-height: 44px; margin: -12px 0; padding: 0 4px; }

/* ---- errors ---- */
.error { border-color: var(--danger-line); background: var(--danger-soft); }
.error pre { margin: 0; white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: 16px; color: var(--danger); }

/* ---- clone page ---- */
.script { background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 16px 18px; }
.card .script { max-height: 260px; overflow-y: auto; } /* the older clone page keeps its scroll box; the voice setup's script is page content */
.script p { margin: 0 0 12px; font-size: 16px; line-height: 1.7; }
.script p:last-child { margin-bottom: 0; }
.takes { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.take { display: flex; align-items: center; gap: 12px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); padding: 6px 12px; font-size: 14px; flex-wrap: wrap; }
.take .n { color: var(--dim); font-family: var(--mono); font-size: 14px; }
.take .secs { color: var(--muted); font-variant-numeric: tabular-nums; }
.take audio { height: 44px; flex: 1; min-width: 160px; }
.take button { appearance: none; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; min-width: 44px; min-height: 44px; padding: 0 8px; border-radius: 999px; }
.take button:hover { color: var(--danger); }
.hint { font-size: 16px; color: var(--muted); }
.hint ul { margin: 6px 0 0; padding-left: 18px; }
.hint li { margin-bottom: 3px; }
.btn { appearance: none; font-family: inherit; font-size: 16px; min-height: 48px; padding: 0 26px; border-radius: 999px; border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; text-decoration: none; transition: background-color .15s ease, border-color .15s ease; }
.btn:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.secondary { background: var(--panel); color: var(--text); border-color: var(--control); }
.btn.secondary:hover:not(:disabled) { background: var(--panel); border-color: var(--accent); }
.btn.danger { background: var(--panel); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover:not(:disabled) { background: var(--danger-soft); border-color: var(--danger); }
.btn.quiet { background: transparent; color: var(--muted); border-color: transparent; font-weight: 500; padding: 0 14px; }
.btn.quiet:hover:not(:disabled) { background: transparent; border-color: transparent; color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.btn:disabled { opacity: .45; cursor: not-allowed; } /* dimmed, still outlined or filled like its enabled self */
.btn.small { font-size: 16px; padding: 0 16px; }

/* ---- history ---- */
.clip .clip-head { margin-bottom: 14px; align-items: center; }
.clip .panes { gap: 10px; }
.clip .pane .body { font-size: 16px; }
.clip .pane.ko .body { font-size: 17px; }
.clip .player { margin-top: 14px; }
.clip audio { max-width: 320px; }
#say-hint { font-size: 16px; }
.mono { font-size: 14px; color: var(--muted); }
/* Monospace is for real codes and timings only; .mono on its own is plain text. */
.chip .mono, .linkbox, #playback { font-family: var(--mono); }

/* ---- typed input ---- */
textarea#typed {
  width: 100%;
  min-height: 64px;
  resize: vertical;
  background: var(--field);
  color: var(--text);
  border: 1px solid var(--control);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font: inherit;
  line-height: 1.55;
}
textarea#typed::placeholder { color: var(--dim); }
textarea#typed:focus { border-color: var(--focus); }

/* ---- the room page outside the call: setup, status, waiting, dead link ---- */
#intro p { margin: 0 0 8px; color: var(--text); }
#intro p:last-child { margin-bottom: 0; }
.tips-title { margin: 16px 0 6px; font-size: 16px; font-weight: 600; color: var(--text); }
.tips { margin: 0; padding-left: 20px; }
.tips li { margin: 0 0 6px; }
.tips li:last-child { margin-bottom: 0; }
/* ---- voice setup, in three steps ---- */
.step-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; margin-bottom: 8px; }
.step-top .btn.quiet { margin-left: -12px; }
.step-count { margin-left: auto; font-size: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
h2[tabindex="-1"]:focus-visible, #banner:focus-visible { outline: none; } /* focus lands here to say where the person is; it is not a control */
#step-1 h2, #step-3 h2 { font-size: 22px; line-height: 1.4; margin-bottom: 14px; }
.step-actions { margin-top: 20px; }
#status h2 { font-size: 22px; line-height: 1.4; margin-bottom: 14px; }
#start { min-height: 56px; padding: 0 40px; font-size: 18px; }

/* Step 2: the script is page content that scrolls with the page; the bar is pinned to the screen. */
#step-2 { padding-bottom: 260px; } /* the page replaces this with the bar's measured height */
#step-2 h2 { font-size: 22px; line-height: 1.4; margin: 4px 0 6px; }
.read-for { margin: 0 0 14px; font-size: 16px; color: var(--muted); }
.script-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.script-showing { font-size: 16px; color: var(--muted); }
.btn.script-switch { display: block; height: auto; font-size: 16px; padding-top: 8px; padding-bottom: 8px; line-height: 1.4; text-align: left; white-space: normal; }
.script-switch span { display: inline; }
#step-2 .script { padding: 18px 20px; }
#step-2 .script p { font-size: 19px; line-height: 1.75; margin-bottom: 16px; }
#step-2 .script p:last-child { margin-bottom: 0; }

.rec-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: var(--panel); border-top: 1px solid var(--border-soft); box-shadow: 0 -8px 24px var(--bar-shadow); padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.rec-bar-in { max-width: 760px; margin: 0 auto; }
.progress-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; } /* the takes control's height, kept from the start */
.progress-row .count { flex: 1 1 auto; min-width: 0; color: var(--text); }
.takes-toggle { appearance: none; flex: none; min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 4px 0 12px; background: transparent; color: var(--text); border: 0; font: inherit; font-size: 16px; text-decoration: underline; text-underline-offset: 4px; cursor: pointer; }
.takes-toggle::after { content: "\25B4"; color: var(--muted); text-decoration: none; display: inline-block; }
.takes-toggle[aria-expanded="true"]::after { content: "\25BE"; }
.takes-toggle:hover { color: var(--accent-strong); }
.rec-bar .takes { margin: 0 0 8px; max-height: 32vh; overflow-y: auto; }
.rec-bar .meter.wide { margin-bottom: 0; }
.rec-bar .count { margin-bottom: 0; }
#rec-note, #join-note, #create-error { font-size: 16px; }
#rec-note, #short-note { margin: 6px 0 0; }
/* One line is kept for the reason, or for the time while recording, so that a change of words moves nothing. */
.bar-line { display: flex; align-items: center; min-height: 30px; margin: 0 0 8px; }
/* The longer English reason takes two lines on a phone; room is kept so that it moves nothing. */
@media (max-width: 560px) { :lang(en) .bar-line { min-height: calc(16px * 1.4 * 2); } }
.next-why { font-size: 16px; line-height: 1.4; color: var(--muted); }
.rec-time { font-size: 22px; line-height: 1.3; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.bar-buttons { display: flex; gap: 12px; }
.bar-buttons .recbtn, .bar-buttons .next-btn { flex: 1 1 0; min-width: 0; height: 64px; min-height: 64px; font-size: 18px; }
.bar-buttons .recbtn { white-space: nowrap; width: auto; border-radius: 999px; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 0 16px; font-family: inherit; font-weight: 600; line-height: 1.2; }
.bar-buttons .next-btn { padding: 0 16px; }
.bar-buttons .recbtn:not(.is-primary) { background: var(--panel); color: var(--text); box-shadow: inset 0 0 0 1px var(--control); }
.bar-buttons .recbtn:not(.is-primary) .dot { background: var(--rec); }
.bar-buttons .recbtn:not(.is-primary):hover:not(:disabled) { background: var(--panel); box-shadow: inset 0 0 0 1px var(--accent); }
.bar-buttons .recbtn.is-primary { background: var(--accent); color: var(--on-accent); }
.bar-buttons .recbtn.is-primary:hover:not(:disabled) { background: var(--accent-strong); }
.next-btn.is-off, #create.is-off { background: var(--panel); color: var(--muted); border-color: var(--control); font-weight: 500; cursor: not-allowed; opacity: .6; }

/* Step 3. */
.summary { margin: 0 0 12px; font-size: 20px; font-weight: 600; }
.keep-note { margin: 14px 0 0; }
.record-more-row #record-more { margin-top: 10px; }
.progress-line { margin-top: 16px; }
.progress-track { display: block; position: relative; height: 8px; border-radius: 999px; background: var(--border-soft); overflow: hidden; }
.progress-track i { position: absolute; top: 0; bottom: 0; width: 35%; border-radius: 999px; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { left: -35%; } to { left: 100%; } }
@media (prefers-reduced-motion: reduce) { .progress-track i { animation: none; width: 100%; opacity: .6; } }
.create-row { display: flex; align-items: center; justify-content: space-between; gap: 12px 16px; flex-wrap: wrap; margin-top: 16px; }
.create-why { flex: 1 1 10em; font-size: 16px; line-height: 1.4; color: var(--muted); min-height: 1.4em; }
#create { min-height: 56px; padding: 0 28px; font-size: 18px; }
#create[aria-busy="true"] { opacity: .85; }
#create[aria-busy="true"] { cursor: progress; } /* while the voice is being made: dimmed, but its words are still the message */
/* Whether the other person is in the call. The dot is filled when they are and hollow when
   not, so the difference is a shape and not only a colour. Two lines are kept on a phone so
   that the words changing does not move the join button. */
.presence { display: flex; align-items: flex-start; gap: 10px; margin: 14px 0 0; font-size: 16px; line-height: 1.5; color: var(--text); }
.presence-dot { flex: none; box-sizing: border-box; width: 14px; height: 14px; margin-top: 5px; border-radius: 50%; border: 2px solid var(--muted); background: transparent; }
.presence.is-here .presence-dot { border-color: var(--ok); background: var(--ok); }
@media (max-width: 560px) { .presence { min-height: 3em; } }
.join-actions { margin-top: 14px; }
#join { min-height: 52px; padding: 0 32px; font-size: 18px; }
@media (max-width: 560px) {
  #join, #create, #start, #record-more { width: 100%; }
  .create-row { flex-direction: column; align-items: stretch; gap: 10px; }
  .create-why { flex: none; text-align: center; min-height: 0; }
  .create-why:empty { display: none; }
}
#gone { text-align: center; padding-top: 32px; padding-bottom: 32px; }
.gone-icon { display: block; margin: 0 auto 12px; color: var(--dim); }
#gone h2 span { display: block; }
#gone h2 span + span { margin-top: 2px; }
#gone p { margin: 0 0 8px; }
#gone p:last-child { margin-bottom: 0; }

/* ---- host and room pages ---- */
.input { width: 100%; min-height: 48px; background: var(--field); color: var(--text); border: 1px solid var(--control); border-radius: var(--radius-sm); padding: 9px 14px; font: inherit; }
.input:focus { border-color: var(--focus); }
select.input { appearance: none; padding-right: 40px; background: linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 22px) 50% / 6px 6px no-repeat, linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 16px) 50% / 6px 6px no-repeat, var(--field); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
@media (max-width: 560px) { .form { grid-template-columns: 1fr; } }
.linkbox { font-size: 14px; color: var(--muted); word-break: break-all; margin: 4px 0 10px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.3; letter-spacing: -0.01em; margin: 0 0 14px; }

/* ---- the host page ---- */
.help { font-size: 16px; line-height: 1.45; color: var(--muted); }
/* Visibly not editable: the same size as a field, but flat and dashed. */
.input.readonly { background: var(--panel-2); border-style: dashed; color: var(--muted); cursor: default; }
.input::placeholder { color: var(--dim); }
.actions .help { max-width: 14em; }
/* A text-weight button lines up with the words above it, not with its own padding. */
.actions > .btn.quiet, .player > .btn.quiet { margin-left: -12px; }
/* The actions that cannot be undone sit apart from the ones that cannot hurt. */
.risky { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--border); }
.confirm { flex: 1 1 100%; border: 1px solid var(--danger); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--danger-soft); }
.confirm p { margin: 0 0 10px; font-size: 16px; line-height: 1.5; }
/* Your own details: open while there is something to do, one line once saved. */
.me-line { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; font-size: 17px; flex-wrap: wrap; }
.me-line .btn.quiet { margin-right: -12px; }
#me-card:has(#me-summary-line:not([hidden])) { padding-top: 6px; padding-bottom: 6px; }
/* Invite: one compact row on a wide screen, stacked on a phone. */
.invite-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; margin-bottom: 10px; }
@media (max-width: 640px) { .invite-form { grid-template-columns: 1fr; align-items: stretch; } }
.invite-form .btn { align-self: end; }
#invite-card .help { margin: 4px 0 0; }
.empty { margin: 8px 0; font-size: 17px; color: var(--muted); }
#invite-open { margin: 0 0 20px; }
#me-sample-row { align-items: center; }
#me-sample-row .help { max-width: none; font-size: 16px; }
/* A room: the next step first, then what it is, then the rest folded away. */
.room-card .headline { font-size: 21px; line-height: 1.3; margin: 0 0 12px; }
.room-card > .help { margin: 0 0 12px; font-size: 16px; }
.room-card .actions { gap: 10px 14px; }
.room-card .actions .copy-note { max-width: 24em; color: var(--text); font-size: 16px; }
.room-card .linkbox { margin: 12px 0 0; padding: 10px 12px; background: var(--panel-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); user-select: all; }
.room-card .meta { margin: 12px 0 0; font-size: 16px; line-height: 1.5; color: var(--muted); }
.room-card .field.register { margin-top: 12px; }
.room-more { margin-top: 18px; border-top: 1px dashed var(--border); padding-top: 4px; }
.more-title { display: flex; align-items: center; min-height: 44px; cursor: pointer; color: var(--muted); font-size: 16px; list-style: none; }
.more-title::-webkit-details-marker { display: none; }
.more-title::before { content: ""; width: 8px; height: 8px; margin-right: 10px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.room-more[open] > .more-title::before { transform: rotate(45deg); }
.more-title:hover { color: var(--text); }
.room-more .actions { margin-top: 4px; }
.room-more .actions .help { max-width: none; font-size: 16px; }
.room-more .risky { margin-top: 12px; padding-top: 12px; }
/* Several classes here set `display`, which silently beats the browser's own rule for the
   `hidden` attribute. These pages show and hide whole sections with it, so it has to win. */
[hidden] { display: none !important; }

/* ---- the call ----
   .feed and .turn are the generic rules below; everything specific to the call is scoped to #call. */
.feed { display: flex; flex-direction: column; gap: 14px; max-height: 46vh; overflow-y: auto; }
.feed:empty::before { content: "…"; color: var(--dim); }
.turn { border-left: 2px solid var(--border); padding-left: 12px; }
.turn.other { border-left-color: var(--other); }
.turn .line { font-size: 16px; }
.turn.failed { opacity: .55; }
.turn.pending .line { color: var(--dim); }

/* The banner: the one thing to read. Kind = colour + shape + words, never colour alone:
   talk = filled circle (green), wait = filled square (amber), idle = hollow ring (grey),
   problem = triangle (red). It stays at the top of the card while the feed scrolls. */
#call { word-break: keep-all; overflow-wrap: anywhere; padding-bottom: env(safe-area-inset-bottom); } /* Korean breaks between words, not inside them */
#call .call-card { padding: 0; }
.callbar {
  --kind: var(--muted); --tint: transparent;
  position: sticky; top: 0; z-index: 5;
  padding: 14px 20px 4px;
  background: linear-gradient(var(--tint), var(--tint)), var(--panel);
  border-bottom: 3px solid var(--kind);
  border-radius: var(--radius) var(--radius) 0 0;
}
.callbar[data-kind="talk"] { --kind: var(--ok); --tint: var(--ok-soft); }
.callbar[data-kind="wait"] { --kind: var(--muted); --tint: var(--panel-2); }
.callbar[data-kind="problem"] { --kind: var(--warn); --tint: var(--warn-soft); }
.banner { display: flex; align-items: center; gap: 14px; font-size: 22px; font-weight: 600; line-height: 1.35; min-height: 60px; }
.banner::before { content: ""; flex: none; width: 22px; height: 22px; background: var(--kind); }
.callbar[data-kind="talk"] .banner::before { border-radius: 50%; }
/* wait = a pause mark: two bars. Used nowhere else. */
.callbar[data-kind="wait"] .banner::before { background: linear-gradient(90deg, var(--kind) 0 36%, transparent 36% 64%, var(--kind) 64%); }
.callbar[data-kind="idle"] .banner::before { border-radius: 50%; background: transparent; border: 4px solid var(--kind); }
.callbar[data-kind="problem"] .banner::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.callbar .meter.wide { margin: 8px 0 0; }
.callbar .meter i { background: var(--kind); }
.callbar .note-slot { margin: 4px 0 6px; }

#call .feed-wrap { padding: 16px 20px 20px; }
.feed-empty { margin: 0; padding: 24px 0; text-align: center; color: var(--muted); font-size: 16px; }
#call .feed { max-height: none; overflow: visible; gap: 16px; }
#call .feed:empty::before { content: none; }
#call .turn { max-width: 88%; padding: 10px 14px; border-radius: var(--radius-sm); border-left-width: 0; }
#call .turn.other { align-self: flex-start; background: var(--other-soft); border: 1px solid var(--other-line); }
#call .turn.me { align-self: flex-end; background: var(--accent-soft); border: 1px solid var(--accent-line); }
#call .turn.failed { opacity: 1; }
#call .turn.pending .line { color: var(--muted); }
#call .turn .who { display: flex; align-items: baseline; gap: 10px; font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .02em; margin-bottom: 2px; }
#call .turn.me .who { justify-content: flex-end; }
#call .turn .mark { font-weight: 400; }
#call .turn .mark::before { content: "·"; margin-right: 8px; }
#call .turn .line { font-size: 18px; line-height: 1.5; }
#call .turn .note { margin-top: 8px; }
.peek { appearance: none; font: inherit; font-size: 16px; color: var(--muted); background: transparent; border: 0; padding: 0 8px; min-height: 44px; min-width: 44px; cursor: pointer; text-decoration: underline; text-underline-offset: 4px; display: block; margin-left: auto; }
.peek:hover { color: var(--text); }
.heard { margin-top: 2px; padding: 4px 0 4px 12px; border-left: 3px solid var(--control); }
.heard-label { font-size: 14px; color: var(--muted); }
#call .heard .line { font-size: 16px; }

/* The controls: a bar at the bottom of the screen, clear of the phone's own home bar. */
/* The bar is about 69px tall. Under the last entry the card, the feed and the page's own bottom
   padding already leave about 100px, so about 30px clears the bar; the safe area is added. */
#call .note { font-size: 16px; }
#call .note-slot { min-height: calc(16px * 1.5 * 2 + 12px); } /* two lines: "sound is blocked" takes two in Korean */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.controls {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--panel); border-top: 1px solid var(--border-soft); box-shadow: 0 -8px 24px var(--bar-shadow);
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.controls-in { max-width: 760px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ctl-main { display: flex; gap: 10px; flex: 1; min-width: 0; }
.ctl { line-height: 1.25; text-align: center; min-height: 48px; gap: 10px; }
.ctl-main .ctl { flex: 1 1 0; max-width: 300px; padding: 4px 12px; }
.ctl-main .ctl-mute { flex-grow: 2; }
/* These two labels never break or shrink: a word cut in half is worse than a shorter mute button. */
.ctl-main .ctl-interrupt, .ctl-leave { flex: 0 0 auto; white-space: nowrap; }
.ctl::before { content: ""; flex: none; width: 16px; height: 16px; }
.ctl-mute::before { border: 3px solid currentColor; border-radius: 50%; }
.ctl-mute.on { background: var(--danger); border-color: var(--danger); color: var(--on-accent); font-weight: 700; }
.ctl-mute.on::before { border-radius: 50%; border: 0; background-color: currentColor; background-image: linear-gradient(135deg, transparent 40%, var(--danger) 40% 60%, transparent 60%); }
.ctl-interrupt { background: var(--panel); color: var(--warn); border-color: var(--warn); }
.ctl-interrupt::before { background: var(--warn); clip-path: polygon(15% 0, 100% 50%, 15% 100%); }
.ctl-leave::before { background: linear-gradient(45deg, transparent 40%, currentColor 40% 60%, transparent 60%), linear-gradient(-45deg, transparent 40%, currentColor 40% 60%, transparent 60%); }
.leave-confirm { display: flex; align-items: center; gap: 10px; flex: 1 0 100%; order: -1; flex-wrap: wrap; }
.leave-confirm::before { content: none; }
.leave-confirm .ctl::before { content: none; }
.leave-ask { flex-basis: 100%; font-size: 18px; font-weight: 600; }
.leave-confirm .ctl { flex: 1; }
/* The "new" strip sits in the bar itself, above the buttons, so it never covers a line. */
.newmsg { display: flex; width: 100%; max-width: 760px; margin: 0 auto 8px; min-height: 48px; border-color: var(--accent); background: var(--accent-soft); color: var(--text); }

.segmented button:disabled { opacity: .45; cursor: not-allowed; }


/* ---- focus: one ring for every control ---- */
button:focus-visible, a:focus-visible, summary:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, audio:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Korean: break between words, not inside them; very long strings may still wrap. */
:lang(ko) { word-break: keep-all; overflow-wrap: anywhere; }

/* ---- history ---- */
.more { display: flex; justify-content: center; margin: 0 0 16px; }
.details-body { padding: 4px 24px 20px; }
.details-body p { margin: 0 0 6px; }

/* ---- practice: the options that most people never change ---- */
.options { padding: 0; }
.options summary { display: flex; flex-wrap: wrap; gap: 0 4px; align-items: center; min-height: 48px; padding: 0 24px; cursor: pointer; color: var(--muted); font-size: 16px; list-style: none; border-radius: var(--radius); }
.options summary::-webkit-details-marker { display: none; }
.options summary::before { content: "\25B8"; display: inline-block; width: 1.2em; }
.options[open] summary::before { content: "\25BE"; }
.options summary:hover { color: var(--text); }
.options[open] > .row { padding: 4px 24px 24px; }
.options summary .sel { color: var(--text); }
#done .player { margin-top: 16px; }
#today { margin: 0 0 14px; font-size: 16px; line-height: 1.5; color: var(--muted); }

/* ---- a page that is not there ---- */
.notfound { text-align: center; padding: 40px 24px; }
.notfound h2 { font-size: 26px; margin-bottom: 20px; }
.notfound .btn { display: inline-flex; }
