/* =============================================================================
   बर'आव फराय — Stylesheet (Bodo)
   ----------------------------------------------------------------------------
   Aesthetic: ARONAI. The aronai is the Bodo ceremonial scarf — a deep indigo
   ground carrying vibrant orange-gold woven motifs. That is the whole palette:

       indigo  = ground, structure, ink
       gold    = the weave; our single accent
       cream   = undyed cotton, the light-mode paper

   Light mode reads as cloth: warm undyed cream, indigo text, gold accents.
   Dark mode IS the aronai: indigo ground, gold motifs, cream text. This is
   the inverse of the Assamese build (parchment + saffron) and deliberately so
   — the two apps should feel like siblings, not clones.

   Typography: Noto Sans Devanagari for Bodo body text (Bodo is Devanagari,
   NOT the Bengali script the Assamese build used), Lora for English/numerals,
   JetBrains Mono for technical accents.
   ----------------------------------------------------------------------------
   Mobile-first. Every interactive element is at least 44pt tall.
   ============================================================================= */

/* =============================================================================
   SELF-HOSTED FONTS
   ----------------------------------------------------------------------------
   Previously loaded from fonts.googleapis.com. Two reasons that had to go:

     1. It broke. gstatic returned 404 for every Noto Sans Devanagari woff2 on
        the test device, so the app fell back to a system font. Content
        blockers commonly interfere with fonts.gstatic.com as well.
     2. It is wrong for an offline-first PWA. A reader meant to work on a
        school laptop with no connection should not need a CDN round-trip to
        render its own script.

   Files come from the @fontsource packages (the same upstream Google fonts,
   subset per script). Devanagari and Latin are separate files with
   unicode-range set, so a Latin-only page never downloads the 50KB
   Devanagari subset.
   ============================================================================= */

/* ---- Noto Sans Devanagari (Bodo body text) ---- */
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-devanagari-400-normal.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-latin-400-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-devanagari-500-normal.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-latin-500-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-devanagari-600-normal.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-latin-600-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-devanagari-700-normal.woff2') format('woff2');
  unicode-range: U+0900-097F, U+1CD0-1CF9, U+200C-200D, U+20A8, U+20B9, U+25CC, U+A830-A839, U+A8E0-A8FF;
}
@font-face {
  font-family: 'Noto Sans Devanagari';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/noto-sans-devanagari-latin-700-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Lora (English / numerals) ---- */
@font-face {
  font-family: 'Lora';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/lora-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora';
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/lora-latin-400-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/lora-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('fonts/lora-latin-500-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('fonts/lora-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Lora';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/lora-latin-700-normal.woff2') format('woff2');
}

/* ---------------- Tokens ---------------- */
:root {
  /* Light theme — undyed cotton with an indigo/gold weave */
  --paper:        #faf6ec;        /* page background — raw cotton */
  --paper-2:      #f1ebda;        /* recessed surfaces */
  --surface:      #fffdf7;        /* raised cards */
  --surface-2:    #fbf7ea;
  --line:         #e3dcc6;        /* hairlines */
  --line-strong:  #c9bd9c;
  --ink:          #1a1c4a;        /* primary text — deep indigo */
  --ink-2:        #3a3d6e;        /* secondary text */
  --ink-3:        #6a6d95;        /* tertiary */
  --ink-4:        #a3a5bd;        /* muted */
  --accent:       #d2701c;        /* aronai gold-orange */
  --accent-soft:  #eda65a;
  --accent-tint:  rgba(210,112,28,0.10);
  --indigo:       #2b2f9e;        /* the aronai ground colour */
  --indigo-soft:  #4a4fc4;
  --indigo-tint:  rgba(43,47,158,0.08);
  --highlight:    #ffd89b;        /* sentence highlight (woven gold) */
  --highlight-pen:#e0a03f;        /* penned underline */
  --danger:       #b73a3a;
  --shadow-1:     0 1px 2px rgba(26, 28, 74, 0.07), 0 2px 6px rgba(26, 28, 74, 0.05);
  --shadow-2:     0 4px 14px rgba(26, 28, 74, 0.11), 0 1px 3px rgba(26, 28, 74, 0.07);
  --shadow-3:     0 12px 40px rgba(16, 18, 54, 0.20), 0 4px 12px rgba(16, 18, 54, 0.12);

  --radius-sm:    8px;
  --radius:       14px;
  --radius-lg:    22px;
  --radius-pill:  999px;

  /* Bodo is DEVANAGARI. Noto Sans/Serif Devanagari must come first — a
     Bengali-script stack would render every Bodo glyph as tofu. */
  --font-asm:     'Noto Sans Devanagari', 'Noto Serif Devanagari', 'Mangal', system-ui, sans-serif;
  --font-bodo:    var(--font-asm);
  --font-en:      'Lora', Georgia, 'Times New Roman', serif;
  /* JetBrains Mono is no longer downloaded (it was decorative only and
     cost another CDN round-trip). System monospace is used instead. */
  --font-mono:    ui-monospace, 'SF Mono', Menlo, Consolas, monospace;

  --t-snap:       cubic-bezier(0.2, 0.7, 0.2, 1);
  --t-spring:     cubic-bezier(0.34, 1.45, 0.45, 1);

  --safe-bottom:  env(safe-area-inset-bottom, 0px);
  --safe-top:     env(safe-area-inset-top, 0px);
}

/* Dark theme — walnut & lamplight */
[data-theme="dark"], html[data-theme="dark"] body {
  --paper:        #14164a;
  --paper-2:      #1b1e5c;
  --surface:      #1f2266;
  --surface-2:    #262a75;
  --line:         #343886;
  --line-strong:  #454a9e;
  --ink:          #f6efdd;
  --ink-2:        #cfc7ae;
  --ink-3:        #9a94b8;
  --ink-4:        #6e6a92;
  --accent:       #f0a04b;
  --accent-soft:  #d8832c;
  --accent-tint:  rgba(240,160,75,0.16);
  --indigo:       #4a4fc4;
  --indigo-soft:  #6b70dd;
  --indigo-tint:  rgba(107,112,221,0.16);
  --highlight:    #5a4410;
  --highlight-pen:#f0b860;
  --danger:       #e06a6a;
  --shadow-1:     0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2:     0 4px 14px rgba(0, 0, 0, 0.55);
  --shadow-3:     0 12px 40px rgba(0, 0, 0, 0.65), 0 4px 12px rgba(0, 0, 0, 0.45);
}

/* Auto theme respects OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --paper:        #14164a;
  --paper-2:      #1b1e5c;
  --surface:      #1f2266;
  --surface-2:    #262a75;
  --line:         #343886;
  --line-strong:  #454a9e;
  --ink:          #f6efdd;
  --ink-2:        #cfc7ae;
  --ink-3:        #9a94b8;
  --ink-4:        #6e6a92;
  --accent:       #f0a04b;
  --accent-soft:  #d8832c;
  --accent-tint:  rgba(240,160,75,0.16);
  --indigo:       #4a4fc4;
  --indigo-soft:  #6b70dd;
  --indigo-tint:  rgba(107,112,221,0.16);
  --highlight:    #5a4410;
  --highlight-pen:#f0b860;
  --danger:       #e06a6a;
    --shadow-1:     0 1px 2px rgba(0, 0, 0, 0.45);
    --shadow-2:     0 4px 14px rgba(0, 0, 0, 0.55);
    --shadow-3:     0 12px 40px rgba(0, 0, 0, 0.65), 0 4px 12px rgba(0, 0, 0, 0.45);
  }
}

/* ---------------- Reset / base ---------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-asm);
  font-size: 16px;
  line-height: 1.75;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  min-height: 100dvh;
  /* Subtle paper grain — pure CSS, no image load */
  background-image:
    radial-gradient(ellipse 60% 80% at 0% 0%,    rgba(43,47,158,0.06), transparent 60%),
    radial-gradient(ellipse 60% 80% at 100% 100%, rgba(210,112,28,0.05), transparent 60%);
}
[data-theme="dark"] body,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) body {
    background-image:
      radial-gradient(ellipse 60% 80% at 0% 0%,    rgba(240,160,75,0.07), transparent 60%),
      radial-gradient(ellipse 60% 80% at 100% 100%, rgba(107,112,221,0.06), transparent 60%);
  }
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Sectioned <h1> baseline.
 * Browsers no longer auto-shrink an <h1> nested inside <article>/<section>/etc.,
 * and they emit a console warning when one lacks explicit font-size and
 * margin-block. We set sane defaults at low specificity (via :where) so any
 * specific .hero__title / .reader__title / etc. rule still wins.
 * Ref: https://developer.mozilla.org/docs/Web/HTML/Element/Heading_Elements */
:where(article, aside, nav, section) h1 {
  font-size: 2em;
  margin-block: 0.67em;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
button:focus-visible, input:focus-visible, textarea:focus-visible, [role="tab"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

input, textarea {
  font-family: var(--font-asm);
  color: inherit;
}

img { max-width: 100%; display: block; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; top: -100px; left: 8px; z-index: 1000;
  background: var(--accent); color: #fff; padding: 8px 14px;
  border-radius: 8px; font-weight: 600;
}
.skip-link:focus { top: calc(var(--safe-top) + 8px); }

.en {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-3);
  font-size: 0.85em;
}

/* ---------------- Top bar ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: rgba(247, 241, 227, 0.85);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}
[data-theme="dark"] .topbar,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .topbar { background: rgba(26, 22, 18, 0.78); }
}
.topbar__brand {
  display: flex; align-items: center; gap: 9px;
  flex: 1; min-width: 0;
  text-decoration: none; color: var(--ink);
  font-weight: 700; letter-spacing: -0.01em;
}
.topbar__brand:hover { text-decoration: none; }
.topbar__mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 9px;
  flex-shrink: 0;
}
.topbar__name {
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar__name em {
  font-style: normal;
  color: var(--accent);
}
.topbar__icon, .topbar__back {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background 0.16s var(--t-snap), color 0.16s;
}
.topbar__icon:hover, .topbar__back:hover {
  background: var(--accent-tint);
  color: var(--accent);
}
.topbar__back[hidden] { display: none; }

/* ---------------- View switching ---------------- */

.view {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px calc(140px + var(--safe-bottom));   /* room for player */
}
.view[hidden] { display: none; }

/* ---------------- Update banner ----------------
   Sits at the top of the home view. Hidden until the service worker reports
   a new version is ready. Single-tap to apply; small × to dismiss for the
   session. Matches the warm-parchment palette of the hero. */

.update-banner {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 12px;
  margin: 16px 0 4px;
  padding: 12px 14px;
  background: linear-gradient(135deg, var(--accent-tint), color-mix(in oklab, var(--accent-tint) 60%, var(--surface)));
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--line));
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  /* Slide in from above on first reveal */
  animation: update-banner-enter 360ms var(--t-spring);
}
.update-banner[hidden] { display: none !important; }

@keyframes update-banner-enter {
  from { transform: translateY(-8px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.update-banner__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.update-banner__icon svg {
  /* Gentle rotation on first reveal to read as "refresh" */
  animation: update-banner-spin 1.4s var(--t-snap);
  transform-origin: 50% 50%;
}
@keyframes update-banner-spin {
  0%   { transform: rotate(-180deg); }
  100% { transform: rotate(0deg); }
}

.update-banner__text {
  min-width: 0;
}
.update-banner__title {
  font-family: var(--font-asm);
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  line-height: 1.3;
}
.update-banner__title .en {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  color: var(--ink-3);
}
.update-banner__sub {
  font-family: var(--font-en);
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.update-banner__btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-asm);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-1);
  transition: transform 120ms var(--t-snap), box-shadow 120ms var(--t-snap), background 120ms var(--t-snap);
  white-space: nowrap;
  flex-shrink: 0;
}
.update-banner__btn:hover {
  background: color-mix(in oklab, var(--accent) 90%, #000);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}
.update-banner__btn:active { transform: translateY(0); }
.update-banner__btn:disabled {
  opacity: 0.6;
  cursor: progress;
}
.update-banner__btn-en {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  font-size: 13px;
  opacity: 0.9;
  margin-left: 4px;
}

.update-banner__dismiss {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms var(--t-snap), color 120ms var(--t-snap);
  flex-shrink: 0;
}
.update-banner__dismiss:hover {
  background: var(--paper-2);
  color: var(--ink);
}

/* Narrow screens: stack the dismiss row, keep the button tappable */
@media (max-width: 480px) {
  .update-banner {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: auto auto;
    gap: 8px 12px;
  }
  .update-banner__icon { grid-row: span 2; }
  .update-banner__dismiss {
    grid-column: 3;
    grid-row: 1;
    align-self: start;
    margin-top: -4px;
    margin-right: -4px;
  }
  .update-banner__btn {
    grid-column: 2 / span 2;
    grid-row: 2;
    justify-self: stretch;
    text-align: center;
  }
}

/* ---------------- Hero ---------------- */

.hero {
  padding: 36px 4px 28px;
  text-align: left;
}
.hero__eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 14px;
}
.hero__title {
  /* Explicit font-size & margin-block so a sectioned <h1> doesn't fall back
     to the UA stylesheet's old auto-shrunk default (browsers warn about
     this; see https://developer.mozilla.org/docs/Web/HTML/Element/Heading_Elements). */
  font-size: clamp(36px, 9vw, 56px);
  margin-block: 0 14px;
  margin-inline: 0;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.hero__title-asm {
  display: block;
  font-size: clamp(36px, 9vw, 56px);
  font-weight: 700;
  color: var(--ink);
}
.hero__title-asm::after {
  content: '';
  display: inline-block;
  width: 0.5em; height: 0.12em;
  background: var(--accent);
  border-radius: 2px;
  margin-left: 0.18em;
  vertical-align: 0.18em;
}
.hero__title-en {
  display: block;
  margin-top: 8px;
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(15px, 3.6vw, 19px);
  color: var(--ink-3);
  letter-spacing: 0.005em;
}
.hero__lead {
  margin: 14px 0 0;
  max-width: 560px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-2);
}

/* ---------------- Card / Tabs / Inputs ---------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  margin-top: 8px;
}
.card--input { margin-top: 0; }

.tabs {
  position: relative;
  display: flex;
  padding: 6px;
  background: var(--paper-2);
  border-bottom: 1px solid var(--line);
}
.tab {
  position: relative;
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-3);
  border-radius: var(--radius-sm);
  transition: color 0.18s var(--t-snap);
  z-index: 1;
}
.tab.is-active { color: var(--ink); }
.tab svg { opacity: 0.85; }
.tab__indicator {
  position: absolute;
  top: 6px; bottom: 6px;
  left: 6px;
  /* Sized for 3 tabs: each occupies ~33.33% of the strip. Subtract a
     small fixed amount (8px) to leave breathing room from the strip's
     inner padding so the pill never bumps the right edge. */
  width: calc(33.333% - 8px);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  transition: transform 0.32s var(--t-spring);
  z-index: 0;
}
/* Indicator position per mode. URL (default) is at translateX(0). */
.tabs[data-mode="text"] .tab__indicator {
  transform: translateX(100%);
}
.tabs[data-mode="ocr"] .tab__indicator {
  transform: translateX(200%);
}

.card__body { padding: 16px; }
.input-pane { display: none; }
.input-pane.is-active { display: block; animation: fadeUp 0.36s var(--t-snap); }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.url-row {
  display: flex; gap: 8px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 6px 6px 14px;
  transition: border-color 0.18s, box-shadow 0.18s;
}
.url-row:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-tint);
}
.url-row input {
  flex: 1; min-width: 0;
  border: 0; outline: 0;
  background: transparent;
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 0;
  color: var(--ink);
}
.url-row input::placeholder { color: var(--ink-4); font-family: var(--font-mono); }

textarea {
  width: 100%;
  min-height: 140px;
  padding: 14px 16px;
  font-family: var(--font-asm);
  font-size: 17px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
  outline: 0;
  transition: border-color 0.18s, box-shadow 0.18s;
}
textarea::placeholder { color: var(--ink-4); }
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-tint);
}

.text-row {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 12px;
}

/* ---------------- Inline URL error ----------------
   Sits between the URL input and the help text. Persistent (unlike the
   toast) so the user can still see what went wrong after the toast has
   auto-hidden. Uses --danger for the bar and icon; body text stays
   readable on parchment. The "Paste text instead" action is always
   visible and one tap — every error message ends with that suggestion
   anyway, so let's make it actionable. */

.url-error {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  margin: 12px 0 0;
  padding: 12px 14px;
  background: color-mix(in oklab, var(--danger) 8%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--danger) 30%, var(--line));
  border-left: 3px solid var(--danger);
  border-radius: var(--radius-sm);
  animation: url-error-enter 240ms var(--t-snap);
}
.url-error[hidden] { display: none !important; }

@keyframes url-error-enter {
  from { transform: translateY(-4px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.url-error__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  flex-shrink: 0;
}

.url-error__text {
  font-family: var(--font-asm);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  align-self: center;
  /* Wrap long worker messages without horizontal overflow */
  overflow-wrap: anywhere;
}

.url-error__action {
  grid-column: 2;
  justify-self: start;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  font-family: var(--font-asm);
  font-weight: 600;
  font-size: 13.5px;
  padding: 4px 0;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: opacity 120ms var(--t-snap);
}
.url-error__action:hover { opacity: 0.75; }
.url-error__action .en {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 400;
  font-size: 12.5px;
  opacity: 0.85;
  margin-left: 3px;
}
/* The "Open in browser to copy the text" variant — rendered as an anchor
   tag, gets a small external-link icon. Inline-flex aligns the icon with
   the underlined text neatly. */
.url-error__action--open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.url-error__action--open[hidden] { display: none; }
.url-error__action--open svg { flex-shrink: 0; }

/* When the open-in-browser action is visible, the paste action moves to
   a secondary position (smaller, lower-emphasis). */
.url-error:has(.url-error__action--open:not([hidden])) .url-error__action--paste {
  font-weight: 400;
  font-size: 12.5px;
  opacity: 0.75;
  text-decoration: none;
}
.url-error:has(.url-error__action--open:not([hidden])) .url-error__action--paste:hover {
  opacity: 1;
  text-decoration: underline;
}

/* Kind-specific accents. Defaults to "danger" red; some errors aren't
   really failures (no-Assamese on an English page) so they get a softer
   amber tone. */
.url-error[data-kind="no-assamese"],
.url-error[data-kind="invalid-url"],
.url-error[data-kind="proxy-not-configured"] {
  background: color-mix(in oklab, var(--accent-soft) 14%, var(--surface));
  border-color: color-mix(in oklab, var(--accent-soft) 45%, var(--line));
  border-left-color: var(--accent-soft);
}
.url-error[data-kind="no-assamese"] .url-error__icon,
.url-error[data-kind="invalid-url"] .url-error__icon,
.url-error[data-kind="proxy-not-configured"] .url-error__icon {
  background: var(--accent-soft);
  color: #1f1a13;
}
.url-error[data-kind="no-assamese"] .url-error__action,
.url-error[data-kind="invalid-url"] .url-error__action,
.url-error[data-kind="proxy-not-configured"] .url-error__action {
  color: var(--accent);
}

/* ---------------- "Still loading" hint ----------------
   Appears below the URL row after ~6 seconds of pending fetch, so the
   user knows the app is working on something slow rather than broken. */

.url-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 10px 14px;
  background: color-mix(in oklab, var(--accent-tint) 55%, var(--surface));
  border: 1px solid color-mix(in oklab, var(--accent) 18%, var(--line));
  border-radius: var(--radius-sm);
  font-family: var(--font-asm);
  font-size: 13.5px;
  color: var(--ink-2);
  animation: url-loading-enter 220ms var(--t-snap);
}
.url-loading[hidden] { display: none !important; }

@keyframes url-loading-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.url-loading__spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid color-mix(in oklab, var(--accent) 30%, transparent);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: url-loading-spin 0.8s linear infinite;
  flex-shrink: 0;
}
@keyframes url-loading-spin {
  to { transform: rotate(360deg); }
}

.url-loading__text { line-height: 1.45; }
.url-loading__text .en {
  display: inline-block;
  margin-left: 4px;
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  opacity: 0.8;
}

.help-text {
  margin: 12px 4px 0;
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.55;
}
.help-text__en {
  font-family: var(--font-en);
  font-style: italic;
  display: inline-block;
  margin-left: 4px;
  opacity: 0.8;
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 11px 18px;
  font-family: var(--font-asm);
  font-size: 14.5px;
  font-weight: 600;
  border-radius: var(--radius);
  transition: transform 0.12s var(--t-snap), background 0.18s, box-shadow 0.18s, color 0.18s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }

.btn--primary {
  background: var(--ink);
  color: var(--paper);
  box-shadow: var(--shadow-1);
}
.btn--primary:hover { background: var(--accent); }

.btn--ghost {
  color: var(--ink-2);
  background: transparent;
}
.btn--ghost:hover { background: var(--accent-tint); color: var(--accent); }

.btn--icon {
  padding: 10px 12px;
  width: 44px; height: 44px;
  justify-content: center;
}

.btn--sm { padding: 7px 12px; font-size: 12.5px; }

/* ---------------- Suggestion chips ---------------- */

.suggestions { margin-top: 28px; }
.suggestions__title {
  margin: 0 4px 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px;
  margin: -4px;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  transition: background 0.18s, color 0.18s, border-color 0.18s, transform 0.12s;
  flex-shrink: 0;
}
.chip:hover { background: var(--accent-tint); border-color: var(--accent); color: var(--accent); }
.chip:active { transform: scale(0.96); }
.chip svg { opacity: 0.7; }

/* ---------------- Features ---------------- */

.features {
  display: grid;
  gap: 14px;
  margin-top: 36px;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .features { grid-template-columns: 1fr 1fr 1fr; }
}
.feature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.feature__icon {
  flex-shrink: 0;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 9px;
}
.feature__title {
  font-size: 14.5px; font-weight: 600;
  margin-bottom: 3px;
  color: var(--ink);
}
.feature__desc {
  font-family: var(--font-en);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-3);
}

/* ---------------- Cross-promo callout (Chrome extension link) ----------------
 * Distinct from feature cards: single full-width row, dashed accent border,
 * hover lifts subtly to suggest it's an action. */
.cross-promo {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 18px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--accent-tint), transparent 80%);
  border: 1px dashed var(--accent);
  border-radius: var(--radius);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.15s var(--t-spring), box-shadow 0.15s ease,
              background 0.18s ease;
}
.cross-promo:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
  background: linear-gradient(135deg, var(--accent-tint), var(--accent-tint));
}
.cross-promo__icon {
  flex-shrink: 0;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  background: var(--surface);
  color: var(--accent);
  border-radius: 50%;
  border: 1px solid var(--accent);
}
.cross-promo__text {
  flex: 1;
  min-width: 0;
}
.cross-promo__title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 2px;
}
.cross-promo__title-en {
  font-family: var(--font-en);
  font-style: italic;
  font-weight: 500;
  color: var(--ink-3);
  font-size: 13px;
}
.cross-promo__desc {
  font-family: var(--font-en);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}
.cross-promo__cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.cross-promo:hover .cross-promo__cta {
  background: var(--accent);
  color: #fff;
}
@media (max-width: 560px) {
  .cross-promo { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px 16px; }
  .cross-promo__cta { align-self: stretch; justify-content: center; }
}

/* ---------------- Footer ---------------- */

.page-footer {
  margin-top: 40px;
  padding: 18px 4px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.page-footer__line {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-3);
  line-height: 1.55;
}
.page-footer__line a {
  color: var(--ink-1);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted var(--line-strong);
}
.page-footer__line a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.page-footer__line .dot { color: var(--ink-4); margin: 0 8px; }
.page-footer__credit {
  margin-top: 8px;
  font-size: 12px;
  color: var(--ink-4);
  letter-spacing: 0.01em;
}
.page-footer__thanks {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  color: var(--ink-4);
  letter-spacing: 0.01em;
  line-height: 1.6;
}
.page-footer__thanks strong {
  color: var(--ink-2);
  font-weight: 600;
}

/* =============================================================================
   READER VIEW
   ============================================================================= */

.view--reader {
  padding-top: 8px;
}

.reader__meta {
  padding: 18px 4px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}
.reader__source {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin-bottom: 8px;
  word-break: break-all;
}
.reader__source a { color: inherit; }
.reader__title {
  /* Explicit font-size & margin-block — same reason as .hero__title above. */
  margin-block: 0;
  margin-inline: 0;
  font-family: var(--font-asm);
  font-weight: 700;
  font-size: clamp(24px, 6vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.reader__body { font-size: 18px; line-height: 1.85; color: var(--ink); }
.reader__body[data-size="sm"] { font-size: 16px; }
.reader__body[data-size="md"] { font-size: 18px; }
.reader__body[data-size="lg"] { font-size: 21px; }

.reader__body h1, .reader__body h2, .reader__body h3 {
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.reader__body h1 {
  font-size: 1.55em;
  margin: 1.6em 0 0.5em;
  border-bottom: 2px solid var(--line-strong);
  padding-bottom: 0.3em;
}
.reader__body h2 {
  font-size: 1.3em;
  margin: 1.6em 0 0.5em;
  position: relative;
  padding-left: 14px;
}
.reader__body h2::before {
  content: '';
  position: absolute;
  left: 0; top: 0.25em; bottom: 0.25em;
  width: 3px; background: var(--accent);
  border-radius: 2px;
}
.reader__body h3 {
  font-size: 1.13em;
  margin: 1.4em 0 0.4em;
  color: var(--ink-2);
}
.reader__body p, .reader__body li {
  margin: 0 0 1.1em;
  text-align: justify;
  text-justify: inter-character;
  hyphens: none;
}
.reader__body ul, .reader__body ol {
  padding-left: 1.3em;
  margin: 0 0 1.1em;
}

/* The crown jewel — sentence-level highlighting */
.sentence {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 2px;
  margin: 0 -2px;
  transition: background 0.4s var(--t-snap), color 0.3s, opacity 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.sentence:hover {
  background: var(--accent-tint);
}
.sentence.is-played {
  color: var(--ink-3);
}
.sentence.is-current {
  background: var(--highlight);
  color: var(--ink);
  box-shadow: 0 0 0 2px var(--highlight),
              inset 0 -2px 0 var(--highlight-pen);
  border-radius: 3px;
  /* gentle bloom */
  animation: bloom 0.6s var(--t-snap);
}
[data-theme="dark"] .sentence.is-current,
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .sentence.is-current {
    color: var(--ink);
    background: var(--highlight);
    box-shadow: 0 0 0 2px var(--highlight),
                inset 0 -2px 0 var(--highlight-pen);
  }
}
@keyframes bloom {
  0%   { background: var(--accent-tint); }
  100% { background: var(--highlight); }
}

.reader__end {
  text-align: center;
  font-size: 28px;
  color: var(--accent);
  opacity: 0.5;
  margin: 40px 0;
}

/* =============================================================================
   PLAYER BAR
   ============================================================================= */

.player {
  position: fixed;
  left: 50%;
  bottom: max(16px, var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 90;
  width: min(640px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-3);
  overflow: hidden;
  animation: rise 0.35s var(--t-spring);
}
@keyframes rise {
  from { transform: translate(-50%, 30px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
.player[hidden] { display: none; }
.player__progress {
  height: 3px;
  background: var(--paper-2);
  position: relative;
  overflow: hidden;
}
.player__fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-soft), var(--accent));
  transition: width 0.4s var(--t-snap);
}
.player__bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 8px;
}
.player__btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
  transition: background 0.16s, color 0.16s, transform 0.12s;
}
.player__btn:hover { background: var(--accent-tint); color: var(--accent); }
.player__btn:active { transform: scale(0.92); }
.player__btn--play {
  background: var(--ink);
  color: var(--paper);
  width: 48px; height: 48px;
}
.player__btn--play:hover { background: var(--accent); color: #fff; }
.player__btn--stop { color: var(--danger); }
.player__btn--stop:hover { background: rgba(183, 58, 58, 0.12); color: var(--danger); }

/* Prev / Next sentence navigation — slightly smaller than other btns so the
   play button remains the visual anchor in the middle. */
.player__btn--nav { width: 40px; height: 40px; }
.player__btn:disabled,
.player__btn[aria-disabled="true"] {
  color: var(--ink-4);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.5;
}
.player__btn:disabled:hover,
.player__btn[aria-disabled="true"]:hover { background: transparent; }

.player__info {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
  gap: 1px;
}
.player__line {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player__counter {
  display: flex; align-items: baseline; gap: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}
.player__counter .sep { color: var(--ink-4); }
.player__counter-label {
  font-family: var(--font-asm);
  margin-left: 4px;
  font-size: 11px;
}

/* =============================================================================
   LOADER (model download)
   ============================================================================= */

.loader {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(20, 15, 5, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: fadeIn 0.3s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.loader[hidden] { display: none; }

.loader__panel {
  width: min(420px, 100%);
  padding: 32px 28px 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  box-shadow: var(--shadow-3);
}
.loader__icon {
  display: inline-grid; place-items: center;
  margin-bottom: 18px;
  color: var(--accent);
}
#loader-arc { transition: stroke-dasharray 0.3s var(--t-snap); }
.loader__title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
}
.loader__sub {
  margin: 0 auto 18px;
  font-family: var(--font-en);
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-3);
  max-width: 32em;
}
.loader__file {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-2);
  padding: 8px 12px;
  background: var(--paper-2);
  border-radius: 8px;
  margin-bottom: 10px;
  word-break: break-all;
}
.loader__details {
  display: flex; justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
}

/* =============================================================================
   SETTINGS BOTTOM SHEET
   ============================================================================= */

.sheet-scrim {
  position: fixed; inset: 0; z-index: 110;
  background: rgba(20, 15, 5, 0.5);
  backdrop-filter: blur(2px);
  animation: fadeIn 0.25s ease-out;
}
.sheet-scrim[hidden] { display: none; }

.sheet {
  position: fixed;
  z-index: 120;
  left: 0; right: 0; bottom: 0;
  background: var(--surface);
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  box-shadow: 0 -10px 40px rgba(20, 15, 5, 0.25);
  max-height: min(80vh, 700px);
  overflow-y: auto;
  padding-bottom: calc(20px + var(--safe-bottom));
  animation: sheetUp 0.36s var(--t-spring);
}
@keyframes sheetUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0);    }
}
@media (min-width: 640px) {
  .sheet {
    left: 50%; right: auto; bottom: 20px;
    transform: translateX(-50%);
    width: 460px;
    border-radius: var(--radius-lg);
    max-height: min(85vh, 700px);
  }
  @keyframes sheetUp {
    from { transform: translate(-50%, 100%); }
    to   { transform: translate(-50%, 0);    }
  }
}
.sheet[hidden] { display: none; }

.sheet__handle {
  width: 40px; height: 4px;
  background: var(--line-strong);
  border-radius: 2px;
  margin: 8px auto 0;
}
.sheet__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px 8px;
}
.sheet__head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.sheet__close {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: var(--ink-2);
}
.sheet__close:hover { background: var(--accent-tint); color: var(--accent); }

.sheet__body { padding: 4px 18px 12px; }

.setting {
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.setting h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}
.setting__head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 10px;
}
.setting__value {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.speed-row {
  display: flex; align-items: center; gap: 10px;
}
.speed-row__label { font-size: 11px; color: var(--ink-3); }
.speed-row input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--line);
  border-radius: 2px;
  outline: 0;
}
.speed-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(176, 106, 26, 0.4);
}
.speed-row input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 0;
  box-shadow: 0 2px 6px rgba(176, 106, 26, 0.4);
}

.theme-row, .size-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}
.theme-opt, .size-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 10px 8px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  transition: border-color 0.18s, background 0.18s;
}
.size-opt { flex-direction: row; gap: 8px; padding: 12px; }
.theme-opt[aria-checked="true"], .size-opt.is-active {
  border-color: var(--accent);
  background: var(--accent-tint);
  color: var(--accent);
}
.theme-swatch {
  width: 28px; height: 28px;
  border-radius: 8px;
  border: 1px solid var(--line);
}
.theme-swatch--auto { background: linear-gradient(135deg, #f7f1e3 50%, #1a1612 50%); }
.theme-swatch--light { background: #f7f1e3; }
.theme-swatch--dark { background: #1a1612; }

.model-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.model-card__row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0;
  font-size: 13px;
}
.model-card__label { color: var(--ink-3); }
.model-card__val { font-family: var(--font-mono); color: var(--ink); }
.model-card__actions { margin-top: 10px; display: flex; gap: 8px; }

.about-blurb {
  font-family: var(--font-en);
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--ink-2);
  margin: 0 0 10px;
}

/* =============================================================================
   TOAST
   ============================================================================= */

.toast {
  position: fixed;
  bottom: calc(100px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  z-index: 130;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 18px;
  /* A pill radius only reads correctly on ONE line. Error messages wrap to
     three or four lines on a phone, where a 999px radius turns the box into a
     lozenge with the text crammed into the middle. Use the standard card
     radius instead, and allow a wider box so messages wrap less. */
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.45;
  box-shadow: var(--shadow-3);
  width: max-content;
  max-width: min(420px, calc(100vw - 32px));
  text-align: center;
  animation: toastIn 0.3s var(--t-spring);
}
.toast[hidden] { display: none; }
.toast.is-error { background: var(--danger); color: #fff; }
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}

/* ============================================================================
   WARMING-UP PILL
   Shown for a couple of seconds when the engine is loading models from
   IndexedDB cache (a real download has its own fullscreen overlay).
   ============================================================================ */
.warming {
  position: fixed;
  top: calc(72px + var(--safe-top, 0px));   /* below the header */
  left: 50%;
  transform: translateX(-50%);
  z-index: 120;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--paper-2);
  color: var(--ink-2);
  border: 1px solid var(--line);
  padding: 9px 16px 9px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-2);
  max-width: calc(100vw - 24px);
  animation: warmingIn 0.28s var(--t-spring);
}
.warming[hidden] { display: none; }
.warming.is-leaving { animation: warmingOut 0.22s ease-in forwards; }

.warming__dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.warming__dots i {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  opacity: 0.35;
  animation: warmingDot 1.1s ease-in-out infinite;
}
.warming__dots i:nth-child(2) { animation-delay: 0.18s; }
.warming__dots i:nth-child(3) { animation-delay: 0.36s; }

.warming__label {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.warming__as {
  font-family: var(--font-asm);
  color: var(--ink);
  font-weight: 600;
}
.warming__sep { color: var(--ink-4); }
.warming__en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
}

@keyframes warmingIn {
  from { transform: translate(-50%, -8px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
@keyframes warmingOut {
  from { transform: translate(-50%, 0);     opacity: 1; }
  to   { transform: translate(-50%, -8px); opacity: 0; }
}
@keyframes warmingDot {
  0%, 80%, 100% { opacity: 0.35; transform: scale(0.8); }
  40%           { opacity: 1;    transform: scale(1.15); }
}

@media (max-width: 480px) {
  .warming { font-size: 12px; padding: 7px 14px 7px 12px; gap: 10px; }
  .warming__en { font-size: 11.5px; }
}

/* =============================================================================
   Reduced motion
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* =============================================================================
   Tap targets on small screens
   ============================================================================= */

@media (max-width: 380px) {
  .topbar__name { font-size: 14px; }
  .hero__title-asm { font-size: 36px; }
  .features { gap: 10px; }
  .player { width: calc(100vw - 16px); }
  .reader__body p, .reader__body li { text-align: left; }
  /* Compress player slightly: 5 transport buttons + info + 2 utility */
  .player__bar { gap: 4px; padding: 8px 6px; }
  .player__btn { width: 40px; height: 40px; }
  .player__btn--play { width: 44px; height: 44px; }
  .player__btn--nav { width: 36px; height: 36px; }
}

/* =============================================================================
   OCR / Photo mode (v1.3.0)
   Matches the warm-parchment palette of the rest of the app. The pane swaps
   between four state panels (.ocr-state--empty/busy/review/error) controlled
   by [data-state] on the .ocr-pane container.
   ============================================================================= */

/* Beta badge on the tab itself */
.tab--beta { position: relative; }
.tab__badge {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  font-family: var(--font-en, 'Lora', serif);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--accent-tint);
  color: var(--accent);
  border-radius: 4px;
  vertical-align: 2px;
  line-height: 1;
}

/* --- The pane itself ---
   We deliberately do NOT override `display`. The pane inherits the same
   `.input-pane { display: none }` → `.input-pane.is-active { display: block }`
   visibility toggle as URL and Text panes, so switching tabs hides
   everything inside it (including the beta note). */
.ocr-state {
  animation: ocr-fade 200ms ease both;
}
@keyframes ocr-fade {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --- Beta note (visible across all states) --- */
.ocr-beta-note {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: var(--accent-tint);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  font-family: var(--font-asm);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink-2);
}
.ocr-beta-note svg {
  flex-shrink: 0;
  color: var(--accent);
  margin-top: 2px;
}
.ocr-beta-note strong { color: var(--ink); font-weight: 600; }
.ocr-beta-note .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-right: 4px;
}

/* --- Empty state --- */
.ocr-hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: 8px;
  font-family: var(--font-asm);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-bottom: 16px;
}
.ocr-hint__icon {
  flex-shrink: 0;
  color: var(--ink-3);
  margin-top: 2px;
}
.ocr-hint .en {
  display: block;
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-top: 2px;
}

.ocr-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
@media (max-width: 480px) {
  .ocr-buttons { grid-template-columns: 1fr; }
}

.ocr-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 22px 16px;
  background: var(--surface);
  border: 1.5px dashed color-mix(in oklab, var(--accent) 30%, transparent);
  border-radius: 10px;
  font-family: var(--font-asm);
  color: var(--ink);
  cursor: pointer;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 100ms ease;
  text-align: center;
  min-height: 110px;
}
.ocr-btn:hover {
  background: var(--surface-2);
  border-color: var(--accent);
}
.ocr-btn:active { transform: scale(0.985); }
.ocr-btn svg { color: var(--accent); }

.ocr-btn--primary {
  background: color-mix(in oklab, var(--accent-tint) 60%, var(--surface));
  border-style: solid;
  border-color: color-mix(in oklab, var(--accent) 50%, transparent);
}

.ocr-btn__label {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ocr-btn__label .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 400;
}

.ocr-fineprint {
  font-family: var(--font-asm);
  font-size: 12.5px;
  color: var(--ink-3);
  line-height: 1.5;
  margin: 0;
}
.ocr-fineprint .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 11.5px;
}

/* --- Busy state --- */
.ocr-thumb-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.ocr-thumb {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 8px;
  object-fit: cover;
  background: var(--paper-2);
  border: 1px solid color-mix(in oklab, var(--ink-4) 30%, transparent);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.ocr-busy-text { flex: 1; min-width: 0; }
.ocr-busy-asm {
  font-family: var(--font-asm);
  font-size: 15px;
  color: var(--ink);
  margin-bottom: 2px;
}
.ocr-busy-en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.ocr-busy-phase {
  font-family: var(--font-asm);
  font-size: 12.5px;
  color: var(--ink-2);
}

.ocr-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.ocr-progress__bar {
  flex: 1;
  height: 6px;
  background: var(--paper-2);
  border-radius: 999px;
  overflow: hidden;
}
.ocr-progress__fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 280ms cubic-bezier(.4,0,.2,1);
}
.ocr-progress__pct {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--ink-2);
  min-width: 38px;
  text-align: right;
}

/* --- Review state --- */
.ocr-thumb-collapsible {
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}
.ocr-thumb-collapsible summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  font-family: var(--font-asm);
  font-size: 13.5px;
  color: var(--ink-2);
}
.ocr-thumb-collapsible summary::-webkit-details-marker { display: none; }
.ocr-thumb-collapsible summary .ocr-thumb {
  width: 36px; height: 36px;
}
.ocr-thumb-label .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
}
.ocr-thumb-full {
  display: block;
  width: 100%;
  max-height: 320px;
  object-fit: contain;
  background: var(--paper-2);
}

.ocr-review-label {
  display: block;
  font-family: var(--font-asm);
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 8px;
  line-height: 1.4;
}
.ocr-review-label strong { font-weight: 600; }
.ocr-review-label .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
  font-weight: 400;
}

.ocr-review-text {
  /* Match the existing #text-input styling: same font, same look, so users
     immediately recognize this as "the same kind of editable Assamese text
     box as Text mode" — because it is. */
  width: 100%;
  padding: 14px;
  background: var(--paper-2);
  border: 1px solid color-mix(in oklab, var(--ink-4) 30%, transparent);
  border-radius: 8px;
  font-family: var(--font-asm);
  font-size: 16px;
  line-height: 1.7;
  color: var(--ink);
  resize: vertical;
  min-height: 180px;
}
.ocr-review-text:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.ocr-review-meta {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
  margin: 6px 2px 12px;
  min-height: 16px;
}

.ocr-review-controls {
  display: flex;
  align-items: center;
  /* Left-aligned now that "Send to Text tab" is gone and only the
     Improve-contrast toggle remains. */
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.ocr-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-asm);
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  user-select: none;
}
.ocr-toggle input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
}
.ocr-toggle .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
}

/* --- Shared row of action buttons (used in busy/review/error) --- */
.ocr-row {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
@media (max-width: 480px) {
  .ocr-row { flex-direction: column-reverse; }
  .ocr-row .btn { width: 100%; justify-content: center; }
}

/* --- Error state --- */
.ocr-error {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 14px;
  background: color-mix(in oklab, #c44 8%, var(--surface));
  border-left: 3px solid #c44;
  border-radius: 6px;
  font-family: var(--font-asm);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
}
.ocr-error__icon {
  flex-shrink: 0;
  color: #c44;
  margin-top: 2px;
}
.ocr-error__text strong { display: block; font-weight: 600; margin-bottom: 2px; }
.ocr-error__text .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
}

/* Dark mode tweaks (most CSS vars handle this automatically, a few don't) */
@media (prefers-color-scheme: dark) {
  .ocr-error {
    background: color-mix(in oklab, #e57 14%, var(--surface));
    border-left-color: #e57;
  }
  .ocr-error__icon { color: #e57; }
}
:root[data-theme="dark"] .ocr-error {
  background: color-mix(in oklab, #e57 14%, var(--surface));
  border-left-color: #e57;
}
:root[data-theme="dark"] .ocr-error__icon { color: #e57; }

/* =============================================================================
   PDF / Page-picker (v1.4.0)
   ============================================================================= */

.ocr-pdf-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
  font-family: var(--font-asm);
  font-size: 15px;
  color: var(--ink);
}
.ocr-pdf-header strong { font-weight: 600; }
.ocr-pdf-header .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 13px;
  color: var(--ink-3);
  font-weight: 400;
}
.ocr-pdf-count {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12.5px;
  color: var(--ink-3);
}

.ocr-pdf-hint {
  font-family: var(--font-asm);
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
  margin: 6px 0 14px;
}
.ocr-pdf-hint .en {
  font-family: var(--font-en);
  font-style: italic;
  font-size: 12px;
  color: var(--ink-3);
}

/* Grid of page thumbnails.
   - 2 cols on tight mobile, 3 cols on wider mobile, 4 cols on desktop
   - Each tile is keyboard- and screen-reader-accessible (it's a <button>) */
.ocr-pdf-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
  /* Cap height so a 20-page PDF doesn't push the picker off-screen.
     Internal scroll lets the user browse without losing context. */
  max-height: 56vh;
  overflow-y: auto;
  /* Subtle inset so the scrollable area reads as its own region */
  padding: 6px;
  background: var(--surface-2);
  border-radius: 8px;
}

.ocr-pdf-thumb {
  position: relative;
  display: block;
  padding: 0;
  margin: 0;
  background: var(--paper-2);
  border: 1.5px solid color-mix(in oklab, var(--ink-4) 30%, transparent);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 100ms ease, border-color 160ms ease, box-shadow 160ms ease;
  aspect-ratio: 1 / 1.35;   /* portrait page proportion */
}
.ocr-pdf-thumb:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
}
.ocr-pdf-thumb:active { transform: scale(0.98); }
.ocr-pdf-thumb:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.ocr-pdf-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: white;
}
.ocr-pdf-thumb__num {
  position: absolute;
  left: 4px; bottom: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: white;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
}


/* =============================================================================
   ARONAI MOTIF BAND
   ----------------------------------------------------------------------------
   The aronai's signature edge is a row of gold triangles ("dingkhia" fern
   tips) marching along an indigo ground, with a fine double rule above and
   below. Reproduced in pure CSS — no image request, works offline, scales to
   any width, and respects the current theme via the accent/indigo tokens.

   Usage:  <div class="aronai-band" aria-hidden="true"></div>
   Place it under the header and above the footer.
   ============================================================================= */

.aronai-band {
  height: 14px;
  width: 100%;
  flex: none;
  /* Triangle row + the two hairlines that frame it. */
  background-image:
    /* gold triangles */
    linear-gradient(135deg, var(--accent) 25%, transparent 25%),
    linear-gradient(225deg, var(--accent) 25%, transparent 25%),
    /* indigo ground */
    linear-gradient(var(--indigo), var(--indigo));
  background-size: 12px 12px, 12px 12px, 100% 100%;
  background-position: 0 3px, 0 3px, 0 0;
  background-repeat: repeat-x, repeat-x, no-repeat;
  border-top: 1px solid var(--accent);
  border-bottom: 1px solid var(--accent);
  opacity: 0.9;
}

/* A quieter variant for inside cards, where a full band would shout. */
.aronai-rule {
  height: 3px;
  width: 100%;
  border: 0;
  margin: 18px 0;
  background-image:
    repeating-linear-gradient(
      90deg,
      var(--accent) 0 6px,
      transparent 6px 10px,
      var(--indigo) 10px 16px,
      transparent 16px 20px
    );
  opacity: 0.55;
}

/* Diamond chain — the aronai's central lozenge row. Used as a section mark. */
.aronai-diamonds {
  height: 10px;
  width: 100%;
  background-image:
    linear-gradient(45deg, var(--accent) 25%, transparent 25%, transparent 75%, var(--accent) 75%),
    linear-gradient(45deg, var(--accent) 25%, transparent 25%, transparent 75%, var(--accent) 75%);
  background-size: 10px 10px;
  background-position: 0 0, 5px 5px;
  opacity: 0.35;
}

@media (prefers-reduced-motion: reduce) {
  .aronai-band, .aronai-rule, .aronai-diamonds { transition: none; }
}

