:root {
  --bg: #FAF5EC; --surface: #FFFFFF; --surface-2: #F4EDDF; --ink: #211C36; --muted: #6B6580; --line: #E6DCCB;
  --brand: #D9480F; --brand-ink: #FFFFFF; --brand-deep: #A8360A; --gold: #F59F00; --teal: #0C7C86; --indigo: #3B2F8F;
  --ok: #2B8A3E; --ok-bg: #E4F3E6; --bad: #C92A2A; --bad-bg: #FCE9E9;
  --shadow: 0 1px 2px rgba(33, 28, 54, .06), 0 8px 24px rgba(33, 28, 54, .06);
  --r: 18px;
  --ui: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
  --deva: "Tiro Devanagari Hindi", "Nirmala UI", "Noto Sans Devanagari", "Kohinoor Devanagari", "Mangal", serif;
}
:root[data-theme="dark"] {
  --bg: #14121C; --surface: #1E1B2B; --surface-2: #272338; --ink: #F2EDE4; --muted: #A59FB9; --line: #342F48;
  --brand: #FF7A3D; --brand-ink: #1B1020; --brand-deep: #C9541F; --gold: #FFB938; --teal: #46C6CE; --indigo: #A99BFF;
  --ok: #69C97B; --ok-bg: #17301C; --bad: #FF7B7B; --bad-bg: #3A1818;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14121C; --surface: #1E1B2B; --surface-2: #272338; --ink: #F2EDE4; --muted: #A59FB9; --line: #342F48;
    --brand: #FF7A3D; --brand-ink: #1B1020; --brand-deep: #C9541F; --gold: #FFB938; --teal: #46C6CE; --indigo: #A99BFF;
    --ok: #69C97B; --ok-bg: #17301C; --bad: #FF7B7B; --bad-bg: #3A1818;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--ui); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; border-radius: 8px; }
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--display); line-height: 1.15; margin: 0; font-weight: 600; letter-spacing: -.01em; }
.hi { font-family: var(--deva); font-weight: 400; line-height: 1.6; }
.muted { color: var(--muted); }
svg { display: block; }

/* ── shell ── */
#app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100%; }
.nav { position: sticky; top: 0; height: 100vh; padding: 22px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; background: var(--brand); color: #fff; display: grid; place-items: center; font-family: var(--deva); font-size: 26px; line-height: 1; padding-top: 4px; }
.brand-name { font-family: var(--display); font-weight: 700; font-size: 24px; }
.brand-name small { display: block; font-family: var(--ui); font-weight: 500; font-size: 11.5px; color: var(--muted); letter-spacing: .02em; margin-top: -2px; }
.tab { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 12px; font-weight: 600; color: var(--muted); width: 100%; text-align: left; position: relative; }
.tab svg { width: 22px; height: 22px; flex: none; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.on { background: var(--surface); color: var(--brand); box-shadow: var(--shadow); }
.tab .badge { margin-left: auto; background: var(--brand); color: var(--brand-ink); font-size: 12px; font-weight: 700; border-radius: 99px; padding: 1px 8px; }
.view { padding-block: 28px 80px; padding-left: max(28px, env(safe-area-inset-left, 0px)); padding-right: max(28px, env(safe-area-inset-right, 0px)); max-width: 860px; width: 100%; margin: 0 auto; outline: none; }

@media (max-width: 820px) {
  #app { grid-template-columns: minmax(0, 1fr); }
  .nav { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 20; flex-direction: row; justify-content: space-around; padding: 6px max(6px, env(safe-area-inset-right, 0px)) calc(6px + env(safe-area-inset-bottom, 0px)) max(6px, env(safe-area-inset-left, 0px)); border-right: 0; border-top: 1px solid var(--line); background: var(--bg); gap: 0; }
  .brand { display: none; }
  .tab { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; text-align: center; align-items: center; }
  .tab.on { box-shadow: none; background: none; }
  .tab .badge { position: absolute; top: 2px; left: 55%; margin: 0; font-size: 10px; padding: 0 6px; }
  .view { padding-block: 18px 110px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
}

/* ── buttons ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 22px; border-radius: 14px; font-weight: 700; letter-spacing: .01em; background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 0 var(--brand-deep); transition: transform .06s, box-shadow .06s, filter .15s; }
.btn:hover { filter: brightness(1.05); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brand-deep); }
.btn:disabled { background: var(--line); color: var(--muted); box-shadow: none; transform: none; filter: none; }
.btn.ghost { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1.5px var(--line) inset, 0 3px 0 var(--line); }
.btn.ghost:active { box-shadow: 0 0 0 1.5px var(--line) inset; }
.btn.small { padding: 8px 14px; border-radius: 11px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.ok { background: var(--ok); color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.btn.bad { background: var(--bad); color: #fff; box-shadow: 0 4px 0 rgba(0, 0, 0, .25); }
.link { color: var(--teal); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.spk { width: 42px; height: 42px; border-radius: 50%; display: inline-grid; place-items: center; background: var(--surface-2); color: var(--teal); flex: none; transition: transform .1s; }
.spk:hover { transform: scale(1.06); }
.spk svg { width: 22px; height: 22px; }
.spk.small { width: 32px; height: 32px; }
.spk.small svg { width: 17px; height: 17px; }
.spk.huge { width: 112px; height: 112px; background: var(--teal); color: #fff; box-shadow: 0 6px 0 rgba(0, 0, 0, .2); }
.spk.huge svg { width: 52px; height: 52px; }
.spk.slow { font-size: 11px; font-weight: 700; }

/* ── home ── */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: flex; align-items: center; gap: 12px; text-align: left; }
.stat b { font-family: var(--display); font-size: 26px; line-height: 1; display: block; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat .ico { width: 36px; height: 36px; flex: none; }
button.stat:hover { border-color: var(--brand); }
@media (max-width: 640px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.hero { position: relative; overflow: hidden; background: #241E3D; color: #FAF5EC; border-radius: 24px; padding: 26px 28px; display: flex; align-items: center; gap: 20px; margin-bottom: 30px; }
.hero::after { content: "बोलो"; position: absolute; right: -8px; bottom: -46px; font-family: var(--deva); font-size: 150px; opacity: .08; pointer-events: none; }
.hero .eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--gold); }
.hero h1 { font-size: 30px; margin: 4px 0 4px; }
.hero p { margin: 0; opacity: .8; }
.hero .grow { flex: 1; min-width: 0; position: relative; z-index: 1; }
.hero .btn { position: relative; z-index: 1; white-space: nowrap; }
@media (max-width: 640px) { .hero { flex-direction: column; align-items: stretch; padding: 22px; } .hero h1 { font-size: 25px; } }

.notice { background: var(--surface); border: 1.5px dashed var(--gold); border-radius: var(--r); padding: 14px 16px; margin-bottom: 20px; font-size: 14.5px; display: flex; gap: 12px; align-items: flex-start; }
.notice b { display: block; margin-bottom: 2px; }
.notice .x { margin-left: auto; color: var(--muted); font-size: 20px; line-height: 1; padding: 2px 6px; }

.stage { margin: 34px 0 14px; display: flex; align-items: baseline; gap: 12px; border-top: 3px solid var(--ink); padding-top: 10px; }
.stage .num { font-family: var(--display); font-size: 14px; font-weight: 700; color: var(--brand); letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.stage h2 { font-size: 24px; }
.stage p { margin: 0 0 0 auto; color: var(--muted); font-size: 14px; text-align: right; }
@media (max-width: 640px) { .stage { flex-wrap: wrap; } .stage p { margin: 0; width: 100%; text-align: left; } }

.units { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .units { grid-template-columns: minmax(0, 1fr); } }
.unit { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 14px; display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; transition: transform .12s, border-color .12s, box-shadow .12s; position: relative; }
.unit:hover { transform: translateY(-2px); border-color: var(--brand); box-shadow: var(--shadow); }
.unit .tile { width: 56px; height: 56px; border-radius: 16px; flex: none; display: grid; place-items: center; background: var(--surface-2); font-size: 28px; }
.unit .tile.deva { font-family: var(--deva); color: var(--indigo); font-size: 30px; padding-top: 4px; }
.unit .meta { flex: 1; min-width: 0; }
.unit h3 { font-family: var(--ui); font-size: 16.5px; font-weight: 700; letter-spacing: 0; }
.unit .sub { font-size: 13.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit .sub.hi { font-size: 15px; }
.dots { display: flex; gap: 4px; margin-top: 8px; }
.dots i { height: 6px; flex: 1; max-width: 34px; border-radius: 99px; background: var(--line); }
.dots i.on { background: var(--gold); }
.unit.done .dots i.on { background: var(--ok); }
.unit.locked { opacity: .55; }
.unit.locked .tile { filter: grayscale(1); }
.unit.current { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.unit .state { flex: none; color: var(--muted); }
.unit .state svg { width: 20px; height: 20px; }
.unit.done .state { color: var(--ok); }

/* ── sheet (unit detail / onboarding) ── */
.sheet { position: fixed; inset: 0; z-index: 70; background: rgba(20, 16, 36, .5); display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); animation: fade .15s; }
.sheet-card { background: var(--bg); border-radius: 24px; width: min(720px, 100%); max-height: min(92vh, 900px); overflow: auto; overscroll-behavior: contain; box-shadow: 0 24px 80px rgba(0, 0, 0, .35); animation: rise .2s; }
.sheet-head { display: flex; gap: 14px; align-items: center; padding: 20px 22px; position: sticky; top: 0; background: var(--bg); z-index: 2; border-bottom: 1px solid var(--line); }
.sheet-head .tile { width: 52px; height: 52px; border-radius: 15px; background: var(--surface-2); display: grid; place-items: center; font-size: 26px; flex: none; }
.sheet-head .tile.deva { font-family: var(--deva); color: var(--indigo); padding-top: 4px; }
.sheet-head h2 { font-size: 23px; }
.sheet-head p { margin: 0; color: var(--muted); font-size: 14px; }
.sheet-head .x { margin-left: auto; width: 38px; height: 38px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.sheet-head .x svg { width: 18px; height: 18px; }
.sheet-body { padding: 18px 22px 26px; }
.sec-title { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 10px; }
.sec-title:first-child { margin-top: 0; }
.lesson-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; margin-bottom: 8px; }
.lesson-row .n { width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.lesson-row.done .n { background: var(--ok); color: #fff; }
.lesson-row.done .n svg { width: 15px; height: 15px; }
.lesson-row.locked { opacity: .5; }
.lesson-row .t { flex: 1; min-width: 0; }
.lesson-row .t small { display: block; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.lesson-row .t b { font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-row .t b.hi { font-size: 18px; line-height: 1.4; }

.guide { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 6px 20px 10px; font-size: 15.5px; }
.guide p { margin: 12px 0; }
.guide .hi { font-size: 1.2em; color: var(--indigo); }
.guide table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.guide td { padding: 7px 10px 7px 0; border-bottom: 1px solid var(--line); vertical-align: baseline; }
.guide tr:last-child td { border-bottom: 0; }
.guide .ex { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }

.wordlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.wl { display: flex; align-items: center; gap: 10px; text-align: left; padding: 9px 12px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; width: 100%; }
.wl:hover { border-color: var(--teal); }
.wl .hi { font-size: 20px; line-height: 1.3; }
.wl .g { flex: 1; min-width: 0; }
.wl small { display: block; color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.str { display: flex; gap: 2px; flex: none; }
.str i { width: 4px; height: 14px; border-radius: 2px; background: var(--line); }
.str i.on { background: var(--ok); }
.tag { display: inline-block; font-family: var(--ui); font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 6px; vertical-align: middle; margin-left: 6px; line-height: 1.5; }
.tag.m { background: color-mix(in srgb, var(--teal) 16%, transparent); color: var(--teal); }
.tag.f { background: color-mix(in srgb, var(--brand) 16%, transparent); color: var(--brand); }

/* ── generic page bits ── */
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 32px; }
.page-head p { color: var(--muted); margin: 6px 0 0; }
.card { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 20px; margin-bottom: 14px; }
.card h3 { font-size: 19px; margin-bottom: 6px; }
.row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.row .grow { flex: 1; min-width: 180px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.setting { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.setting:last-child { border-bottom: 0; padding-bottom: 0; }
.setting:first-child { padding-top: 0; }
.setting .grow { flex: 1; min-width: 200px; }
.setting b { display: block; }
.setting small { color: var(--muted); font-size: 13.5px; }
select, input[type="search"], input[type="text"] { font: inherit; color: var(--ink); background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 12px; max-width: 100%; }
textarea { font: 13px/1.4 ui-monospace, Consolas, monospace; color: var(--ink); background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; width: 100%; min-height: 96px; resize: vertical; }
input[type="search"] { width: 100%; padding: 13px 16px; font-size: 16.5px; }
input[type="range"] { accent-color: var(--brand); width: 160px; }

.meter { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.meter div { background: var(--surface-2); border-radius: 12px; padding: 10px 8px; text-align: center; }
.meter b { font-family: var(--display); font-size: 22px; display: block; line-height: 1.1; }
.meter span { font-size: 11.5px; color: var(--muted); font-weight: 600; }

.conv { display: flex; gap: 14px; align-items: center; padding: 14px 16px; background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); margin-bottom: 10px; }
.conv .t { flex: 1; min-width: 0; }
.conv .t b { display: block; }
.conv .t small { color: var(--muted); }
.conv.locked { opacity: .5; }
.conv .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.chart { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 8px; margin-bottom: 8px; }
.glyph { background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 4px 6px; text-align: center; }
.glyph:hover { border-color: var(--teal); transform: translateY(-1px); }
.glyph .hi { font-size: 30px; display: block; line-height: 1.35; }
.glyph small { color: var(--muted); font-size: 12.5px; }

/* ── tappable Hindi + romanisation ── */
.hib { display: inline-block; max-width: 100%; }
.hib .hi { font-size: 26px; }
.hib.big .hi { font-size: clamp(40px, 9vw, 64px); line-height: 1.4; }
.hib.mid .hi { font-size: 32px; }
.rom { font-size: 14.5px; color: var(--muted); font-style: italic; letter-spacing: .01em; }
.hib.big .rom { font-size: 18px; }
body[data-rom="off"] .rom { display: none; }
body[data-rom="peek"] .rom { filter: blur(5px); cursor: pointer; user-select: none; transition: filter .15s; }
body[data-rom="peek"] .rom.show { filter: none; }
.w { cursor: help; border-bottom: 2px dotted color-mix(in srgb, var(--teal) 55%, transparent); padding-bottom: 1px; }
.w:hover { background: color-mix(in srgb, var(--teal) 12%, transparent); border-radius: 4px; }
.nogloss .w, .opt .w, .chip .w, .mbtn .w, .wl .w, .glyph .w { cursor: inherit; border-bottom: 0; background: none; }
.pop { position: absolute; z-index: 80; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 10px 14px; max-width: 260px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); animation: rise .12s; }
.pop .hi { font-size: 24px; line-height: 1.3; }
.pop i { opacity: .75; font-size: 13.5px; margin-left: 8px; }
.pop div { font-size: 14.5px; font-weight: 500; }

/* ── player ── */
.player { position: fixed; inset: 0; z-index: 60; background: var(--bg); display: flex; flex-direction: column; animation: fade .15s; }
.p-top { display: flex; align-items: center; gap: 14px; padding: calc(16px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-right, 0px)) 16px max(20px, env(safe-area-inset-left, 0px)); max-width: 760px; width: 100%; margin: 0 auto; }
.p-top .x { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.p-top .x:hover { background: var(--surface-2); }
.p-top .x svg { width: 18px; height: 18px; }
.bar { flex: 1; height: 14px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), var(--brand)); border-radius: 99px; transition: width .35s cubic-bezier(.3, 1.3, .6, 1); min-width: 14px; }
.p-top .count { font-weight: 700; color: var(--muted); font-size: 14px; min-width: 44px; text-align: right; }
.p-body { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 8px max(20px, env(safe-area-inset-right, 0px)) 24px max(20px, env(safe-area-inset-left, 0px)); }
.ex { max-width: 640px; margin: 0 auto; animation: slide .22s; }
.ask { font-family: var(--display); font-size: 25px; font-weight: 600; margin: 6px 0 20px; }
.ask small { display: block; font-family: var(--ui); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 4px; }
.prompt { display: flex; align-items: center; gap: 16px; margin-bottom: 26px; min-height: 64px; }
.prompt.center { justify-content: center; flex-direction: column; text-align: center; margin: 14px 0 30px; }
.prompt .en { font-size: 23px; font-weight: 600; }
.prompt .roman { font-family: var(--display); font-size: 54px; font-weight: 600; color: var(--indigo); }
.note { display: inline-block; font-size: 12.5px; font-weight: 600; color: var(--teal); background: color-mix(in srgb, var(--teal) 13%, transparent); border-radius: 8px; padding: 2px 9px; margin-top: 6px; }
.audio-pair { display: flex; align-items: flex-end; gap: 12px; justify-content: center; }

.opts { display: grid; gap: 10px; }
.opts.grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opt { display: flex; align-items: center; gap: 12px; text-align: left; padding: 14px 16px; background: var(--surface); border-radius: 15px; box-shadow: 0 0 0 1.5px var(--line) inset, 0 3px 0 var(--line); font-weight: 500; font-size: 16.5px; width: 100%; transition: transform .06s; }
.opt:hover { box-shadow: 0 0 0 1.5px var(--muted) inset, 0 3px 0 var(--line); }
.opt:active { transform: translateY(2px); }
.opt .key { width: 26px; height: 26px; border-radius: 8px; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: 12.5px; font-weight: 700; color: var(--muted); flex: none; }
.opt .hi { font-size: 24px; line-height: 1.35; }
.opt .rom { font-size: 13.5px; }
.opts.bigopts .opt { justify-content: center; padding: 18px 12px; }
.opts.bigopts .opt .hi { font-size: 44px; }
.opts.bigopts .opt .key { position: absolute; left: 12px; top: 12px; }
.opts.bigopts .opt { position: relative; }
.opts.roman .opt { justify-content: center; font-size: 22px; font-weight: 600; position: relative; padding: 18px 12px; }
.opts.roman .opt .key { position: absolute; left: 12px; top: 12px; }
.opt.sel { box-shadow: 0 0 0 2.5px var(--teal) inset, 0 3px 0 var(--teal); background: color-mix(in srgb, var(--teal) 9%, var(--surface)); }
.opt.right { box-shadow: 0 0 0 2.5px var(--ok) inset, 0 3px 0 var(--ok); background: var(--ok-bg); }
.opt.wrong { box-shadow: 0 0 0 2.5px var(--bad) inset, 0 3px 0 var(--bad); background: var(--bad-bg); }
.locked-ui .opt, .locked-ui .chip, .locked-ui .mbtn { pointer-events: none; }

.answer-line { min-height: 66px; border-bottom: 2px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0 10px; margin-bottom: 26px; align-content: flex-start; }
.bank { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { padding: 9px 14px; background: var(--surface); border-radius: 13px; box-shadow: 0 0 0 1.5px var(--line) inset, 0 3px 0 var(--line); font-weight: 500; font-size: 16.5px; animation: pop .15s; }
.chip.hi { font-size: 23px; padding: 5px 14px 3px; line-height: 1.5; }
.chip.used { visibility: hidden; }
.chip:active { transform: translateY(2px); }

.cloze-line { font-size: 30px; margin-bottom: 4px; }
.cloze-line .hi { font-size: 34px; }
.blank { display: inline-block; min-width: 90px; border-bottom: 3px solid var(--brand); text-align: center; color: var(--brand); padding: 0 8px; margin: 0 4px; line-height: 1.35; }

.match { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
.mbtn { padding: 13px 12px; background: var(--surface); border-radius: 14px; box-shadow: 0 0 0 1.5px var(--line) inset, 0 3px 0 var(--line); font-weight: 500; min-height: 58px; width: 100%; }
.mbtn.hi { font-size: 24px; padding: 6px 12px 4px; }
.mbtn.sel { box-shadow: 0 0 0 2.5px var(--teal) inset, 0 3px 0 var(--teal); }
.mbtn.gone { opacity: .35; pointer-events: none; box-shadow: 0 0 0 1.5px var(--ok) inset; background: var(--ok-bg); }
.mbtn.shake { animation: shake .3s; box-shadow: 0 0 0 2.5px var(--bad) inset, 0 3px 0 var(--bad); }

.intro-card { background: var(--surface); border: 1.5px solid var(--line); border-radius: 24px; padding: 30px 24px; text-align: center; box-shadow: var(--shadow); }
.intro-card .mean { font-size: 22px; font-weight: 600; margin-top: 10px; }
.intro-card .hint { color: var(--muted); margin-top: 4px; }
.intro-card .audio-pair { margin-top: 18px; }
.trace { margin-top: 20px; }
.trace canvas { background: var(--surface-2); border-radius: 18px; touch-action: none; cursor: crosshair; max-width: 100%; }
.trace small { display: block; color: var(--muted); margin-bottom: 8px; }

.chatlog { display: flex; flex-direction: column; gap: 10px; margin-bottom: 22px; }
.bubble { max-width: 86%; padding: 10px 14px 8px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--line); border-bottom-left-radius: 6px; align-self: flex-start; display: flex; gap: 10px; align-items: flex-start; }
.bubble.you { align-self: flex-end; background: color-mix(in srgb, var(--teal) 12%, var(--surface)); border-color: color-mix(in srgb, var(--teal) 35%, var(--line)); border-radius: 18px; border-bottom-right-radius: 6px; }
.bubble .hi { font-size: 21px; }
.bubble .tr { font-size: 13.5px; color: var(--muted); }
.bubble.pending { border-style: dashed; color: var(--muted); font-weight: 600; }
.bubble.playing { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 30%, transparent); }
.scene-box { background: var(--surface-2); border-radius: 16px; padding: 14px 16px; margin-bottom: 18px; color: var(--muted); font-style: italic; }
.cue { font-weight: 700; margin: 4px 0 12px; }
.cue small { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }

.speak-box { text-align: center; background: var(--surface); border: 1.5px solid var(--line); border-radius: 24px; padding: 26px 20px; }
.speak-box .en-cue { font-size: 22px; font-weight: 600; margin-bottom: 10px; }
.speak-box .tr { color: var(--muted); margin-top: 6px; }
.mic { width: 84px; height: 84px; border-radius: 50%; background: var(--brand); color: #fff; display: inline-grid; place-items: center; box-shadow: 0 6px 0 var(--brand-deep); margin: 22px 10px 8px; }
.mic svg { width: 36px; height: 36px; }
.mic.live { animation: pulse 1s infinite; background: var(--bad); }
.heard { min-height: 24px; margin-top: 8px; font-size: 15px; color: var(--muted); }
.heard .hi { font-size: 20px; color: var(--ink); }

.p-foot { border-top: 1.5px solid var(--line); padding: 16px max(20px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); }
.p-foot .in { max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 16px; }
.p-foot .fb { flex: 1; min-width: 0; }
.p-foot .fb h4 { margin: 0; font-family: var(--display); font-size: 21px; display: flex; align-items: center; gap: 8px; }
.p-foot .fb .hi { font-size: 22px; }
.p-foot .fb .tr { font-size: 14.5px; }
.p-foot .fb .rom { font-size: 13.5px; }
.p-foot.ok { background: var(--ok-bg); border-color: transparent; }
.p-foot.ok h4 { color: var(--ok); }
.p-foot.bad { background: var(--bad-bg); border-color: transparent; }
.p-foot.bad h4 { color: var(--bad); }
.p-foot .skip { color: var(--muted); font-weight: 600; font-size: 14.5px; }
.p-foot .btn { margin-left: auto; min-width: 150px; }
@media (max-width: 560px) { .p-foot .in { flex-direction: column; align-items: stretch; } .p-foot .btn { margin: 0; } .opts.grid { grid-template-columns: minmax(0, 1fr); } .opts.grid.bigopts, .opts.grid.roman { grid-template-columns: repeat(2, minmax(0, 1fr)); } .ask { font-size: 22px; } }

.finish { max-width: 520px; margin: 6vh auto 0; text-align: center; animation: rise .3s; }
.finish .burst { font-family: var(--deva); font-size: 84px; line-height: 1.2; color: var(--brand); }
.finish h1 { font-size: 34px; margin: 6px 0; }
.finish .trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 26px 0; }
.finish .trio div { background: var(--surface); border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 8px; }
.finish .trio b { font-family: var(--display); font-size: 28px; display: block; line-height: 1.1; }
.finish .trio span { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }

.onb { padding: 30px 28px; text-align: center; }
.onb .burst { font-family: var(--deva); font-size: 64px; color: var(--brand); line-height: 1.2; }
.onb h2 { font-size: 28px; margin: 4px 0 8px; }
.onb p { color: var(--muted); margin: 0 auto 20px; max-width: 460px; }
.choices { display: grid; gap: 10px; text-align: left; }
.choice { padding: 15px 18px; background: var(--surface); border-radius: 16px; box-shadow: 0 0 0 1.5px var(--line) inset, 0 3px 0 var(--line); width: 100%; text-align: left; }
.choice:hover { box-shadow: 0 0 0 2px var(--brand) inset, 0 3px 0 var(--brand); }
.choice b { display: block; font-size: 17px; }
.choice small { color: var(--muted); font-size: 14px; }
.steps { display: flex; gap: 6px; justify-content: center; margin-bottom: 18px; }
.steps i { width: 28px; height: 5px; border-radius: 9px; background: var(--line); }
.steps i.on { background: var(--brand); }

.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 600; z-index: 100; animation: fade .2s; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes slide { from { opacity: 0; transform: translateX(24px); } }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes pulse { 50% { box-shadow: 0 0 0 14px color-mix(in srgb, var(--bad) 22%, transparent); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ── letters ── */
.tab-deva { font-family: var(--deva); font-size: 22px; line-height: 22px; width: 22px; height: 22px; text-align: center; flex: none; padding-top: 2px; }
.glyph { position: relative; }
.glyph .sg { font-style: normal; font-size: .62em; color: var(--muted); margin-left: 2px; }
.glyph.say { border-style: dashed; }
.glyph.flag { border-color: var(--gold); }
.chart.wide { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); }
.sdot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.sdot.s1 { background: var(--gold); } .sdot.s2 { background: color-mix(in srgb, var(--gold) 50%, var(--ok)); } .sdot.s3, .sdot.s4 { background: var(--ok); }
.secnote { margin: -4px 0 10px; font-size: 14px; }
.big-inline { font-size: 1.35em; color: var(--indigo); }
.tablewrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 14.5px; }
table.grid th { text-align: left; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 6px 10px 6px 0; white-space: nowrap; }
table.grid td { padding: 5px 10px 5px 0; border-top: 1px solid var(--line); vertical-align: middle; }
table.grid td.hi, table.grid .cell { font-size: 26px; line-height: 1.5; }
table.grid .cell { padding: 0 8px; border-radius: 8px; }
table.grid .cell:hover { background: var(--surface-2); color: var(--teal); }
.markrow { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); }
.markrow:first-of-type { border-top: 0; }
.markrow > .glyph { width: 92px; flex: none; }
.markrow .pairs { display: flex; gap: 6px; flex: none; }
.markrow .pairs .glyph { width: 62px; }
.guide-text { font-size: 14.5px; color: var(--muted); margin-top: 3px; }
.guide-text .hi, .guide-text b { color: var(--ink); }
.guide-text .hi { font-size: 1.25em; }
.mbar { height: 6px; background: var(--line); border-radius: 9px; margin: 6px 0 2px; max-width: 260px; overflow: hidden; }
.mbar i { display: block; height: 100%; background: var(--ok); border-radius: 9px; }
.conv .t small { display: block; }
.dec { background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.dec-head { display: flex; align-items: center; gap: 14px; }
.dec-word { font-size: 38px; line-height: 1.3; }
.aks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 14px; }
.ak { background: var(--surface-2); border-radius: 14px; padding: 10px 12px 12px; }
.ak-top { display: flex; align-items: baseline; gap: 10px; width: 100%; text-align: left; border-bottom: 1.5px solid var(--line); padding-bottom: 4px; margin-bottom: 8px; }
.ak-top .hi { font-size: 34px; line-height: 1.35; color: var(--indigo); }
.ak-top i { color: var(--muted); font-size: 16px; }
.ak-top:hover .hi { color: var(--teal); }
.part { display: flex; gap: 10px; align-items: flex-start; padding: 4px 0; }
.part .pg { font-size: 22px; line-height: 1.3; width: 34px; text-align: center; flex: none; }
.part b { font-size: 14px; display: block; line-height: 1.3; }
.part small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.35; }
.part.silent { opacity: .6; }
.ak-note { margin-top: 8px; font-size: 12.5px; color: var(--teal); font-weight: 600; line-height: 1.35; }
.pop-link { display: block; margin-top: 6px; font-size: 12.5px; font-weight: 700; color: var(--gold); text-decoration: underline; text-underline-offset: 3px; }
@media (max-width: 820px) { .tab { font-size: 10.5px; } }
@media (max-width: 560px) { .markrow { flex-direction: column; gap: 6px; } .markrow > .glyph { width: 110px; } }

/* ── writing trainer ── */
.wr { text-align: center; --wr-faint: color-mix(in srgb, var(--ink) 14%, var(--surface-2)); }
.wr-steps { display: inline-flex; flex-wrap: wrap; justify-content: center; gap: 2px; background: var(--surface-2); border-radius: 14px; padding: 4px; margin-bottom: 12px; max-width: 100%; }
.wr-steps button { display: flex; align-items: center; gap: 7px; padding: 7px 12px; border-radius: 10px; font-weight: 600; font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.wr-steps b { width: 20px; height: 20px; border-radius: 50%; background: var(--line); color: var(--ink); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.wr-steps button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.wr-steps button.got b { background: var(--ok); color: var(--surface); }
.wr-pad { width: min(100%, 380px); aspect-ratio: 1; margin: 0 auto; background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 22px; overflow: hidden; touch-action: none; overscroll-behavior: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.wr.compact .wr-pad { width: min(100%, 300px); }
.wr-pad svg { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; cursor: crosshair; }
.wr-cross { fill: none; stroke: var(--line); stroke-width: .5; stroke-dasharray: 1.6 1.6; }
.wr-top { fill: none; stroke: color-mix(in srgb, var(--teal) 50%, transparent); stroke-width: .6; }
.wr-t { fill: none; stroke: var(--wr-faint); stroke-width: 6.4; stroke-linecap: round; stroke-linejoin: round; }
.wr-t.dot { stroke: none; fill: var(--wr-faint); }
.wr-t.cur { stroke: color-mix(in srgb, var(--indigo) 36%, var(--surface-2)); }
.wr-t.dot.cur { fill: color-mix(in srgb, var(--indigo) 36%, var(--surface-2)); }
.wr-t.done, .wr-t.good { stroke: color-mix(in srgb, var(--ok) 34%, var(--surface-2)); }
.wr-t.dot.done, .wr-t.dot.good { fill: color-mix(in srgb, var(--ok) 34%, var(--surface-2)); }
.wr-t.miss { stroke: color-mix(in srgb, var(--bad) 62%, var(--surface-2)); }
.wr-t.dot.miss { fill: color-mix(in srgb, var(--bad) 62%, var(--surface-2)); }
.wr-t.play { stroke: var(--indigo); stroke-width: 5.2; }
.wr-t.dot.play { fill: var(--indigo); }
.wr-ink { fill: none; stroke: var(--brand); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; pointer-events: none; }
.wr-ink.kept { stroke: var(--ink); stroke-width: 2.6; }
.wr-ink.stray { stroke: var(--bad); }
.wr-ink.bad { stroke: var(--bad); animation: wr-out .42s forwards; }
.wr-badge circle { fill: var(--indigo); }
.wr-badge text { fill: var(--surface); font: 700 4.2px var(--ui); text-anchor: middle; }
.wr-badge.start circle { fill: var(--brand); transform-box: fill-box; transform-origin: center; animation: wr-pulse 1.5s ease-in-out infinite; }
.wr-arrow { fill: none; stroke: var(--indigo); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.wr-pen { fill: var(--brand); }
.wr-tpl, .wr-hint, .wr-demo, .wr-guides { pointer-events: none; }
.wr-msg { min-height: 24px; margin: 12px 0 6px; font-weight: 600; }
.wr-msg.ok { color: var(--ok); }
.wr-msg.bad { color: var(--bad); }
.wr-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 27px; }
.wr-chip { font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.wr-chip.ok { background: var(--ok-bg); color: var(--ok); }
.wr-chip.bad { background: var(--bad-bg); color: var(--bad); }
.wr-chip.warn { background: color-mix(in srgb, var(--gold) 24%, var(--surface)); color: var(--ink); }
.wr-bar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 12px; }
@keyframes wr-pulse { 50% { transform: scale(1.22); } }
@keyframes wr-out { to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .wr-badge.start circle { animation: none; } }

/* progress on the Letters tab */
.lprog { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.lprog button { text-align: left; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 9px 12px; min-width: 0; }
.lprog button:hover { border-color: var(--teal); }
.lprog small { display: block; color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lprog b { font-family: var(--display); font-size: 21px; line-height: 1.25; }
.lprog b span { font: 600 12.5px var(--ui); color: var(--muted); }
.lprog .mbar { margin: 6px 0 4px; max-width: none; }
.lprog .w .mbar i, .pstat .steps.w i.on, .wpip i.on, .wsteps i.on { background: var(--indigo); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; color: var(--muted); font-size: 12.5px; margin: 0 0 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .sdot, .legend .wpip { position: static; }
.wpip { position: absolute; top: 7px; left: 7px; display: flex; gap: 2px; }
.wpip i { width: 5px; height: 5px; border-radius: 1.5px; background: var(--line); }
.wsteps { display: flex; gap: 3px; justify-content: center; margin-top: 5px; }
.wsteps i { width: 14px; height: 4px; border-radius: 2px; background: var(--line); }
.pstat { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 12px 0 2px; }
.pstat > * { text-align: left; background: var(--surface-2); border-radius: 12px; padding: 9px 12px; min-width: 0; }
.pstat small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pstat .steps { display: flex; gap: 3px; margin: 6px 0 4px; }
.pstat .steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.pstat .steps i.on { background: var(--ok); }
.pstat b { font-size: 13.5px; }
.trace canvas { width: min(100%, 300px); aspect-ratio: 1; }
@media (max-width: 560px) {
  .lprog { gap: 6px; }
  .lprog button { padding: 7px 9px; border-radius: 12px; }
  .lprog .note { display: none; }
  .lprog b { font-size: 18px; }
  .lprog .mbar { margin-bottom: 1px; }
  .wr-steps button { padding: 6px 9px; gap: 5px; font-size: 13px; }
}
