/* trAIslator: operator pages (light) and the audience Live View (dark).
   Be Vietnam Pro is served from /fonts (SIL Open Font License, see fonts/LICENSE-be-vietnam-pro.txt);
   scripts it does not cover (Hangul, kana, Han, Thai, Arabic…) fall back to the system fonts. */
@font-face { font-family: "Be Vietnam Pro"; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro-vietnamese-400-normal.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-ext-400-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 400; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-400-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 500; font-display: swap; src: url(/fonts/be-vietnam-pro-vietnamese-500-normal.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 500; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-ext-500-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 500; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-500-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 600; font-display: swap; src: url(/fonts/be-vietnam-pro-vietnamese-600-normal.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 600; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-ext-600-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 600; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-600-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 700; font-display: swap; src: url(/fonts/be-vietnam-pro-vietnamese-700-normal.woff2) format("woff2"); unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 700; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-ext-700-normal.woff2) format("woff2"); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "Be Vietnam Pro"; font-weight: 700; font-display: swap; src: url(/fonts/be-vietnam-pro-latin-700-normal.woff2) format("woff2"); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #f5f5f2;
  --panel: #ffffff;
  --panel-2: #fafaf8;
  --tint: #f0f1ee;
  --text: #15181d;
  --text-2: #2b313a;
  --text-3: #3d4450;
  --muted: #5a6270;
  --line: #e2e4e0;
  --line-2: #d5d8d2;
  --field: #8a9087; /* field borders: 3.3:1 on white (WCAG 1.4.11) */
  --accent: #0b6e66;
  --accent-2: #08534d;
  --accent-soft: #e1f0ee;
  --accent-line: #b9dad5;
  --live: #c8281e;
  --live-dot: #d92d20;
  --live-text: #b42318;
  --live-soft: #fcedea;
  --err-soft: #fef3f2;
  --err-line: #f1b5ae;
  --revise: #2952a3;
  --revise-soft: #e8eefa;
  --warn: #c98a12;
  --warn-text: #8a5300;
  --warn-soft: #fdf3e1;
  --ok: #1e8e4e;
  --radius: 14px;
  --sans: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, Roboto, "Noto Sans", "Noto Sans KR", "Noto Sans JP",
    "Noto Sans SC", "Malgun Gothic", "Yu Gothic UI", "Microsoft YaHei UI", "Leelawadee UI", "Segoe UI Arabic", sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, "SF Mono", Menlo, monospace;
  /* Motion tokens. Easings from open-props@1.7.23 easings.min.css (MIT, Adam Argyle). */
  --ease-3: cubic-bezier(.25, 0, .3, 1);
  --ease-out-3: cubic-bezier(0, 0, .3, 1);
  --ease-out-4: cubic-bezier(0, 0, .1, 1);
  --ease-in-out-3: cubic-bezier(.5, 0, .5, 1);
  --ease-spring-2: linear(0,0.007,0.029 2.2%,0.118 4.7%,0.625 14.4%,0.826 19%,0.902,0.962,1.008 26.1%,1.041 28.7%,1.064 32.1%,1.07 36%,1.061 40.5%,1.015 53.4%,0.999 61.6%,0.995 71.2%,1);
  --dur-1: 120ms; --dur-2: 180ms; --dur-3: 240ms; --dur-4: 600ms;
  --dir: 1; /* sign for direction-aware motion */
  font-family: var(--sans);
  color-scheme: light;
}
[dir=rtl] { --dir: -1; }
[dir=ltr] { --dir: 1; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
a:hover { color: var(--accent-2); }
[hidden] { display: none !important; }
svg { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.muted { color: var(--muted); }
.small-text { font-size: 13px; }
.mono { font-family: var(--mono); }
.error-text { color: var(--live-text); }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
@keyframes flash-fade { from { opacity: 1; } }
@keyframes pop { from { opacity: 0; scale: .5; } }
@keyframes fade-in { from { opacity: 0; } }

/* ---- buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--field);
  background: var(--panel); color: var(--text); font-size: 14px; font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: #aeb3ab; color: var(--text); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.lg { height: 44px; padding: 0 18px; font-size: 15px; }
.btn.small { height: 36px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.danger { background: var(--live); border-color: var(--live); color: #fff; }
.btn.danger:hover { background: #a61f16; border-color: #a61f16; color: #fff; }
.btn.dark { background: var(--text); border-color: var(--text); color: #fff; }
.btn.dark:hover { background: #000; color: #fff; }
.btn.ghost { border-color: transparent; background: none; }
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border-radius: 10px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer;
}
.icon-btn.ghost { border-color: transparent; background: none; }
.icon-btn:hover { border-color: var(--field); }

/* ---- fields ---- */
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
fieldset.field { margin: 0; padding: 0; border: 0; }
.field > span, .field > legend, .field-label { font-size: 14px; font-weight: 600; color: var(--text); }
fieldset.field > legend { padding: 0; margin-bottom: 10px; }
.count { margin-inline-start: 6px; color: var(--muted); font-weight: 500; }
.hint { font-size: 13px; color: var(--muted); }
input[type=text], input[type=search], input[type=email], input[type=password], select, textarea {
  border: 1px solid var(--field); border-radius: 10px; background: var(--panel); outline: none;
}
input[type=text], input[type=search], input[type=email], input[type=password], select { height: 44px; padding: 0 14px; }
select { padding: 0 10px; }
textarea { padding: 12px 14px; line-height: 1.6; resize: vertical; }
input[type=text]:focus, input[type=search]:focus, input[type=email]:focus, input[type=password]:focus, select:focus, textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea.mono { font-size: 13px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* Language chips: a hidden checkbox inside a pill; a tick shows when it is on. */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px;
  border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); color: var(--text-3);
  font-size: 14px; cursor: pointer; user-select: none;
}
.chip input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); font-weight: 600; }
.chip:has(input:checked)::before {
  content: ""; width: 14px; height: 14px; background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip .slow { padding: 1px 6px; border-radius: 4px; background: var(--warn-soft); color: var(--warn-text); font-size: 11px; font-weight: 600; }

/* ---- small labels ---- */
.code-pill {
  display: inline-flex; align-items: center; height: 24px; padding: 0 8px; border-radius: 6px;
  background: var(--tint); color: var(--text-3); font-family: var(--mono); font-size: 12px; font-weight: 500; text-transform: uppercase;
}
.code-pill.auto { background: none; border: 1px dashed #b9beb6; font-family: var(--sans); text-transform: none; }
.code-pill.more { background: none; color: var(--muted); padding: 0 4px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 999px;
  background: var(--tint); color: var(--text-3); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.badge.live { background: var(--live-soft); color: var(--live-text); font-weight: 600; }
.badge.idle { background: none; border: 1px solid var(--line-2); }
.tag { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--tint); color: var(--text-3); font-size: 13px; }
.tag.revised { background: var(--revise-soft); color: var(--revise); font-weight: 500; cursor: help; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #8a919c; flex: none; }
.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--warn); }
.status-dot.bad, .status-dot.live { background: var(--live-dot); }
/* Pulses 3 times, then stays solid: an endless pulse costs frames for hours on phones and projectors. */
.status-dot.live { animation: pulse 1.6s ease-in-out 3; }

/* ---- top bar & brand ---- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; min-height: 64px; padding: 10px 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.topbar h1 { flex: 1 1 240px; min-width: 0; margin: 0; font-size: 18px; line-height: 1.3; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; font-weight: 700; font-size: 19px; letter-spacing: -0.01em; }
.brand:hover { color: var(--text); }
.wordmark em { font-style: normal; color: var(--accent); }
.engine-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--text-3);
}
.stt-chip { font-family: var(--mono); font-size: 12px; color: var(--muted); }
/* interface language picker (i18n.js) */
.ui-lang {
  display: inline-flex; align-items: center; gap: 4px; height: 40px; padding-inline: 10px 2px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--panel); color: var(--muted);
}
.ui-lang:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.ui-lang select { height: 38px; padding: 0 6px; border: 0; background: none; box-shadow: none; color: var(--text); font-size: 14px; cursor: pointer; }
.ui-lang select:focus { box-shadow: none; }
[dir=rtl] .flip-rtl { transform: scaleX(-1); }
.timer-pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; border-radius: 999px;
  background: var(--tint); color: var(--text-3); font-family: var(--mono); font-size: 14px; font-weight: 500;
}
.timer-pill.on { background: var(--live-soft); color: var(--live-text); font-weight: 600; }
#toggle .ico-stop { display: none; }
#toggle.danger .ico-stop { display: block; }
#toggle.danger .ico-play { display: none; }

/* ---- dashboard ---- */
.page { max-width: 1200px; margin: 0 auto; padding: 40px 32px 72px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px; }
.page-head > div { flex: 1 1 420px; min-width: 0; }
.page-head h1 { margin: 0; font-size: 30px; line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; }
.lead { margin: 6px 0 0; color: var(--muted); }
/* The controller's lasting warning (connection, audio, a paused session, saving). */
.alert-bar { display: flex; align-items: center; gap: 12px; padding: 12px 20px; background: #8f1d22; color: #fff; font-weight: 600; }
.alert-bar span { flex: 1; min-width: 0; }
.alert-bar .btn { border-color: rgb(255 255 255 / .6); background: transparent; color: #fff; }
.btn.danger-ghost { border-color: var(--err-line); color: var(--live-text); }
.btn.danger-ghost:hover:not(:disabled) { background: var(--err-soft); }
.feed > .older { align-self: center; }
/* Shown only while it has keyboard focus. */
.skip-link { position: absolute; z-index: 20; inset-inline-start: 12px; margin-top: 8px; padding: 8px 14px; border-radius: 10px; background: var(--accent-2); color: #fff; font-weight: 600; text-decoration: none; }
.skip-link:not(:focus) { width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon-btn.row-delete { width: 32px; height: 32px; border-color: transparent; background: transparent; color: var(--muted); }
.icon-btn.row-delete:hover { border-color: var(--err-line); background: var(--err-soft); color: var(--live-text); }
.icon-btn.row-dup { width: 32px; height: 32px; border-color: transparent; background: transparent; color: var(--muted); margin-inline-end: 2px; }
.icon-btn.row-dup:hover { border-color: var(--line); color: var(--text); }
.notice { padding: 12px 16px; border-radius: 12px; border: 1px solid #f1d7a3; background: #fff8e8; color: var(--warn-text); }
.notice.bad { border-color: var(--err-line); background: var(--err-soft); color: var(--live-text); }
.live-banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; padding: 20px 24px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.live-banner-main { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.live-banner-main h2 { margin: 0; font-size: 20px; line-height: 1.3; font-weight: 600; }
.live-banner-main p { margin: 0; font-size: 14px; color: var(--muted); }
.live-banner-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }
.search {
  flex: 1 1 320px; max-width: 420px; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px;
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 10px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input[type=search] { flex: 1; min-width: 0; height: 40px; padding: 0; border: 0; background: none; box-shadow: none; color: var(--text); }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.table { width: 100%; min-width: 880px; border-collapse: collapse; font-size: 14px; }
.table th { padding: 14px 20px; text-align: start; font-size: 13px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--line); }
.table td { padding: 16px 20px; border-bottom: 1px solid #edeeea; vertical-align: middle; transition: background-color var(--dur-1); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: var(--panel-2); }
.table .num { text-align: end; font-family: var(--mono); }
.table .when { color: var(--muted); white-space: nowrap; }
.table .name a { color: var(--text); font-weight: 600; text-decoration: none; }
.table .name a:hover { color: var(--accent); }
.empty { margin: 0; padding: 48px 0; text-align: center; color: var(--muted); }
.foot-note { margin: 0; font-size: 14px; color: var(--muted); }
.notice code { font-family: var(--mono); font-size: 13px; }

/* ---- memory page ---- */
.mem-stats { display: flex; flex-wrap: wrap; gap: 8px; }
.mem-tabs { width: min(640px, 100%); }
.tab-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-inline-start: 6px; padding: 0 6px;
  border-radius: 999px; background: var(--warn-soft); color: var(--warn-text); font-size: 12px; font-weight: 600;
}
.mem-panel { display: flex; flex-direction: column; gap: 16px; }
.toolbar .spacer { flex: 1; }
.mem-panel .hint { margin: 0; }
.mem-panel h2 { margin: 0; font-size: 17px; font-weight: 600; }
.table.plain { min-width: 720px; }
.table.plain tbody tr { cursor: auto; }
.table.plain tbody tr:hover td { background: none; }
.table.plain td { vertical-align: top; }
.table .actions { width: 1%; text-align: end; white-space: nowrap; }
.table .actions .btn + .btn { margin-inline-start: 6px; }
.table .wrap { overflow-wrap: break-word; } /* not "anywhere": that would squeeze the column to a letter */
.table .num small { display: block; font-family: var(--sans); font-size: 12px; white-space: nowrap; }
.table .note { color: var(--text-3); max-width: 280px; }
.name-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.name-chip {
  display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; padding: 2px 8px; border-radius: 6px;
  background: var(--tint); color: var(--text); overflow-wrap: break-word;
}
.name-chip .code { flex: none; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--muted); text-transform: uppercase; }
.lang-text { display: flex; align-items: baseline; gap: 8px; }
.lang-text .code-pill { flex: none; }
.table .edit-row td { background: var(--panel-2); }
.term-editor { display: flex; flex-direction: column; gap: 14px; max-width: 760px; }
.term-meta { display: grid; grid-template-columns: minmax(0, 1fr) minmax(10rem, 14rem); gap: 12px; }
.name-edit { display: grid; grid-template-columns: minmax(9rem, 13rem) minmax(0, 1fr) 40px; gap: 8px; align-items: center; }
.name-edit .icon-btn { width: 40px; height: 40px; }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.more-row { display: flex; justify-content: center; }
.danger-zone { border-color: var(--err-line); }
.danger-zone .section-title { color: var(--live-text); }
.danger-zone p { margin: 0; color: var(--text-3); font-size: 14px; }
.wipe-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.wipe-row input[type=text] { flex: 0 1 240px; min-width: 0; }
@media (max-width: 640px) {
  .term-meta, .name-edit { grid-template-columns: minmax(0, 1fr); }
  .name-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
}
/* memory page: Quality tab */
.q-filter { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; }
.q-filter select { min-width: 10rem; max-width: 18rem; font-weight: 400; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 12px; margin: 0; }
.kpi { gap: 4px; padding: 16px 18px; }
.kpi dt { font-size: 13px; font-weight: 600; color: var(--muted); }
.kpi dd { margin: 0; }
.kpi .kpi-value { font-family: var(--mono); font-size: 24px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.kpi .kpi-sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.q-tables { display: flex; flex-direction: column; gap: 16px; }
.kpi-grid.partial .kpi-value, .q-tables.partial td { color: var(--muted); }
.table.q-table { min-width: 760px; }
.table.q-table th, .table.q-table td { padding-inline: 14px; }
.table .model-name { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.how-to-read ul { margin: 0; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--text-3); font-size: 14px; }

/* ---- session dialog ---- */
dialog {
  width: min(760px, 94vw); max-height: 92vh; padding: 0; border: 0; border-radius: 16px; color: var(--text); background: var(--panel);
  box-shadow: 0 24px 48px rgba(21, 24, 29, 0.18), 0 2px 6px rgba(21, 24, 29, 0.08);
}
dialog::backdrop { background: rgba(21, 24, 29, 0.45); }
dialog form { display: flex; flex-direction: column; max-height: 92vh; }
.dlg-head { display: flex; align-items: flex-start; gap: 16px; padding: 24px 28px 20px; border-bottom: 1px solid var(--line); }
.dlg-head > div { flex: 1; min-width: 0; }
.dlg-head h2 { margin: 0; font-size: 22px; line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.dlg-head p { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.dlg-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 24px; padding: 24px 28px 28px; }
.dlg-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px; padding: 16px 28px; border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 16px 16px; }
.dlg-foot .error-text { flex: 1 1 100%; margin: 0; }

/* glossary import (glossary-ui.js) */
.import-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: -12px; }
.import-row small { font-size: 13px; }
.import-panel {
  display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--accent-line);
  border-radius: 12px; background: #f3faf8; font-size: 14px;
}
.import-panel .import-title { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.import-table { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.import-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

/* ---- controller ---- */
.controller { height: 100%; display: flex; flex-direction: column; }
.workspace { flex: 1; min-height: 0; display: grid; grid-template-columns: 280px minmax(0, 1fr) 340px; gap: 20px; padding: 20px; }
.sidebar, .rightbar { min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 16px; }
/* A column taller than the screen scrolls; its cards and buttons never shrink to fit it (at
   1366×768 with LAN=1, "Edit session" and "Delete session" were squeezed from 44 to 24 px). */
.sidebar > *, .rightbar > * { flex-shrink: 0; }
.card { display: flex; flex-direction: column; gap: 12px; padding: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.section-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--muted); }
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv .k { font-size: 13px; color: var(--muted); }
.kv .v { font-weight: 500; overflow-wrap: anywhere; }
.kv .v.mono { font-size: 13px; }
.copy-row { display: flex; align-items: center; gap: 8px; }
.copy-row input[type=text] { flex: 1; min-width: 0; height: 40px; padding: 0 10px; border-color: var(--line-2); background: var(--panel-2); font-family: var(--mono); font-size: 12px; color: var(--text-3); }
.copy-row .icon-btn { height: 40px; }
.lan-link { display: flex; flex-direction: column; gap: 4px; }
.lan-name { font-size: 12px; font-weight: 600; color: var(--muted); overflow-wrap: anywhere; }
.stack { display: flex; flex-direction: column; gap: 8px; }

/* The jump button sits over the bottom of the feed (same grid cell), whatever the audio bar's height. */
.center { position: relative; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; }
.feed { grid-area: 1 / 1; flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 0 4px 8px 0; }
.feed-empty { margin: auto; max-width: 380px; text-align: center; color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 12px; }
.cards:empty { display: none; }
/* Keyboard focus passes through these on its way into or out of the cards (see "keyboard"
   in controller.js); it never stays. Fixed, so focusing one never scrolls the feed. */
.focus-guard { position: fixed; top: 0; left: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }
.seg { display: flex; flex-direction: column; gap: 12px; padding: 16px 18px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
/* The rest of a sentence cut by the recognizer (controller-feed.js "joins"): the two cards
   touch, a dashed seam between them. Each stays a card of its own (editing is per line). */
.seg + .seg.joins { margin-top: -12px; border-top: 1px dashed var(--line); border-top-left-radius: 0; border-top-right-radius: 0; }
.seg:has(+ .seg.joins) { border-bottom-color: transparent; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
/* The card holding keyboard focus (arrow keys move it): drawn inside the card, as the feed
   clips anything outside it. */
.seg:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
/* Cards far from the newest are laid out only when scrolled into view: with all 2,000 cards
   of a 3-hour meeting shown, a view-language change or "Show earlier" otherwise re-lays out
   every one of them (~2–3 s). The newest 50 always are, so following the latest sentence
   lands exactly at the bottom. Not while hovered or focused: the containment would clip a
   check badge's tooltip at the card's edge. */
.cards > .seg:nth-last-child(n+51):not(:hover, :focus-within) { content-visibility: auto; contain-intrinsic-size: auto 260px; }
.seg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 13px; color: var(--muted); }
.seg-head .seq { font-family: var(--mono); font-weight: 500; color: var(--text-3); }
.seg-head .time { font-family: var(--mono); }
.seg-head .spacer { flex: 1; }
.seg-row { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 12px; align-items: baseline; }
.seg-row .lang {
  display: inline-flex; justify-content: center; align-items: center; height: 24px; border-radius: 6px;
  background: var(--tint); color: var(--text-3); font-family: var(--mono); font-size: 12px; font-weight: 500; text-transform: uppercase;
}
.seg-row.source .lang { background: var(--accent-soft); color: var(--accent-2); }
.seg-row .text { font-size: 15px; line-height: 1.6; color: var(--text-2); overflow-wrap: anywhere; }
.seg-row.source .text { font-size: 17px; line-height: 1.55; font-weight: 500; color: var(--text); }
.seg-row.pending .text { color: var(--muted); font-style: italic; }
.seg-trans { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid #edeeea; }
.seg-error {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  background: var(--err-soft); color: var(--live-text); font-size: 14px;
}
.seg-error > span { flex: 1 1 240px; }
.seg-error .btn { border-color: var(--err-line); color: var(--live-text); }
.speaking {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px; border: 1px dashed var(--accent-line);
  border-radius: var(--radius); color: var(--accent-2); font-size: 14px; font-weight: 500;
}
.dots { display: inline-flex; gap: 4px; }
.dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
.jump {
  grid-area: 1 / 1; align-self: end; justify-self: end; position: relative; z-index: 1;
  margin: 0 16px 12px; box-shadow: 0 6px 16px rgba(21, 24, 29, 0.12);
}

/* Line tools: check badge, "corrected" tag, edit button (shown on hover or focus; always on touch).
   Negative margins keep a line as tall as its text. */
.seg-row { grid-template-columns: 40px minmax(0, 1fr) auto; }
.row-tools { display: inline-flex; align-items: center; gap: 6px; align-self: start; margin-block: -2px; }
.row-edit {
  display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid transparent; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer; opacity: 0;
}
.row-edit:hover { border-color: var(--line-2); background: var(--panel); color: var(--text); }
.seg-row:hover .row-edit, .seg-row:focus-within .row-edit { opacity: 1; }
.row-edit:disabled { visibility: hidden; }
@media (hover: none) { .row-edit { opacity: 1; } }
.tag.corrected { padding: 0 6px; font-size: 12px; background: var(--accent-soft); color: var(--accent-2); font-weight: 500; cursor: help; }
/* Check badge with its own tooltip (also on keyboard focus), above the line. */
.check { position: relative; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; color: var(--warn-text); cursor: help; }
.check::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 6px); inset-inline-end: -4px; z-index: 5; display: none;
  width: max-content; max-width: 300px; padding: 8px 10px; border-radius: 8px; background: var(--text); color: #fff;
  font-size: 12px; line-height: 1.45; font-weight: 400; text-align: start; white-space: pre-line; pointer-events: none;
  box-shadow: 0 6px 16px rgba(21, 24, 29, 0.18);
}
.check:hover::after, .check:focus-visible::after { display: block; }
/* The line being corrected */
.seg-row.editing { align-items: start; }
.seg-row.editing > .text, .seg-row.editing > .row-tools { display: none; }
.row-editor { grid-column: 2 / -1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.row-input { width: 100%; min-height: 64px; max-height: 40vh; field-sizing: content; padding: 8px 12px; font-size: 15px; line-height: 1.6; resize: vertical; }
.seg-row.source .row-input { font-size: 17px; font-weight: 500; }
.row-input[readonly] { color: var(--muted); }
.row-editor-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row-editor-foot .hint { flex: 1 1 220px; }

/* Spoken-language tag of a card: a button that opens .lang-menu */
.lang-btn { display: inline-flex; align-items: center; gap: 4px; border: 1px solid transparent; line-height: inherit; cursor: pointer; }
.lang-btn:hover, .lang-btn[aria-expanded=true] { border-color: var(--line-2); color: var(--text); }
.lang-btn svg { color: var(--muted); }
/* Floating pieces placed from JS through --x/--y (CSSOM, so the CSP allows it). */
.lang-menu, .pick-btn { position: fixed; left: var(--x, 0); top: var(--y, 0); z-index: 15; }
.lang-menu {
  display: flex; flex-direction: column; gap: 2px; width: max-content; min-width: 220px; max-width: min(340px, calc(100vw - 16px));
  max-height: min(380px, 70vh); overflow: auto; padding: 6px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 30px rgba(21, 24, 29, 0.18);
}
.lang-menu [role=menu] { display: flex; flex-direction: column; gap: 2px; }
.lang-menu-title { margin: 4px 8px 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.lang-menu [role=menuitemradio] {
  display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 10px; border: 0; border-radius: 8px;
  background: none; color: var(--text); font-size: 14px; text-align: start; cursor: pointer;
}
.lang-menu [role=menuitemradio]:hover, .lang-menu [role=menuitemradio]:focus-visible { background: var(--tint); }
.lang-menu [role=menuitemradio][aria-checked=true] { color: var(--accent-2); font-weight: 600; cursor: default; }
.lang-menu-confirm { max-width: 320px; margin: 6px 8px; font-size: 14px; line-height: 1.5; }
.lang-menu-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 4px; }
.pick-btn { translate: -50% calc(-100% - 8px); box-shadow: 0 6px 16px rgba(21, 24, 29, 0.16); }
.pick-btn.below { translate: -50% 8px; }

/* Compact dialogs (add to glossary, confirmations) */
dialog.dlg-compact { width: min(560px, 94vw); }
.name-rows { display: flex; flex-direction: column; gap: 8px; }
.name-row { display: grid; grid-template-columns: minmax(7rem, 11rem) minmax(0, 1fr); align-items: center; gap: 10px; }
.name-lang { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; color: var(--text-3); }
.name-lang > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.name-row input[type=text] { min-width: 0; }

.audiobar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 12px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.audiobar select { flex: 0 1 260px; min-width: 160px; }
.meter { flex: 1 1 160px; height: 8px; border-radius: 4px; background: #ecede9; overflow: hidden; }
/* The level is a scaleX transform (set by controller.js), never a width: no layout 10 times a second. */
.meter > div {
  width: 100%; height: 100%; background: var(--ok); transform: scaleX(0);
  transform-origin: calc(50% - 50% * var(--dir)) 50%; transition: transform 100ms linear;
}
.speaking-label { min-width: 90px; font-size: 14px; color: var(--muted); }
.mic-btn { display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid var(--accent); border-radius: 50%; background: var(--accent); color: #fff; cursor: pointer; }
.mic-btn .ico-off { display: none; }
.mic-btn.active { border-color: var(--err-line); background: var(--err-soft); color: var(--live-text); }
.mic-btn.active .ico-on { display: none; }
.mic-btn.active .ico-off { display: block; }

.tabs { display: flex; gap: 4px; padding: 4px; background: #e8e9e5; border-radius: 12px; }
.tabs button { flex: 1; height: 40px; border: 0; border-radius: 9px; background: none; color: var(--text-3); font-size: 14px; font-weight: 500; cursor: pointer; }
.tabs button[aria-selected=true] { background: var(--panel); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgba(21, 24, 29, 0.1); }
.tabpanel { display: flex; flex-direction: column; gap: 16px; }
.tabpanel textarea { min-height: 180px; }
.tabpanel textarea.context-box { min-height: 130px; }
.tabpanel textarea#glossary { white-space: pre; overflow-x: auto; }
.summary { margin: 0; padding: 12px 14px; border-radius: 10px; background: var(--bg); font-size: 14px; line-height: 1.6; color: var(--muted); white-space: pre-wrap; }
.summary.has { color: var(--text-2); }
.summary-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.summary-row small { flex: 1 1 auto; font-size: 13px; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat { padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.stat .n { font-family: var(--mono); font-size: 20px; font-weight: 500; overflow-wrap: anywhere; }
.stat .l { font-size: 12px; color: var(--muted); }
.stat.bad { background: var(--err-soft); }
.stat.bad .n, .stat.bad .l { color: var(--live-text); }
.dl-row { display: flex; gap: 8px; }
.dl-row .btn { flex: 1; }

/* Revised highlight: an overlay behind the text whose opacity fades (no background paint per frame). */
.seg.flash, .cap.flash { position: relative; isolation: isolate; }
.seg.flash::after, .cap.flash::after {
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none;
  background: #fff6cf; opacity: 0; animation: flash-fade 1.6s var(--ease-out-3);
}
.cap.flash::after { inset: -4px -12px; border-radius: 10px; background: rgb(255 214 102 / .18); }
/* "Copied" confirmation on the copy-link button */
.icon-btn .ico-done { display: none; }
.icon-btn.copied .ico-copy { display: none; }
.icon-btn.copied .ico-done { display: block; color: var(--ok); }
.toast {
  position: fixed; inset-inline-end: 20px; bottom: 20px; z-index: 20; max-width: 420px; padding: 12px 16px; border-radius: 12px;
  background: var(--text); color: #fff; box-shadow: 0 12px 30px rgba(21, 24, 29, 0.25);
}
.toast.bad { background: #8f1d22; }

@media (max-width: 1100px) {
  body.ctl { height: auto; }
  .controller { height: auto; min-height: 100%; }
  .workspace { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .rightbar { overflow: visible; }
  .feed { min-height: 320px; max-height: 70vh; }
}
@media (max-width: 640px) {
  .page { padding: 24px 16px 48px; }
  .topbar { padding: 10px 16px; }
  .workspace { padding: 12px; gap: 12px; }
  .dlg-head, .dlg-body, .dlg-foot { padding-left: 18px; padding-right: 18px; }
}

/* ---- live view (audience) ---- */
body.live { display: flex; flex-direction: column; background: #0d0f12; color: #f3f4f6; color-scheme: dark; }
body.live a { color: #5cc8bc; }
.live-top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; padding: 16px 32px; border-bottom: 1px solid #222730; }
.live-top h1 { flex: 1 1 280px; min-width: 0; margin: 0; font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-badge {
  display: inline-flex; align-items: center; gap: 8px; height: 32px; padding: 0 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: #a3abb8; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.live-badge.on { background: rgba(255, 90, 78, 0.14); color: #ff8a80; }
.live-badge .status-dot.live { background: #ff5a4e; }
.live-lang { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #a3abb8; }
.live-top select { height: 44px; padding: 0 12px; border: 1px solid #2e343d; border-radius: 10px; background: #1a1e24; color: #f3f4f6; font-size: 15px; }
.live-tools { display: flex; gap: 6px; }
.live-top .icon-btn { border-color: #2e343d; background: #1a1e24; color: #f3f4f6; font-size: 14px; font-weight: 600; }
.live-top .icon-btn.big { font-size: 18px; }
.src-btn { height: 44px; padding: 0 14px; border: 1px solid #2e343d; border-radius: 10px; background: #1a1e24; color: #f3f4f6; font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.src-btn[aria-pressed=true] { border-color: #5cc8bc; background: rgba(92, 200, 188, 0.14); color: #8fdcd3; font-weight: 600; }
.captions { flex: 1; min-height: 0; width: 100%; max-width: 1160px; margin: 0 auto; overflow: auto; display: flex; flex-direction: column; gap: 28px; padding: 48px 40px 12vh; }
.captions > .live-empty[hidden] + .cap { margin-top: auto; } /* bottom-aligned, still scrollable */
/* The rest of a sentence cut by the recognizer (live.js "joins"): no gap, so the two lines
   read as one paragraph. */
.captions > .cap.joins { margin-top: -22px; }
/* Long words, e-mail addresses, links and form codes wrap instead of running off a phone's
   screen once the text is enlarged (A+); the size never exceeds what a narrow screen holds.
   Older and waiting captions are dimmed with colours of at least 4.5:1 on the background
   (WCAG AA), never with opacity, which would multiply onto the source line too. */
.cap { margin: 0; font-size: calc(min(var(--cap-size, 40px), 11vw) * 0.66); line-height: 1.4; font-weight: 500; color: #9aa3b0; transition: color 0.3s, opacity 0.3s; overflow-wrap: anywhere; hyphens: auto; }
.cap.current { font-size: min(var(--cap-size, 40px), 11vw); line-height: 1.35; font-weight: 600; color: #f7f8fa; }
.cap .src { display: block; margin-bottom: 6px; font-size: 16px; line-height: 1.5; font-weight: 400; color: #a3abb8; overflow-wrap: anywhere; hyphens: auto; }
.cap .src-code { margin-inline-end: 8px; font-family: var(--mono); font-size: 12px; }
.cap[dir="rtl"] .src { text-align: right; } /* keep the source line on the caption's side */
.cap.pending { color: #858d99; } /* 5.7:1 */
.cap.old { color: #858d99; }
.cap.failed .note { display: block; margin-top: 4px; font-size: 15px; font-weight: 500; color: #ffd27a; }
.live-empty { margin: auto; color: #8b93a1; text-align: center; font-size: 18px; }
.live-conn { margin: 0; padding: 10px 32px; background: rgba(255, 196, 61, 0.12); color: #ffd27a; font-size: 15px; font-weight: 500; text-align: center; }
.live-top .icon-btn[aria-pressed=true] { border-color: #5cc8bc; background: rgba(92, 200, 188, 0.14); color: #8fdcd3; }
/* "Latest subtitles" sits over the bottom of the captions: a negative margin, not a fixed
   position, because the footer's height changes with its text. Takes no height of its own. */
.live-latest { align-self: center; position: relative; z-index: 1; margin: -64px 0 20px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5); }
.live-tts { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 16px; padding: 12px 32px; border-bottom: 1px solid #222730; background: rgba(92, 200, 188, 0.1); color: #d5f3ef; font-size: 15px; }
.live-tts p { flex: 1 1 280px; max-width: 640px; margin: 0; }
.live-tts-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.src-btn.primary { border-color: #5cc8bc; background: #0b6e66; color: #fff; font-weight: 600; }
.live-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 14px 32px; border-top: 1px solid #222730; font-size: 13px; color: #8b93a1; }
.live-foot .wordmark em { color: #5cc8bc; }
/* The AI notice: small, wraps beside the wordmark (two lines on a phone). */
.live-foot #disclaimer { flex: 1 1 280px; line-height: 1.45; }
.live-foot #privacy { white-space: nowrap; }
@media (max-width: 640px) {
  .live-top { padding: 14px 16px; }
  .live-lang { flex: 1 1 100%; }
  .live-lang select { flex: 1; min-width: 0; }
  .captions { padding: 20px 18px 8vh; gap: 22px; }
  .captions > .cap.joins { margin-top: -17px; }
  .live-foot { padding: 12px 18px; }
  .live-conn { padding: 10px 18px; }
  .live-tts { padding: 12px 18px; }
}

/* ---- motion (every page) ----
   Only transform/translate/scale and opacity move, and nothing runs while a page is idle.
   Kept last so these rules win over the base rules above. JS checks motionOK() from fx.js. */

/* Control feedback: colour and press, all cheap. */
.btn, .icon-btn, .chip, .src-btn, .tabs button, .mic-btn, .timer-pill, .stat {
  transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1), box-shadow var(--dur-1), scale var(--dur-1);
}
@media (prefers-reduced-motion: no-preference) {
  .btn:active:not(:disabled), .icon-btn:active, .mic-btn:active { scale: .97; }
}

/* Cross-page fade between /, /app and /controller; the top bar morphs. Never on reload. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
::view-transition { pointer-events: none; } /* the overlay must not swallow clicks */
::view-transition-group(*) { animation-duration: 220ms; }
.topbar { view-transition-name: topbar; }

@media (prefers-reduced-motion: no-preference) {
  /* Things that appear when [hidden] is removed: fade in (and slide, for the toast and jump button). */
  .tabpanel, .live-banner, .speaking, .import-panel, #jump, .toast {
    transition: opacity var(--dur-2) var(--ease-out-3), translate var(--dur-2) var(--ease-out-3);
  }
  @starting-style {
    .tabpanel, .speaking, .import-panel { opacity: 0; }
    .live-banner { opacity: 0; translate: 0 -6px; }
    #jump, .toast { opacity: 0; translate: 0 8px; }
  }
  /* Toast exit (Chromium, Safari 18+; Firefox hides it instantly) */
  .toast { transition-property: opacity, translate, display; transition-behavior: allow-discrete; }
  .toast[hidden] { opacity: 0; translate: 0 8px; }

  /* Dialog: animated open everywhere; animated close only where `overlay` exists (Chromium) */
  dialog[open] { transition: opacity var(--dur-2) var(--ease-out-3), scale var(--dur-2) var(--ease-out-3); }
  @starting-style { dialog[open] { opacity: 0; scale: .97; } }
  dialog[open]::backdrop { transition: background-color var(--dur-2); }
  @starting-style { dialog[open]::backdrop { background-color: transparent; } }
  @supports (overlay: auto) {
    dialog { opacity: 0; scale: .97; transition: opacity var(--dur-2) var(--ease-out-3), scale var(--dur-2) var(--ease-out-3), overlay var(--dur-2) allow-discrete, display var(--dur-2) allow-discrete; }
    dialog[open] { opacity: 1; scale: 1; }
    dialog::backdrop { background-color: transparent; transition: background-color var(--dur-2), overlay var(--dur-2) allow-discrete, display var(--dur-2) allow-discrete; }
    dialog[open]::backdrop { background-color: rgb(21 24 29 / .45); }
  }
  .chip:has(input:checked)::before { animation: pop var(--dur-3) var(--ease-spring-2); }
  .icon-btn.copied .ico-done { animation: pop var(--dur-3) var(--ease-spring-2); }

  /* /app: the session rows fade in on the first load only (dashboard.js adds .row-in and --i). */
  .table tbody tr.row-in { animation: fade-in .3s var(--ease-out-3) backwards; animation-delay: calc(min(var(--i, 0), 12) * 25ms); }
  /* Rows rebuilt by a search or language change keep a steady live dot instead of pulsing anew. */
  .table tbody tr:not(.row-in) .status-dot.live { animation: none; }

  /* Controller: .enter only on a new card, .filled only on a translation that just arrived
     (cards are rebuilt with replaceWith(), so plain @starting-style would replay on every update). */
  .seg.enter { transition: opacity var(--dur-2) var(--ease-out-3), translate var(--dur-2) var(--ease-out-3); }
  @starting-style { .seg.enter { opacity: 0; translate: 0 8px; } }
  .seg-row.filled .text { transition: opacity var(--dur-3) var(--ease-out-3); }
  @starting-style { .seg-row.filled .text { opacity: .3; } }
  .seg.flash .tag.revised { animation: pop var(--dur-3) var(--ease-spring-2); }
  /* Line tools: the edit button fades in on hover; a fresh "corrected" tag pops; the floating
     "Add to glossary" button and the language menu fade in where they appear. */
  .row-edit { transition: opacity var(--dur-1), background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1); }
  .seg-row.just-saved .tag.corrected { animation: pop var(--dur-3) var(--ease-spring-2); }
  .pick-btn { transition: opacity var(--dur-2) var(--ease-out-3); }
  @starting-style { .pick-btn { opacity: 0; } }
  .lang-menu { animation: fade-in var(--dur-1) var(--ease-out-3); }

  /* Live View: a new caption rises a quarter line; a pending one brightens when its translation lands. */
  .cap.enter { transition: opacity var(--dur-2) var(--ease-out-3), translate var(--dur-2) var(--ease-out-3), color .3s; }
  @starting-style { .cap.enter { opacity: 0; translate: 0 .25em; } }
  .cap.resolved { transition: opacity var(--dur-3) var(--ease-out-3), color .3s; }
  @starting-style { .cap.resolved { opacity: .5; } }
}

/* Reduced motion: a safety net for every CSS animation and transition. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-delay: 0s !important; animation-iteration-count: 1 !important;
    transition-duration: 1ms !important; transition-delay: 0s !important; scroll-behavior: auto !important;
  }
  /* The revised highlight is a colour fade, not movement, and it carries information: keep it. */
  .seg.flash::after, .cap.flash::after { animation-duration: 1.6s !important; }
}

/* ---- sign-in page (/login, hosted mode) ---- */
.login-page { max-width: 420px; }
.login-card { gap: 16px; padding: 24px; }
.login-card h1 { margin: 0; font-size: 24px; line-height: 1.25; font-weight: 700; }
.login-card form { display: flex; flex-direction: column; gap: 16px; }
.login-card .btn { width: 100%; justify-content: center; }

.login-card .login-privacy { margin: 0; font-size: 13px; text-align: center; }

/* ---- privacy notice (/privacy, hosted mode) and the consent dialog (consent.js) ---- */
.prose { max-width: 760px; gap: 56px; }
.prose article { display: flex; flex-direction: column; gap: 12px; }
.prose h1 { margin: 0; font-size: 28px; line-height: 1.25; font-weight: 700; letter-spacing: -0.015em; }
.prose h2 { margin: 16px 0 0; font-size: 18px; line-height: 1.35; font-weight: 700; }
.prose p, .prose ul { margin: 0; }
.prose ul { padding-inline-start: 22px; display: flex; flex-direction: column; gap: 8px; }
.doc-nav { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 14px; }
.doc-nav a[aria-current] { color: var(--text); font-weight: 600; text-decoration: none; }
dialog.consent-dlg { width: min(560px, 94vw); }
.consent-body { gap: 16px; }
.consent-body > p { margin: 0; }
.consent-check { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); cursor: pointer; }
.consent-check input { flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); }

/* ---- buying prepaid hours through payOS (payments.js, hosted mode) ---- */
dialog.pay-dlg { width: min(640px, 94vw); }
.pay-body { gap: 16px; }
.pay-body h3 { margin: 8px 0 0; font-size: 16px; font-weight: 700; }
.pay-packages { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.pay-package { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.pay-package:hover:not(:disabled), .pay-package:focus-visible { border-color: var(--accent); }
.pay-package:disabled { opacity: 0.6; cursor: progress; }
.pay-hours { color: var(--muted); font-size: 14px; }
.pay-price { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pay-top { display: flex; }
.pay-payable { display: grid; grid-template-columns: minmax(0, 220px) minmax(0, 1fr); gap: 12px 24px; align-items: start; }
.pay-payable > .lead, .pay-actions { grid-column: 1 / -1; margin: 0; }
.pay-qr { padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; line-height: 0; }
.pay-qr svg { width: 100%; height: auto; }
.pay-details { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 14px; }
.pay-details dt { color: var(--muted); }
.pay-details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.pay-amount { font-size: 18px; font-variant-numeric: tabular-nums; }
.pay-note { font-family: var(--mono); }
.pay-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.table.pay-history { min-width: 0; }
.pay-history th, .pay-history td { padding: 10px 12px; }
.pay-history tbody tr { cursor: default; }
.pay-history .num { white-space: nowrap; }
.pay-state { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--panel-2); font-weight: 600; }
.pay-state.paid { background: #e7f6ef; color: #0b6e4f; }
.pay-state.review, .pay-state.failed { background: var(--err-soft); color: var(--live-text); }
.pay-status.paid { color: #0b6e4f; font-weight: 600; }
.pay-status.review, .pay-status.failed { color: var(--live-text); }
@media (max-width: 540px) { .pay-payable { grid-template-columns: 1fr; } .pay-qr { max-width: 260px; } }

/* ---- hosted mode (DEPLOY=hosted, site.js) ---- */
/* What only local mode has: the model choice, agy, tokens and cost, the LAN=1 hints (D2).
   Hidden until site.js knows the mode (it sets data-deploy="local" also when /api/site fails),
   so a hosted page never paints them first. */
html:not([data-deploy="local"]) .local-only { display: none !important; }
/* The school's name and Sign out, in the top bar of /app, /controller and /memory. */
.account-box { display: flex; align-items: center; gap: 8px; min-width: 0; }
.account-name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--text-3); }
/* A prepaid school's hours left (site.js). */
.account-hours { font-size: 13px; color: var(--text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.account-hours.empty { color: var(--danger, #b42318); font-weight: 600; }

/* ---- the audience link's QR code (controller-qr.js) ---- */
.qr-box { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.qr { width: 168px; max-width: 100%; line-height: 0; }
.qr svg, .qr-big svg { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.qr-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
/* Full screen, white, for a projector: as large as the screen allows, the link under it. */
dialog.qr-dlg { width: 100vw; height: 100vh; max-width: none; max-height: none; border-radius: 0; background: #fff; color: #000; cursor: pointer; }
dialog.qr-dlg[open] { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; padding: 3vh 3vw; }
dialog.qr-dlg h2 { margin: 0; font-size: clamp(20px, 4vh, 44px); line-height: 1.2; font-weight: 700; text-align: center; }
.qr-big { width: min(70vh, 90vw); line-height: 0; }
.qr-link { margin: 0; max-width: 90vw; font-family: var(--mono); font-size: clamp(14px, 2.6vh, 30px); font-weight: 600; text-align: center; overflow-wrap: anywhere; }
.qr-hint { margin: 0; font-size: 14px; color: #5a6270; }
.qr-close { position: absolute; top: 16px; inset-inline-end: 16px; }
