/* ───────────────────────── Design tokens ───────────────────────── */
:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
          "Helvetica Neue", Helvetica, Arial, sans-serif;
  --accent: #007aff;
  --accent-press: #0060df;
  --green: #34c759;
  --red: #ff3b30;
  --amber: #ff9f0a;

  --bg: #f2f2f7;
  --bg-grad-1: #eef1f6;
  --bg-grad-2: #e7ebf3;
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1c1c1e;
  --text-2: #3c3c43;
  --text-3: rgba(60, 60, 67, 0.78);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.04);
  --radius: 22px;
  --radius-sm: 14px;
  --fill: rgba(120, 120, 128, 0.14);
  --live-bg: rgba(52, 199, 89, 0.16);
  --live-fg: #248a3d;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-grad-1: #0a0a0c;
    --bg-grad-2: #15151a;
    --card: rgba(28, 28, 30, 0.72);
    --card-solid: #1c1c1e;
    --border: rgba(255, 255, 255, 0.10);
    --text: #f5f5f7;
    --text-2: #ebebf0;
    --text-3: rgba(235, 235, 245, 0.6);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
    --fill: rgba(120, 120, 128, 0.24);
    --live-bg: rgba(52, 199, 89, 0.2);
    --live-fg: #4ade80;
  }
}

/* Explicit theme override (listener theme switch) — wins over the media query. */
:root[data-theme="light"] {
  --bg: #f2f2f7;
  --bg-grad-1: #eef1f6;
  --bg-grad-2: #e7ebf3;
  --card: rgba(255, 255, 255, 0.72);
  --card-solid: #ffffff;
  --border: rgba(0, 0, 0, 0.08);
  --text: #1c1c1e;
  --text-2: #3c3c43;
  --text-3: rgba(60, 60, 67, 0.78);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.10), 0 2px 8px rgba(0, 0, 0, 0.04);
  --fill: rgba(120, 120, 128, 0.14);
  --live-bg: rgba(52, 199, 89, 0.16);
  --live-fg: #248a3d;
}
:root[data-theme="dark"] {
  --bg: #000000;
  --bg-grad-1: #0a0a0c;
  --bg-grad-2: #15151a;
  --card: rgba(28, 28, 30, 0.72);
  --card-solid: #1c1c1e;
  --border: rgba(255, 255, 255, 0.10);
  --text: #f5f5f7;
  --text-2: #ebebf0;
  --text-3: rgba(235, 235, 245, 0.6);
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  --fill: rgba(120, 120, 128, 0.24);
  --live-bg: rgba(52, 199, 89, 0.2);
  --live-fg: #4ade80;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(140% 120% at 50% 0%, var(--bg-grad-1) 0%, var(--bg-grad-2) 55%, var(--bg) 100%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100%;
  transition: background 0.3s ease, color 0.3s ease;
}

.wrap {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 40px;
  flex: 1;
  display: flex;
  flex-direction: column;
}
.wrap.wide { max-width: 900px; }

/* ───────────────────────── Cards / typography ───────────────────────── */
.card {
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card + .card { margin-top: 16px; }

h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 2px; }
.subtitle { color: var(--text-3); font-size: 15px; margin: 0; }
.label { font-size: 13px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 8px; }

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand .glyph {
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(160deg, var(--accent), #5e5ce6);
  display: grid; place-items: center; color: #fff; flex: none;
  box-shadow: 0 6px 16px rgba(0, 122, 255, 0.35);
}
.brand .glyph svg { width: 24px; height: 24px; }

/* ───────────────────────── Buttons / controls ───────────────────────── */
button { font-family: var(--font); cursor: pointer; }
.btn {
  width: 100%;
  border: none;
  border-radius: var(--radius-sm);
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  transition: transform 0.12s ease, background 0.2s ease, opacity 0.2s ease;
}
.btn:hover { background: var(--accent-press); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #e0352b; }
.btn.ghost { background: rgba(120, 120, 128, 0.16); color: var(--text); }
.btn.ghost:hover { background: rgba(120, 120, 128, 0.24); }

.btn-clear {
  border: none;
  background: rgba(120, 120, 128, 0.14);
  color: var(--text-3);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  transition: background 0.15s ease, color 0.15s ease;
}
.btn-clear:hover { background: rgba(120, 120, 128, 0.24); color: var(--text); }
.btn-clear:active { transform: scale(0.96); }

select, input[type="password"], input[type="text"] {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  color: var(--text);
  background: rgba(120, 120, 128, 0.10);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  appearance: none;
  -webkit-appearance: none;
}
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238e8e93' d='M6 8 0 2l1.4-1.4L6 5.2 10.6.6 12 2z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:focus-visible, a:focus-visible, [contenteditable]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }

/* Compact language select next to the monitor switch */
select.monitor-lang { width: auto; font-size: 14px; padding: 7px 30px 7px 12px; background-position: right 10px center; border-radius: 10px; }
.field + .field { margin-top: 16px; }

/* iOS-style toggle */
.switch { position: relative; display: inline-block; width: 51px; height: 31px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; border-radius: 999px;
  background: rgba(120, 120, 128, 0.32); transition: background 0.2s ease;
}
.switch .track::before {
  content: ""; position: absolute; height: 27px; width: 27px; left: 2px; top: 2px;
  background: #fff; border-radius: 50%; transition: transform 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::before { transform: translateX(20px); }

/* ───────────────────────── Status chips / dots ───────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  background: rgba(120, 120, 128, 0.14);
  border-radius: 999px; padding: 7px 12px;
}
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: none; }
.dot.green { background: var(--green); box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.18); }
.dot.red { background: var(--red); }
.dot.amber { background: var(--amber); }

/* ───────────────────────── VU meter ───────────────────────── */
.vu { height: 14px; border-radius: 8px; background: rgba(120, 120, 128, 0.18); overflow: hidden; position: relative; }
.vu .fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0%;
  background: linear-gradient(90deg, var(--green), #a3e635 70%, var(--amber));
  border-radius: 8px; transition: width 0.06s linear;
}

/* ───────────────────────── Captions ───────────────────────── */
.captions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 6px; }
@media (max-width: 480px) { .captions { grid-template-columns: 1fr; } }
.captions-vertical { display: flex !important; flex-direction: column; gap: 14px; }
.cap-col { min-height: 120px; max-height: 220px; overflow-y: auto; }
.cap-col p { margin: 0; font-size: 16px; line-height: 1.5; color: var(--text); white-space: pre-wrap; }
.cap-col.muted p { color: var(--text-3); }

/* ───────────────────────── Admin two-column layout ───────────────────────── */
.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
}
@media (max-width: 640px) {
  .admin-grid { grid-template-columns: 1fr; }
}
.admin-col-left { display: flex; flex-direction: column; gap: 16px; }
.admin-col-right { display: flex; flex-direction: column; height: 100%; }
.admin-captions-card {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.admin-captions-card .captions-vertical { flex: 1; }
.admin-captions-card .cap-col {
  min-height: 140px;
  max-height: none;        /* let the card height drive it */
  height: 200px;           /* fixed height per column so both are readable */
}

/* ───────────────────────── Listener page (transcript-first) ───────────────────────── */
.hint { color: var(--text-3); font-size: 15px; max-width: 320px; }
.statusline { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 14px; font-weight: 500; }

.wrap.listener-page {
  position: relative;
  max-width: 560px;
  padding: 0;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.lst-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 16px) 22px 12px;
}
.lst-titles { flex: 1 1 auto; min-width: 0; }
.lst-header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lst-header .subtitle { margin: 2px 0 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lst-header-right { display: flex; align-items: center; gap: 8px; flex: none; }
/* Narrow phones: tighter header so title, save, language, pill and theme all fit. */
@media (max-width: 420px) {
  .lst-header { padding-left: 14px; padding-right: 14px; gap: 6px; }
  .lst-header-right { gap: 6px; }
  .lst-header h1 { font-size: 19px; }
  .pill { padding: 6px 9px; font-size: 11px; }
  .lst-hint { padding-left: 14px; padding-right: 14px; }
}

/* Status pill */
.pill {
  display: inline-flex; align-items: center; gap: 7px; white-space: nowrap;
  font-size: 12px; font-weight: 700; letter-spacing: 0.04em;
  padding: 7px 12px; border-radius: 999px;
  background: rgba(120, 120, 128, 0.2); color: var(--text-3);
  transition: background 0.3s ease, color 0.3s ease;
}
.pill-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.live { background: var(--live-bg); color: var(--live-fg); }
.pill.live .pill-dot { animation: glowPulse 1.6s ease-in-out infinite; }
.pill.amber { background: rgba(255, 159, 10, 0.16); color: var(--amber); }
@keyframes glowPulse { 0%, 100% { opacity: 0.45; } 50% { opacity: 0.8; } }

/* Round chip button (theme switch, save) — 36px visual, ≥44px hit target */
.chip-btn {
  position: relative;
  width: 36px; height: 36px; border-radius: 50%; border: none;
  display: grid; place-items: center;
  background: var(--fill); color: var(--text);
  transition: transform 0.12s ease, background 0.3s ease;
}
.chip-btn::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; }
.chip-btn:active { transform: scale(0.92); }

/* Language picker (flag button + popover) — shown only when >1 language */
.lang-group { position: relative; }
.lang-btn { font-size: 12px; font-weight: 700; letter-spacing: 0.04em; }
.lang-chip {
  display: inline-grid; place-items: center; min-width: 30px; height: 22px; padding: 0 6px;
  border-radius: 6px; background: var(--fill); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; flex: none;
}
.lang-menu button.active .lang-chip { background: var(--accent); color: #fff; }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40;
  display: flex; flex-direction: column; gap: 2px;
  min-width: 150px; padding: 6px;
  background: var(--card-solid); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.lang-menu button {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: none; border-radius: 10px;
  background: none; color: var(--text);
  font-size: 15px; font-weight: 500; text-align: left;
  transition: background 0.15s ease;
}
.lang-menu button:hover { background: var(--fill); }
.lang-menu button.active { background: var(--fill); font-weight: 600; }

/* Transcript */
.lst-transcript {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 24px 150px;
  text-align: left;
  font-size: var(--fs, 19px);
  mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 86%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 7%, black 86%, transparent 100%);
}
.para {
  margin: 0 0 20px;
  line-height: 1.65;
  font-weight: 450;
  letter-spacing: -0.01em;
  color: var(--text);
  opacity: 0.62;
  transition: opacity 0.4s ease;
  white-space: pre-wrap;
}
.lst-col p.para:last-of-type { opacity: 1; }
.word { display: inline-block; animation: wordIn 0.45s ease both; }
@keyframes wordIn {
  from { opacity: 0; filter: blur(5px); transform: translateY(3px); }
  to   { opacity: 1; filter: blur(0); transform: none; }
}
.lst-empty { color: var(--text-3); font-size: 15px; text-align: center; margin: 48px 0 0; }

#saveTranscript { color: var(--text-3); }
#saveTranscript:hover { color: var(--text); }
.lst-scroll-down { position: absolute; right: 18px; bottom: 156px; z-index: 5; }

/* Bottom overlay: glass control bar + keep-awake row */
.lst-overlay {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 18px calc(env(safe-area-inset-bottom, 0px) + 20px);
  pointer-events: none;
  z-index: 4;
}
.control-bar {
  pointer-events: auto;
  display: flex; align-items: center; gap: 6px;
  padding: 8px;
  border-radius: 999px;
  background: var(--card);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: background 0.3s ease;
}
.cb-round {
  flex: none;
  width: 52px; height: 52px; border-radius: 50%; border: none;
  display: grid; place-items: center;
  background: var(--fill); color: var(--text);
  transition: transform 0.12s ease, background 0.3s ease, box-shadow 0.3s ease;
}
.cb-round:active { transform: scale(0.94); }
.cb-round.on {
  background: radial-gradient(circle at 50% 30%, #5ea0ff, var(--accent) 70%);
  color: #fff;
}
#playBtn.on { box-shadow: 0 6px 18px rgba(0, 122, 255, 0.35); }
.cb-round .wave { animation: none; }
#muteBtn.on .wave1 { animation: speakerWave 1.4s ease-in-out infinite; }
#muteBtn.on .wave2 { animation: speakerWave 1.4s ease-in-out 0.35s infinite; }
@keyframes speakerWave { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }

.cb-size { flex: 1; display: flex; align-items: center; justify-content: center; min-width: 0; }
.cb-size button {
  border: none; background: none; color: var(--text);
  font-family: var(--font); font-weight: 600;
  padding: 12px 16px;
  transition: transform 0.12s ease;
}
.cb-size button:active { transform: scale(0.94); }
#fontDown { font-size: 15px; }
#fontUp { font-size: 19px; padding: 10px 16px; }
.cb-divider { width: 1px; height: 22px; background: var(--border); flex: none; }

.wake-row {
  pointer-events: auto;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  margin-top: 12px;
  min-height: 27px;
}
.wake-group { display: inline-flex; align-items: center; gap: 10px; }
.wake-label { font-size: 13px; font-weight: 500; color: var(--text-3); cursor: pointer; }
.captions-tag { font-size: 12px; font-weight: 600; cursor: default; }

/* Compact iOS switch (44×27, 23px knob) */
.switch.sm { width: 44px; height: 27px; }
.switch.sm .track::before { height: 23px; width: 23px; }
.switch.sm input:checked + .track::before { transform: translateX(17px); }

/* Desktop (design 4a) */
@media (min-width: 900px) {
  .wrap.listener-page { max-width: none; }
  .lst-header { padding: 26px 40px 14px; }
  .lst-header h1 { font-size: 24px; }
  .lst-transcript {
    padding: 20px 40px 150px;
    font-size: calc(var(--fs, 19px) + 3px);
    mask-image: linear-gradient(to bottom, transparent 0%, black 6%, black 86%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 6%, black 86%, transparent 100%);
  }
  .lst-col { max-width: 720px; margin: 0 auto; }
  .para { margin-bottom: 24px; text-wrap: pretty; }
  .lst-empty { font-size: 16px; margin-top: 60px; }
  .lst-overlay {
    padding: 0 0 28px;
    display: flex; flex-direction: column; align-items: center;
  }
  .control-bar { width: 440px; }
  .wake-row { margin-top: 12px; }
  .lst-scroll-down { right: calc(50% - 220px - 56px); bottom: 40px; }
}

.footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 16px 0 4px; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ───────────────────────── Listener transcript ───────────────────────── */
.scroll-down-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(0, 122, 255, 0.45);
  transition: transform 0.12s ease, opacity 0.2s ease;
  cursor: pointer;
}
.scroll-down-btn:hover { transform: scale(1.08); }
.scroll-down-btn:active { transform: scale(0.94); }
.scroll-down-btn.hidden { opacity: 0; pointer-events: none; }

.transcript-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 16px 0 12px;
  white-space: nowrap;
}
.transcript-sep::before,
.transcript-sep::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ───────────────────────── Listener: admin notice ───────────────────────── */
.notice {
  position: fixed;
  top: calc(var(--header-h, 84px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: min(92vw, 560px);
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 14%, var(--card-solid));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
}
.notice button {
  background: none; border: none; flex: none;
  color: var(--text-3); font-size: 14px; padding: 6px 8px; min-width: 28px; min-height: 28px;
}
.notice button:hover { color: var(--text); }
.notice a { color: inherit; text-decoration: underline; }
.notice.notice-warning {
  background: color-mix(in srgb, var(--amber) 16%, var(--card-solid));
  border-color: color-mix(in srgb, var(--amber) 45%, transparent);
}
.notice.notice-critical {
  background: color-mix(in srgb, var(--red) 14%, var(--card-solid));
  border-color: color-mix(in srgb, var(--red) 45%, transparent);
}

/* ───────────────────────── Admin: notice & branding cards ───────────────────────── */
.btn.slim { width: auto; padding: 10px 18px; font-size: 15px; }
.notice-severity { width: auto; padding: 8px 30px 8px 12px; font-size: 14px; border-radius: 10px; background-position: right 10px center; }
.notice-toolbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fmt-btn {
  width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border);
  background: rgba(120, 120, 128, 0.10); color: var(--text); font-size: 14px;
  display: grid; place-items: center; transition: background 0.15s ease;
}
.fmt-btn:hover { background: rgba(120, 120, 128, 0.2); }
.fmt-btn:active { transform: scale(0.94); }
.fmt-color { width: 34px; height: 34px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); background: rgba(120, 120, 128, 0.10); cursor: pointer; }
.notice-editor {
  width: 100%; min-height: 72px; max-height: 200px; overflow-y: auto;
  font-family: var(--font); font-size: 16px; color: var(--text);
  background: rgba(120, 120, 128, 0.10); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 13px 14px; line-height: 1.5;
}
.notice-editor:focus { outline: none; border-color: var(--accent); }
.notice-editor:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.notice-editor:empty::before { content: attr(data-placeholder); color: var(--text-3); }
.notice-editor a { color: var(--accent); }
.field-label { font-size: 13px; font-weight: 500; color: var(--text-3); margin: 0 0 6px; }
.brand-fields { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.brand-fields > div:first-child { flex: 1; min-width: 220px; }
input[type="color"] {
  width: 52px; height: 44px; padding: 3px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(120, 120, 128, 0.10);
  cursor: pointer;
}

/* ───────────────────────── Admin: banner ───────────────────────── */
.admin-grid > .admin-full { grid-column: 1 / -1; }
.banner {
  position: fixed;
  top: calc(var(--header-h, 90px) + 10px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  max-width: min(92vw, 560px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: var(--text);
}
.banner.warn { background: rgba(255, 159, 10, 0.14); border: 1px solid rgba(255, 159, 10, 0.35); }
.banner.error { background: rgba(255, 59, 48, 0.12); border: 1px solid rgba(255, 59, 48, 0.35); }
.banner.info { background: rgba(0, 122, 255, 0.10); border: 1px solid rgba(0, 122, 255, 0.30); }
.banner button {
  margin-left: auto; background: none; border: none;
  color: var(--text-3); font-size: 14px; padding: 2px 6px; flex: none;
}
.banner button:hover { color: var(--text); }
.chip.rec { color: var(--red); }

/* ───────────────────────── Admin: dashboard ───────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.tile { background: rgba(120, 120, 128, 0.10); border-radius: var(--radius-sm); padding: 12px 14px; }
.tile-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin: 0 0 4px; }
.tile-value { font-size: 22px; font-weight: 600; margin: 0; }

.chart-wrap { position: relative; }
#chart svg { width: 100%; height: auto; display: block; }
#chart .bar { fill: var(--accent); }
#chart .hit { fill: transparent; cursor: default; }
#chart .grid { stroke: var(--border); stroke-width: 1; }
#chart .tick { font-size: 10px; fill: var(--text-3); font-family: var(--font); }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--card-solid); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 10px;
  font-size: 12px; font-weight: 500; color: var(--text);
  box-shadow: var(--shadow); white-space: nowrap;
}

/* ───────────────────────── Admin: recordings ───────────────────────── */
#recTotal { text-transform: none; font-weight: 500; letter-spacing: normal; }
.rec-list { display: flex; flex-direction: column; gap: 12px; }
.rec-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; }
.rec-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.rec-title { font-weight: 600; font-size: 15px; }
.rec-sub { color: var(--text-3); font-size: 13px; }
.rec-players { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
@media (max-width: 640px) { .rec-players { grid-template-columns: 1fr; } }
.rec-players audio { width: 100%; height: 36px; }
.rec-player-label { font-size: 12px; font-weight: 600; color: var(--text-3); margin: 0 0 4px; }
.rec-actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.rec-actions a { color: var(--accent); font-size: 13px; font-weight: 600; text-decoration: none; }
.rec-actions a:hover { text-decoration: underline; }
.rec-delete { color: var(--red); margin-left: auto; }

/* ───────────────────────── Listener: hints, backlog, a11y ───────────────────────── */
.lst-hint { flex: none; margin: 0; padding: 0 22px 8px; font-size: 13px; font-weight: 500; color: var(--amber); }
.para.backlog { opacity: 0.55; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
@media (min-width: 900px) { .lst-hint { padding: 0 40px 8px; text-align: center; } }

/* Honour the user's motion preference: no per-word fade, no pulsing dots. */
@media (prefers-reduced-motion: reduce) {
  .word { animation: none; }
  .pill.live .pill-dot { animation: none; opacity: 0.8; }
  #muteBtn.on .wave1, #muteBtn.on .wave2 { animation: none; opacity: 1; }
  body, .pill, .control-bar, .cb-round, .chip-btn, .btn, .btn-clear, .para { transition: none; }
}

/* ───────────────────────── Admin: dialogs, QR, pause ───────────────────────── */
dialog.sheet {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 20px 22px;
  background: var(--card-solid); color: var(--text); box-shadow: var(--shadow); max-width: min(92vw, 420px);
}
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.35); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.sheet h2 { font-size: 17px; margin: 0 0 8px; }
dialog.sheet p { margin: 0 0 16px; color: var(--text-2); font-size: 15px; line-height: 1.45; }
dialog.sheet .row { justify-content: flex-end; }
.share-row { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.share-row .qr { width: 132px; height: 132px; padding: 8px; background: #fff; border-radius: 10px; border: 1px solid var(--border); flex: none; }
.share-row .qr svg { width: 100%; height: 100%; display: block; }
.share-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; color: var(--text); }
.btn.paused { background: var(--amber); }
.kbd { font: 600 11px/1 var(--font); padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; background: var(--fill); color: var(--text-2); }
.chart-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 10px; }
.chart-table th, .chart-table td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.chart-table th { color: var(--text-3); font-weight: 600; font-size: 12px; }
.lang-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 16px; }
.lang-grid .field { margin: 0; }

/* ───────────────────────── Listener: debug overlay + preview ───────────────────────── */
#debugBox {
  position: fixed; left: 8px; right: 8px; top: 8px; z-index: 100; margin: 0; padding: 8px 10px;
  font: 10px/1.35 ui-monospace, Menlo, monospace; white-space: pre-wrap; word-break: break-all;
  background: rgba(0, 0, 0, 0.82); color: #8dff9b; border-radius: 8px; pointer-events: none; max-height: 45vh; overflow: hidden;
}

/* Admin preview iframe: follow the admin's theme, no controls that write shared storage. */
html.preview #themeBtn { display: none; }

/* No zoom gestures on the listener page: repeated taps on the controls must
   never zoom (iOS ignores user-scalable=no, so double-tap zoom is disabled
   per element and pinch is blocked in listener.js). */
html, body { touch-action: manipulation; }
button, .control-bar, .lst-overlay, .lst-header { touch-action: manipulation; }
.scroll-down-btn::after { content: ''; position: absolute; inset: -10px; border-radius: 50%; }
