/*
 * LVH Translator — design system
 *
 * Direction: an interpreter's booth. Captions are the stage; the live lamp, the level meter and the language
 * channels carry the identity. Everything around them stays quiet: flat surfaces, one border weight, shadows
 * only on what floats (menus, dialogs, toasts, docks).
 *
 * View modes live on <html>:
 *   data-theme     auto (none) | light | dark | contrast
 *   data-density   auto (none) | compact | comfortable
 *   --ui-scale     interface text size (0.9 … 1.3)
 */
:root {
  /* palette */
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --surface-3: #e2e7ef;
  --border: #dde3ec;
  --border-strong: #c3ccda;
  --input-border: #8d99ad;
  --text: #0f1a2e;
  --muted: #56647b;
  --faint: #6f7d94;
  --primary: #2563eb;
  --primary-strong: #2563eb;
  --primary-600: #1d4ed8;
  --primary-soft: #e3ebff;
  --primary-contrast: #ffffff;
  --accent: #0f766e;
  --accent-strong: #0f766e;
  --accent-soft: #d7f2ee;
  --accent-contrast: #ffffff;
  --live: #dc2f3a;
  --live-soft: #fde6e7;
  --live-contrast: #ffffff;
  --danger: #d92d20;
  --danger-strong: #d92d20;
  --danger-soft: #fde7e5;
  --warning: #b45309;
  --warning-soft: #fdf0d9;
  --success: #15803d;
  --success-soft: #dcf5e4;
  --focus: #2563eb;
  /* the dark stage of focus views and projection, whatever the theme */
  --stage: #0a1222;
  --stage-text: #f3f6fb;
  --stage-muted: #93a2bd;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2356647b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");

  /* type: the system families cover every caption script (Vietnamese, CJK, Thai, Arabic, Devanagari…) */
  --font: 'Segoe UI Variable Text', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Text', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Segoe UI Variable Display', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'SF Pro Display', Roboto, 'Noto Sans', 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', 'SF Mono', 'SFMono-Regular', Consolas, monospace;
  --ui-scale: 1;
  --fs-body: 0.9375rem;
  --fs-xs: 0.75rem;
  --fs-sm: 0.84375rem;
  --fs-md: 0.9375rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;
  --cap-size: 28px;

  /* size and rhythm */
  --ctl-h: 40px;
  --pad-card: 18px;
  --gap: 16px;
  --topbar-h: 60px;
  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-pill: 999px;
  --radius: var(--r-md);
  --radius-sm: var(--r-sm);

  /* elevation: only floating things */
  --shadow: 0 1px 2px rgba(15, 26, 46, 0.06);
  --shadow-float: 0 18px 40px -12px rgba(15, 26, 46, 0.28), 0 3px 8px rgba(15, 26, 46, 0.08);
  --shadow-lg: var(--shadow-float);

  /* motion */
  --ease: cubic-bezier(0.2, 0.75, 0.25, 1);
  --t-fast: 120ms;
  --t-med: 200ms;
  --t-slow: 320ms;
  color-scheme: light;
}

@media (pointer: coarse) {
  :root {
    --fs-body: 1rem;
    --ctl-h: 44px;
  }
}
:root[data-density='compact'] {
  --fs-body: 0.875rem;
  --ctl-h: 34px;
  --pad-card: 14px;
  --gap: 12px;
}
:root[data-density='comfortable'] {
  --fs-body: 1rem;
  --ctl-h: 44px;
  --pad-card: 22px;
  --gap: 20px;
}

/* dark: the auditorium */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']):not([data-theme='contrast']) {
    --bg: #0b1222;
    --surface: #111b2f;
    --surface-2: #17233b;
    --surface-3: #1f2c47;
    --border: #24324f;
    --border-strong: #33456b;
    --input-border: #5b6c8e;
    --text: #e8eef8;
    --muted: #9fadc6;
    --faint: #8190ab;
    --primary: #7ea6ff;
    --primary-strong: #3566e8;
    --primary-600: #4a78f0;
    --primary-soft: #1a2b52;
    --accent: #3fd4c2;
    --accent-strong: #0f7f75;
    --accent-soft: #0f3936;
    --live-soft: #3d1a1f;
    --danger: #f87171;
    --danger-soft: #3d1a1f;
    --warning: #fbbf24;
    --warning-soft: #3a2c10;
    --success: #4ade80;
    --success-soft: #12331f;
    --focus: #7ea6ff;
    --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239fadc6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-float: 0 20px 44px -12px rgba(0, 0, 0, 0.7), 0 3px 10px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #0b1222;
  --surface: #111b2f;
  --surface-2: #17233b;
  --surface-3: #1f2c47;
  --border: #24324f;
  --border-strong: #33456b;
  --input-border: #5b6c8e;
  --text: #e8eef8;
  --muted: #9fadc6;
  --faint: #8190ab;
  --primary: #7ea6ff;
  --primary-strong: #3566e8;
  --primary-600: #4a78f0;
  --primary-soft: #1a2b52;
  --accent: #3fd4c2;
  --accent-strong: #0f7f75;
  --accent-soft: #0f3936;
  --live-soft: #3d1a1f;
  --danger: #f87171;
  --danger-soft: #3d1a1f;
  --warning: #fbbf24;
  --warning-soft: #3a2c10;
  --success: #4ade80;
  --success-soft: #12331f;
  --focus: #7ea6ff;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239fadc6' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 20px 44px -12px rgba(0, 0, 0, 0.7), 0 3px 10px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}
/* high contrast: low vision, bright projectors, sunlight */
:root[data-theme='contrast'] {
  --bg: #000000;
  --surface: #000000;
  --surface-2: #141414;
  --surface-3: #242424;
  --border: #9a9a9a;
  --border-strong: #ffffff;
  --input-border: #ffffff;
  --text: #ffffff;
  --muted: #e2e2e2;
  --faint: #d0d0d0;
  --primary: #ffd60a;
  --primary-strong: #ffd60a;
  --primary-600: #ffe14d;
  --primary-soft: #2e2700;
  --primary-contrast: #000000;
  --accent: #5ef2df;
  --accent-strong: #5ef2df;
  --accent-soft: #00302b;
  --accent-contrast: #000000;
  --live: #ff4545;
  --live-soft: #3a0000;
  --live-contrast: #000000;
  --danger: #ff7a7a;
  --danger-strong: #ff7a7a;
  --danger-soft: #3a0000;
  --warning: #ffd60a;
  --warning-soft: #2e2700;
  --success: #6dff9c;
  --success-soft: #00300f;
  --focus: #ffd60a;
  --stage: #000000;
  --stage-text: #ffffff;
  --stage-muted: #d0d0d0;
  --chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  --shadow: none;
  --shadow-float: 0 0 0 2px #ffffff;
  color-scheme: dark;
}

/* ---------- base ---------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
html {
  font-size: calc(100% * var(--ui-scale));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  min-height: 100vh;
  min-height: 100dvh;
}
a {
  color: var(--primary);
  text-decoration: none;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration: underline;
}
h1,
h2,
h3,
h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.22;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
  text-wrap: balance;
}
h1 {
  font-size: var(--fs-2xl);
  letter-spacing: -0.02em;
}
h2 {
  font-size: var(--fs-xl);
}
h3 {
  font-size: var(--fs-lg);
  font-weight: 650;
}
h4 {
  font-size: var(--fs-md);
}
p {
  margin: 0 0 0.75em;
  text-wrap: pretty;
}
small,
.muted {
  color: var(--muted);
}
code,
kbd {
  overflow-wrap: anywhere;
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 0.1em 0.4em;
  border-radius: var(--r-xs);
}
hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 18px 0;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
::selection {
  background: color-mix(in srgb, var(--primary) 30%, transparent);
}
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
details > summary {
  cursor: pointer;
  width: fit-content;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- header ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--topbar-h);
  padding: 8px max(20px, env(safe-area-inset-right)) 8px max(20px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.0625rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand:hover {
  text-decoration: none;
}
.brand img,
.brand svg {
  width: 32px;
  height: 32px;
}
.brand .tag {
  font-weight: 500;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.nav {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  margin-left: 10px;
}
.nav a {
  padding: 7px 12px;
  border-radius: var(--r-pill);
  color: var(--muted);
  font-weight: 550;
  font-size: var(--fs-md);
  transition: color var(--t-fast), background var(--t-fast);
}
.nav a:hover {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}
.nav a.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}
.topbar .spacer {
  flex: 1;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar .nav-toggle,
.nav-langs {
  display: none;
}
.btn-view svg {
  width: 20px;
  height: 20px;
}
/* small phones: the connection state as a coloured dot (its name stays in the tooltip) */
@media (max-width: 420px) {
  .topbar #conn {
    font-size: 0;
    width: 10px;
    height: 10px;
    padding: 0;
    background: currentColor;
  }
}

/* the view menu: theme, density, interface text size */
.popover {
  position: fixed;
  z-index: 60;
  width: min(340px, calc(100vw - 24px));
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  animation: pop-in var(--t-med) var(--ease);
}
.popover .pop-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
}
.popover .pop-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.popover .pop-group > span {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 600;
}
.popover .scale-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.popover .scale-row output {
  flex: 1;
  text-align: center;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
}

/* quick guide of a page ("?" in the header) */
.guide-wrap {
  max-width: 1280px;
  margin: 16px auto 0;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
}
.guide-wrap + .container {
  padding-top: 16px;
}
body.convo .guide-wrap {
  flex: none;
  max-width: none;
  width: 100%;
  margin: 10px 0 0;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
.guide {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface));
  color: var(--text);
  text-align: start;
  animation: pop-in var(--t-med) var(--ease);
}
.guide-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-head b {
  flex: 1;
}
.guide-ico {
  display: inline-grid;
  color: var(--primary);
}
.guide-ico svg {
  width: 18px;
  height: 18px;
}
.guide-steps {
  margin: 0;
  padding-left: 1.4em;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 6px 28px;
}
.guide-steps li {
  padding-left: 2px;
}
.guide-steps li::marker {
  color: var(--primary);
  font-weight: 700;
}
.guide-tip {
  margin: 0;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.btn-guide.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-guide svg {
  width: 20px;
  height: 20px;
}
.guide-slot {
  width: 100%;
  margin-top: 10px;
}
@media (max-width: 900px) {
  .guide-wrap {
    margin-top: 12px;
    padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
  }
  .guide-steps {
    grid-template-columns: 1fr;
  }
}

/* iPhone: "Add to Home Screen" hint (home page, Safari only) */
.install-hint {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 10px 12px 14px;
  border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--border));
  border-radius: var(--r-md);
  background: var(--primary-soft);
  font-size: var(--fs-md);
  line-height: 1.45;
}
.install-hint img {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 9px;
}
.install-hint b {
  display: block;
  margin-bottom: 2px;
}
.install-hint .share {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  margin: 0 1px;
  vertical-align: -0.2em;
  color: var(--primary);
}

/* ---------- layout ---------- */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px max(24px, env(safe-area-inset-right)) calc(64px + env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
}
.container.narrow {
  max-width: 760px;
}
.container.wide {
  max-width: 1680px;
}
.grid {
  display: grid;
  gap: var(--gap);
}
.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-auto {
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.row.nowrap {
  flex-wrap: nowrap;
}
.col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grow {
  flex: 1;
  min-width: 0;
}
.between {
  justify-content: space-between;
}
.end {
  justify-content: flex-end;
}
.center {
  text-align: center;
}
.mt {
  margin-top: 14px;
}
.mb {
  margin-bottom: 14px;
}
.gap-sm {
  gap: 6px;
}

@media (max-width: 900px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
  .nav {
    display: none;
  }
  .topbar {
    padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  }
  .container {
    padding: 16px max(14px, env(safe-area-inset-right)) calc(48px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  /* the page links and the interface language move into the ☰ menu */
  .topbar .nav-toggle {
    display: inline-flex;
    font-size: 1.15rem;
  }
  .topbar #uiLang {
    display: none;
  }
  body.nav-open .topbar .nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin: 0;
    padding: 8px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
    max-height: calc(100vh - 70px);
    overflow-y: auto;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-float);
    animation: pop-in var(--t-med) var(--ease);
  }
  body.nav-open .nav a {
    padding: 12px 14px;
    border-radius: var(--r-sm);
    font-size: 1rem;
  }
  body.nav-open .nav .nav-langs {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding: 12px 14px 0;
    border-top: 1px solid var(--border);
  }
}

/* ---------- surfaces ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--pad-card);
}
.card.flat {
  background: var(--surface-2);
  border-color: transparent;
}
.card.raised {
  box-shadow: var(--shadow-float);
}
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.card-title h2,
.card-title h3 {
  margin: 0;
}
.notice {
  border-radius: var(--r-sm);
  padding: 10px 14px;
  background: var(--primary-soft);
  color: var(--text);
  font-size: var(--fs-md);
}
.notice.warn {
  background: var(--warning-soft);
}
.notice.err {
  background: var(--danger-soft);
}
.notice.ok {
  background: var(--success-soft);
}
.empty {
  text-align: center;
  color: var(--muted);
  padding: 30px 10px;
}
.stat {
  display: flex;
  flex-direction: column;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
}
.stat b {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat span {
  font-size: var(--fs-xs);
  color: var(--muted);
}
.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}
.footer {
  color: var(--muted);
  font-size: var(--fs-sm);
  text-align: center;
  padding: 24px 12px 30px;
}

/* ---------- forms ---------- */
label {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field > .label {
  font-weight: 600;
  font-size: var(--fs-sm);
}
.field .hint {
  font-weight: 400;
  color: var(--muted);
  font-size: var(--fs-sm);
}
input[type='text'],
input[type='password'],
input[type='url'],
input[type='number'],
input[type='search'],
input[type='email'],
input:not([type]),
select,
textarea {
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--r-sm);
  min-height: var(--ctl-h);
  padding: 0 12px;
  width: 100%;
  min-width: 0;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea {
  padding: 10px 12px;
  resize: vertical;
  min-height: 90px;
  line-height: 1.55;
}
/* what people type or paste lays out in its own direction, line by line: English in the Arabic interface, Arabic in
   the English one */
textarea,
input[type='text'],
input[type='search'],
input:not([type]) {
  unicode-bidi: plaintext;
}
select {
  -webkit-appearance: none;
  appearance: none;
  padding-inline-end: 34px;
  background-image: var(--chevron);
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
  text-overflow: ellipsis;
}
/* the arrow at the end of the box in a right-to-left interface too (no added weight: a class's own rule still wins) */
:where([dir='rtl']) select {
  background-position: left 10px center;
}
::placeholder {
  color: var(--faint);
  opacity: 1;
}
input:hover,
select:hover,
textarea:hover {
  border-color: var(--muted);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent);
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
input[type='range'] {
  accent-color: var(--primary-strong);
  width: 100%;
}
input[type='checkbox'],
input[type='radio'] {
  accent-color: var(--primary-strong);
}
/* iPhone / iPad Safari zoom into a field whose text is under 16 px as soon as it is tapped */
@supports (-webkit-touch-callout: none) {
  input[type='text'],
  input[type='password'],
  input[type='url'],
  input[type='number'],
  input[type='search'],
  input[type='email'],
  input:not([type]),
  select,
  select.btn-sm,
  textarea {
    font-size: max(16px, 1em);
  }
}
.input-lg {
  font-size: 1.15rem !important;
  min-height: calc(var(--ctl-h) + 8px) !important;
  padding: 0 14px !important;
}
.code-input {
  font-family: var(--mono) !important;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  text-align: center;
  font-size: 1.6rem !important;
  font-weight: 700;
  min-height: calc(var(--ctl-h) + 12px) !important;
}

/* switch */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 550;
  user-select: none;
  -webkit-user-select: none;
}
.switch input {
  -webkit-appearance: none;
  appearance: none;
  width: 42px;
  height: 24px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  border: 1px solid var(--input-border);
  position: relative;
  cursor: pointer;
  transition: background var(--t-med) var(--ease), border-color var(--t-med);
  flex: none;
  margin: 0;
}
.switch input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  transition: transform var(--t-med) var(--ease);
}
.switch input:checked {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
}
.switch input:checked::after {
  transform: translateX(18px);
}
:root[data-theme='contrast'] .switch input::after {
  background: var(--text);
}
:root[data-theme='contrast'] .switch input:checked::after {
  background: #000;
}

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--ctl-h);
  padding: 0 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
  text-decoration: none !important;
  user-select: none;
  -webkit-user-select: none;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), color var(--t-fast), transform 60ms;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn svg {
  width: 1.15em;
  height: 1.15em;
  flex: none;
}
.btn-primary {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: var(--primary-contrast);
  box-shadow: 0 1px 2px rgba(15, 26, 46, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}
.btn-primary:hover {
  background: var(--primary-600);
  border-color: var(--primary-600);
}
.btn-accent {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--accent-contrast);
}
.btn-accent:hover {
  background: color-mix(in srgb, var(--accent-strong) 88%, #000);
}
.btn-danger {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
  color: #fff;
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--danger-strong) 88%, #000);
}
:root[data-theme='contrast'] .btn-danger {
  color: #000;
}
.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-2);
}
.btn-sm {
  min-height: calc(var(--ctl-h) - 8px);
  padding: 0 12px;
  font-size: var(--fs-sm);
  border-radius: calc(var(--r-sm) - 2px);
}
.btn-lg {
  min-height: calc(var(--ctl-h) + 8px);
  padding: 0 22px;
  font-size: 1.0625rem;
  border-radius: 12px;
}
.btn-icon {
  width: var(--ctl-h);
  min-width: var(--ctl-h);
  padding: 0;
}
.btn-sm.btn-icon {
  width: calc(var(--ctl-h) - 8px);
  min-width: calc(var(--ctl-h) - 8px);
}
.btn-block {
  width: 100%;
}
.btn-group {
  display: inline-flex;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}
.btn-group .btn {
  border: 0;
  border-radius: 0;
}
.btn-group .btn + .btn {
  border-left: 1px solid var(--border-strong);
}
.btn-group .btn.active {
  background: var(--primary-soft);
  color: var(--primary);
}

/* segmented control: one choice among a few (view modes) */
.seg {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  max-width: 100%;
}
.seg > button {
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: calc(var(--ctl-h) - 10px);
  padding: 0 13px;
  border: 0;
  border-radius: var(--r-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.seg > button:hover {
  color: var(--text);
}
.seg > button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(15, 26, 46, 0.14), 0 0 0 1px var(--border);
}
:root[data-theme='contrast'] .seg > button[aria-pressed='true'] {
  background: var(--primary);
  color: #000;
}
.seg > button svg {
  width: 16px;
  height: 16px;
}
.seg.block {
  display: flex;
  align-items: stretch; /* (a wrapped label: its neighbours as tall) */
}
.seg.block > button {
  flex: 1;
  /* (a narrow phone: a long label wraps instead of pushing the page sideways) */
  min-width: 0;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  padding-block: 4px;
}

/* ---------- chips / badges ---------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: var(--fs-sm);
  font-weight: 550;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast), color var(--t-fast);
}
.chip:hover {
  border-color: var(--primary);
}
.chip.active {
  background: var(--primary-strong);
  border-color: var(--primary-strong);
  color: var(--primary-contrast);
}
.chip .x {
  opacity: 0.7;
  font-weight: 700;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 650;
  line-height: 1.5;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.ok {
  background: var(--success-soft);
  color: var(--success);
}
.badge.warn {
  background: var(--warning-soft);
  color: var(--warning);
}
.badge.err {
  background: var(--danger-soft);
  color: var(--danger);
}
.badge.info {
  background: var(--primary-soft);
  color: var(--primary);
}
.badge.free {
  background: var(--accent-soft);
  color: var(--accent);
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  background: var(--faint);
  flex: none;
}
.dot.ok {
  background: var(--success);
}
.dot.err {
  background: var(--danger);
}
.dot.warn {
  background: var(--warning);
}
.dot.live {
  background: var(--live);
  animation: blink 1.4s ease-in-out infinite;
}
@keyframes blink {
  50% {
    opacity: 0.3;
  }
}
/* language code as a receiver channel: VI, EN, JA */
.chan {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  height: 22px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  background: var(--text);
  color: var(--bg);
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

/* ---------- tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar {
  display: none;
}
.tabs button {
  font: inherit;
  font-weight: 600;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 14px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.tabs button:hover {
  color: var(--text);
}
.tabs button.active {
  color: var(--text);
  border-bottom-color: var(--primary-strong);
}

/* ---------- table ---------- */
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
}
th,
td {
  text-align: start;
  padding: 10px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: var(--fs-sm);
}

/* ---------- toast ---------- */
#toasts {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(420px, calc(100vw - 32px));
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary-strong);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  box-shadow: var(--shadow-float);
  font-size: var(--fs-md);
  animation: toast-in var(--t-med) var(--ease);
}
.toast.error {
  border-left-color: var(--danger);
}
.toast.success {
  border-left-color: var(--success);
}
.toast.warn {
  border-left-color: var(--warning);
}
@keyframes toast-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}
@media (max-width: 640px) {
  #toasts {
    left: 12px;
    right: 12px;
    max-width: none;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }
  body.listener #toasts,
  body.has-dock #toasts {
    bottom: calc(86px + env(safe-area-inset-bottom));
  }
}

/* ---------- dialog: centred on wide screens, a bottom sheet on phones ---------- */
dialog {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  width: min(640px, calc(100vw - 24px));
  max-width: none;
  max-height: min(88vh, 900px);
  box-shadow: var(--shadow-float);
}
dialog[open] {
  display: flex;
  flex-direction: column;
  animation: dlg-in var(--t-med) var(--ease);
}
dialog::backdrop {
  background: rgba(6, 10, 20, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
dialog .dlg-head {
  padding: 16px 18px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
dialog .dlg-head h3 {
  margin: 0;
}
dialog .dlg-body {
  padding: 12px 18px 16px;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}
dialog .dlg-foot {
  padding: 12px 18px 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}
@keyframes dlg-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }
}
@media (max-width: 640px) {
  dialog {
    margin: auto 0 0;
    width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  dialog[open] {
    animation: sheet-in var(--t-slow) var(--ease);
  }
  dialog .dlg-head {
    position: relative;
    padding-top: 22px;
  }
  dialog .dlg-head::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    width: 38px;
    height: 4px;
    margin-left: -19px;
    border-radius: 2px;
    background: var(--border-strong);
  }
  dialog .dlg-foot .btn {
    flex: 1;
  }
}
@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

/* ---------- live: on-air lamp, microphone, level meter ---------- */
.onair {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px 0 10px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  white-space: nowrap;
  transition: background var(--t-med), color var(--t-med), box-shadow var(--t-med);
}
.onair::before {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.55;
}
.onair.live {
  color: var(--live-contrast);
  background: var(--live);
  border-color: var(--live);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--live) 18%, transparent), 0 0 24px color-mix(in srgb, var(--live) 40%, transparent);
}
.onair.live::before {
  background: currentColor;
  opacity: 1;
  animation: blink 1.6s ease-in-out infinite;
}
.onair.paused {
  color: var(--warning);
  background: var(--warning-soft);
  border-color: transparent;
}
.mic-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 0;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--primary-strong) 82%, #fff) 0, var(--primary-strong) 62%);
  color: var(--primary-contrast);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--primary-strong) 60%, transparent), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
  transition: transform 0.1s, background var(--t-med), box-shadow var(--t-med);
  position: relative;
  flex: none;
}
.mic-btn svg {
  width: 40px;
  height: 40px;
}
.mic-btn:active {
  transform: scale(0.96);
}
.mic-btn.on {
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--live) 80%, #fff) 0, var(--live) 62%);
  color: var(--live-contrast);
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--live) 65%, transparent), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.mic-btn.on::before {
  content: '';
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 3px solid var(--live);
  opacity: 0.6;
  animation: pulse 1.4s ease-out infinite;
}
.mic-btn.small {
  width: 64px;
  height: 64px;
}
.mic-btn.small svg {
  width: 28px;
  height: 28px;
}
@keyframes pulse {
  from {
    transform: scale(0.95);
    opacity: 0.7;
  }
  to {
    transform: scale(1.25);
    opacity: 0;
  }
}
/* level meter: lit segments green → amber → red, like a mixing desk; --lvl is 0…1 */
.vu {
  --lvl: 0;
  position: relative;
  height: 10px;
  width: 100%;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
  -webkit-mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
  mask: repeating-linear-gradient(90deg, #000 0 6px, transparent 6px 8px);
}
.vu > i {
  position: absolute;
  inset: 0;
  display: block;
  background: linear-gradient(90deg, var(--success) 0 58%, var(--warning) 58% 82%, var(--live) 82%);
  clip-path: inset(0 calc(100% - var(--lvl) * 100%) 0 0);
  transition: clip-path 80ms linear;
}

/* ---------- captions (shared by host / join / display) ---------- */
.captions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
  padding: 4px 2px;
}
.cap {
  padding: 12px 14px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border);
  animation: cap-in var(--t-med) var(--ease);
}
@keyframes cap-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
.cap .who {
  font-size: var(--fs-xs);
  color: var(--faint);
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 3px;
  font-variant-numeric: tabular-nums;
}
.cap .who b {
  color: var(--muted);
  font-weight: 650;
}
.cap .main {
  font-size: calc(var(--cap-size) * var(--cap-mult, 1));
  line-height: 1.42;
  font-weight: 500;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.cap .orig {
  font-size: calc(var(--cap-size) * var(--cap-mult, 1) * 0.62);
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.45;
}
.cap.pending .main {
  color: var(--muted);
  font-style: italic;
}
.cap.interim {
  border-style: dashed;
  background: transparent;
}
.cap.interim .main {
  color: var(--muted);
}
.cap.question {
  border-color: var(--accent);
  background: var(--accent-soft);
}
[dir='rtl'] {
  /* (start, not right: on the Arabic interface's page a right would carry down to English lines too) */
  text-align: start;
}

/* ---------- header extras: Join, the guide's label, the phone menu's extra links, the language offer ---------- */
.topbar .btn-join {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: transparent;
  font-weight: 650;
}
.topbar .btn-join:hover {
  text-decoration: none;
  border-color: color-mix(in srgb, var(--primary) 35%, transparent);
}
.nav .nav-more {
  display: none;
}
.nav-globe {
  display: inline-grid;
  color: var(--muted);
}
.nav-globe svg {
  width: 18px;
  height: 18px;
}
.lang-offer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  background: var(--primary-soft);
  border-bottom: 1px solid color-mix(in srgb, var(--primary) 25%, var(--border));
}
.lang-offer .nav-globe {
  color: var(--primary);
}
@media (max-width: 900px) {
  body.nav-open .nav a.nav-more {
    display: block;
  }
  body.nav-open .nav .nav-langs {
    align-items: center;
  }
  body.nav-open .nav .nav-langs select {
    flex: 1;
  }
  .btn-guide .lbl {
    display: none;
  }
}
/* small phones: the logo alone, so Join, the guide and the menu still fit */
@media (max-width: 400px) {
  .topbar .brand {
    font-size: 0;
    gap: 0;
  }
}
/* the menu stays on one line; where it does not fit, common.js folds it into ☰ (body.nav-fold), as on phones */
.topbar .nav {
  flex-wrap: nowrap;
  min-width: 0;
  overflow: hidden;
}
.topbar .nav a {
  white-space: nowrap;
}
body.nav-fold .topbar .nav {
  display: none;
}
body.nav-fold .topbar .nav-toggle {
  display: inline-flex;
  font-size: 1.15rem;
}
body.nav-fold .topbar #uiLang {
  display: none;
}
body.nav-fold.nav-open .topbar .nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 0;
  padding: 8px max(14px, env(safe-area-inset-right)) 14px max(14px, env(safe-area-inset-left));
  max-height: calc(100vh - 70px);
  overflow-y: auto;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-float);
  animation: pop-in var(--t-med) var(--ease);
}
body.nav-fold.nav-open .nav a {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  font-size: 1rem;
}
body.nav-fold.nav-open .nav a.nav-more {
  display: block;
}
body.nav-fold.nav-open .nav .nav-langs {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 12px 14px 0;
  border-top: 1px solid var(--border);
}
body.nav-fold.nav-open .nav .nav-langs select {
  flex: 1;
}

/* ---------- home: the translator first, then the app's other parts ---------- */
.tr-app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 18px;
  padding-bottom: 20px;
}
/* for screen readers and search engines: the modes say it on screen */
.tr-title {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.tr-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.tabs.tr-modes {
  flex: 1;
  min-width: 0;
  gap: 8px;
  margin: 0;
  padding: 2px;
  border-bottom: 0;
}
.tabs.tr-modes button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 16px 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--text);
}
.tabs.tr-modes button:hover {
  background: var(--surface-2);
}
.tabs.tr-modes button.active {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}
.tabs.tr-modes button > [data-icon] svg {
  width: 18px;
  height: 18px;
  vertical-align: 0;
}
.tr-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}
.tr-actions [data-icon] svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.tr-actions .btn[aria-pressed='true'],
.tr-actions .btn[aria-expanded='true'] {
  color: var(--primary);
  background: var(--primary-soft);
}
/* context or a glossary is set: a dot on Options, as they change every translation */
#btnOptions.is-set::after {
  content: '';
  width: 7px;
  height: 7px;
  margin-inline-start: 4px;
  border-radius: 50%;
  background: var(--primary);
}
.tr-bar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 10px 12px;
}
.tr-langs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.tr-lang {
  flex: 0 1 280px;
  min-width: 0;
}
.tr-lang select {
  width: 100%;
  font-weight: 600;
}
.tr-extra {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-inline-start: 6px;
  font-size: var(--fs-sm);
}
.tr-extra .chips {
  gap: 6px;
}
.tr-add {
  width: auto;
  max-width: 200px;
  padding: 4px 8px;
}
.tr-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px var(--gap);
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.tr-panes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}
.tr-pane-foot {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.tr-out {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.tr-out #notice:empty,
.tr-out #results:empty {
  display: none;
}
.tr-out #resultsEmpty {
  min-height: 300px;
  display: grid;
  place-items: center;
}
.tr-kinds {
  align-self: flex-start;
}
.tr-history-item {
  display: block;
  width: 100%;
  min-height: 0;
  font: inherit;
  color: inherit;
  text-align: start;
  cursor: pointer;
}
.tr-history-item:hover {
  border-color: var(--primary);
}
.tr-history-item .text {
  font-size: var(--fs-md);
}

/* below the translator: one line, then a card per part of the app */
.tr-app + .home-more {
  padding-top: 8px;
}
.home-intro {
  margin-bottom: 14px;
}
.home-intro h2 {
  margin: 0 0 4px;
  font-size: var(--fs-lg);
}
.home-intro p {
  margin: 0;
  max-width: 72ch;
}
.home-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.home-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  align-items: start;
  gap: 2px 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
a.home-card:hover {
  border-color: var(--primary);
  text-decoration: none;
}
.home-card .ico {
  grid-row: 1 / span 2;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: var(--primary-soft);
  color: var(--primary);
}
.home-card .ico svg {
  width: 22px;
  height: 22px;
}
.home-card > span:not(.ico):not(.row) {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.home-join {
  background: var(--primary-soft);
  border-color: color-mix(in srgb, var(--primary) 30%, var(--border));
}
.home-join .ico {
  background: var(--surface);
}
.home-join .row {
  margin-top: 6px;
  gap: 8px;
}
.home-join .code-input {
  font-size: 1.05rem !important;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

@media (max-width: 1000px) {
  .home-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 760px) {
  .tr-panes {
    grid-template-columns: minmax(0, 1fr);
  }
  .tr-panes .tr-pane {
    min-height: 0;
  }
  .tr-panes .tr-pane textarea {
    min-height: 150px;
  }
  /* on a phone the empty answer box only pushes the rest down */
  .tr-out #resultsEmpty {
    display: none;
  }
}
/* phones: the four modes take the whole row as icon-over-label buttons (their names stay whole in every interface
   language); History and Options go under them, on the right */
@media (max-width: 640px) {
  .tr-app {
    padding-top: 12px;
  }
  .tr-top {
    flex-wrap: wrap;
    row-gap: 2px;
  }
  .tabs.tr-modes {
    flex-basis: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
  }
  .tr-actions {
    margin-inline-start: auto;
  }
  .tabs.tr-modes button {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px;
    border-radius: var(--r-sm);
    font-size: var(--fs-xs);
  }
  .tabs.tr-modes button > span:last-child {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .tr-actions .btn {
    min-height: 38px;
  }
  .tr-lang {
    flex: 1 1 0;
  }
  .tr-extra {
    flex-basis: 100%;
    margin-inline-start: 0;
  }
  .tr-options {
    grid-template-columns: minmax(0, 1fr);
  }
  .home-cards {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---------- translator page ---------- */
.tr-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 320px;
}
.tr-pane textarea {
  flex: 1;
  min-height: 240px;
  font-size: 1.08rem;
  border-color: var(--border-strong);
}
.tr-result {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 14px 16px;
  min-height: 90px;
  white-space: pre-wrap;
  font-size: 1.08rem;
  line-height: 1.6;
  position: relative;
}
.tr-result .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: var(--fs-sm);
  color: var(--muted);
  white-space: normal;
}
.tr-result .text {
  white-space: pre-wrap;
  word-break: break-word;
}
.counter {
  font-size: var(--fs-sm);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.dropzone {
  border: 2px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 26px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.img-preview {
  display: block;
  max-width: 100%;
  max-height: 320px;
  margin: 12px auto 0;
  border-radius: var(--r-sm);
  box-shadow: var(--shadow);
}
.dropzone.drag,
.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

/* ---------- join (listener) ---------- */
body.listener {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
body.listener > main {
  overflow-y: auto;
}
.listen-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px max(14px, env(safe-area-inset-right)) 10px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.listen-head .title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.listen-body {
  position: relative; /* the captions' offsets are measured from here (join.js) */
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 8px max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
}
/* a transcript to read, set in short rows like subtitles; it sits on the live area, so the first words of a talk
   appear at the bottom, where the eye rests */
.listen-body .captions,
.live-rows {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
}
.listen-body .captions {
  display: block;
  margin-top: auto;
  overflow: visible;
  padding: 4px 2px 0;
}
/* the newest 2–3 rows: under the transcript, and pinned to the bottom while the reader reads back */
.live-rows {
  position: sticky;
  bottom: 0;
  z-index: 2;
  padding: 0 2px 18px;
}
/* new rows come up from its lower edge; clipped there, they never lengthen the page while they glide (the scroll
   position would follow them, then snap back) */
.live-list {
  overflow: hidden;
  overflow: clip;
}
.live-rows.stuck {
  background: var(--bg);
  box-shadow:
    0 -1px 0 var(--border),
    0 -16px 22px -18px rgba(15, 26, 46, 0.4);
}
.cap-row {
  font-size: calc(var(--cap-size) * var(--cap-mult, 1));
  line-height: 1.42;
  font-weight: 500;
  overflow-wrap: anywhere;
  transition: color 0.6s var(--ease);
}
.cap-row.orig {
  font-size: calc(var(--cap-size) * var(--cap-mult, 1) * 0.62);
  line-height: 1.5;
  font-weight: 400;
  color: var(--muted);
}
/* words still being said: lighter, they may change */
.cap-row.tail {
  color: color-mix(in srgb, var(--text) 48%, var(--bg));
}
.cap-row.tail.orig {
  color: color-mix(in srgb, var(--muted) 70%, var(--bg));
}
.cap-row.failed {
  color: var(--muted);
  font-style: italic;
}
/* the lines in the live area in full ink, earlier ones a step back */
.listen-body .captions .cap-row:not(.cur) {
  color: color-mix(in srgb, var(--text) 74%, var(--bg));
}
.listen-body .captions .cap-row.orig:not(.cur),
.listen-body .captions .cap-row.failed:not(.cur) {
  color: color-mix(in srgb, var(--muted) 82%, var(--bg));
}
.cap-label {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: var(--fs-xs);
  color: var(--faint);
  padding: 12px 0 2px;
  font-variant-numeric: tabular-nums;
}
.cap-label b {
  color: var(--muted);
  font-weight: 650;
}
/* the speaker is talking and the translation is on its way */
.live-dots {
  position: absolute;
  left: 4px;
  bottom: 6px;
  display: flex;
  gap: 4px;
}
.live-dots i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--faint);
  animation: live-dot 1.2s ease-in-out infinite;
}
.live-dots i:nth-child(2) {
  animation-delay: 0.15s;
}
.live-dots i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes live-dot {
  0%,
  60%,
  100% {
    opacity: 0.25;
  }
  30% {
    opacity: 1;
  }
}
.listen-body .cap.question {
  position: sticky;
  top: 0;
  z-index: 3;
  width: 100%;
  max-width: 980px;
  margin: 0 auto 8px;
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.listen-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px max(10px, env(safe-area-inset-right)) calc(8px + env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
}
.listen-bar::-webkit-scrollbar {
  display: none;
}
.listen-bar .btn,
.listen-bar .seg {
  flex: none;
}
.listen-bar .bar-gap {
  flex: 1;
}
/* narrow phones: the view modes as icons (their names stay in the tooltip and for screen readers) */
@media (max-width: 520px) {
  .listen-bar .seg > button {
    padding: 0 10px;
  }
  .listen-bar .seg > button span:not([data-icon]),
  .listen-bar #askBtn .lbl {
    display: none;
  }
}
@media (max-width: 420px) {
  .listen-bar #audioBtn .lbl {
    display: none;
  }
}
.jump-latest {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%);
  z-index: 20;
  box-shadow: var(--shadow-float);
}
.more-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.more-grid .btn {
  justify-content: flex-start;
  min-height: 48px;
}
/* focus view: only the live area, a few large rows in the middle of the dark stage */
body.listener.view-focus .listen-body {
  background: var(--stage);
  color: var(--stage-text);
  overflow: hidden;
  justify-content: center;
  padding-top: 24px;
  padding-bottom: 24px;
}
body.listener.view-focus .listen-body .captions {
  display: none;
}
body.listener.view-focus .live-rows {
  position: static;
  max-width: 1100px;
  margin-block: auto;
}
/* as high as its rows from the start, the newest at the bottom: nothing re-centres as rows come */
body.listener.view-focus .live-list {
  min-height: var(--live-h, 0px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
body.listener.view-focus .cap-row {
  font-size: calc(var(--cap-size) * 1.45);
  line-height: 1.3;
  font-weight: 600;
  color: var(--stage-text);
}
body.listener.view-focus .cap-row.orig {
  font-size: calc(var(--cap-size) * 0.9);
  font-weight: 500;
}
body.listener.view-focus .cap-row.orig,
body.listener.view-focus .cap-row.failed,
body.listener.view-focus .cap-label,
body.listener.view-focus .cap-label b,
body.listener.view-focus .listen-body .empty {
  color: var(--stage-muted);
}
body.listener.view-focus .cap-row.tail {
  color: color-mix(in srgb, var(--stage-text) 50%, var(--stage));
}
body.listener.view-focus .live-dots i {
  background: var(--stage-muted);
}
body.listener.view-focus .jump-latest {
  display: none;
}
.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
  max-height: 46vh;
  overflow-y: auto;
  padding: 2px;
}
.lang-btn {
  font: inherit;
  text-align: start;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
  transition: border-color var(--t-fast), background var(--t-fast);
}
.lang-btn:hover {
  border-color: var(--primary);
}
.lang-btn.active {
  border-color: var(--primary-strong);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary-strong);
}
.lang-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.lang-btn b {
  display: block;
  font-size: 0.98rem;
}
.lang-btn span {
  font-size: var(--fs-xs);
  color: var(--muted);
}

/* ---------- host console ---------- */
.console {
  display: grid;
  gap: var(--gap);
  grid-template-columns: minmax(290px, 340px) minmax(0, 1fr) minmax(270px, 320px);
  grid-template-areas:
    'head head head'
    'controls live audience';
  align-items: start;
}
.console-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.console-head .room-title {
  min-width: 0;
}
.console-head .room-title .muted {
  font-size: var(--fs-sm);
}
.console-head h2 {
  margin: 0;
  font-size: var(--fs-xl);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.console-tabs {
  display: none;
}
.pane-controls {
  grid-area: controls;
}
.pane-live {
  grid-area: live;
}
.pane-audience {
  grid-area: audience;
}
.mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
}
.mic-zone .mic-meta {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
}
.mic-zone #micStatus {
  font-size: var(--fs-sm);
}
/* audio sources: the summary in the speaker card, a row per source in the dialog, a meter per source while live */
.source-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: calc(var(--ctl-h) - 8px);
  font-size: var(--fs-sm);
}
.source-summary .src-main {
  font-weight: 600;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.src-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.src-row .hint {
  margin: 0;
  font-size: var(--fs-sm);
}
.src-row .vu {
  height: 8px;
}
.src-meters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.src-meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 8px;
  align-items: center;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.src-meter span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.src-meter .vu {
  height: 6px;
}
@media (max-width: 1279px) {
  .console {
    grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
    grid-template-areas:
      'head head'
      'controls live'
      'audience audience';
  }
  .pane-audience {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    align-items: start;
  }
}
/* focus: the microphone in a slim column, the captions take the rest (wide screens; phones use the tabs) */
@media (min-width: 900px) {
  .console[data-view='focus'] {
    grid-template-columns: 200px minmax(0, 1fr);
    grid-template-areas:
      'head head'
      'controls live';
  }
  .console[data-view='focus'] .pane-audience,
  .console[data-view='focus'] .pane-controls > :not(.speaker-card),
  .console[data-view='focus'] .speaker-card > :not(.mic-zone) {
    display: none;
  }
  .console[data-view='focus'] .speaker-card {
    position: sticky;
    top: calc(var(--topbar-h) + 16px);
  }
  .console[data-view='focus'] .live-panel {
    --cap-mult: 1.4;
  }
}
/* phones and small tablets: one pane at a time, the microphone docked at the bottom */
@media (max-width: 899px) {
  .console {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'head'
      'tabs'
      'controls'
      'live'
      'audience';
  }
  .console-head .view-seg {
    display: none;
  }
  .console-head h2 {
    font-size: var(--fs-lg);
  }
  .console-tabs {
    grid-area: tabs;
    display: flex;
    position: sticky;
    top: calc(var(--topbar-h) + 6px);
    z-index: 20;
  }
  .console-tabs > button {
    flex: 1;
  }
  .console:not([data-tab='controls']) .pane-controls > :not(.speaker-card),
  .console:not([data-tab='controls']) .speaker-card > :not(.mic-zone),
  .console:not([data-tab='live']) .pane-live,
  .console:not([data-tab='audience']) .pane-audience,
  .console[data-tab='controls'] .pane-audience {
    display: none;
  }
  .console:not([data-tab='controls']) .pane-controls,
  .console:not([data-tab='controls']) .speaker-card {
    display: contents;
  }
  .console:not([data-tab='controls']) .mic-zone {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    flex-direction: row;
    gap: 14px;
    padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -8px 24px -12px rgba(15, 26, 46, 0.25);
  }
  .console:not([data-tab='controls']) .mic-zone .mic-btn {
    width: 58px;
    height: 58px;
  }
  .console:not([data-tab='controls']) .mic-zone .mic-btn svg {
    width: 26px;
    height: 26px;
  }
  .console:not([data-tab='controls']) .mic-zone .mic-meta {
    flex: 1;
    min-width: 0;
  }
  .console:not([data-tab='controls']) .mic-zone #micStatus {
    text-align: start;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .console:not([data-tab='controls']) .mic-zone #copyRecLog {
    display: none;
  }
  .console {
    padding-bottom: calc(84px + env(safe-area-inset-bottom));
  }
  .pane-audience {
    grid-template-columns: minmax(0, 1fr);
  }
}
.live-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--topbar-h) - 120px);
  height: calc(100dvh - var(--topbar-h) - 120px);
  min-height: 460px;
}
@media (max-width: 899px) {
  .live-panel {
    height: calc(100dvh - var(--topbar-h) - 250px);
    min-height: 340px;
  }
}
.live-panel .captions {
  flex: 1;
  --cap-size: 24px;
}
.live-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
/* translation first (what the audience reads), the speaker's original small underneath */
.cap .tr-line .lang-tag {
  font-size: 0.5em;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--faint);
  margin-right: 8px;
  vertical-align: 0.25em;
}
.cap .tr-line.tr-more {
  font-size: calc(var(--cap-size) * var(--cap-mult, 1) * 0.8);
  margin-top: 6px;
}
.cap .tr-line.reading {
  background: var(--primary-soft);
  box-shadow: -6px 0 0 var(--primary-soft);
  border-radius: var(--r-xs);
}
.cap .src-line {
  margin-top: 6px;
}
.cap-act {
  min-height: 26px !important;
  padding: 0 6px !important;
  opacity: 0.55;
  vertical-align: 0.1em;
}
.cap:hover .cap-act,
.cap-act:focus-visible {
  opacity: 1;
}
.cap-edit {
  margin-top: 6px;
  font-size: calc(var(--cap-size) * 0.75);
}
.voice-bar {
  display: flex;
  align-items: center;
  gap: 8px 10px;
  flex-wrap: wrap;
  padding: 8px 10px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
/* the voice's state gets a line of its own under the switch and the tools */
.voice-state {
  order: 3;
  flex: 1 1 100%;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-sm);
}
.voice-state > .muted,
.voice-state .voice-text {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.voice-state .voice-text {
  flex: 1 1 120px;
  color: var(--muted);
}
.voice-state:empty {
  display: none;
}
.voice-tools {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-inline-start: auto;
}
.size-ctl {
  display: inline-flex;
}
.voice-ch {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) 90px auto 32px;
  gap: 6px;
  align-items: center;
}
.mode-opt {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.mode-opt:has(input:checked) {
  border-color: var(--primary-strong);
  background: var(--primary-soft);
}
.mode-opt input {
  margin-top: 3px;
}
.mode-opt > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
@media (max-width: 600px) {
  .voice-ch {
    grid-template-columns: 1fr 1fr;
  }
}
.qr-box {
  background: #fff;
  border-radius: var(--r-md);
  padding: 12px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
}
.qr-box img {
  width: 100%;
  max-width: 220px;
  height: auto;
  image-rendering: pixelated;
}
.room-code {
  font-family: var(--mono);
  font-size: 1.9rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.q-item {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
}
.q-item.answered {
  opacity: 0.6;
}
.q-item .q-tr {
  font-weight: 600;
}
.q-item .q-src {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.term-info {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: start;
  font: inherit;
  color: inherit;
}
.ok-text {
  color: var(--success);
}
.smart-filter {
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
}

/* ---------- conversation ---------- */
body.convo {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
}
/* phones: the engine and the switches get a row of their own under the title */
@media (max-width: 640px) {
  body.convo .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }
  body.convo .cv-controls {
    order: 5;
    flex: 1 1 100%;
    min-width: 0;
  }
  body.convo .cv-controls #engine {
    flex: 1 1 auto;
    min-width: 0;
    width: 0 !important;
  }
  body.convo .cv-controls .switch,
  body.convo .cv-controls .seg {
    flex: none;
    white-space: nowrap;
  }
}
.convo-wrap {
  flex: 1;
  display: grid;
  grid-template-rows: 1fr 1fr;
  min-height: 0;
}
.convo-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px max(18px, env(safe-area-inset-right)) 16px max(18px, env(safe-area-inset-left));
  min-height: 0;
}
.convo-side + .convo-side {
  border-top: 1px solid var(--border-strong);
}
.convo-side.flip {
  transform: rotate(180deg);
}
.convo-side .say {
  flex: 1;
  overflow-y: auto;
  font-size: clamp(1.35rem, 3.4vw, 2.2rem);
  line-height: 1.38;
  font-weight: 550;
  text-wrap: pretty;
}
.convo-side .say .heard {
  font-size: 0.6em;
  color: var(--muted);
  font-weight: 400;
  margin-bottom: 6px;
}
.convo-side .say .ph {
  color: var(--muted);
  font-size: 0.6em;
  font-weight: 400;
}
.convo-side.a {
  background: color-mix(in srgb, var(--primary-soft) 50%, var(--bg));
}
.convo-side.b {
  background: color-mix(in srgb, var(--accent-soft) 50%, var(--bg));
}
.convo-side.b .mic-btn:not(.on) {
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--accent-strong) 80%, #fff) 0, var(--accent-strong) 62%);
  color: var(--accent-contrast);
  box-shadow: 0 10px 28px -6px color-mix(in srgb, var(--accent-strong) 60%, transparent), inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}
.convo-side select {
  max-width: 280px;
  font-weight: 600;
}
@media (min-width: 1000px) {
  .convo-wrap:not(.facing) {
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr;
  }
  .convo-wrap:not(.facing) .convo-side + .convo-side {
    border-top: 0;
    border-left: 1px solid var(--border-strong);
  }
}

/* ---------- display / overlay ---------- */
body.display {
  background: #000;
  color: #fff;
  height: 100vh;
  overflow: hidden;
  font-family: var(--font);
}
body.display.bg-transparent {
  background: transparent;
}
body.display.bg-green {
  background: #00b140;
}
body.display.bg-white {
  background: #fff;
  color: #111;
}
body.display.bg-blue {
  background: var(--stage);
}
.stage {
  position: fixed;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  gap: 2.2vh;
  padding: 3vh 4vw;
}
.stage.pos-bottom {
  bottom: 0;
}
.stage.pos-top {
  top: 0;
}
.stage.pos-center {
  top: 50%;
  transform: translateY(-50%);
}
.stage .block {
  display: flex;
  flex-direction: column;
  gap: 0.4vh;
}
/* a language's rows roll up in a window as high as its rows (set by display.js), the newest at the bottom */
.stage .win {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: flex-start;
  overflow: hidden;
}
.stage .win > .line {
  flex: none;
}
.stage .win.orig > .line {
  font-size: calc(var(--disp-size, 4.6vh) * 0.62);
  font-weight: 500;
  opacity: 0.75;
}
.stage .block .lbl {
  font-size: 1.8vh;
  letter-spacing: 0.02em;
  opacity: 0.75;
  font-weight: 700;
}
.stage .line {
  font-size: var(--disp-size, 4.6vh);
  line-height: 1.32;
  font-weight: 600;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
  text-wrap: pretty;
}
body.display.bg-white .stage .line {
  text-shadow: none;
}
.stage .line.box {
  background: rgba(0, 0, 0, 0.66);
  padding: 0.3em 0.6em;
  border-radius: 0.3em;
  align-self: flex-start;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
}
.stage.align-center .line.box,
.stage.align-center .win,
.stage.align-center .lbl {
  align-self: center;
  text-align: center;
  align-items: center;
}
.stage.align-center .win {
  align-self: stretch;
}
/* words still being said: lighter, they may change */
.stage .line.interim {
  opacity: 0.55;
}
.disp-qr {
  position: fixed;
  top: 3vh;
  right: 3vw;
  background: #fff;
  color: var(--stage);
  border-radius: 14px;
  padding: 1.2vh;
  text-align: center;
  font-weight: 700;
  font-size: 1.8vh;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.disp-qr img {
  width: 18vh;
  height: 18vh;
  display: block;
}
.disp-qr .code {
  font-family: var(--mono);
  letter-spacing: 0.15em;
  font-size: 2.6vh;
}
/* the interpretation channels' QR codes (display.js renderChans): a row at the top left, clear of the audience QR */
.disp-chans {
  position: fixed;
  top: 3vh;
  left: 4vw;
  max-width: calc(100vw - 7vw - 24vh);
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1.2vh;
}
.disp-chans.below-title {
  top: 8.5vh;
}
.disp-chans.at-bottom {
  top: auto;
  bottom: 3vh;
}
.disp-chan {
  background: #fff;
  color: var(--stage);
  border-radius: 1.2vh;
  padding: 0.9vh 0.9vh 1vh;
  text-align: center;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.disp-chan .n {
  font-weight: 800;
  font-size: 2.1vh;
  white-space: nowrap;
}
.disp-chan .l {
  font-weight: 600;
  font-size: 1.8vh;
  white-space: nowrap;
  margin-bottom: 0.5vh;
}
.disp-chan img {
  width: 14vh;
  height: 14vh;
  display: block;
  margin: 0 auto;
}
/* five or six channels: smaller codes, one row beside the audience QR even on a 4:3 screen */
.disp-chans.many .disp-chan img {
  width: 12vh;
  height: 12vh;
}
.disp-title {
  position: fixed;
  top: 3vh;
  left: 4vw;
  font-size: 2.6vh;
  font-weight: 700;
  opacity: 0.85;
}
.disp-question {
  position: fixed;
  top: 12vh;
  left: 4vw;
  right: 4vw;
  background: rgba(15, 118, 110, 0.94);
  color: #fff;
  padding: 2vh 2.5vw;
  border-radius: 1.4vh;
  font-size: 3.4vh;
  font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
.disp-question small {
  display: block;
  font-size: 1.8vh;
  opacity: 0.85;
  color: #fff;
  margin-bottom: 0.6vh;
}
.disp-settings {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 50;
  max-width: 420px;
  max-height: calc(100vh - 20px);
  overflow-y: auto;
  color: var(--text);
  box-shadow: var(--shadow-float);
}

/* ---------- admin ---------- */
.prov {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.prov-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.prov-head h3 {
  margin: 0;
  font-size: 1rem;
}
.kv {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 6px 14px;
  font-size: var(--fs-md);
}
.kv dt {
  color: var(--muted);
}
.kv dd {
  margin: 0;
  word-break: break-all;
}
@media (max-width: 560px) {
  .kv {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  .kv dd {
    margin-bottom: 8px;
  }
}
.bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 90px;
  padding-top: 6px;
}
.bars i {
  flex: 1;
  background: var(--primary-strong);
  border-radius: 3px 3px 0 0;
  min-height: 2px;
  opacity: 0.85;
}
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.steps li {
  counter-increment: step;
  display: flex;
  gap: 10px;
}
.steps li::before {
  content: counter(step);
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: var(--fs-sm);
}
.setup-result {
  font-size: var(--fs-sm);
}
.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  display: inline-block;
  vertical-align: middle;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- documents (markdown) ---------- */
.md {
  line-height: 1.65;
}
.md h1,
.md h2,
.md h3 {
  margin-top: 1.1em;
}
.md h1:first-child,
.md h2:first-child {
  margin-top: 0;
}
.md p,
.md li {
  max-width: 78ch;
}
.md ul,
.md ol {
  padding-left: 1.3em;
}
.md pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  overflow-x: auto;
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.md pre code {
  background: none;
  padding: 0;
  overflow-wrap: normal;
}
.md blockquote {
  border-left: 3px solid var(--primary);
  margin: 0.6em 0;
  padding: 0.2em 0.9em;
  color: var(--muted);
}
.md table {
  margin: 0.6em 0 1em;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* recommended set-up of a translation mode (room settings) */
.preset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--primary-soft);
}
.preset-head { display: flex; align-items: center; gap: 6px; }
.preset-text { margin: 0; font-size: .92rem; line-height: 1.45; }
.preset-items { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; padding: 0; list-style: none; font-size: .88rem; }

/* ---------- Lắng nghe (listen.html): one listener, the talk translated into the earphones ---------- */
.ls-small {
  font-size: var(--fs-sm);
}
.ls-intro h1 {
  margin: 0 0 6px;
}
.ls-intro .lead {
  margin: 0;
  color: var(--muted);
}
.ls-lock {
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 32px 22px;
}
.ls-lock h2,
.ls-lock p {
  margin: 0;
}
.ls-lock p {
  max-width: 54ch;
}
.ls-lock-ico {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.ls-lock-ico svg {
  width: 30px;
  height: 30px;
}
.ls-levels {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
  gap: 8px;
}
.ls-level {
  font: inherit;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.ls-level:hover:not(:disabled) {
  border-color: var(--primary);
}
.ls-level.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.ls-level:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}
.ls-level-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.ls-price {
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ls-level.on .ls-price {
  color: var(--primary);
}
.ls-level-text {
  font-size: var(--fs-sm);
  color: var(--muted);
  line-height: 1.4;
}
.ls-why {
  font-size: var(--fs-xs);
  color: var(--warning);
}
/* the level on the live bar: a button (another level while listening) */
.ls-level-btn {
  border: 0;
  font-family: inherit;
  cursor: pointer;
  flex: none;
}
.ls-level-btn::after {
  content: '';
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.7;
}
.ls-level-btn:hover:not(:disabled) {
  box-shadow: inset 0 0 0 1px currentColor;
}
.ls-level-btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.ls-level-btn:disabled {
  cursor: default;
}
.ls-level-btn.busy {
  opacity: 0.6;
}
.ls-level-dlg {
  width: min(560px, calc(100vw - 24px));
}
.ls-level-dlg .ls-levels {
  grid-template-columns: 1fr;
}
.ls-level-now {
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--primary);
}
.ls-more summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 600;
  font-size: var(--fs-sm);
}
#lsLockTip p {
  margin: 0;
}
#lsLockTip p + p {
  margin-top: 6px;
}
.ls-hist {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 4px 8px 4px 4px;
}
.ls-hist-main {
  font: inherit;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: start;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--r-xs);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}
.ls-hist-main:hover {
  background: var(--surface-2);
}
.ls-hist-main b {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-wrap: anywhere;
}

/* the live screen: the captions fill it, the controls stay under the thumb */
body.ls-living .topbar,
body.ls-living .guide-wrap {
  display: none;
}
body.ls-living {
  overflow: hidden;
}
.ls-live {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.ls-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  font-size: var(--fs-sm);
  min-width: 0;
}
.ls-bar .spacer {
  flex: 1;
}
.ls-time {
  font-variant-numeric: tabular-nums;
  font-size: var(--fs-md);
}
.ls-vu {
  width: 72px;
  flex: none;
}
.ls-vu.gated {
  opacity: 0.45;
}
.ls-stat {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
#lsState {
  flex: 0 1 auto;
}
.ls-notice {
  margin: 8px max(14px, env(safe-area-inset-left)) 0;
}
.ls-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px max(14px, env(safe-area-inset-right)) 18px max(14px, env(safe-area-inset-left));
}
.ls-lines {
  overflow: visible;
  scroll-behavior: auto;
  max-width: 980px;
  margin: 0 auto;
}
.ls-scroll > .cap.interim {
  max-width: 980px;
  margin: 10px auto 0;
}
.ls-live .cap .main {
  font-size: calc(var(--cap-size) * var(--cap-mult, 1));
}
.ls-live.no-orig .cap .orig {
  display: none;
}
.ls-ts {
  font-variant-numeric: tabular-nums;
}
.ls-star {
  color: var(--warning);
}
.cap.ls-marked {
  border-color: color-mix(in srgb, var(--warning) 55%, var(--border));
  box-shadow: inset 3px 0 0 var(--warning);
}
.ls-gap {
  align-self: center;
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--muted);
  padding: 3px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-pill);
}
.ls-jump {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 2;
  box-shadow: var(--shadow-float);
}
.ls-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  background: var(--surface);
}
#lsVoiceBtn.active {
  border-color: var(--accent);
  color: var(--accent);
}
#lsVoiceBtn.ls-speaking svg {
  animation: blink 1.2s ease-in-out infinite;
}
@media (max-width: 640px) {
  .ls-bar {
    gap: 8px;
  }
  #lsCost {
    display: none;
  }
  .ls-vu {
    width: 48px;
  }
  .ls-controls {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px;
  }
  .ls-controls .btn {
    padding: 0 6px;
    min-height: 48px;
    flex-direction: column;
    gap: 2px;
    font-size: var(--fs-xs);
    white-space: normal;
    text-align: center;
  }
  #lsPause,
  #lsEnd {
    grid-column: span 2;
    flex-direction: row;
    font-size: var(--fs-sm);
  }
  /* the icon button fills its cell; without the recap button End takes its place too */
  .ls-controls .btn-icon {
    width: auto;
  }
  #lsRecap[hidden] ~ #lsEnd {
    grid-column: span 3;
  }
  .ls-jump {
    bottom: calc(132px + env(safe-area-inset-bottom));
  }
}

/* pocket mode: a black screen that stays on (OLED: almost no battery), the microphone keeps listening */
.ls-pocket {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: #000;
  color: #8a94a6;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  padding: 24px;
  text-align: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.ls-pocket-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.ls-pocket-line {
  max-width: 34ch;
  font-size: 1.05rem;
  line-height: 1.5;
  color: #5d6676;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ls-pocket-hint {
  position: absolute;
  bottom: calc(24px + env(safe-area-inset-bottom));
  font-size: var(--fs-xs);
  color: #3d4452;
}

/* dialogs of the live screen */
.ls-qr {
  display: grid;
  place-items: center;
  min-height: 220px;
}
.ls-qr img,
.ls-qr svg {
  width: min(260px, 70vw);
  height: auto;
  background: #fff;
  padding: 10px;
  border-radius: var(--r-sm);
}
.ls-link {
  font-family: var(--mono);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.ls-qa {
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
}
.ls-q {
  font-weight: 650;
  margin-bottom: 6px;
}
.ls-q .ls-ts {
  color: var(--faint);
  font-weight: 500;
  font-size: var(--fs-xs);
}
.ls-session-dlg {
  width: min(820px, calc(100vw - 24px));
}
@media (max-width: 640px) {
  /* a phone: the full-width sheet every dialog is there */
  .ls-session-dlg {
    width: 100%;
  }
}
.ls-session-lines {
  --cap-size: 17px;
  overflow: visible;
}
.ls-session-foot {
  flex-wrap: wrap;
  justify-content: flex-start;
}
.ls-session-foot .spacer {
  flex: 1;
}

/* floating captions (Document Picture-in-Picture): the last lines, large, on the dark stage */
.ls-pip-body {
  margin: 0;
  background: var(--stage);
  color: var(--stage-text);
  font-family: var(--font);
  height: 100vh;
  overflow: hidden;
}
.ls-pip {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px 16px 12px;
  gap: 4px;
}
.ls-pip p {
  margin: 0;
  font-size: calc(var(--cap-size) * 0.9);
  line-height: 1.35;
  font-weight: 500;
}
.ls-pip p:not(:last-child) {
  opacity: 0.6;
}
.ls-pip p.it {
  color: var(--stage-muted);
  opacity: 1;
}

/* ---------- Dịch đa phương tiện (media.html): any sound on the computer, the translation over the picture ---------- */
.mp-setup {
  gap: var(--gap);
}
.mp-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}
.mp-opts {
  gap: var(--gap);
}
.mp-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: var(--fs-lg);
}
.mp-step {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-strong);
  color: var(--primary-contrast);
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 900px) {
  .mp-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* the levels, one row each: what the chosen one does is said under it (the others: name and price) */
.mp-levels {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
.mp-levels .ls-level {
  padding: 9px 12px;
}
.mp-levels .ls-level:not(.on) .ls-level-text {
  display: none;
}

/* «Bắt đầu dịch»: kept at the bottom of the screen until the form above it has been passed */
.mp-go {
  position: sticky;
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 18px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-float);
}
.mp-sum {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: var(--fs-sm);
  line-height: 1.4;
  color: var(--muted);
}
.mp-sum b {
  color: var(--text);
  font-weight: 650;
}
.mp-go .btn {
  flex: none;
}
.mp-privacy {
  margin: -4px 0 0;
}
@media (max-width: 560px) {
  .mp-go {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 10px;
  }
  .mp-sum {
    padding: 0 4px;
    font-size: var(--fs-xs);
  }
}

/* the history: folded, with how many there are */
.mp-hist > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
}
.mp-hist > summary::-webkit-details-marker {
  display: none;
}
.mp-hist > summary::before {
  content: '';
  width: 8px;
  height: 8px;
  flex: none;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg);
  transition: transform var(--t-fast);
  color: var(--muted);
}
.mp-hist[open] > summary::before {
  transform: rotate(45deg);
}
.mp-hist > summary h3 {
  margin: 0;
  font-size: var(--fs-lg);
}
.mp-hist[open] > summary {
  margin-bottom: 12px;
}

/* the source cards: each with its own colour, two by two (a phone: its two), the icon beside the name */
.mp-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.mp-card {
  --c: var(--primary);
  font: inherit;
  text-align: start;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  row-gap: 2px;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.mp-card[data-card='video'] {
  --c: #e5484d;
}
.mp-card[data-card='meeting'] {
  --c: #4f6bed;
}
.mp-card[data-card='file'] {
  --c: #d97706;
}
.mp-card[data-card='mic'] {
  --c: #c026d3;
}
.mp-card:hover {
  border-color: var(--c);
  transform: translateY(-1px);
}
.mp-card.on {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 9%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--c);
}
.mp-card:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.mp-card-ico {
  grid-row: span 2;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: var(--c);
  background: color-mix(in srgb, var(--c) 14%, transparent);
  transition: background var(--t-fast), color var(--t-fast);
}
.mp-card.on .mp-card-ico {
  background: var(--c);
  color: #fff;
}
.mp-card-ico svg {
  width: 20px;
  height: 20px;
}
.mp-card-t {
  font-weight: 650;
  line-height: 1.25;
}
.mp-card-s {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.35;
}
@media (max-width: 560px) {
  .mp-cards {
    gap: 8px;
  }
  .mp-card {
    column-gap: 9px;
    row-gap: 1px;
    padding: 9px 10px;
  }
  .mp-card-ico {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }
  .mp-card-ico svg {
    width: 17px;
    height: 17px;
  }
  .mp-card-t {
    font-size: var(--fs-sm);
  }
}

/* (a phone: why it has two cards only) */
.mp-phone-note {
  font-size: var(--fs-sm);
  line-height: 1.45;
}

/* under the cards: how it is heard, the link, the file, the microphone, the steps */
.mp-where {
  gap: 12px;
}
.mp-via-ico {
  display: inline-flex;
}
.mp-url {
  display: flex;
  gap: 8px;
}
.mp-url .btn {
  flex: none;
}
#mpUrl[aria-invalid='true'] {
  border-color: var(--danger);
}
#mpUrlHint:not(:empty) {
  color: var(--danger);
}
.mp-file {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 16px;
}
.mp-file b {
  color: var(--text);
}
.mp-file .hint {
  max-width: 52ch;
}
.mp-file-ico {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--primary-soft);
  color: var(--primary);
}
.mp-file-ico svg {
  width: 22px;
  height: 22px;
}
.mp-file.has {
  border-style: solid;
  border-color: var(--accent);
  background: var(--accent-soft);
}
.mp-file.has .mp-file-ico {
  background: var(--accent);
  color: var(--accent-contrast);
}
.mp-file-name {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
  font-variant-numeric: tabular-nums;
}
.mp-how {
  list-style: none;
  counter-reset: how;
  margin: 0;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.mp-how:empty {
  display: none;
}
.mp-how li {
  counter-increment: how;
  position: relative;
  padding-left: 30px;
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.mp-how li::before {
  content: counter(how);
  position: absolute;
  left: 0;
  top: 0;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
}
#mpNote p {
  margin: 0;
}

/* ---------- the live screen: the picture (dark, like a player) and the lines beside it ---------- */
.mp-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.mp-stage {
  flex: none;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--stage);
  color: var(--stage-text);
}
.mp-screen {
  position: relative;
  /* the captions' size follows the picture's (a size container: cqi and cqh) */
  container-type: size;
  /* (--mp-screen-h: the height chosen with the bar under the picture, media-look.js) */
  height: min(56.25vw, 42vh);
  height: var(--mp-screen-h, min(56.25vw, 42vh));
  overflow: hidden;
  background: #000;
  user-select: none;
  -webkit-user-select: none;
}
.mp-stage.mp-audio .mp-screen {
  height: max(160px, min(46vw, 30vh));
  height: var(--mp-screen-h, max(160px, min(46vw, 30vh)));
}
@supports (height: 1dvh) {
  .mp-screen {
    height: var(--mp-screen-h, min(56.25vw, 42dvh));
  }
  .mp-stage.mp-audio .mp-screen {
    height: var(--mp-screen-h, max(160px, min(46vw, 30dvh)));
  }
}
.mp-k-file .mp-screen {
  cursor: pointer;
}
.mp-screen video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}
.mp-side {
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  /* the list beside the picture: smaller than the listen page's, A− / A+ still change it */
  --cap-mult: 0.64;
}
.mp-side .ls-scroll {
  padding: 10px max(12px, env(safe-area-inset-right)) 16px max(12px, env(safe-area-inset-left));
}
.mp-side .ls-lines {
  max-width: none;
  gap: 8px;
}
.mp-side .ls-scroll > .cap.interim {
  max-width: none;
}
.mp-side .cap {
  padding: 9px 11px;
  border-radius: var(--r-sm);
}
.mp-side .cap .orig {
  font-size: max(13px, calc(var(--cap-size) * 0.5));
}
.mp-side .ls-jump {
  bottom: 12px;
}
.mp-side .empty {
  padding: 24px 10px;
}
/* the list's own look (the «Tùy chỉnh» panel's «Danh sách», media-look.js) */
.mp-side .cap {
  font-family: var(--ls-font, inherit);
}
.mp-side .cap .main {
  line-height: var(--ls-lh, 1.42);
}
.mp-side .cap:not(.pending):not(.interim) .main {
  color: var(--ls-color, inherit);
}
.mp-side[data-bg] {
  background: var(--bg);
  color: var(--text);
}
.mp-side[data-bg='dark'] {
  --bg: #0b1324;
  --surface: #121c31;
  --surface-2: #19243b;
  --surface-3: #202d47;
  --border: #26324b;
  --border-strong: #34425f;
  --text: #e8eef8;
  --muted: #a3b1c9;
  --faint: #7f8ea9;
  --primary-soft: #1a2b52;
  color-scheme: dark;
}
.mp-side[data-bg='black'] {
  --bg: #000000;
  --surface: #0a0a0a;
  --surface-2: #141414;
  --surface-3: #1c1c1c;
  --border: #262626;
  --border-strong: #3a3a3a;
  --text: #f5f5f5;
  --muted: #b5b5b5;
  --faint: #8a8a8a;
  --primary-soft: #1a2440;
  color-scheme: dark;
}
.mp-side[data-bg='paper'] {
  --bg: #f4eedf;
  --surface: #fffaf0;
  --surface-2: #efe6d2;
  --surface-3: #e7dcc4;
  --border: #e2d6bd;
  --border-strong: #cdbd9c;
  --text: #2a2317;
  --muted: #6a5d45;
  --faint: #8b7e66;
  --primary-soft: #efe3c4;
  color-scheme: light;
}

/* the bar between the picture and the list: dragged to make one bigger (media-look.js) */
.mp-split {
  position: relative;
  z-index: 4;
  flex: none;
  height: 14px;
  margin: -3px 0 -11px;
  cursor: row-resize;
  touch-action: none;
}
.mp-split::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 4px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  background: var(--border-strong);
  transition: background var(--t-fast, 0.15s);
}
.mp-split:hover::after,
.mp-split.dragging::after,
.mp-split:focus-visible::after {
  background: var(--primary);
}
.mp-split:focus-visible {
  outline: none;
}
body.mp-resizing {
  user-select: none;
  -webkit-user-select: none;
}
/* the list hidden: the picture fills the page */
.mp-body.lo-none .mp-side,
.mp-body.lo-none .mp-split {
  display: none;
}
.mp-body.lo-none .mp-stage {
  flex: 1 1 auto;
  min-height: 0;
}
.mp-body.lo-none .mp-screen {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
}
.cap.mp-now {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 8%, var(--surface));
  box-shadow: inset 3px 0 0 var(--primary);
}
.mp-at {
  font: inherit;
  font-variant-numeric: tabular-nums;
  color: var(--primary);
  background: none;
  border: 0;
  padding: 1px 5px;
  margin: -1px -5px;
  border-radius: var(--r-xs);
  cursor: pointer;
  text-decoration: underline dotted;
  text-underline-offset: 2px;
}
.mp-at:hover {
  background: var(--primary-soft);
}
.mp-at:focus-visible {
  outline: 2px solid var(--focus);
}

/* wide screens (and a phone held sideways): the picture on the left, the lines on the right */
@media (min-width: 1000px), (min-width: 640px) and (orientation: landscape) and (max-height: 560px) {
  .mp-body {
    display: grid;
    /* (--mp-side-w: the list's width chosen with the bar, media-look.js) */
    grid-template-columns: minmax(0, 1fr) auto var(--mp-side-w, clamp(300px, 30vw, 440px));
    grid-template-rows: minmax(0, 1fr);
  }
  .mp-stage {
    min-height: 0;
    padding: 12px max(12px, env(safe-area-inset-left));
    gap: 8px;
  }
  .mp-screen,
  .mp-stage.mp-audio .mp-screen {
    flex: 1 1 0;
    height: auto;
    min-height: 0;
    border-radius: 12px;
  }
  .mp-side {
    border-left: 1px solid var(--border);
  }
  .mp-split {
    width: 14px;
    height: auto;
    margin: 0 -7px;
    cursor: col-resize;
  }
  .mp-split::after {
    width: 4px;
    height: 40px;
  }
  /* the list on the left */
  .mp-body.lo-left {
    grid-template-columns: var(--mp-side-w, clamp(300px, 30vw, 440px)) auto minmax(0, 1fr);
  }
  .mp-body.lo-left .mp-side {
    order: -2;
    border-left: 0;
    border-right: 1px solid var(--border);
  }
  .mp-body.lo-left .mp-split {
    order: -1;
  }
  .mp-body.lo-none {
    grid-template-columns: minmax(0, 1fr);
  }
  /* the list under the picture */
  .mp-body.lo-bottom {
    display: flex;
    flex-direction: column;
  }
  .mp-body.lo-bottom .mp-stage {
    flex: none;
  }
  .mp-body.lo-bottom .mp-screen {
    flex: none;
    height: var(--mp-screen-h, 56vh);
  }
  .mp-body.lo-bottom .mp-split {
    width: auto;
    height: 14px;
    margin: -3px 0 -11px;
    cursor: row-resize;
  }
  .mp-body.lo-bottom .mp-split::after {
    width: 40px;
    height: 4px;
  }
  .mp-body.lo-bottom .mp-side {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}
@supports (height: 1dvh) {
  @media (min-width: 1000px), (min-width: 640px) and (orientation: landscape) and (max-height: 560px) {
    .mp-body.lo-bottom .mp-screen {
      height: var(--mp-screen-h, 56dvh);
    }
  }
}

/* sound only (a microphone, an audio file, a hidden picture): a meter that moves with the voice */
.mp-idle {
  position: absolute;
  inset: 0 0 42% 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(4px, 1.6cqh, 12px);
  padding: 8px 16px clamp(4px, 2cqh, 16px);
  text-align: center;
  pointer-events: none;
}
.mp-stage.mp-audio .mp-screen {
  background: radial-gradient(ellipse at 50% 45%, #18294d 0%, #0d1a33 45%, var(--stage) 80%);
}
.mp-idle-ico {
  position: relative;
  width: clamp(34px, 17cqh, 72px);
  height: clamp(34px, 17cqh, 72px);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(126, 166, 255, 0.14);
  color: #a9c2ff;
}
.mp-idle-ico svg {
  width: 46%;
  height: 46%;
}
.mp-k-mic .mp-idle-ico::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(126, 166, 255, 0.35);
  animation: mp-ring 2.4s ease-out infinite;
}
@keyframes mp-ring {
  from {
    transform: scale(0.9);
    opacity: 1;
  }
  to {
    transform: scale(1.25);
    opacity: 0;
  }
}
.mp-idle-title {
  max-width: 92%;
  color: #f3f6fb;
  font-weight: 650;
  font-size: clamp(14px, min(2.4cqi, 4.4cqh), 22px);
  line-height: 1.3;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.mp-idle-sub {
  max-width: 92%;
  color: #93a2bd;
  font-size: clamp(12px, min(1.8cqi, 3.4cqh), 15px);
  line-height: 1.35;
}
.mp-viz {
  width: min(560px, 86%);
  height: clamp(26px, 13cqh, 96px);
  color: #7ea6ff;
}
/* a short screen (a phone, sound only): the name on one line between the corners' buttons, and the meter */
@container (max-height: 239px) {
  .mp-idle {
    inset: 0 0 50% 0;
    padding-top: 6px;
  }
  .mp-idle-ico,
  .mp-idle-sub {
    display: none;
  }
  .mp-idle-title {
    max-width: calc(100% - 208px);
    min-width: 120px;
    -webkit-line-clamp: 1;
  }
}

/*
 * The translation over the picture: big, on a dark band, the original under it. Its look and place are the viewer's
 * (the «Tùy chỉnh» panel, media-look.js: variables on #mpStage). x, y: where the box is between the picture's edges
 * (0: against the left / top edge, 100: against the right / bottom one), so it never leaves the picture.
 */
.mp-subs {
  --mp-fs: clamp(calc(14px * min(1, var(--mp-sub-scale, 1))), calc(2.9 * min(1cqi, 1.78cqh) * var(--mp-sub-scale, 1)), calc(64px * max(1, var(--mp-sub-scale, 1))));
  position: absolute;
  left: var(--mp-sub-x, 50%);
  /* (never under the badge and the tools along the top: the box's highest place is just below them) */
  top: max(min(50px, 30%), var(--mp-sub-y, 94%));
  transform: translate(calc(var(--mp-sub-x, 50%) * -1), calc(var(--mp-sub-y, 94%) * -1));
  width: max-content;
  max-width: var(--mp-sub-w, 92%);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3em;
  text-align: center;
  font-family: var(--mp-sub-font, inherit);
  pointer-events: none;
  /* the left or right the viewer picks is the picture's, in an Arabic interface too (each line keeps its own direction) */
  direction: ltr;
}
.mp-subs.al-left {
  align-items: flex-start;
  text-align: left;
}
.mp-subs.al-right {
  align-items: flex-end;
  text-align: right;
}
.mp-subs.dragging {
  outline: 2px dashed rgba(255, 255, 255, 0.6);
  outline-offset: 4px;
  border-radius: 6px;
}
/* the captions themselves are dragged (a click on them still plays or pauses a file) */
.mp-sub-main,
.mp-sub-orig {
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
}
.mp-subs.dragging .mp-sub-main,
.mp-subs.dragging .mp-sub-orig {
  cursor: grabbing;
}
.mp-screen.mp-gesture {
  touch-action: none;
}
.mp-sub {
  max-width: 100%;
  /* the line's own size here too, so its lines are as close as the text (no taller line of the page around it) */
  font-size: var(--mp-fs);
  line-height: 1.34;
  animation: mp-sub-in 140ms var(--ease);
}
.mp-sub-o {
  font-size: max(11px, calc(var(--mp-fs) * 0.62));
  line-height: 1.4;
}
@keyframes mp-sub-in {
  from {
    opacity: 0.4;
  }
}
.mp-sub-main,
.mp-sub-orig {
  display: inline;
  padding: 0.06em 0.42em;
  border-radius: 0.22em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  overflow-wrap: anywhere;
}
.mp-sub-main {
  font-size: var(--mp-fs);
  line-height: 1.34;
  font-weight: var(--mp-sub-weight, 600);
  color: var(--mp-sub-color, #fff);
  background: var(--mp-sub-bg, rgba(0, 0, 0, 0.74));
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.mp-sub-orig {
  font-size: max(11px, calc(var(--mp-fs) * 0.62));
  line-height: 1.4;
  font-weight: 500;
  color: var(--mp-orig-color, #d6deeb);
  background: var(--mp-orig-bg, rgba(0, 0, 0, 0.62));
}
.mp-sub.pending .mp-sub-main {
  color: #cbd5e1;
  color: color-mix(in srgb, var(--mp-sub-color, #fff) 78%, #64748b);
  font-style: italic;
}
.mp-sub.soft .mp-sub-main {
  color: #dbe4f3;
  color: color-mix(in srgb, var(--mp-sub-color, #fff) 86%, #64748b);
  font-weight: 500;
  font-style: italic;
  background: rgba(0, 0, 0, 0.52);
}
/* no band: the letters outlined, or with a shadow, or bare */
.mp-subs.bg-outline .mp-sub-main,
.mp-subs.bg-outline .mp-sub-orig {
  background: none;
  text-shadow:
    0.05em 0 0 #000,
    -0.05em 0 0 #000,
    0 0.05em 0 #000,
    0 -0.05em 0 #000,
    0.04em 0.04em 0 #000,
    -0.04em 0.04em 0 #000,
    0.04em -0.04em 0 #000,
    -0.04em -0.04em 0 #000;
}
.mp-subs.bg-shadow .mp-sub-main,
.mp-subs.bg-shadow .mp-sub-orig {
  background: none;
  text-shadow:
    0 2px 4px rgba(0, 0, 0, 0.95),
    0 0 10px rgba(0, 0, 0, 0.8);
}
.mp-subs.bg-none .mp-sub-main,
.mp-subs.bg-none .mp-sub-orig {
  background: none;
  text-shadow: none;
}

/* on the picture: what the session is doing (top left), its tools (top right) */
.mp-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px 3px 8px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #fff;
  background: rgba(10, 18, 34, 0.72);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  pointer-events: none;
}
.mp-badge:empty {
  display: none;
}
.mp-badge::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}
.mp-b-live {
  background: rgba(220, 47, 58, 0.92);
}
.mp-b-live::before {
  animation: blink 1.4s ease-in-out infinite;
}
.mp-b-paused,
.mp-b-ended {
  color: #cbd5e1;
}
.mp-b-replay {
  background: rgba(15, 118, 110, 0.92);
}
.mp-b-hold {
  background: rgba(180, 83, 9, 0.92);
}
.mp-tools {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 3;
  display: flex;
  gap: 6px;
}
.mp-tool {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(10, 18, 34, 0.62);
  color: #f3f6fb;
  cursor: pointer;
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transition: background var(--t-fast), border-color var(--t-fast);
}
.mp-tool:hover {
  background: rgba(10, 18, 34, 0.88);
}
.mp-tool[aria-pressed='true'] {
  border-color: rgba(126, 166, 255, 0.8);
  color: #a9c2ff;
}
.mp-tool svg {
  width: 18px;
  height: 18px;
}
.mp-tool:focus-visible,
.mp-cbtn:focus-visible,
.mp-ctl select:focus-visible,
.mp-ctl input:focus-visible {
  outline: 2px solid #7ea6ff;
  outline-offset: 2px;
}
@media (pointer: coarse) {
  .mp-tool {
    width: 40px;
    height: 40px;
  }
}

/* a file's controls under the picture */
.mp-ctl {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px max(10px, env(safe-area-inset-right)) 6px max(10px, env(safe-area-inset-left));
  color: #e8eef8;
  color-scheme: dark;
  font-size: var(--fs-sm);
}
.mp-cbtn {
  flex: none;
  min-width: 36px;
  height: 36px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background var(--t-fast);
}
.mp-cbtn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.mp-cbtn svg {
  width: 20px;
  height: 20px;
}
.mp-play {
  min-width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary-strong);
  color: #fff;
}
.mp-play:hover {
  background: var(--primary-600);
}
.mp-skip {
  font-size: var(--fs-xs);
}
.mp-time {
  flex: none;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  color: #cbd5e1;
  padding: 0 4px;
}
.mp-seek {
  position: relative;
  flex: 1;
  min-width: 90px;
  height: 30px;
}
/* the bar: the parts already translated (teal), what has been played (a light veil over them) */
.mp-track {
  position: absolute;
  left: 7px;
  right: 7px;
  top: 50%;
  height: 8px;
  transform: translateY(-50%);
  border-radius: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
}
.mp-cover {
  position: absolute;
  inset: 0;
}
.mp-cover span {
  position: absolute;
  top: 0;
  bottom: 0;
  min-width: 2px;
  background: rgba(63, 212, 194, 0.62);
}
.mp-played {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0;
  background: rgba(255, 255, 255, 0.5);
}
.mp-seek input[type='range'] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.mp-seek input[type='range']::-webkit-slider-runnable-track {
  height: 100%;
  background: transparent;
}
.mp-seek input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  margin-top: 8px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.55), 0 1px 3px rgba(0, 0, 0, 0.5);
}
.mp-seek input[type='range']::-moz-range-track {
  background: transparent;
}
.mp-seek input[type='range']::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.55), 0 1px 3px rgba(0, 0, 0, 0.5);
}
.mp-done {
  flex: none;
  white-space: nowrap;
  font-size: var(--fs-xs);
  font-weight: 650;
  color: #5eead4;
  font-variant-numeric: tabular-nums;
}
.mp-done:empty,
.mp-done-s {
  display: none;
}
.mp-ctl .mp-rate {
  flex: none;
  width: auto;
  min-height: 32px;
  padding: 0 8px;
  background-image: none;
  background-color: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.22);
  color: #e8eef8;
  font-variant-numeric: tabular-nums;
}
.mp-ctl input:focus,
.mp-ctl select:focus {
  box-shadow: none;
}
.mp-ctl .mp-vol {
  flex: none;
  width: 84px;
  accent-color: #e8eef8;
}
@media (max-width: 640px) {
  /* a phone: the seek bar on a row of its own, above the buttons */
  .mp-ctl {
    flex-wrap: wrap;
    row-gap: 2px;
    padding-top: 2px;
  }
  .mp-seek {
    order: -1;
    flex-basis: 100%;
  }
  .mp-time {
    margin-inline-end: auto;
  }
  .mp-ctl .mp-vol {
    display: none;
  }
}
@media (max-width: 440px) {
  /* a narrow phone: the buttons on one row (the percent alone, the time smaller, closer together) */
  .mp-ctl {
    column-gap: 4px;
  }
  .mp-time {
    padding: 0 2px;
    font-size: var(--fs-xs);
  }
  .mp-done-l {
    display: none;
  }
  .mp-done-s {
    display: inline;
  }
}

/* full screen: the picture and its captions only (an iPhone: the page's own full screen) */
.mp-stage:fullscreen,
.mp-stage.mp-full {
  padding: 0;
  gap: 0;
  background: #000;
}
.mp-stage.mp-full {
  position: fixed;
  inset: 0;
  z-index: 70;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.mp-stage:fullscreen .mp-screen,
.mp-stage.mp-full .mp-screen {
  flex: 1 1 0;
  height: auto;
  min-height: 0;
  border-radius: 0;
}
.mp-stage:fullscreen .mp-subs,
.mp-stage.mp-full .mp-subs {
  --mp-fs: clamp(calc(18px * min(1, var(--mp-sub-scale, 1))), calc(2.9 * min(1cqi, 1.78cqh) * var(--mp-sub-scale, 1)), calc(84px * max(1, var(--mp-sub-scale, 1))));
}
.mp-stage:fullscreen .mp-ctl,
.mp-stage.mp-full .mp-ctl {
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.mp-stage::backdrop {
  background: #000;
}

/*
 * «Tùy chỉnh»: sound, captions, list, while the session goes on (media-look.js). A popover, so it stays over the
 * picture in full screen; beside the picture on a wide screen (moved by its head), a sheet at the bottom of a phone.
 */
.mp-look {
  position: fixed;
  inset: auto;
  top: calc(64px + env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: auto;
  width: min(380px, calc(100vw - 24px));
  height: auto; /* (a popover's own is its content's: here from top to bottom) */
  max-height: none;
  margin: 0;
  padding: 0;
  z-index: 90;
  display: flex;
  flex-direction: column;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
@media (max-height: 560px) {
  .mp-look {
    top: calc(8px + env(safe-area-inset-top));
    bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
@media (max-width: 640px) {
  .mp-look {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: min(62vh, 560px);
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  @supports (height: 1dvh) {
    .mp-look {
      max-height: min(62dvh, 560px);
    }
  }
}
.mp-look-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px 6px 16px;
}
.mp-look-head h3 {
  flex: 1;
  margin: 0;
  font-size: var(--fs-md);
}
@media (min-width: 1000px), (min-width: 640px) and (orientation: landscape) and (max-height: 560px) {
  .mp-look-head {
    cursor: move;
    touch-action: none;
  }
}
.mp-look-tabs {
  margin: 0 12px 6px;
}
.mp-look-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mp-look-sec {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mp-look-sec + .mp-look-sec {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.mp-look-h {
  margin: 0;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.mp-look-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.mp-look-lbl {
  font-size: var(--fs-sm);
  font-weight: 600;
}
.mp-look-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.mp-look-ctl > .seg,
.mp-look-range {
  flex: 1 1 100%;
  min-width: 0;
}
.mp-look-range {
  display: flex;
  align-items: center;
  gap: 10px;
}
.mp-look-range input[type='range'] {
  flex: 1;
  min-width: 0;
}
.mp-look-ctl > .mp-look-range:not(:only-child) {
  flex-basis: 0;
  flex-grow: 1;
}
.mp-look-val {
  min-width: 3.6em;
  text-align: end;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.mp-look-seg > button {
  padding: 0 8px;
  white-space: normal;
  line-height: 1.2;
  text-align: center;
}
.mp-look-hint {
  margin: 0;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.mp-look-switch {
  font-size: var(--fs-sm);
}
.mp-look-presets {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.mp-look-preset {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 3px;
  padding: 9px 11px;
  font: inherit;
  text-align: start;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: border-color var(--t-fast, 0.15s), background var(--t-fast, 0.15s);
}
.mp-look-preset:hover {
  border-color: var(--primary);
}
.mp-look-preset b {
  font-size: var(--fs-sm);
}
.mp-look-preset span {
  font-size: var(--fs-xs);
  color: var(--muted);
  line-height: 1.35;
}
.mp-look-preset[aria-pressed='true'] {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.mp-look-sw {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.mp-sw {
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  cursor: pointer;
}
.mp-sw.theme {
  background: linear-gradient(135deg, var(--surface) 0 50%, var(--text) 50% 100%);
}
.mp-sw[aria-pressed='true'] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}
.mp-sw-pick {
  width: 34px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xs);
  background: var(--surface);
  cursor: pointer;
}
.mp-sw-pick.on {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--primary);
}
.mp-look-fonts .chip {
  min-height: 30px;
}
.mp-look-mute {
  flex: none;
}
.mp-look-reset {
  align-self: flex-start;
}
.mp-look-auto[aria-pressed='true'] {
  border-color: var(--primary);
  color: var(--primary);
}
.mp-sw:focus-visible,
.mp-sw-pick:focus-visible,
.mp-look-preset:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .mp-card,
  .mp-sub {
    transition: none;
    animation: none;
  }
  .mp-card:hover {
    transform: none;
  }
  .mp-k-mic .mp-idle-ico::after,
  .mp-b-live::before {
    animation: none;
  }
}

/* ---------- interpretation channels: settings rows, the channels dialog, their printed QR cards ---------- */
.ch-row select {
  flex: 1;
  min-width: 0;
}
.ch-num {
  min-width: 4.6em;
  font-size: var(--fs-sm, 0.9rem);
}
.ch-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.ch-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px;
  background: var(--surface-2);
}
.ch-card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ch-card-head span {
  color: var(--muted);
  font-size: var(--fs-sm, 0.9rem);
}
.ch-card .qr-box img {
  max-width: 160px;
}
.ch-link {
  font-size: var(--fs-xs, 0.78rem);
  word-break: break-all;
}
.ch-print {
  display: none;
}
@media print {
  html.print-channels body {
    background: #fff;
  }
  html.print-channels body > *:not(#chPrintArea) {
    display: none !important;
  }
  html.print-channels .ch-print {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8mm;
    color: #000;
  }
  .ch-print-card {
    break-inside: avoid;
    border: 1px dashed #777;
    border-radius: 4mm;
    padding: 6mm 5mm;
    text-align: center;
    background: #fff;
  }
  .ch-print-room {
    font-size: 11pt;
    color: #444;
  }
  .ch-print-n {
    font-size: 20pt;
    font-weight: 700;
    margin-top: 2mm;
  }
  .ch-print-lang {
    font-size: 28pt;
    font-weight: 800;
    line-height: 1.15;
  }
  .ch-print-card img {
    display: block;
    width: 55mm;
    height: 55mm;
    margin: 4mm auto;
  }
  .ch-print-scan {
    font-size: 13pt;
  }
  .ch-print-link {
    margin-top: 2mm;
    font-size: 8pt;
    color: #555;
    word-break: break-all;
  }
}

/* the join page: the room's channels above the languages */
.chan-box .chan-btns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 8px;
}
.chan-btn b {
  font-size: 1.02rem;
}
.chan-btn.featured {
  grid-column: 1 / -1;
  border-color: var(--primary-strong);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary-strong);
  padding: 14px 16px;
}
.chan-btn.featured b {
  font-size: 1.15rem;
}
.ch-badge {
  margin-inline-start: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary-strong);
  font-size: 0.78em;
  font-weight: 600;
  white-space: nowrap;
}

/* ---------- the cabin station (cabin.html): one panel per channel ---------- */
.cabin-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cabin-head h1 {
  margin: 0;
  font-size: 1.35rem;
}
.cabin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.cabin-ch {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  padding: 12px;
}
.cabin-ch.off {
  opacity: 0.6;
}
.cabin-ch.active {
  border-color: var(--success);
  box-shadow: inset 0 0 0 1px var(--success);
}
.cabin-ch-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.cabin-ch-head b {
  font-size: 1.1rem;
  white-space: nowrap;
}
.cabin-ch-head span {
  min-width: 0;
  text-align: end;
}
.cabin-now {
  min-height: 3.2em;
  max-height: 6.5em;
  overflow: hidden;
  font-size: var(--fs-md, 1rem);
  line-height: 1.45;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.cabin-now.idle {
  color: var(--muted);
}
.cabin-ch .switch {
  align-self: flex-start;
}

/* ---------- the multi-tool page: PDF, photos, Han and Nom texts, EPUB books, articles ---------- */
.tl-head {
  margin-bottom: 14px;
}
.tl-head h1 {
  margin: 0 0 4px;
}
.tl-head p {
  margin: 0;
}
.tl-settings {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.tl-settings > [hidden] {
  display: none;
}
@media (max-width: 900px) {
  .tl-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 520px) {
  .tl-settings {
    grid-template-columns: minmax(0, 1fr);
  }
}
.tabs button > [data-icon] svg {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
}
.tl-tab-han {
  font-weight: 700;
  line-height: 1;
}
.tl-panel .dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.tl-drop-ico svg {
  width: 28px;
  height: 28px;
  opacity: 0.7;
}
.tl-file {
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}
.tl-file:empty {
  display: none;
}
.dropzone.disabled {
  pointer-events: none;
  opacity: 0.6;
}
.tl-progress {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tl-bar {
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
  overflow: hidden;
}
.tl-bar > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 4px;
  background: var(--primary);
  transition: width var(--t-med) var(--ease);
}
.tl-step,
.tl-pct {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.tl-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tl-compare {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.tl-compare figure {
  margin: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tl-compare figcaption {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tl-sheet {
  min-height: 120px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: #fff;
  overflow: hidden;
}
.tl-sheet canvas,
.tl-stage canvas,
.tl-stage img {
  display: block;
  width: 100%;
  height: auto;
}
.tl-stage {
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.tl-pairs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--fs-sm);
}
.tl-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.tl-pair > :first-child {
  color: var(--muted);
}
@media (max-width: 640px) {
  .tl-compare,
  .tl-pair {
    grid-template-columns: minmax(0, 1fr);
  }
}
/* a photo fits the screen: tall portrait shots stay whole instead of running far below the fold */
.tl-stage canvas,
.tl-stage img {
  width: auto;
  max-width: 100%;
  max-height: 80vh;
  margin: 0 auto;
}
.tl-pageno {
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
}
.tl-ask {
  width: min(440px, 92vw);
}

/* Han and Nom: fonts that carry the rare and Nom-only characters come first, when the device has them */
.tl-han {
  font-family: 'Nom Na Tong', 'Han-Nom Gothic', 'Han-Nom Minh', 'Noto Serif TC', 'Noto Serif CJK TC', 'Source Han Serif TC', 'Noto Sans TC', 'Microsoft JhengHei', PMingLiU, MingLiU, SimSun, SimSun-ExtB, MingLiU-ExtB, serif;
  line-height: 1.6;
}
textarea.tl-han {
  font-size: 1.25rem;
  line-height: 1.7;
}
.tl-anc {
  gap: 18px;
}
.tl-anc h4 {
  margin: 0;
}
.tl-anc-table td,
.tl-anc-table th {
  vertical-align: top;
}
.tl-anc-table .tl-han {
  font-size: 1.3em;
}
.tl-ch {
  cursor: help;
  border-radius: 3px;
}
.tl-ch:hover {
  background: var(--primary-soft);
}
.tl-flag {
  background: var(--warning-soft);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.tl-ch.tl-unknown {
  text-decoration: underline dotted var(--danger);
  text-underline-offset: 4px;
}
.tl-big {
  font-size: 1.5em;
}
.tl-anc-tr {
  margin: 0;
  line-height: 1.65;
}
.tl-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 8px;
}
.tl-card {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.tl-card.tl-unknown {
  border-style: dashed;
  border-color: var(--danger);
}
.tl-glyph {
  font-size: 2.2rem;
  line-height: 1.1;
  min-width: 1.15em;
  text-align: center;
}
.tl-card-body {
  gap: 2px;
  font-size: var(--fs-sm);
  min-width: 0;
  overflow-wrap: anywhere;
}

/* EPUB: the list of chapters to translate */
.tl-chapters {
  max-height: 290px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.tl-chapters .switch {
  display: flex;
  font-weight: 400;
}
.tl-chapters .switch .grow {
  min-width: 0;
  overflow-wrap: anywhere;
}
.tl-chapters .switch .muted {
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.tl-chapters-sum {
  font-size: var(--fs-sm);
}
.tl-sample h4 {
  margin: 0 0 6px;
}
.tl-sample p {
  margin: 0 0 6px;
}
.tl-sample p:not(.muted) {
  margin-bottom: 14px;
}

/* articles: the extracted page, read like a newspaper column */
.tl-article {
  line-height: 1.7;
  overflow-wrap: break-word;
}
.tl-art {
  max-width: 760px;
  margin: 0 auto;
}
.tl-art img,
.tl-art video {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px auto;
}
.tl-art figure {
  margin: 16px 0;
}
.tl-art figcaption {
  font-size: var(--fs-sm);
  color: var(--muted);
  text-align: center;
}
.tl-art blockquote {
  margin: 14px 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--border-strong);
  color: var(--muted);
}
.tl-art pre {
  overflow-x: auto;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}
.tl-art table {
  display: block;
  overflow-x: auto;
  margin: 12px 0;
}
.tl-art td,
.tl-art th {
  border: 1px solid var(--border);
  padding: 4px 8px;
  vertical-align: top;
}
.tl-art-head {
  margin-bottom: 18px;
}
.tl-art-head h1 {
  margin: 0 0 8px;
  line-height: 1.25;
}
.tl-dek {
  margin: 0 0 8px;
  font-size: var(--fs-lg);
  color: var(--muted);
}
.tl-byline {
  margin: 0;
  font-size: var(--fs-sm);
}
.lvh-tr {
  color: var(--primary);
}

/* "Print / save PDF" on an article: only the article goes to paper, dark ink on white whatever the theme */
@media print {
  body.tl-printing {
    --text: #000;
    --muted: #444;
    --surface: #fff;
    --surface-2: #f2f2f2;
    --border: #bbb;
    --border-strong: #888;
    --primary: #1d4ed8;
    background: #fff;
    color: #000;
  }
  body.tl-printing > :not(main),
  body.tl-printing main > :not([data-panel='web']),
  body.tl-printing [data-panel='web'] > :not(#webArticle) {
    display: none !important;
  }
  body.tl-printing main {
    max-width: none;
    padding: 0;
    margin: 0;
  }
  body.tl-printing #webArticle {
    border: 0;
    box-shadow: none;
    padding: 0;
    background: #fff;
  }
  body.tl-printing .tl-art {
    max-width: none;
  }
  body.tl-printing .tl-art img,
  body.tl-printing .tl-art figure,
  body.tl-printing .tl-art pre,
  body.tl-printing .tl-art blockquote {
    break-inside: avoid;
  }
  body.tl-printing .tl-art h1,
  body.tl-printing .tl-art h2,
  body.tl-printing .tl-art h3 {
    break-after: avoid;
  }
}

/* ---------- the speaking course «Học nói» (learn.html): phone first, one column ---------- */
.ln-main {
  max-width: 720px;
}
.ln-app {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.ln-app > p,
.ln-session-body > p {
  margin: 0;
}
.ln-loading {
  text-align: center;
  padding: 40px 0;
}
.ln-hero h1 {
  margin: 0 0 6px;
  font-size: var(--fs-2xl);
  line-height: 1.2;
}
.ln-hero p {
  margin: 0;
}
.ln-h1 {
  margin: 0;
  font-size: var(--fs-xl);
  line-height: 1.25;
}
.ln-h2 {
  margin: 6px 0 -4px;
  font-size: var(--fs-lg);
}
.ln-small {
  margin: 0;
  font-size: var(--fs-sm);
}
.ln-q {
  display: block;
  font-weight: 650;
  font-size: var(--fs-lg);
}
.ln-setup {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ln-setup select {
  width: 100%;
}
.ln-ready {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.ln-device {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: var(--fs-sm);
}
.ln-paces {
  display: grid;
  gap: 8px;
}
.ln-pace {
  font: inherit;
  color: inherit;
  text-align: start;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast), box-shadow var(--t-fast);
}
.ln-pace b {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-lg);
}
.ln-pace > span {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.ln-pace:hover {
  border-color: var(--border-strong);
}
.ln-pace.on {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.ln-mine h2 {
  margin: 0 0 8px;
  font-size: var(--fs-md);
}
.ln-method > summary {
  font-weight: 650;
}
.ln-method ol {
  margin: 10px 0 0;
  padding-inline-start: 1.3em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* the home screen: where the learner is, what is due, the roadmap */
.ln-home-head {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.ln-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.ln-cta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none !important;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
a.ln-cta:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
}
.ln-cta .grow {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ln-cta b {
  font-size: var(--fs-lg);
}
.ln-cta-ico {
  flex: none;
  font-size: 2rem;
  line-height: 1;
}
.ln-cta.review {
  background: var(--warning-soft);
  border-color: transparent;
}
.ln-road {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ln-road-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: inherit;
  text-decoration: none !important;
  transition: border-color var(--t-fast);
}
.ln-road-item:hover {
  border-color: var(--border-strong);
}
.ln-road-item .grow {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.ln-road-ico {
  flex: none;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 1.15rem;
}
.ln-road-item.done .ln-road-ico {
  background: var(--success-soft);
  color: var(--success);
  font-weight: 700;
}
.ln-road-item.next {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.ln-road-state {
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}
.ln-road-item.done .ln-road-state {
  color: var(--success);
}
.ln-road-item.next .ln-road-state {
  color: var(--primary);
}
.ln-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.ln-tools .btn {
  flex: 1 1 auto;
}

/* a session: its head and steps, the waiting card */
.ln-session-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}
.ln-session-head > .row {
  align-self: stretch;
}
.ln-session-body {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.ln-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 6px;
  align-self: stretch;
}
.ln-steps li {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  color: var(--muted);
  font-size: var(--fs-sm);
}
.ln-steps .n {
  flex: none;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--surface);
  font-size: var(--fs-xs);
  font-weight: 700;
}
.ln-steps .l {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ln-steps li.on {
  background: var(--primary-soft);
  color: var(--text);
  font-weight: 650;
}
.ln-steps li.on .n {
  background: var(--primary-strong);
  color: var(--primary-contrast);
}
.ln-steps li.done .n {
  background: var(--success-soft);
  color: var(--success);
}
.ln-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.ln-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 18px;
  text-align: center;
}
.ln-wait p {
  margin: 0;
}
.ln-spin {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--surface-3);
  border-top-color: var(--primary);
  animation: ln-spin 0.9s linear infinite;
}
@keyframes ln-spin {
  to {
    transform: rotate(360deg);
  }
}

/* the model dialogue */
.ln-dlg-day > summary {
  font-weight: 650;
}
.ln-dlg-day[open] > summary {
  margin-bottom: 12px;
}
.ln-dialogue {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ln-scene-title {
  font-weight: 650;
  font-size: var(--fs-lg);
}
.ln-dlg-tools {
  gap: 8px 16px;
}
.ln-lines {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ln-line {
  font: inherit;
  color: inherit;
  text-align: start;
  align-self: flex-start;
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  border-end-start-radius: var(--r-xs);
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.ln-line.me {
  align-self: flex-end;
  background: var(--primary-soft);
  border-color: transparent;
  border-end-start-radius: var(--r-md);
  border-end-end-radius: var(--r-xs);
}
.ln-line.on {
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}
.ln-who {
  font-size: var(--fs-xs);
  font-weight: 650;
  color: var(--muted);
}
.ln-msg-text {
  font-size: var(--fs-lg);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.ln-roman {
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--muted);
}
.ln-mean {
  font-size: var(--fs-sm);
  color: var(--muted);
}
.ln-shadow-tip {
  font-size: var(--fs-sm);
}

/* a phrase card: learn it, recall it */
.ln-drill-head {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ln-drill-head .ln-bar {
  flex: 1;
}
.ln-count {
  font-size: var(--fs-sm);
  white-space: nowrap;
}
.ln-bar {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.ln-bar > span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--success);
  transition: width var(--t-slow) var(--ease);
}
.ln-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.ln-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ln-daytag {
  margin-inline-start: auto;
  font-size: var(--fs-xs);
}
.ln-phrase {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: center;
}
.ln-phrase .ln-text {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.ln-phrase.big .ln-text {
  font-size: 2.1rem;
}
.ln-phrase .ln-roman,
.ln-sayas {
  font-size: var(--fs-md);
}
.ln-phrase .ln-mean {
  font-size: var(--fs-lg);
  color: var(--text);
}
.ln-hint,
.ln-note {
  font-size: var(--fs-sm);
  color: var(--muted);
}
.ln-tip {
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--accent-soft);
  font-size: var(--fs-sm);
  text-align: start;
}
.ln-play {
  justify-content: center;
}
.ln-say.on {
  border-color: var(--primary);
  color: var(--primary);
}
.ln-nomic {
  margin: 0;
  text-align: center;
}
.ln-feedback:empty {
  display: none;
}
.ln-feedback p {
  margin: 0;
  text-align: center;
}
.ln-ask {
  text-align: center;
  font-weight: 650;
  color: var(--muted);
}
.ln-ask + .ln-prompt {
  margin-top: -8px;
}
.ln-prompt {
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.ln-card > .ln-hint {
  text-align: center;
  margin-top: -8px;
}
.ln-answer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
}
.ln-grades {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ln-grades-q {
  text-align: center;
  font-size: var(--fs-sm);
}
.ln-grade-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}
.ln-grade {
  flex-direction: column;
  gap: 0;
  min-height: 58px;
  padding: 6px 4px;
  white-space: normal;
}
.ln-grade small {
  font-size: var(--fs-xs);
  font-weight: 400;
  color: var(--muted);
}
.ln-grade.g-again {
  border-color: var(--danger);
}
.ln-grade.g-hard {
  border-color: var(--warning);
}
.ln-grade.g-good {
  border-color: var(--success);
}
.ln-grade.g-easy {
  border-color: var(--primary);
}
.ln-grade.suggested {
  box-shadow: inset 0 0 0 2px var(--primary);
}
.ln-grade.g-again.suggested {
  background: var(--danger-soft);
  box-shadow: inset 0 0 0 1px var(--danger);
}
.ln-grade.g-hard.suggested {
  background: var(--warning-soft);
  box-shadow: inset 0 0 0 1px var(--warning);
}
.ln-grade.g-good.suggested {
  background: var(--success-soft);
  box-shadow: inset 0 0 0 1px var(--success);
}
.ln-grade.g-easy.suggested {
  background: var(--primary-soft);
}

/* the microphone and the score */
.ln-mic-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.ln-mic {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--primary-strong);
  color: var(--primary-contrast);
  box-shadow: var(--shadow-float);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform var(--t-fast), background var(--t-fast);
}
.ln-mic svg {
  width: 30px;
  height: 30px;
}
.ln-mic:hover {
  transform: scale(1.04);
}
.ln-mic:disabled {
  opacity: 0.5;
  cursor: default;
  transform: none;
}
.ln-mic.on {
  background: var(--danger-strong);
  color: #fff;
  animation: ln-pulse 1.3s ease-out infinite;
}
@keyframes ln-pulse {
  from {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--danger) 45%, transparent);
  }
  to {
    box-shadow: 0 0 0 18px transparent;
  }
}
.ln-mic-label {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--muted);
}
.ln-live {
  min-height: 1.3em;
  font-size: var(--fs-sm);
  font-style: italic;
  color: var(--muted);
  text-align: center;
}
.ln-score {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  text-align: center;
}
.ln-score.great,
.ln-score.good {
  background: var(--success-soft);
}
.ln-score.close {
  background: var(--warning-soft);
}
.ln-score.retry {
  background: var(--danger-soft);
}
.ln-marks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 6px;
  font-size: var(--fs-lg);
}
.ln-marks .ok {
  color: var(--success);
}
.ln-marks .miss {
  color: var(--danger);
  text-decoration: underline wavy;
  text-underline-offset: 3px;
}
.ln-heard {
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* the role-play */
.ln-scene {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ln-scene p {
  margin: 0;
}
.ln-goals {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ln-goals li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.ln-goal-box {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border: 2px solid var(--border-strong);
  border-radius: 6px;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.ln-goals li.done .ln-goal-box {
  background: var(--success);
  border-color: var(--success);
}
.ln-goals li.done .ln-goal-box::after {
  content: '';
  width: 5px;
  height: 10px;
  border: solid var(--surface);
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}
.ln-goals li.done > span:last-child {
  color: var(--success);
}
.ln-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ln-chat:empty {
  display: none;
}
.ln-msg {
  max-width: 88%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: var(--r-md);
}
.ln-msg.ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-end-start-radius: var(--r-xs);
}
.ln-msg.me {
  align-self: flex-end;
  background: var(--primary-soft);
  border-end-end-radius: var(--r-xs);
}
.ln-msg-tools {
  gap: 6px;
}
.ln-fix {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
}
/* the clue before the better wording: one more try first */
.ln-clue {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  background: var(--warning-soft);
  font-size: var(--fs-sm);
  text-align: start;
}
.ln-clue-ask {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}
.ln-clue-ok,
.ln-self-fixed {
  color: var(--success);
  font-weight: 650;
}
.ln-self-fixed {
  margin-inline-start: 6px;
  font-size: var(--fs-sm);
}
.ln-msg .ln-score {
  text-align: start;
}
.ln-msg .ln-marks {
  justify-content: flex-start;
}
.ln-chat-note {
  margin: 0;
  font-size: var(--fs-sm);
  text-align: center;
}
.ln-chat-note.warn,
.ln-chat-note.ok {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  background: var(--warning-soft);
}
.ln-chat-note.ok {
  background: var(--success-soft);
  font-weight: 650;
}
.ln-chat-note.cue {
  align-self: flex-end;
  max-width: 88%;
  text-align: end;
  font-weight: 650;
  color: var(--primary);
}
.ln-typing {
  animation: ln-blink 1s steps(2) infinite;
}
@keyframes ln-blink {
  50% {
    opacity: 0.3;
  }
}
.ln-hints {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ln-hints-title {
  font-size: var(--fs-sm);
}
.ln-hint-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 40vh;
  overflow: auto;
}
.ln-hint-chip {
  font: inherit;
  color: inherit;
  text-align: start;
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  cursor: pointer;
}
.ln-hint-chip:hover {
  border-color: var(--primary);
}
.ln-hint-chip small {
  font-size: var(--fs-xs);
  color: var(--muted);
}
/* the microphone stays in reach at the foot of the screen while the chat grows */
.ln-chat-bar {
  position: sticky;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 0 calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 24%);
}
.ln-chat-bar:empty {
  display: none;
}
.ln-chat-bar.busy .ln-mic-wrap {
  opacity: 0.6;
}
.ln-type {
  width: 100%;
}
.ln-chat-tools {
  justify-content: center;
  gap: 6px;
}

/* the summary of a session or a review */
.ln-done {
  display: flex;
  flex-direction: column;
  gap: 12px;
  text-align: center;
}
.ln-done h2,
.ln-done p {
  margin: 0;
}
.ln-done-emoji {
  font-size: 3rem;
  line-height: 1;
}
.ln-done .notice {
  text-align: start;
}
.ln-done .ln-actions {
  justify-content: center;
}
.ln-done-list {
  text-align: start;
}
.ln-done-list h3 {
  margin: 4px 0 6px;
  font-size: var(--fs-md);
}
.ln-done-list ul {
  margin: 0;
  padding-inline-start: 1.2em;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* hands-free listening */
.ln-free {
  justify-content: center;
  min-height: 220px;
  text-align: center;
}
.ln-free-answer {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ln-free-answer .ln-text {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 650;
  line-height: 1.3;
  color: var(--primary);
  overflow-wrap: anywhere;
}

/* the phrasebook */
.ln-search {
  width: 100%;
}
.ln-book {
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}
.ln-book-day h2 {
  margin: 0 0 6px;
  font-size: var(--fs-lg);
}
.ln-book-day.off h2 {
  margin: 0;
}
.ln-book-day.rescue {
  border-color: var(--warning);
}
.ln-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}
.ln-book-day h2 + .ln-row {
  border-top: 0;
}
.ln-row-text {
  font-size: var(--fs-lg);
  font-weight: 650;
  overflow-wrap: anywhere;
}
.ln-st {
  flex: none;
  width: 22px;
  text-align: center;
  font-weight: 700;
  color: var(--muted);
}
.ln-st.learn {
  color: var(--warning);
}
.ln-st.ok {
  color: var(--success);
}
.ln-book-dlg {
  margin-top: 10px;
}
.ln-book-dlg > summary {
  font-weight: 650;
  color: var(--primary);
}
.ln-book-dlg[open] > summary {
  margin-bottom: 10px;
}

/* settings and the yes/no question */
.ln-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ln-settings h2 {
  margin: 8px 0 0;
  font-size: var(--fs-md);
}
.ln-settings h2:first-child {
  margin-top: 0;
}
.ln-set-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
}
.ln-set-label {
  font-weight: 600;
}
.ln-set-ctl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.ln-set-ctl input[type='range'] {
  width: 140px;
}
.ln-dlg {
  width: min(440px, calc(100vw - 24px));
}
.ln-dlg .dlg-body p {
  margin: 0;
}

@media (max-width: 560px) {
  .ln-hero h1 {
    font-size: var(--fs-xl);
  }
  .ln-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .ln-cta {
    flex-wrap: wrap;
  }
  .ln-cta > .btn {
    width: 100%;
  }
  .ln-steps li:not(.on) {
    flex: none;
  }
  .ln-steps li:not(.on) .l {
    display: none;
  }
  .ln-phrase .ln-text,
  .ln-free-answer .ln-text {
    font-size: 1.5rem;
  }
  .ln-phrase.big .ln-text {
    font-size: 1.75rem;
  }
  .ln-prompt {
    font-size: var(--fs-xl);
  }
  .ln-actions > .btn {
    flex: 1 1 auto;
  }
  .ln-msg,
  .ln-line {
    max-width: 94%;
  }
  .ln-grade-row {
    gap: 4px;
  }
  .ln-grade {
    padding: 6px 2px;
  }
}
