body {
    background: #f3f6fa;
    font-family: 'Roboto', Arial, sans-serif;
    margin: 0;
    min-height: 100vh;
    display: flex;
    /* top-aligned, NOT centered: the card grows downward when Listen mode adds
       the volume row + screen-on note. Centering would push everything above
       them (language, mode, Start) half that height upward on every switch. */
    align-items: flex-start;
    justify-content: center;
}

#container {
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(60,95,233,0.08), 0 1.5px 6px rgba(0,0,0,0.04);
    padding: 2.5rem 2.5rem 2rem 2.5rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

h2 {
    font-weight: 500;
    font-size: 1.4rem;
    color: #363b44;
    margin-top: 0;
    margin-bottom: 1.1rem;
    letter-spacing: 0.1px;
    text-align: center;
}

label {
    color: #444d5c;
    font-size: 1rem;
    margin-bottom: .5rem;
    margin-top: .2rem;
}

#langSelect {
    width: 100%;
    padding: 0.8em 1em;
    border-radius: 10px;
    border: 1.2px solid #d8e0ed;
    background: #f6f9fc;
    color: #444;
    font-size: 1rem;
    margin-top: 0.4rem;
    margin-bottom: 1.2rem;
    transition: border 0.2s, box-shadow 0.2s;
}
#langSelect:focus {
    border: 1.2px solid #3565fc;
    box-shadow: 0 0 0 2px #d0e0fd;
    outline: none;
}

.button-row {
    display: flex;
    gap: 16px;
    margin-bottom: 0.8rem;
}
/* hidden attribute must override the flex display above */
.button-row[hidden] {
    display: none;
}

button {
    flex: 1;
    padding: 0.75em 1.2em;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, #3565fc 60%, #27ae60 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 18px -8px #7baaf7;
    transition: background 0.2s, box-shadow 0.2s, opacity 0.22s;
}
button:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    background: #dadde2;
    color: #b0b5bb;
    box-shadow: none;
}
/* only ONE action button is ever on screen — Start while idle, Stop while
   running. The other is hidden rather than shown greyed out. */
.button-row button[hidden] { display: none; }

#statusMsg {
    margin-top: 18px;
    font-weight: 500;
    font-size: 1.05rem;
    color: #3565fc;
    text-align: center;
    min-height: 1.4em;
}
#connectionStatus {
    margin-top: 6px;
    font-weight: 500;
    font-size: 0.98rem;
    text-align: center;
    min-height: 1.2em;
    transition: color 0.18s;
}
/* the "Live" indicator: bars in currentColor, so it follows the status colour in
   either theme (it was a GIF with an opaque white background) */
.live-wave {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    height: 14px;
    vertical-align: -1px;
}
.live-wave i {
    width: 2px;
    height: 100%;
    border-radius: 1px;
    background: currentColor;
    transform: scaleY(0.35);
    animation: live-wave 0.9s ease-in-out infinite;
}
.live-wave i:nth-child(2) { animation-delay: -0.6s; }
.live-wave i:nth-child(3) { animation-delay: -0.2s; }
.live-wave i:nth-child(4) { animation-delay: -0.75s; }
.live-wave i:nth-child(5) { animation-delay: -0.4s; }
@keyframes live-wave {
    0%, 100% { transform: scaleY(0.35); }
    50%      { transform: scaleY(1); }
}
@media (prefers-reduced-motion: reduce) {
    .live-wave i { animation: none; }
    .live-wave i:nth-child(odd) { transform: scaleY(0.6); }
    .live-wave i:nth-child(even) { transform: scaleY(1); }
}

/* ----- Mobile Responsive Enhancements ----- */

html, body {
    box-sizing: border-box;
    width: 100%;
    height: 100%;
}
body {
    padding: 0 0.8rem;
}
#container {
    max-width: 420px;
    width: 100%;
    margin: 1.5rem auto;
    padding: 1.2rem 1rem 1rem 1rem;
    border-radius: 16px;
}
h2 {
    font-size: 1.12rem;
    margin-bottom: 1.1rem;
}
label, #langSelect, button {
    font-size: 1rem;
}
#langSelect {
    padding: 0.7em 0.85em;
}
.button-row {
    gap: 10px;
    flex-direction: column;
}
button {
    margin-bottom: 0.4rem;
    padding: 0.70em 0.85em;
    font-size: 1.04em;
    border-radius: 9px;
}

/* For screens 431px and up (tablet/desktop): restore your original layout */
@media (min-width: 431px) {
    #container {
        padding: 2.5rem 2.5rem 2rem 2.5rem;
    }
    .button-row {
        flex-direction: row;
        gap: 16px;
    }
    button {
        margin-bottom: 0;
    }
}

/* Tighter padding on tiny screens */
@media (max-width: 330px) {
    #container {
        padding: 0.5rem 0.2rem;
    }
}

.custom-select-wrapper {
  position: relative;
  width: 100% !important;
  margin-bottom: 16px;
  font-family: inherit;
  box-sizing: border-box;
}

/* These ensure buttons also span full width */
.button-row {
  width: 100%;
  box-sizing: border-box;
}

/* Custom flags dropdown styles */
.custom-select-selected {
border: 1px solid #ccc;
padding: 10px 12px;
cursor: pointer;
background: #fff;
border-radius: 6px;
display: flex;
align-items: center;
gap: 10px;
transition: border-color .2s;
font-size: 1rem;
}
.custom-select-selected.open {
border-color: #007cdd;
box-shadow: 0 2px 8px #2a92d350;
}
.custom-select-options {
position: absolute;
left: 0;
right: 0;
top: 100%;
z-index: 15;
background: #fff;
border: 1px solid #ccc;
border-radius: 0 0 6px 6px;
border-top: none;
display: none;
box-shadow: 0 6px 16px #23232328;
overflow: hidden;
}
.custom-select-options.show { display: block; }
.custom-select-options div {
padding: 10px 12px;
cursor: pointer;
display: flex;
align-items: center;
gap: 10px;
font-size: 1rem;
transition: background .15s;
}
.custom-select-options div:hover, .custom-select-options div.selected {
background: #eaf6ff;
}
.flag-icon {
width: 24px;
height: 18px;
object-fit: contain;
border-radius: 2px;
box-shadow: 0 0 2px #aaa2;
}
/* language picker is locked while listening/reading */
.custom-select-wrapper.disabled {
  opacity: 0.55;
  pointer-events: none;
  cursor: not-allowed;
}
/* Hide the real select */
#langSelect {
display: none;
}

/* Audio/text mode — segmented switch (both options visible, active highlighted).
   Deliberately styled as a SETTING, not an action: same tinted-field look as the
   language picker, with the active option lifted out as a white pill. The blue
   gradient is reserved for the single Start/Stop button, so the page has exactly
   one thing that looks pressable-to-begin. */
#modeRow { margin-top: 4px; margin-bottom: 14px; }
.mode-switch {
  display: flex;
  flex: 1;
  gap: 4px;
  padding: 4px;
  border-radius: 10px;
  background: #f0f3f8;
  border: 1.2px solid #d8e0ed;
}
.mode-switch[hidden] { display: none; }
.mode-switch.disabled { opacity: 0.55; pointer-events: none; }
.mode-seg {
  flex: 1;
  margin: 0;
  padding: 9px 6px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #6b7686;
  font-size: 0.97rem;
  font-weight: 500;
  box-shadow: none;
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .15s;
}
.mode-seg .seg-icon { margin-inline-end: 6px; opacity: .6; }
.mode-seg.active {
  background: #fff;
  color: #1f2937;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(16,24,40,.10), 0 0 0 1.2px rgba(53,101,252,.45);
}
.mode-seg.active .seg-icon { opacity: 1; }

/* Volume (Listen mode only). The id beats .button-row, which stacks its
   children on phones — the slider must stay next to its icon on one line. */
#volumeRow {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}
#volumeRow label { margin: 0; font-weight: 500; }
#volumeSlider { flex: 1; min-width: 0; accent-color: #3565fc; }

/* Read-only translated-text panel */
.text-panel {
  margin-top: 16px;
  text-align: left;
  max-height: 50vh;
  overflow-y: auto;
  background: #f6f9fc;
  border: 1.2px solid #d8e0ed;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1.15rem;
  line-height: 1.5;
  color: #2a2f38;
  -webkit-overflow-scrolling: touch;
  /* trimming the oldest sentences is compensated in JS (trimOldestLines), so
     let no engine also shift scrollTop for it — that would double-correct */
  overflow-anchor: none;
}
.text-panel[hidden] { display: none; }
.text-panel[dir="rtl"] { text-align: right; }
/* Original in Read mode: each sentence is aligned by its own script */
.text-panel p[dir="auto"] { text-align: start; }
.text-panel p { margin: 0 0 10px 0; }
.text-panel p:last-child { margin-bottom: 0; }
.text-panel p.latest { font-weight: 600; color: #1c2433; }
.text-panel .placeholder { color: #8a93a3; font-style: italic; font-weight: 400; }

/* the subtitle: "Live service translation", or the community's welcome text
   when the operator has set one (a greeting, whom to ask for help). The source
   is capped at 140 characters; the clamp is the backstop for translations that
   run long and for narrow phones, so the language picker below can never be
   pushed off the screen. */
.app-subtitle {
  margin: -0.7rem 0 1.25rem;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 400;
  line-height: 1.4;
  color: #6b7280;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
  line-clamp: 5;
  overflow: hidden;
}
html.dark .app-subtitle { color: #aab2c0; }
/* the title is hidden under a logo that spells out the name (hide_name): the
   subtitle's pull-up toward the title would butt it against the logo */
#appTitle[hidden] + .app-subtitle { margin-top: 0.4rem; }
/* first visit to a community: the title and subtitle are hidden (not shown as
   "Commungo" / the default) until the real ones arrive. visibility, not
   display, so nothing below them moves when they appear. */
.brand-pending { visibility: hidden; }

/* low-profile app version at the bottom of the card */
.app-version { margin-top: 18px; text-align: center; font-size: 11px; color: #b0b5bb; }
html.dark .app-version { color: #6b7280; }

/* "tap to enable sound" — only ever visible when audio is arriving and the audio
   session is not running. Deliberately loud: it is the one control that can fix
   a silent session, and the listener is currently staring at a green status that
   says everything is fine. */
.audio-unblock {
  margin-top: 12px;
  width: 100%;
  padding: 0.9em 1em;
  border: none;
  border-radius: 10px;
  background: #cc6600;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.audio-unblock:hover { background: #b35900; }
.audio-unblock[hidden] { display: none; }
#silentHint[hidden] { display: none; }

/* keep-screen-on caveat (Listen mode only) */
.screen-on-note { margin-top: 12px; text-align: center; font-size: 13px; line-height: 1.4; color: #8a93a3; }
html.dark .screen-on-note { color: #9aa6bf; }

/* "jump to latest" button (shown when scrolled up while new lines arrive) */
.text-jump {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  flex: none;
  width: auto;
  background: #3565fc;
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,.28);
  cursor: pointer;
  z-index: 30;
}
.text-jump[hidden] { display: none; }

/* Full-screen reading layout: text mode while actively listening */
body.reading { align-items: stretch; padding: 0; overflow: hidden; }
body.reading #container {
  max-width: none;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  box-sizing: border-box;   /* padding INSIDE the viewport height, or the bottom stop button gets clipped */
  margin: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 10px 14px 14px;
}
/* hide the chrome so the text gets the whole screen (the logo needs
   !important: JS reveals it with an inline display once it loads) */
body.reading #brandLogo { display: none !important; }
body.reading h2,
body.reading #appSubtitle,
body.reading #startBtn,
body.reading label[for="langSelect"],
body.reading .custom-select-wrapper,
body.reading #modeRow,
body.reading #volumeRow,
body.reading #appVersion,
body.reading #statusMsg { display: none; }
/* the stop button sits full-width at the BOTTOM, like the Android reading
   view (order pushes it below the text panel; the theme toggle stays clear
   of it up top, so no right margin is needed anymore) */
body.reading .button-row { order: 99; margin: 10px 0 0; }
body.reading #stopBtn { margin: 0; }
body.reading #connectionStatus { margin: 2px 0 6px; }
/* keep the jump-to-latest pill above the bottom stop button */
body.reading .text-jump { bottom: 84px; }
body.reading .text-panel {
  flex: 1 1 auto;
  min-height: 0;           /* let the flex child actually scroll */
  max-height: none;
  font-size: 1.4rem;
  line-height: 1.55;
  margin-top: 6px;
}

/* ===== Dark mode toggle button ===== */
.theme-toggle {
  position: fixed;
  top: 12px;
  right: 14px;
  z-index: 50;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1.2px solid #d2d2e3;
  background: #fff;
  color: #222;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(30,40,80,.12);
}
.theme-toggle:hover { border-color: #3565fc; }
/* icon is CSS-driven (keyed on html.dark) so the head script fixes it before
   first paint — no glyph flash */
.theme-toggle::before { content: "🌙"; }
html.dark .theme-toggle::before { content: "☀️"; }
/* while reading full-screen, sit in the top bar (not over the scrolling text) */
body.reading .theme-toggle { top: 10px; bottom: auto; right: 14px; }

/* ===== Share-with-a-neighbor QR button (next to the theme toggle) ===== */
.qr-share {
  position: fixed;
  top: 12px;
  right: 62px;   /* theme toggle (40px @ right 14px) + 8px gap */
  z-index: 50;
  flex: none;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1.2px solid #d2d2e3;
  background: #fff;
  color: #3565fc;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(30,40,80,.12);
  display: flex;
  align-items: center;
  justify-content: center;
}
/* The share icon: the three finder squares that make a QR code recognisable at
   any size. It replaces "▦" (SQUARE WITH ORTHOGONAL CROSSHATCH FILL), whose mesh
   collapses into a solid block below ~20px and reads as a stop button -- on the
   one control whose whole job is to be understood at a glance by somebody
   handing their phone to a neighbour.

   Drawn as a mask rather than a background so it takes the button's own colour:
   light, dark and hover all follow from `color`, with one copy of the artwork. */
.qr-share::before {
  content: "";
  width: 21px;
  height: 21px;
  background-color: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M2 2h8v8H2V2Zm2 2v4h4V4H4Zm10-2h8v8h-8V2Zm2 2v4h4V4h-4ZM2 14h8v8H2v-8Zm2 2v4h4v-4H4Z'/%3E%3Cpath d='M5 5h2v2H5V5Zm12 0h2v2h-2V5ZM5 17h2v2H5v-2Zm9-3h3v3h-3v-3Zm5 1h3v3h-3v-3Zm-4 4h3v3h-3v-3Zm5 1h2v2h-2v-2Z'/%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'%3E%3Cpath fill-rule='evenodd' d='M2 2h8v8H2V2Zm2 2v4h4V4H4Zm10-2h8v8h-8V2Zm2 2v4h4V4h-4ZM2 14h8v8H2v-8Zm2 2v4h4v-4H4Z'/%3E%3Cpath d='M5 5h2v2H5V5Zm12 0h2v2h-2V5ZM5 17h2v2H5v-2Zm9-3h3v3h-3v-3Zm5 1h3v3h-3v-3Zm-4 4h3v3h-3v-3Zm5 1h2v2h-2v-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.qr-share:hover { border-color: #3565fc; }
.qr-share[hidden] { display: none; }
html.dark .qr-share {
  background: #1e2129;
  color: #7aa2ff;
  border-color: #2c313c;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
body.reading .qr-share { top: 10px; right: 62px; }

/* ===== Share-with-a-neighbor QR overlay ===== */
.qr-overlay {
  position: fixed;
  inset: 0;
  z-index: 55;   /* above the theme toggle (50), below the notices (59/60) */
  background: rgba(20,25,40,.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5vw;
}
.qr-overlay[hidden] { display: none; }
.qr-card {
  position: relative;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
  padding: 26px 30px 22px;
  max-width: 420px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  animation: code-pop .18s ease-out;
}
html.dark .qr-card { background: #1e2129; }
.qr-close {
  position: absolute;
  top: 12px; right: 14px;
  flex: none;
  width: auto;
  border: none;
  background: none;
  box-shadow: none;
  font-size: 1.25rem;
  line-height: 1;
  color: #8a8f9c;
  cursor: pointer;
  padding: 4px;
}
.qr-card[dir="rtl"] .qr-close { right: auto; left: 14px; }
.qr-close:hover { color: #444; }
html.dark .qr-close:hover { color: #e6e8ee; }
.qr-title { margin: 0 0 4px; font-size: 1.25rem; }
html.dark .qr-title { color: #f0f2f6; }
.qr-sub { margin: 0 0 16px; font-size: .9rem; line-height: 1.4; color: #6b7280; }
html.dark .qr-sub { color: #9aa3b2; }
.qr-canvas-wrap {
  display: inline-block;
  padding: 14px;
  background: #fff;              /* keep a white frame even in dark mode so it scans */
  border-radius: 12px;
  box-shadow: 0 2px 10px rgba(30,40,80,.12);
}
.qr-canvas {
  display: block;
  width: min(64vw, 280px);
  height: auto;
  image-rendering: pixelated;    /* crisp module edges when scaled down */
}
.qr-url {
  margin: 16px 0 4px;
  font-family: monospace;
  font-size: .85rem;
  color: #379268;
  overflow-wrap: anywhere;
  direction: ltr;                /* the URL reads left-to-right even in RTL UIs */
}
html.dark .qr-url { color: #6cc6a2; }

/* ===== Dark theme — keyed on <html> so the inline <head> script can apply it
   before first paint (no flash). The <body> isn't available to that script. ===== */
html.dark { background: #15171c; }
html.dark body { background: #15171c; color: #e6e8ee; }
html.dark .theme-toggle {
  background: #1e2129;
  color: #f0d27a;
  border-color: #2c313c;
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
html.dark #container {
  background: #1e2129;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
html.dark h2 { color: #f0f2f6; }
html.dark label { color: #cdd3de; }
html.dark .custom-select-selected {
  background: #262b34;
  color: #e6e8ee;
  border-color: #3a4150;
}
html.dark .custom-select-selected.open { border-color: #3565fc; }
html.dark .custom-select-options {
  background: #1e2129;
  border-color: #3a4150;
}
html.dark .custom-select-options div { color: #e6e8ee; }
html.dark .custom-select-options div:hover,
html.dark .custom-select-options div.selected { background: #2c333f; }
html.dark .mode-switch {
  background: #21252e;
  border-color: #3a4150;
}
html.dark .mode-seg { color: #9aa6bf; }
html.dark .mode-seg.active {
  background: #333b49;
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.35), 0 0 0 1.2px rgba(122,162,255,.5);
}
html.dark button:disabled { background: #2c313c; color: #6b7280; }
html.dark #statusMsg { color: #7aa2ff; }
html.dark .text-panel {
  background: #15181e;
  border-color: #2c313c;
  color: #e6e8ee;
}
html.dark .text-panel p.latest { color: #ffffff; }
html.dark .text-panel .placeholder { color: #8a93a3; }

/* ===== Listener access-code gate ===== */
.code-gate {
  position: fixed;
  inset: 0;
  z-index: 45;   /* below the theme toggle (50) so it stays reachable */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(28, 36, 54, .55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.code-gate[hidden] { display: none; }
/* keep the (covered) page from being interacted with while the gate is up */
body.gated #container { pointer-events: none; }

.code-card {
  width: 100%;
  max-width: 360px;
  box-sizing: border-box;
  background: #fff;
  border-radius: 18px;
  padding: 30px 28px 26px;
  box-shadow: 0 18px 50px rgba(20,30,60,.28);
  text-align: center;
  animation: code-pop .18s ease-out;
}
@keyframes code-pop { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
html.dark .code-card { background: #1e2129; box-shadow: 0 18px 50px rgba(0,0,0,.6); }

.code-logo { max-height: 48px; max-width: 65%; object-fit: contain; margin: 0 auto 16px; }

/* Single-logo communities whose logo needs the OTHER theme's background get a
   constant-colour plate behind it (configured per community in the admin panel).
   border-box keeps the plated logo inside its original max-height/width. */
.logo-plate { box-sizing: border-box; padding: 8px 16px; border-radius: 14px; }
.logo-plate.plate-dark { background: #1e2129; }
.logo-plate.plate-light { background: #fff; }
.code-title { margin: 0 0 6px; font-size: 1.35rem; font-weight: 500; color: #2b3140; text-align: center; }
html.dark .code-title { color: #f0f2f6; }
.code-sub { margin: 0 0 22px; font-size: .95rem; line-height: 1.45; color: #6b7280; }
html.dark .code-sub { color: #9aa6bf; }

.code-inputs { display: flex; justify-content: center; gap: 12px; direction: ltr; }
.code-digit {
  width: 54px;
  height: 64px;
  padding: 0;
  text-align: center;
  font-size: 1.8rem;
  font-weight: 500;
  color: #2b3140;
  border: 1.6px solid #d8e0ed;
  border-radius: 12px;
  background: #f6f9fc;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.code-digit:focus {
  outline: none;
  border-color: #3565fc;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(53,101,252,.2);
}
.code-digit:disabled { opacity: .6; }
html.dark .code-digit {
  background: #262b34;
  color: #f0f2f6;
  border-color: #3a4150;
}
html.dark .code-digit:focus { background: #2c333f; border-color: #3565fc; }

.code-msg { min-height: 1.3em; margin-top: 16px; font-size: .9rem; color: #6b7280; }
html.dark .code-msg { color: #9aa6bf; }
.code-msg.error { color: #e0483f; }

/* wrong-code shake */
.code-gate.shake .code-card { animation: code-shake .4s ease; }
@keyframes code-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-9px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}

@media (max-width: 480px) {
  .code-digit { width: 48px; height: 58px; font-size: 1.6rem; }
  .code-inputs { gap: 10px; }
}

/* ===== Operator -> listener notices (outage banner + one-time message) ===== */
/* dims + blurs the page behind a notice and swallows clicks/touch scrolling */
.notice-backdrop {
  position: fixed;
  inset: 0;
  z-index: 59;   /* just under the notice stack (60) */
  background: rgba(15, 23, 42, .45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: notice-fade .22s ease-out;
}
.notice-backdrop[hidden] { display: none; }
@keyframes notice-fade { from { opacity: 0; } to { opacity: 1; } }
.notice-stack {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 440px);
  z-index: 60;   /* above the theme toggle (50) and code gate (45) */
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;   /* let the close button re-enable pointer events itself */
}
.notice-banner {
  box-sizing: border-box;
  width: 100%;
  padding: 14px 18px;
  font-size: .98rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(20,30,60,.35);
  animation: notice-pop .22s ease-out;
  max-height: 70vh;   /* page scrolling is locked, so long texts scroll in here */
  overflow-y: auto;
}
.notice-banner[hidden] { display: none; }
@keyframes notice-pop { from { opacity: 0; transform: scale(.92); } to { opacity: 1; transform: scale(1); } }

/* outage: a firm, unmissable warning colour; not dismissable */
.notice-banner.outage {
  background: #c0392b;
  color: #fff;
}
html.dark .notice-banner.outage { background: #a32b20; }

/* one-time message: informational, with a close button */
.notice-banner.message {
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  pointer-events: auto;
  background: #2b4b8f;
  color: #fff;
}
html.dark .notice-banner.message { background: #24407a; }
.notice-banner.message[hidden] { display: none; }
.notice-text { flex: 1; text-align: center; white-space: pre-line; }   /* keep the operator's line breaks */
.notice-close {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255,255,255,.18);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background .15s;
}
.notice-close:hover { background: rgba(255,255,255,.32); }

/* ===== Pause banner: the community's text while translation is paused =====
   In-flow under the connection status, NOT with the notices above: it must be
   seen without blocking anything, and it goes away on its own. */
.pause-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  box-sizing: border-box;
  width: 100%;
  margin: 10px 0 4px;
  padding: 10px 14px;
  font-size: .95rem;
  line-height: 1.4;
  text-align: start;
  border-radius: 10px;
  background: #fff4de;
  color: #6b4a12;
  border: 1px solid #f0d9a8;
  animation: notice-fade .22s ease-out;
}
.pause-banner[hidden] { display: none; }
html.dark .pause-banner { background: #3a2f1c; color: #f1d9a6; border-color: #5a4724; }
.pause-banner-icon { flex: 0 0 auto; font-size: 1.05rem; opacity: .85; }
.pause-banner-text { flex: 1; white-space: pre-line; overflow-wrap: anywhere; }
body.reading .pause-banner { margin: 0 0 6px; }

/* A channel the community has switched off, still shown because it is the one this
   listener was on. Dimmed and struck rather than hidden: they need to see WHY the
   audio stopped, and silently swapping them onto another language would be worse
   than telling them. Not selectable (selectIdx refuses it). */
.custom-select-options div.unavailable { opacity: .45; cursor: not-allowed; text-decoration: line-through; }
.custom-select-options div.unavailable:hover { background: none; }
html.dark .custom-select-options div.unavailable:hover { background: none; }
.custom-select-options div.unavailable .lang-gone-tag {
  margin-left: 8px; font-size: .78em; opacity: .85; text-decoration: none;
  white-space: nowrap;
}
