/* Vaishnav Jan web app. Tokens mirror designsystem/Color.kt, Type.kt, Theme.kt of the Android app.
   Themes: [data-theme=light|dark|contrast] on <html>. Reader palettes: [data-reading=light|sepia|dark|contrast].
   Motion: [data-motion=off] on <html> (set when the reader asks to remove animations or the OS asks for reduced motion). */

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --primary: #7a1e2c; --on-primary: #fff8ec;
  --primary-container: #f7dcd7; --on-primary-container: #3d0a14;
  --secondary: #a85a08; --on-secondary: #ffffff;
  --secondary-container: #ffe2b8; --on-secondary-container: #3b2000;
  --tertiary: #4f6f4a; --on-tertiary: #ffffff;
  --tertiary-container: #dcebd3; --on-tertiary-container: #16270f;
  --background: #fff8ec; --on-background: #2a2320;
  --surface: #fffbf4; --on-surface: #2a2320;
  --surface-variant: #f3e8d6; --on-surface-variant: #5a4e45;
  --surface-lowest: #ffffff; --surface-low: #fff4e2; --surface-container: #fbefdb;
  --surface-high: #f6e9d3; --surface-highest: #f0e1c9;
  --outline: #8a7b6c; --outline-variant: #ddcfbb;
  --error: #b3261e; --on-error: #ffffff;
  --scrim: rgba(20, 12, 8, 0.45);
  --shadow: 0 1px 3px rgba(42, 35, 32, 0.18);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --primary: #f0b3b9; --on-primary: #4a0e19;
  --primary-container: #6b1a28; --on-primary-container: #ffdadc;
  --secondary: #f5b866; --on-secondary: #3b2000;
  --secondary-container: #5a3500; --on-secondary-container: #ffe2b8;
  --tertiary: #a9c9a0; --on-tertiary: #16270f;
  --tertiary-container: #354f30; --on-tertiary-container: #dcebd3;
  --background: #17120f; --on-background: #efe3d1;
  --surface: #1f1914; --on-surface: #efe3d1;
  --surface-variant: #2e251e; --on-surface-variant: #cdbfac;
  --surface-lowest: #120e0b; --surface-low: #1b1511; --surface-container: #241d17;
  --surface-high: #2e251e; --surface-highest: #392f27;
  --outline: #988a7a; --outline-variant: #4a3e34;
  --error: #ffb4ab; --on-error: #690005;
  --scrim: rgba(0, 0, 0, 0.6);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
:root[data-theme="contrast"] {
  color-scheme: dark;
  --primary: #ffd54a; --on-primary: #000000;
  --primary-container: #332a00; --on-primary-container: #ffe98a;
  --secondary: #ffffff; --on-secondary: #000000;
  --secondary-container: #262626; --on-secondary-container: #ffffff;
  --tertiary: #9ce6a0; --on-tertiary: #000000;
  --tertiary-container: #12301a; --on-tertiary-container: #bff2c2;
  --background: #000000; --on-background: #ffffff;
  --surface: #000000; --on-surface: #ffffff;
  --surface-variant: #1a1a1a; --on-surface-variant: #f0f0f0;
  --surface-lowest: #000000; --surface-low: #0d0d0d; --surface-container: #141414;
  --surface-high: #1c1c1c; --surface-highest: #262626;
  --outline: #ffffff; --outline-variant: #8c8c8c;
  --error: #ff8a80; --on-error: #000000;
  --scrim: rgba(0, 0, 0, 0.8);
  --shadow: none;
}
/* Before JS sets data-theme, follow the system so there is no light flash in dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --primary: #f0b3b9; --on-primary: #4a0e19;
    --primary-container: #6b1a28; --on-primary-container: #ffdadc;
    --secondary: #f5b866; --on-secondary: #3b2000;
    --secondary-container: #5a3500; --on-secondary-container: #ffe2b8;
    --tertiary: #a9c9a0; --on-tertiary: #16270f;
    --tertiary-container: #354f30; --on-tertiary-container: #dcebd3;
    --background: #17120f; --on-background: #efe3d1;
    --surface: #1f1914; --on-surface: #efe3d1;
    --surface-variant: #2e251e; --on-surface-variant: #cdbfac;
    --surface-lowest: #120e0b; --surface-low: #1b1511; --surface-container: #241d17;
    --surface-high: #2e251e; --surface-highest: #392f27;
    --outline: #988a7a; --outline-variant: #4a3e34;
    --error: #ffb4ab; --on-error: #690005;
  }
}

/* Scale */
:root {
  --sp-xs: 4px; --sp-sm: 8px; --sp-md: 16px; --sp-lg: 24px; --sp-xl: 32px;
  --min-touch: 48px; --gutter: 16px;
  --r-xs: 8px; --r-sm: 12px; --r-md: 16px; --r-lg: 20px; --r-xl: 28px;
  --dur-short: 120ms; --dur-medium: 200ms;
  --press-scale: 0.98;
  --font-serif: Georgia, "Noto Serif", "Noto Serif Devanagari", "Noto Serif Gujarati", "Times New Roman", serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Gujarati", "Nirmala UI", sans-serif;
  --nav-h: 72px; --rail-w: 88px; --mini-h: 64px;
  --art-deep: #5e1220; --art-light: #9b3445;
}

/* Artwork accents (AccentKey) */
.accent-maroon { --art-deep: #5e1220; --art-light: #9b3445; }
.accent-saffron { --art-deep: #9a4b05; --art-light: #d9791a; }
.accent-lotus { --art-deep: #8a2a4f; --art-light: #c25a7c; }
.accent-tulsi { --art-deep: #2f4f2b; --art-light: #5f8a58; }
.accent-yamuna { --art-deep: #184c62; --art-light: #3f8aa6; }
.accent-gold { --art-deep: #7a5a12; --art-light: #b88c2e; }
.accent-indigo { --art-deep: #283569; --art-light: #5566a8; }

/* Reader palettes (ReadingPalette) */
.reading-scope,
.reading-scope[data-reading="light"] {
  --r-bg: #fff9ee; --r-text: #2b2118; --r-meaning: #5a4a3a; --r-highlight: #ffe3b0; --r-highlight-text: #2b2118;
  --r-divider: #e6d7bc; --r-chrome: #fff3dc; --r-on-chrome: #2b2118; --r-accent: #7a1e2c;
}
.reading-scope[data-reading="sepia"] {
  --r-bg: #f3e5c8; --r-text: #3b2a1a; --r-meaning: #63503c; --r-highlight: #e8c98c; --r-highlight-text: #3b2a1a;
  --r-divider: #d9c49c; --r-chrome: #ebdab6; --r-on-chrome: #3b2a1a; --r-accent: #7a3b14;
}
.reading-scope[data-reading="dark"] {
  --r-bg: #14110e; --r-text: #eadfcb; --r-meaning: #bfb29b; --r-highlight: #4a3418; --r-highlight-text: #fff1d6;
  --r-divider: #3a3028; --r-chrome: #211b15; --r-on-chrome: #eadfcb; --r-accent: #f5b866;
}
.reading-scope[data-reading="contrast"] {
  --r-bg: #000000; --r-text: #ffffff; --r-meaning: #e6e6e6; --r-highlight: #ffd600; --r-highlight-text: #000000;
  --r-divider: #8c8c8c; --r-chrome: #141414; --r-on-chrome: #ffffff; --r-accent: #ffd54a;
}

/* Motion off: nothing animates. */
:root[data-motion="off"] { --dur-short: 0ms; --dur-medium: 0ms; --press-scale: 1; }
:root[data-motion="off"] *, :root[data-motion="off"] *::before, :root[data-motion="off"] *::after {
  animation-duration: 0ms !important; transition-duration: 0ms !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="on"]) { --dur-short: 0ms; --dur-medium: 0ms; --press-scale: 1; }
  :root:not([data-motion="on"]) *, :root:not([data-motion="on"]) *::before, :root:not([data-motion="on"]) *::after {
    animation-duration: 0ms !important; transition-duration: 0ms !important; scroll-behavior: auto !important;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--background); color: var(--on-background);
  font-family: var(--font-sans); font-size: 16px; line-height: 27px;
  -webkit-font-smoothing: antialiased; overflow-wrap: anywhere;
}
h1, h2, h3, h4, h5, h6 { margin: 0; font-family: var(--font-serif); font-weight: 600; }
p { margin: 0; }
a { color: var(--primary); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: var(--sp-md); top: -64px; z-index: 100; background: var(--primary); color: var(--on-primary);
  padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-xs); text-decoration: none;
}
.skip-link:focus { top: var(--sp-sm); }

/* Type scale (Type.kt) */
.t-display { font: 600 34px/46px var(--font-serif); }
.t-headline-md { font: 600 28px/40px var(--font-serif); }
.t-headline-sm { font: 600 24px/36px var(--font-serif); }
.t-title-lg { font: 600 22px/33px var(--font-serif); }
.t-title-md { font: 600 18px/28px var(--font-sans); }
.t-title-sm { font: 500 16px/25px var(--font-sans); }
.t-body-lg { font: 400 18px/30px var(--font-sans); }
.t-body-md { font: 400 16px/27px var(--font-sans); }
.t-body-sm { font: 400 14px/23px var(--font-sans); }
.t-label-lg { font: 600 16px/24px var(--font-sans); }
.t-label-md { font: 500 14px/21px var(--font-sans); }
.t-label-sm { font: 500 13px/19px var(--font-sans); }
.muted { color: var(--on-surface-variant); }
.error-text { color: var(--error); }

/* Shell: bottom nav on phones, side rail from 840px */
#app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.shell-body { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* The shell is empty until boot has decided whether the side rail is reserved (body.rail-reserved). Painting it before
   that and moving it 88px afterwards counted as a layout shift on wide screens, so it stays invisible until boot says ready. */
body:not(.shell-ready) #app { visibility: hidden; }
main#main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 var(--gutter) var(--sp-xl); outline: none; }
body.has-bottom-bar main#main { padding-bottom: calc(var(--nav-h) + var(--sp-xl)); }
body.has-mini main#main { padding-bottom: calc(var(--nav-h) + var(--mini-h) + var(--sp-xl)); }
/* The reader paints its own full-bleed surface and sticky transport bar, so #main must not add a strip of app background below it (REG-004). */
body[data-route="reader"] main#main { padding-bottom: 0; }
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; height: var(--nav-h);
  background: var(--surface-container); border-top: 1px solid var(--outline-variant);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav a {
  flex: 1; min-width: 0; min-height: var(--min-touch); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; text-decoration: none; color: var(--on-surface-variant); font: 500 13px/19px var(--font-sans);
}
.nav a svg { width: 24px; height: 24px; }
.nav a .pill { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; transition: background var(--dur-short); }
.nav a[aria-current="page"] { color: var(--on-surface); font-weight: 600; }
.nav a[aria-current="page"] .pill { background: var(--secondary-container); color: var(--on-secondary-container); }
body:not(.has-bottom-bar) .nav { display: none; }
@media (min-width: 840px) {
  .nav { top: 0; bottom: 0; right: auto; width: var(--rail-w); height: auto; flex-direction: column; justify-content: flex-start; gap: var(--sp-sm);
    padding: var(--sp-lg) 0; border-top: 0; border-right: 1px solid var(--outline-variant); }
  .nav a { flex: 0 0 auto; padding: var(--sp-sm) 0; }
  /* rail-reserved: set at boot, before the first screen exists, so the shell does not jump sideways when the rail appears. */
  body.has-bottom-bar #app, body.rail-reserved #app { padding-left: var(--rail-w); }
  body.has-bottom-bar main#main, body.has-mini main#main { padding-bottom: var(--sp-xl); }
  body.has-mini main#main { padding-bottom: calc(var(--mini-h) + var(--sp-xl)); }
  .mini-player { left: var(--rail-w); }
}

/* Top bar */
.topbar { display: flex; align-items: center; gap: var(--sp-sm); min-height: 64px; padding: var(--sp-sm) 0; position: sticky; top: 0; z-index: 10; background: var(--background); }
.topbar h1 { flex: 1; min-width: 0; font: 600 22px/33px var(--font-serif); }
.topbar .spacer { flex: 1; }

/* Controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-sm); min-height: var(--min-touch); min-width: var(--min-touch);
  padding: 0 var(--sp-lg); border: 0; border-radius: 999px; cursor: pointer; text-decoration: none;
  font: 600 16px/24px var(--font-sans); background: var(--primary); color: var(--on-primary);
  transition: transform var(--dur-short), background var(--dur-short);
}
.btn:active:not(:disabled) { transform: scale(var(--press-scale)); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; cursor: default; }
.btn svg { width: 22px; height: 22px; flex: none; }
.btn.tonal { background: var(--secondary-container); color: var(--on-secondary-container); }
.btn.outlined { background: transparent; color: var(--primary); box-shadow: inset 0 0 0 1px var(--outline); }
.btn.text { background: transparent; color: var(--primary); padding: 0 var(--sp-md); }
.btn.danger { background: var(--error); color: var(--on-error); }
.btn.block { display: flex; width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--min-touch); height: var(--min-touch); padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: inherit; cursor: pointer; flex: none; text-decoration: none; transition: transform var(--dur-short), background var(--dur-short);
}
.icon-btn:hover:not(:disabled) { background: color-mix(in srgb, currentColor 10%, transparent); }
.icon-btn:active:not(:disabled) { transform: scale(var(--press-scale)); }
.icon-btn:disabled { opacity: 0.4; cursor: default; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.filled { background: var(--primary); color: var(--on-primary); }
.icon-btn.big { width: 72px; height: 72px; }
.icon-btn.big svg { width: 36px; height: 36px; }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-xs); min-height: var(--min-touch); padding: 0 var(--sp-md); border-radius: var(--r-sm);
  border: 1px solid var(--outline); background: transparent; color: var(--on-surface); cursor: pointer; font: 500 14px/21px var(--font-sans);
}
.chip[aria-pressed="true"], .chip[aria-checked="true"], .chip.selected { background: var(--secondary-container); color: var(--on-secondary-container); border-color: transparent; }
.chip svg { width: 18px; height: 18px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-sm); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: var(--sp-xs); scrollbar-width: thin; }
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font: 500 13px/19px var(--font-sans); background: var(--surface-highest); color: var(--on-surface-variant); }
.badge.warn { background: var(--secondary-container); color: var(--on-secondary-container); }
.badge.ok { background: var(--tertiary-container); color: var(--on-tertiary-container); }

/* Forms */
.field { display: flex; flex-direction: column; gap: var(--sp-xs); }
.field label, .field .label { font: 500 14px/21px var(--font-sans); color: var(--on-surface-variant); }
.input, .select, textarea.input {
  min-height: var(--min-touch); width: 100%; padding: 0 var(--sp-md); border: 1px solid var(--outline); border-radius: var(--r-xs);
  background: var(--surface); color: var(--on-surface);
}
textarea.input { padding: var(--sp-sm) var(--sp-md); min-height: 120px; line-height: 24px; }
.input:focus-visible, .select:focus-visible { outline: 3px solid var(--primary); outline-offset: 0; }
.help { font: 400 14px/23px var(--font-sans); color: var(--on-surface-variant); }
.search-field { position: relative; display: flex; align-items: center; }
.search-field .input { padding-left: 48px; border-radius: 999px; }
.search-field > svg { position: absolute; left: 14px; width: 22px; height: 22px; pointer-events: none; color: var(--on-surface-variant); }
.search-field .end { position: absolute; right: 0; display: flex; }
.search-field .input { padding-right: 48px; }
.switch-row {
  display: flex; align-items: center; gap: var(--sp-md); min-height: var(--min-touch); padding: var(--sp-sm) 0; cursor: pointer;
}
.switch-row .grow { flex: 1; min-width: 0; }
.switch { position: relative; width: 52px; height: 32px; flex: none; appearance: none; -webkit-appearance: none; border: 2px solid var(--outline); border-radius: 16px;
  background: var(--surface-highest); cursor: pointer; transition: background var(--dur-short); }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 20px; height: 20px; border-radius: 50%; background: var(--outline); transition: transform var(--dur-short); }
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { transform: translateX(20px); background: var(--on-primary); }
.range { width: 100%; min-height: var(--min-touch); accent-color: var(--primary); }
.seg { display: inline-flex; border: 1px solid var(--outline); border-radius: 999px; overflow: hidden; }
.seg button { min-height: var(--min-touch); padding: 0 var(--sp-md); border: 0; border-right: 1px solid var(--outline); background: transparent; cursor: pointer; font: 500 14px/21px var(--font-sans); }
.seg button:last-child { border-right: 0; }
.seg button[aria-pressed="true"], .seg button[aria-checked="true"] { background: var(--secondary-container); color: var(--on-secondary-container); }

/* Cards and lists */
.card { background: var(--surface-container); border-radius: var(--r-md); padding: var(--sp-md); }
.card.outlined { background: transparent; box-shadow: inset 0 0 0 1px var(--outline-variant); }
.card.tonal { background: var(--primary-container); color: var(--on-primary-container); }
.stack { display: flex; flex-direction: column; gap: var(--sp-md); }
.stack.sm { gap: var(--sp-sm); }
.stack.lg { gap: var(--sp-lg); }
.row { display: flex; align-items: center; gap: var(--sp-md); }
.row.wrap { flex-wrap: wrap; }
.row .grow, .grow { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md); margin: var(--sp-lg) 0 var(--sp-sm); }
.section-title h2 { font: 600 22px/33px var(--font-serif); }
.hscroll { display: flex; gap: var(--sp-md); overflow-x: auto; padding-bottom: var(--sp-sm); scroll-snap-type: x proximity; scrollbar-width: thin; }
.hscroll > * { flex: none; scroll-snap-align: start; }
.grid { display: grid; gap: var(--sp-md); grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--outline-variant); }
.list > li:last-child { border-bottom: 0; }
.list-item { display: flex; align-items: center; gap: var(--sp-md); min-height: 64px; padding: var(--sp-sm) 0; color: inherit; text-decoration: none; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; }
.list-item:hover { background: color-mix(in srgb, currentColor 5%, transparent); }
.list-item .lead { flex: none; width: 56px; height: 56px; border-radius: var(--r-xs); overflow: hidden; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .body .t { font: 600 16px/24px var(--font-sans); overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.list-item .body .s { font: 400 14px/21px var(--font-sans); color: var(--on-surface-variant); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Content card (art + text) */
.content-card { position: relative; display: flex; flex-direction: column; border-radius: var(--r-md); overflow: hidden; background: var(--surface-container); color: inherit; text-decoration: none; cursor: pointer; border: 0; text-align: left; padding: 0; transition: transform var(--dur-short); }
.content-card:active { transform: scale(var(--press-scale)); }
.content-card .art { width: 100%; aspect-ratio: 16 / 9; display: block; }
.content-card .meta { padding: var(--sp-sm) var(--sp-md) var(--sp-md); display: flex; flex-direction: column; gap: 2px; }
.content-card .meta .t { font: 600 18px/28px var(--font-serif); }
.content-card .meta .s { font: 400 14px/21px var(--font-sans); color: var(--on-surface-variant); }
.content-card.compact { width: 240px; }
.art-box { position: relative; overflow: hidden; background: linear-gradient(135deg, var(--art-deep), var(--art-light)); color: #fff; }
.art-box > svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.art-box .overlay { position: absolute; left: var(--sp-md); right: var(--sp-md); bottom: var(--sp-sm); color: #fff; }

/* States */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-sm); padding: var(--sp-xl) var(--sp-md); color: var(--on-surface-variant); }
.state svg { width: 48px; height: 48px; opacity: 0.8; }
.state h2 { color: var(--on-surface); font: 600 22px/33px var(--font-serif); }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--outline-variant); border-top-color: var(--primary); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { display: flex; gap: var(--sp-sm); align-items: flex-start; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm); background: var(--secondary-container); color: var(--on-secondary-container); font: 400 14px/21px var(--font-sans); }
.banner.error { background: color-mix(in srgb, var(--error) 18%, var(--surface)); color: var(--on-surface); }
.skeleton { background: linear-gradient(90deg, var(--surface-high), var(--surface-highest), var(--surface-high)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: var(--r-xs); }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Dialog / sheet */
dialog.sheet, dialog.modal {
  border: 0; padding: 0; color: var(--on-surface); background: var(--surface); box-shadow: var(--shadow);
  max-width: 640px; width: calc(100% - 2 * var(--gutter));
}
dialog.modal { border-radius: var(--r-xl); }
dialog.sheet { margin: auto auto 0 auto; border-radius: var(--r-xl) var(--r-xl) 0 0; max-height: 88vh; max-height: 88dvh; width: 100%; max-width: 640px; }
@media (min-width: 840px) { dialog.sheet { margin: auto; border-radius: var(--r-xl); } }
dialog::backdrop { background: var(--scrim); }
.dialog-inner { display: flex; flex-direction: column; gap: var(--sp-md); padding: var(--sp-lg); max-height: 88vh; max-height: 88dvh; overflow-y: auto; }
.dialog-inner .grabber { align-self: center; width: 32px; height: 4px; border-radius: 2px; background: var(--outline-variant); }
.dialog-actions { display: flex; gap: var(--sp-sm); justify-content: flex-end; flex-wrap: wrap; }

/* Toasts and live regions */
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + var(--mini-h) + var(--sp-md)); z-index: 90; display: flex; flex-direction: column; gap: var(--sp-sm); align-items: center; width: calc(100% - 2 * var(--gutter)); max-width: 480px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--on-surface); color: var(--surface); padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-sm); box-shadow: var(--shadow); font: 500 14px/21px var(--font-sans); animation: fade-in var(--dur-medium); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.screen { animation: fade-in 150ms; }

/* Mini player */
.mini-player {
  position: fixed; left: 0; right: 0; bottom: var(--nav-h); z-index: 25; height: var(--mini-h); display: flex; align-items: center; gap: var(--sp-sm);
  padding: 0 var(--sp-sm) 0 var(--sp-md); background: var(--surface-highest); border-top: 1px solid var(--outline-variant); color: var(--on-surface);
}
body:not(.has-bottom-bar) .mini-player { bottom: 0; }
.mini-player .info { flex: 1; min-width: 0; background: none; border: 0; text-align: left; cursor: pointer; padding: 0; }
.mini-player .info .t { font: 600 16px/24px var(--font-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-player .info .s { font: 400 13px/19px var(--font-sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--on-surface-variant); }
.mini-player .progress { position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--outline-variant); }
.mini-player .progress > span { display: block; height: 100%; background: var(--primary); }
@media (min-width: 840px) { .mini-player { bottom: 0; } #toasts { bottom: calc(var(--mini-h) + var(--sp-md)); } }

/* Reader */
.reader { background: var(--r-bg); color: var(--r-text); min-height: 100vh; min-height: 100dvh; margin: 0 calc(-1 * var(--gutter)); }
.reader-chrome { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: var(--sp-xs); padding: var(--sp-xs) var(--sp-sm); background: var(--r-chrome); color: var(--r-on-chrome); border-bottom: 1px solid var(--r-divider); }
.reader-chrome h1 { flex: 1; min-width: 0; font: 600 18px/28px var(--font-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.reader-bottom { position: sticky; bottom: 0; z-index: 10; display: flex; align-items: center; justify-content: space-around; gap: var(--sp-xs); padding: var(--sp-xs) var(--sp-sm); background: var(--r-chrome); color: var(--r-on-chrome); border-top: 1px solid var(--r-divider); }
.reader-body { max-width: 760px; margin: 0 auto; padding: var(--sp-md) var(--gutter) var(--sp-xl); }
.reader-line {
  display: block; width: 100%; text-align: left; background: none; border: 0; padding: var(--sp-sm) var(--sp-md); border-radius: var(--r-xs); cursor: pointer; color: inherit;
  font-family: var(--font-serif); font-size: var(--reader-size, 22px); line-height: var(--reader-line, 1.65); margin-bottom: var(--reader-gap, 6px);
  transition: background var(--dur-medium);
}
.reader-line .meaning { display: block; margin-top: var(--sp-xs); color: var(--r-meaning); font-family: var(--font-sans); font-size: 0.8em; line-height: 1.5; }
.reader-line.current { background: var(--r-highlight); color: var(--r-highlight-text); }
.reader-line.current .meaning { color: var(--r-highlight-text); }
.reader-line.found { outline: 2px dashed var(--r-accent); }
.reader-line mark { background: var(--r-accent); color: var(--r-bg); border-radius: 2px; }
.reader-line .num { display: block; font: 500 13px/19px var(--font-sans); color: var(--r-meaning); }
.reader-heading { margin: var(--sp-lg) var(--sp-md) var(--sp-xs); font-family: var(--font-serif); color: var(--r-accent); }
.reader-heading.l1 { font-size: 1.15em; font-weight: 700; }
.reader-heading.l2 { font-size: 1em; font-weight: 600; }
.reader .btn, .reader .chip { --on-surface: var(--r-on-chrome); }
.reader-chrome .icon-btn, .reader-bottom .icon-btn { color: var(--r-on-chrome); }
.chapter-strip { display: flex; align-items: center; gap: var(--sp-xs); padding: var(--sp-xs) var(--sp-sm); background: var(--r-chrome); color: var(--r-on-chrome); border-bottom: 1px solid var(--r-divider); }
.chapter-strip .label { flex: 1; min-width: 0; font: 500 14px/21px var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.chapter-strip .icon-btn { color: var(--r-on-chrome); }

/* Player */
.player-lines { display: flex; flex-direction: column; gap: var(--sp-sm); text-align: center; }
.player-line { font: 400 22px/33px var(--font-serif); opacity: 0.65; }
.player-line.current { font: 600 28px/40px var(--font-serif); opacity: 1; color: var(--primary); }
.player-controls { display: flex; align-items: center; justify-content: center; gap: var(--sp-sm); }

/* Misc */
.divider { height: 1px; background: var(--outline-variant); border: 0; margin: var(--sp-md) 0; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: var(--sp-sm); justify-content: center; }
.pin-pad button { height: 72px; border-radius: 50%; border: 1px solid var(--outline); background: var(--surface-container); font: 600 24px/32px var(--font-sans); cursor: pointer; color: var(--on-surface); }
.pin-dots { display: flex; gap: var(--sp-md); justify-content: center; }
.pin-dots span { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }
.tabs { display: flex; border-bottom: 1px solid var(--outline-variant); }
.tabs button { flex: 1; min-height: var(--min-touch); background: none; border: 0; border-bottom: 3px solid transparent; font: 600 16px/24px var(--font-sans); cursor: pointer; color: var(--on-surface-variant); }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
mark { background: var(--secondary-container); color: var(--on-secondary-container); border-radius: 2px; }
.prose { max-width: 70ch; }
.prose h2 { margin: var(--sp-lg) 0 var(--sp-sm); font: 600 22px/33px var(--font-serif); }
.prose p { margin: 0 0 var(--sp-md); }
.prose ul { margin: 0 0 var(--sp-md); padding-left: var(--sp-lg); }

@media (max-width: 480px) {
  .t-display { font-size: 30px; line-height: 40px; }
  .content-card.compact { width: 200px; }
  .grid { grid-template-columns: 1fr; }
}
@media print {
  .nav, .mini-player, .topbar, .reader-chrome, .reader-bottom, #toasts { display: none !important; }
  body { background: #fff; color: #000; }
}
.noscript-msg { padding: 24px; font-family: sans-serif; }
.mini-player { animation: fade-in var(--dur-medium); }
.mini-player .info { display: flex; align-items: center; gap: var(--sp-sm); min-height: var(--min-touch); color: inherit; font: inherit; }
.mini-player .info .txt { min-width: 0; flex: 1; }
.mini-player .mini-art { width: 48px; height: 48px; border-radius: 10px; flex: none; }
.spinner.small { width: 24px; height: 24px; border-width: 2px; }

/* Row card (ContentCard) and category tile (CategoryCard) */
.btn.big { min-height: 56px; border-radius: var(--r-md); padding: 0 var(--sp-lg); }
.screen-title { padding: var(--sp-sm) 0 var(--sp-md); }
.screen-title h1 { font: 600 28px/36px var(--font-serif); }
.content-row-card { background: var(--surface-container-low, var(--surface-container)); border-radius: var(--r-md); overflow: hidden; }
.content-row { display: flex; align-items: center; gap: var(--sp-md); min-height: 88px; padding: var(--sp-md); color: inherit; text-decoration: none; }
.content-row:hover { background: color-mix(in srgb, currentColor 5%, transparent); }
.content-row .thumb { flex: none; width: 72px; height: 72px; border-radius: var(--r-sm); }
.content-row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.content-row .title { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.content-row .second { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.content-row .meta-line { display: flex; align-items: center; gap: var(--sp-xs); flex-wrap: wrap; }
.content-row-actions { display: flex; flex-wrap: wrap; gap: var(--sp-sm); justify-content: flex-end; padding: 0 var(--sp-md) var(--sp-sm); }
.cat-card { display: block; border-radius: var(--r-md); overflow: hidden; color: #fff; text-decoration: none; min-width: 112px; }
.cat-card .tile { aspect-ratio: 1.2; min-height: 112px; display: block; border-radius: var(--r-md); }
.cat-card .overlay { display: flex; flex-direction: column; gap: 2px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); }
.cat-card .cat-name { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.cat-card .cat-count { opacity: 0.88; }
.cat-card:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
