/* =============================================================================
   অসমীয়াত পঢ়ক — Stylesheet
   ----------------------------------------------------------------------------
   Aesthetic: editorial. Warm parchment in light mode, walnut at night.
   One accent: saffron — cultural, warm, not the AI-default purple.
   Typography is the hero: Noto Serif Bengali for the Assamese body
   (proper conjuncts, beautiful), Lora for English/numerals,
   JetBrains Mono for technical accents.
   ----------------------------------------------------------------------------
   Mobile-first. Every interactive element is at least 44pt tall.
   ============================================================================= */

/* ---------------- Tokens ---------------- */
:root {
  /* Light theme — parchment */
  --paper:        #f7f1e3;        /* page background */
  --paper-2:      #efe7d4;        /* recessed surfaces */
  --surface:      #fffaef;        /* raised cards */
  --surface-2:    #fcf6e8;
  --line:         #e8dcc1;        /* hairlines */
  --line-strong:  #d3c19a;
  --ink:          #1f1a13;        /* primary text */
  --ink-2:        #4a3f2e;        /* secondary text */
  --ink-3:        #7a6c52;        /* tertiary */
  --ink-4:        #b3a685;        /* muted */
  --accent:       #b06a1a;        /* saffron / ochre */
  --accent-soft:  #e7a85a;
  --accent-tint:  rgba(176,106,26,0.10);
  --highlight:    #f6d57a;        /* sentence highlight (sun-yellow) */
  --highlight-pen:#e6b94a;        /* penned underline */
  --danger:       #b73a3a;
  --shadow-1:     0 1px 2px rgba(60, 40, 10, 0.06), 0 2px 6px rgba(60, 40, 10, 0.04);
  --shadow-2:     0 4px 14px rgba(60, 40, 10, 0.10), 0 1px 3px rgba(60, 40, 10, 0.06);
  --shadow-3:     0 12px 40px rgba(40, 25, 5, 0.18), 0 4px 12px rgba(40, 25, 5, 0.10);

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

  --font-asm:     'Noto Serif Bengali', 'Noto Sans Bengali', 'Hind Siliguri', system-ui, sans-serif;
  --font-en:      'Lora', Georgia, 'Times New Roman', serif;
  --font-mono:    'JetBrains Mono', 'SF Mono', Menlo, 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:        #1a1612;
  --paper-2:      #221c16;
  --surface:      #25201a;
  --surface-2:    #2c2620;
  --line:         #3a3128;
  --line-strong:  #4a3f33;
  --ink:          #f0e6d3;
  --ink-2:        #c5b69a;
  --ink-3:        #998a72;
  --ink-4:        #6b5f4d;
  --accent:       #e09454;
  --accent-soft:  #c97f3f;
  --accent-tint:  rgba(224,148,84,0.16);
  --highlight:    #604a1d;
  --highlight-pen:#e5b96a;
  --danger:       #d65a5a;
  --shadow-1:     0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-2:     0 4px 14px rgba(0, 0, 0, 0.5);
  --shadow-3:     0 12px 40px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Auto theme respects OS preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #1a1612;
    --paper-2:      #221c16;
    --surface:      #25201a;
    --surface-2:    #2c2620;
    --line:         #3a3128;
    --line-strong:  #4a3f33;
    --ink:          #f0e6d3;
    --ink-2:        #c5b69a;
    --ink-3:        #998a72;
    --ink-4:        #6b5f4d;
    --accent:       #e09454;
    --accent-soft:  #c97f3f;
    --accent-tint:  rgba(224,148,84,0.16);
    --highlight:    #604a1d;
    --highlight-pen:#e5b96a;
    --shadow-1:     0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-2:     0 4px 14px rgba(0, 0, 0, 0.5);
    --shadow-3:     0 12px 40px rgba(0, 0, 0, 0.6), 0 4px 12px rgba(0, 0, 0, 0.4);
  }
}

/* ---------------- 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.55;
  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(176,106,26,0.05), transparent 60%),
    radial-gradient(ellipse 60% 80% at 100% 100%, rgba(176,106,26,0.04), 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(224,148,84,0.06), transparent 60%),
      radial-gradient(ellipse 60% 80% at 100% 100%, rgba(224,148,84,0.04), 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; }

/* ---------------- 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;
  width: calc(50% - 6px);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-1);
  transition: transform 0.32s var(--t-spring);
  z-index: 0;
}
.tabs[data-mode="text"] .tab__indicator {
  transform: translateX(100%);
}

.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;
}

.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;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-3);
  max-width: 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; }
}
