@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700;12..96,800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Lexend:wght@400;500&display=swap');

/* ---------- Theme tokens (dark is the default) ---------- */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b0e1a;
  --bg-glow: radial-gradient(900px 520px at 88% -8%, rgba(79, 110, 247, .22), transparent 62%), radial-gradient(700px 420px at -5% 4%, rgba(255, 138, 92, .10), transparent 60%);
  --card: #131829;
  --surface-2: #1b2136;
  --field: #0f1322;
  --line: #232a42;
  --line-2: #323b5a;
  --line-3: #4a557e;
  --ink: #eef1fa;
  --ink-2: #c4cade;
  --muted: #8a92af;
  --accent: #8aa4ff;
  --accent-soft: rgba(109, 141, 255, .14);
  --accent-line: rgba(109, 141, 255, .45);
  --btn: #4f6ef7;
  --btn-d: #6380ff;
  --coral: #ff8a5c;
  --coral-soft: rgba(255, 138, 92, .28);
  --ok: #4ade80;
  --ok-bg: rgba(74, 222, 128, .14);
  --ok-line: rgba(74, 222, 128, .3);
  --bad: #f87171;
  --bad-bg: rgba(248, 113, 113, .15);
  --bad-line: rgba(248, 113, 113, .32);
  --stop: #dc2626;
  --stop-d: #ef4444;
  --warm: #fbbf24;
  --warm-bg: rgba(251, 191, 36, .14);
  --topbar: rgba(9, 12, 23, .82);
  --dot: #262e4a;
  --cover-mix: 24%;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-md: 0 12px 28px -14px rgba(0, 0, 0, .7), 0 2px 6px -2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 34px 70px -26px rgba(0, 0, 0, .85), 0 0 0 1px rgba(255, 255, 255, .03);
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #faf9f6;
  --bg-glow: radial-gradient(900px 520px at 88% -8%, rgba(47, 91, 234, .10), transparent 62%), radial-gradient(700px 420px at -5% 4%, rgba(255, 122, 69, .08), transparent 60%);
  --card: #fff;
  --surface-2: #f1efea;
  --field: #fff;
  --line: #ebe9e4;
  --line-2: #dad7cf;
  --line-3: #b9b5aa;
  --ink: #17181c;
  --ink-2: #3d404a;
  --muted: #6c6f7a;
  --accent: #2f5bea;
  --accent-soft: #edf1ff;
  --accent-line: #c8d4fb;
  --btn: #2f5bea;
  --btn-d: #2246c2;
  --coral: #ff7a45;
  --coral-soft: #ffe1d1;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --ok-line: #cdeed8;
  --bad: #c2261b;
  --bad-bg: #fee2e0;
  --bad-line: #fbd3cf;
  --stop: #c2261b;
  --stop-d: #9f1d14;
  --warm: #a16207;
  --warm-bg: #fef6d7;
  --topbar: rgba(23, 24, 34, .94);
  --dot: #d9d6cc;
  --cover-mix: 15%;
  --shadow-sm: 0 1px 2px rgba(23, 24, 28, .05);
  --shadow-md: 0 10px 24px -12px rgba(23, 24, 28, .18), 0 2px 6px -2px rgba(23, 24, 28, .06);
  --shadow-lg: 0 30px 60px -24px rgba(30, 40, 90, .28), 0 8px 20px -10px rgba(30, 40, 90, .12);
}
:root {
  --radius: 14px;
  --display: 'Bricolage Grotesque', 'Plus Jakarta Sans', system-ui, sans-serif;
  --sans: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --read: 'Lexend', 'Plus Jakarta Sans', system-ui, sans-serif;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg-glow), var(--bg); background-repeat: no-repeat; color: var(--ink); font: 15px/1.6 var(--sans); -webkit-font-smoothing: antialiased; transition: background-color .25s, color .25s; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }
h1, h2 { font-family: var(--display); letter-spacing: -.025em; }
h3 { letter-spacing: -.01em; }
svg { width: 18px; height: 18px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--coral-soft); }

/* ---------- Top bar (always dark) ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--topbar); backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid rgba(255, 255, 255, .07); color: #eef1fa; }
.topbar-inner { max-width: 1200px; height: 64px; margin: auto; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 20px; letter-spacing: -.03em; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 10px; color: #fff; background: linear-gradient(140deg, #3f63f2 0%, #6d8dff 55%, #ff8a5c 140%); box-shadow: 0 4px 14px -4px rgba(79, 110, 247, .8); }
.brand-mark svg { width: 17px; height: 17px; stroke-width: 2.4; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
nav { display: flex; gap: 2px; padding: 4px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .06); border-radius: 12px; }
.nav-link { background: none; border: 0; border-radius: 9px; color: #9aa2bf; font-weight: 600; font-size: 14px; padding: 6px 14px; }
.nav-link:hover { color: #fff; }
.nav-link.active { color: #fff; background: rgba(255, 255, 255, .12); }
.theme-toggle { display: grid; place-items: center; width: 38px; height: 38px; padding: 0; border-radius: 11px; border: 1px solid rgba(255, 255, 255, .08); background: rgba(255, 255, 255, .06); color: #c4cade; }
.theme-toggle:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }

.shell { flex: 1; width: 100%; max-width: 1200px; margin: auto; padding: 24px 24px 72px; }

/* ---------- Buttons ---------- */
.primary, .secondary, .stop { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 11px; font-weight: 600; font-size: 14px; padding: 9px 16px; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s, transform .15s; }
.primary { border: 1px solid var(--btn); background: var(--btn); color: #fff; box-shadow: 0 8px 20px -10px var(--btn), inset 0 1px 0 rgba(255, 255, 255, .15); }
.primary:hover { background: var(--btn-d); border-color: var(--btn-d); transform: translateY(-1px); }
.secondary { border: 1px solid var(--line-2); background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.secondary:hover { border-color: var(--line-3); }
.stop { border: 1px solid var(--stop); background: var(--stop); color: #fff; box-shadow: 0 8px 20px -10px var(--stop); }
.stop:hover { background: var(--stop-d); border-color: var(--stop-d); }
.large { padding: 12px 22px; font-size: 15px; }
.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.back { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; color: var(--muted); padding: 4px 6px 4px 0; margin-bottom: 18px; font-size: 14px; font-weight: 600; }
.back svg { width: 16px; height: 16px; }
.back:hover { color: var(--ink); }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font-size: 13px; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Hero ---------- */
.hero {
  position: relative; isolation: isolate;
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 390px); align-items: center; gap: 48px;
  padding: 28px 8px 36px; margin-bottom: 8px;
}
/* Dotted texture fading out from the right */
.hero::before {
  content: ''; position: absolute; inset: 0 -24px; z-index: -1;
  background-image: radial-gradient(var(--dot) 1px, transparent 1px); background-size: 18px 18px;
  -webkit-mask-image: radial-gradient(70% 90% at 78% 45%, #000 0%, transparent 75%);
  mask-image: radial-gradient(70% 90% at 78% 45%, #000 0%, transparent 75%);
}
.eyebrow { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.eyebrow i { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); box-shadow: 0 0 0 3px var(--coral-soft); }
.hero h1 { font-size: clamp(32px, 4vw, 48px); font-weight: 800; line-height: 1.05; letter-spacing: -.035em; margin: 16px 0 12px; }
.mark { position: relative; color: var(--accent); white-space: nowrap; }
.mark::after { content: ''; position: absolute; left: -2%; right: -4%; bottom: .06em; height: .26em; z-index: -1; border-radius: 4px; background: var(--coral-soft); transform: rotate(-1.2deg); }
.hero-copy > p { margin: 0; max-width: 440px; color: var(--muted); font-size: 15px; line-height: 1.6; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.hero-actions .large { padding: 10px 18px; font-size: 14px; }

.hero-visual { position: relative; padding: 40px 16px 28px 22px; }
.hero-demo { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px 14px; box-shadow: var(--shadow-lg); }
.demo-top { display: flex; justify-content: space-between; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.demo-title { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.demo-icon { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); font-size: 14px; }
.demo-live { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; background: var(--bad-bg); color: var(--bad); font-weight: 600; font-size: 12px; }
.demo-live i { width: 6px; height: 6px; border-radius: 50%; background: var(--bad); animation: pulse 1.4s ease-in-out infinite; }
.demo-text { font-family: var(--read); font-size: 18px; line-height: 1.9; margin: 10px 0; }
.demo-heard { padding: 7px 10px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); }
.demo-heard span { display: block; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.demo-heard p { margin: 0; min-height: 20px; font-size: 12.5px; color: var(--ink-2); }
.float-chip { position: absolute; display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-md); font-size: 11.5px; color: var(--muted); }
.chip-acc { top: 0; right: 0; flex-direction: column; align-items: flex-start; gap: 0; padding: 7px 12px; animation: float 6s ease-in-out infinite; }
.chip-acc strong { font-family: var(--display); font-size: 20px; line-height: 1.1; color: var(--ok); font-variant-numeric: tabular-nums; }
.chip-progress { left: 0; bottom: 4px; padding: 6px 12px 6px 8px; font-weight: 600; color: var(--ink-2); animation: float 6s ease-in-out -3s infinite; }
.chip-progress svg { width: 24px; height: 24px; padding: 5px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); }
@keyframes float { 50% { transform: translateY(-6px); } }

/* ---------- Library ---------- */
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding-top: 28px; margin-bottom: 18px; border-top: 1px solid var(--line); scroll-margin-top: 72px; }
.section-head h2 { font-size: 28px; font-weight: 700; margin: 0 0 2px; }
.section-head p { margin: 0; color: var(--muted); font-size: 14.5px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.search { display: flex; align-items: center; gap: 8px; flex: 0 1 340px; background: var(--field); border: 1px solid var(--line-2); border-radius: 11px; padding: 0 12px; color: var(--muted); box-shadow: var(--shadow-sm); }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 16px; height: 16px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 10px 0; color: var(--ink); font-size: 14px; }
.search input::placeholder { color: var(--muted); }
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; }
.segmented button { border: 0; background: none; border-radius: 8px; padding: 5px 14px; font-size: 13px; font-weight: 600; color: var(--muted); }
.segmented button:hover { color: var(--ink); }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }
.result-count { margin-left: auto; font-size: 13px; color: var(--muted); }

.passage-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.passage-card {
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm);
  cursor: pointer; transition: box-shadow .2s, transform .2s, border-color .2s;
}
.passage-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-2); }
.card-cover { position: relative; display: flex; align-items: flex-end; justify-content: space-between; height: 76px; padding: 0 14px 12px; background: color-mix(in srgb, var(--cover, #3b6cff) var(--cover-mix), var(--card)); }
/* Soft highlight in the cover's corner */
.card-cover::after { content: ''; position: absolute; width: 120px; height: 120px; right: -40px; top: -60px; border-radius: 50%; background: color-mix(in srgb, var(--cover, #3b6cff) 18%, transparent); }
.card-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: -26px; border-radius: 14px; background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow-sm); font-size: 24px; transition: transform .2s; }
.passage-card:hover .card-icon { transform: rotate(-6deg) scale(1.05); }
.card-delete { position: absolute; z-index: 1; top: 10px; right: 10px; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 8px; background: color-mix(in srgb, var(--card) 70%, transparent); color: var(--muted); transition: color .15s, background .15s; }
.card-delete svg { width: 15px; height: 15px; }
.card-delete:hover { color: var(--bad); background: var(--card); }
.card-body { display: flex; flex-direction: column; flex: 1; padding: 34px 16px 14px; }
.passage-card h3 { font-size: 15.5px; font-weight: 700; line-height: 1.35; margin: 0 0 4px; }
.passage-card p { margin: 0 0 14px; color: var(--muted); font-size: 13px; line-height: 1.55; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-foot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--line); font-size: 12px; color: var(--muted); }
.badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); color: var(--ink-2); }
.badge-image { background: var(--warm-bg); color: var(--warm); }
.card-open { margin-left: auto; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); color: var(--ink); font-weight: 700; transition: background .15s, color .15s; }
.passage-card:hover .card-open { background: var(--btn); color: #fff; }
.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 48px 20px; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed var(--line-2); border-radius: var(--radius); }
.empty strong { color: var(--ink); }

/* ---------- Editor ---------- */
.editor-panel { max-width: 680px; margin: auto; background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 34px; box-shadow: var(--shadow-md); }
.editor-heading { margin-bottom: 24px; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.editor-heading h1 { font-size: 30px; font-weight: 700; margin: 0 0 4px; }
.editor-heading p { margin: 0; color: var(--muted); }
.field-label { display: block; font-weight: 600; font-size: 14px; color: var(--ink-2); margin: 20px 0 6px; }
.field { width: 100%; border: 1px solid var(--line-2); border-radius: 11px; padding: 10px 12px; color: var(--ink); background: var(--field); box-shadow: var(--shadow-sm); }
.field::placeholder { color: var(--muted); }
.field:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; line-height: 1.65; font-family: var(--read); }
.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.type-option { display: flex; align-items: flex-start; gap: 12px; text-align: left; background: var(--field); border: 1px solid var(--line-2); border-radius: 12px; padding: 13px 14px; }
.type-option svg { margin-top: 2px; color: var(--muted); }
.type-option span { display: flex; flex-direction: column; }
.type-option strong { font-size: 14px; font-weight: 700; }
.type-option small { color: var(--muted); font-size: 12.5px; }
.type-option:hover { border-color: var(--line-3); }
.type-option.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.type-option.selected svg { color: var(--accent); }
#imageFields, #textFields { margin-top: 4px; }
.upload { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 20px; padding: 30px; border: 1.5px dashed var(--line-2); border-radius: 14px; background: var(--surface-2); cursor: pointer; text-align: center; transition: border-color .15s, background .15s; }
.upload svg { width: 22px; height: 22px; color: var(--accent); margin-bottom: 4px; }
.upload strong { font-size: 14px; font-weight: 700; }
.upload:hover { border-color: var(--accent); background: var(--accent-soft); }
.upload small, .helper { color: var(--muted); font-size: 13px; }
.ocr-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.file-chip { display: inline-flex; align-items: center; gap: 8px; min-width: 0; max-width: 100%; padding: 6px 12px; border-radius: 9px; background: var(--surface-2); color: var(--ink-2); font-size: 13px; font-weight: 600; }
.file-chip svg { width: 16px; height: 16px; }
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ocr-status { margin-top: 8px; }
.optional { font-weight: 400; color: var(--muted); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); }
.error { background: var(--bad-bg); color: var(--bad); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin-top: 16px; }

/* ---------- Reader ---------- */
.reader-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.reader-title-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.reader-heading { display: flex; align-items: center; gap: 14px; min-width: 0; }
.reader-icon { display: grid; place-items: center; flex-shrink: 0; width: 46px; height: 46px; border-radius: 14px; font-size: 24px; border: 1px solid var(--line); background: color-mix(in srgb, var(--cover, #3b6cff) var(--cover-mix), var(--card)); }
.reader-title-row h1 { font-size: 30px; font-weight: 700; margin: 0; }
.reader-tag { flex-shrink: 0; border: 1px solid var(--line); background: var(--card); color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 4px 12px; border-radius: 999px; }
.reader-card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 22px 34px 30px; box-shadow: var(--shadow-md); }
.reader-top { display: flex; justify-content: space-between; align-items: center; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.live-dot { display: inline-flex; align-items: center; gap: 7px; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; }
.live-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--line-3); }
.live-dot.active { color: var(--bad); background: var(--bad-bg); }
.live-dot.active i { background: var(--bad); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.word-area { font-family: var(--read); font-size: clamp(21px, 2.2vw, 28px); line-height: 2.1; padding-top: 18px; color: var(--ink); overflow-wrap: anywhere; }

.word { padding: 2px 4px; border-radius: 7px; transition: background .15s, color .15s; }
.word.punct { padding-inline: 0; }
.word.correct { color: var(--ok); background: var(--ok-bg); }
.word.wrong { color: var(--bad); background: var(--bad-bg); text-decoration: underline wavy var(--bad) 1px; text-underline-offset: 6px; }
.word.current { box-shadow: inset 0 -3px 0 var(--coral); }

.heard-box { margin-top: 14px; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.heard-label { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 4px; }
.heard-text { margin: 0; max-height: 78px; overflow-y: auto; font-size: 15px; color: var(--ink-2); }
.heard-text.placeholder { color: var(--muted); }

.reader-controls { display: flex; gap: 10px; margin-top: 16px; }
.reader-message { margin-top: 10px; }

.reader-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 88px; }
.side-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 18px; box-shadow: var(--shadow-sm); }
.side-card h3 { font-size: 14px; font-weight: 700; margin: 0 0 12px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.stat strong { font-family: var(--display); font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat.ok { background: var(--ok-bg); border-color: var(--ok-line); }
.stat.ok strong { color: var(--ok); }
.stat.bad { background: var(--bad-bg); border-color: var(--bad-line); }
.stat.bad strong { color: var(--bad); }
.progress-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 14px; }
.progress-track > div { width: 0; height: 100%; background: linear-gradient(90deg, var(--btn), var(--coral)); border-radius: 99px; transition: width .25s; }
.legend { display: flex; flex-direction: column; gap: 9px; font-size: 13px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; }
.legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 10px; }
.legend-dot.correct { background: var(--ok-bg); border: 1px solid var(--ok); }
.legend-dot.wrong { background: var(--bad-bg); border: 1px solid var(--bad); }
.legend-dot.untouched { background: var(--card); border: 1px solid var(--line-3); }

/* ---------- Footer ---------- */
footer { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 24px 30px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; }
footer strong { font-family: var(--display); color: var(--ink); font-weight: 700; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .passage-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero { gap: 32px; }
}
@media (max-width: 920px) {
  .hero { grid-template-columns: 1fr; gap: 20px; padding: 20px 0 32px; }
  .hero-visual { max-width: 420px; }
}
@media (max-width: 860px) {
  .passage-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .reader-layout { grid-template-columns: 1fr; }
  .reader-side { position: static; }
}
@media (max-width: 580px) {
  .topbar-inner, .shell { padding-inline: 16px; }
  .brand { font-size: 18px; }
  .brand > span:last-child { display: none; }
  .nav-link { padding: 6px 10px; font-size: 13px; }
  .hero { padding: 8px 0 24px; }
  .hero h1 { font-size: 32px; }
  .hero-actions .large { flex: 1 1 auto; }
  .hero-visual { padding: 46px 0 26px; }
  .chip-acc { right: -4px; }
  .chip-progress { left: -4px; }
  .demo-text { font-size: 17px; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .section-head h2 { font-size: 24px; }
  .search { flex: 1 1 100%; }
  .result-count { margin-left: 0; }
  .passage-grid { grid-template-columns: 1fr; gap: 12px; }
  .editor-panel { padding: 20px; }
  .type-switch { grid-template-columns: 1fr; }
  .reader-title-row { flex-direction: column; align-items: flex-start; gap: 10px; }
  .reader-title-row h1 { font-size: 24px; }
  .reader-card { padding: 16px 18px 22px; }
  .reader-controls .large { flex: 1; }
  footer { flex-direction: column; gap: 4px; padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
