/* Monsoon: rain-washed teal and storm slate on misty paper; "night rain" in dark mode. */
:root,
[data-theme-preview='light'] {
  --bg: #f2f5f3;
  --surface: #fbfcfb;
  --surface-2: #e8eeeb;
  --line: #d9e1dd;
  --text: #13262b;
  --muted: #53676b;
  --faint: #91a2a1;
  --accent: #1d6b66;
  --accent-soft: #dcebe7;
  --sun: #c98a2e; /* a little marigold, used sparingly */
  --good: #2b7a4b;
  --good-soft: #e0f0e5;
  --bad: #b3372f;
  --bad-soft: #f7e3e1;
  --sky-1: #173b42;
  --sky-2: #2a6463;
  --sky-text: #eef6f3;
  --rain: rgba(225, 242, 238, 0.22);
  --on-accent: #fff;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 40, 45, 0.05), 0 4px 14px rgba(15, 40, 45, 0.05);
  --nf: system-ui;
  --ui: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #0e181b;
    --surface: #142226;
    --surface-2: #1b2c31;
    --line: #26393e;
    --text: #e2ece9;
    --muted: #9cb1ae;
    --faint: #62777a;
    --accent: #6cc3b5;
    --accent-soft: #173733;
    --sun: #e2a74f;
    --good: #6cc191;
    --good-soft: #1a3326;
    --bad: #ec7d74;
    --bad-soft: #3b2220;
    --sky-1: #0b1f25;
    --sky-2: #17403f;
    --sky-text: #e2ece9;
    --rain: rgba(170, 220, 210, 0.16);
    --on-accent: #0e181b;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme='dark'],
[data-theme-preview='dark'] {
  --bg: #0e181b;
  --surface: #142226;
  --surface-2: #1b2c31;
  --line: #26393e;
  --text: #e2ece9;
  --muted: #9cb1ae;
  --faint: #62777a;
  --accent: #6cc3b5;
  --accent-soft: #173733;
  --sun: #e2a74f;
  --good: #6cc191;
  --good-soft: #1a3326;
  --bad: #ec7d74;
  --bad-soft: #3b2220;
  --sky-1: #0b1f25;
  --sky-2: #17403f;
  --sky-text: #e2ece9;
  --rain: rgba(170, 220, 210, 0.16);
  --on-accent: #0e181b;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- extra themes (Settings → Themes) ---------- */
:root[data-theme='jasmine'],
[data-theme-preview='jasmine'] {
  --bg: #f8f4ec; --surface: #fffdf8; --surface-2: #efe8da; --line: #e3d9c6;
  --text: #2a2118; --muted: #6e604f; --faint: #a89a85;
  --accent: #a8561a; --accent-soft: #f5e3cf; --sun: #d4a017;
  --good: #4b7f3a; --good-soft: #e4efd9; --bad: #b33a2f; --bad-soft: #f7e2dc;
  --sky-1: #6e3510; --sky-2: #c07a2c; --sky-text: #fff6e8; --rain: rgba(255, 240, 220, 0.22);
  --on-accent: #fff; color-scheme: light;
}
:root[data-theme='lotus'],
[data-theme-preview='lotus'] {
  --bg: #f8f1f2; --surface: #fffafa; --surface-2: #f0e3e6; --line: #e6d3d8;
  --text: #2b1a20; --muted: #6f5560; --faint: #a88f98;
  --accent: #a8355f; --accent-soft: #f6dde7; --sun: #d08a3a;
  --good: #3f7f55; --good-soft: #e0efe5; --bad: #b3372f; --bad-soft: #f7e3e1;
  --sky-1: #4e1b33; --sky-2: #a3456e; --sky-text: #fff0f5; --rain: rgba(255, 228, 238, 0.22);
  --on-accent: #fff; color-scheme: light;
}
:root[data-theme='tea'],
[data-theme-preview='tea'] {
  --bg: #f1f4ec; --surface: #fbfcf7; --surface-2: #e4ebdb; --line: #d5dfca;
  --text: #1d2a17; --muted: #56664b; --faint: #93a187;
  --accent: #3d7428; --accent-soft: #dfeccf; --sun: #c98a2e;
  --good: #2b7a4b; --good-soft: #e0f0e5; --bad: #b3372f; --bad-soft: #f7e3e1;
  --sky-1: #203a17; --sky-2: #4f7a35; --sky-text: #f1f8e8; --rain: rgba(230, 245, 220, 0.22);
  --on-accent: #fff; color-scheme: light;
}
:root[data-theme='ink'],
[data-theme-preview='ink'] {
  --bg: #ffffff; --surface: #ffffff; --surface-2: #f0f0f0; --line: #d4d4d4;
  --text: #111111; --muted: #4a4a4a; --faint: #8a8a8a;
  --accent: #1f1f1f; --accent-soft: #ececec; --sun: #b8860b;
  --good: #1e7a3c; --good-soft: #e2f1e6; --bad: #b3261e; --bad-soft: #f8e1df;
  --sky-1: #161616; --sky-2: #3a3a3a; --sky-text: #f5f5f5; --rain: rgba(255, 255, 255, 0.2);
  --on-accent: #fff; color-scheme: light;
}
:root[data-theme='indigo'],
[data-theme-preview='indigo'] {
  --bg: #0f1222; --surface: #161a2e; --surface-2: #1e2340; --line: #2a3052;
  --text: #e4e6f5; --muted: #a0a6c8; --faint: #666d94;
  --accent: #9aa8ff; --accent-soft: #252c55; --sun: #f0b860;
  --good: #7fd19b; --good-soft: #1b3326; --bad: #f08a80; --bad-soft: #3b2224;
  --sky-1: #0b0e22; --sky-2: #2a2f6b; --sky-text: #e4e6f5; --rain: rgba(200, 210, 255, 0.16); --on-accent: #0f1222;
  --shadow: none; color-scheme: dark;
}
:root[data-theme='diya'],
[data-theme-preview='diya'] {
  --bg: #17110c; --surface: #211912; --surface-2: #2b2118; --line: #3a2d21;
  --text: #f3e7d7; --muted: #c3ad93; --faint: #7f6c58;
  --accent: #f0a64a; --accent-soft: #3a2915; --sun: #f0c060;
  --good: #8cc98a; --good-soft: #1f3020; --bad: #f08a74; --bad-soft: #3d221b;
  --sky-1: #1f120a; --sky-2: #5b3418; --sky-text: #fbe9d2; --rain: rgba(255, 220, 170, 0.16); --on-accent: #17110c;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  overflow-x: clip;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--ui);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 0.5em; font-weight: 650; letter-spacing: -0.01em; }
h1, h2 { font-family: var(--serif); font-weight: 560; letter-spacing: -0.015em; font-variation-settings: 'SOFT' 60; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 0.8em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 0.875rem; }
.tiny { font-size: 0.78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-in { max-width: 1040px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 12px; }
.brand { font-family: var(--serif); font-weight: 600; font-size: 1.3rem; text-decoration: none; display: flex; align-items: center; gap: 8px; letter-spacing: -0.02em; font-variation-settings: 'SOFT' 100; }
.brand-mark { width: 22px; height: 26px; color: var(--accent); display: grid; place-items: center; }
.brand-mark svg { width: 100%; height: 100%; }
.topbar .spacer { flex: 1; }
.topbar .lang-pill { text-decoration: none; padding: 4px 10px; border-radius: 99px; background: var(--surface-2); font-size: 0.9rem; white-space: nowrap; }
.user-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 0.9rem; text-decoration: none; white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; }

.subnav { border-bottom: 1px solid var(--line); background: var(--bg); }
.subnav-in { max-width: 1040px; margin: 0 auto; padding: 0 12px; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.subnav-in::-webkit-scrollbar { display: none; }
.subnav a { text-decoration: none; padding: 12px 10px; color: var(--muted); font-size: 0.93rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.subnav a.on { color: var(--text); border-color: var(--accent); }
.subnav a .badge { margin-left: 4px; }

main { max-width: 1040px; margin: 0 auto; padding: 28px 16px 80px; }
main.narrow { max-width: 720px; }
.footer { max-width: 1040px; margin: 0 auto; padding: 24px 16px 40px; color: var(--faint); font-size: 0.85rem; border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 8px 18px; }
.footer a { color: var(--muted); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.section { margin-top: 36px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.section-head h2 { margin: 0; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
a.card { text-decoration: none; display: block; transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); transform: translateY(-1px); }
.card.flat { box-shadow: none; background: var(--surface-2); border-color: transparent; }
.card h3 { margin-bottom: 4px; }

/* ---------- buttons & inputs ---------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 10px;
  cursor: pointer; font-weight: 550; display: inline-flex; align-items: center; gap: 8px; text-decoration: none;
  transition: background 0.15s, border-color 0.15s; line-height: 1.2;
}
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn.primary:hover { opacity: 0.9; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.small { padding: 5px 10px; font-size: 0.88rem; border-radius: 8px; }
.btn.big { padding: 13px 22px; font-size: 1.05rem; }
.btn.block { width: 100%; justify-content: center; }
.link-btn { background: none; border: 0; padding: 4px 6px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
.link-btn:hover { color: var(--text); }
.quiet { margin-top: 18px; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  display: inline-grid; place-items: center; cursor: pointer; flex: none; color: var(--text); padding: 0;
}
.icon-btn:hover { border-color: var(--faint); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.lg { width: 52px; height: 52px; }
.icon-btn svg { width: 50%; height: 50%; }
.icon-btn.playing { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.icon-btn.rec { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 0.88rem; color: var(--muted); margin-bottom: 4px; }
input[type='text'], input[type='password'], input[type='search'], input[type='number'], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; cursor: pointer; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 7px 12px; cursor: pointer; font-size: 0.9rem; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--text); color: var(--bg); }

.badge { display: inline-block; font-size: 0.75rem; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--muted); font-weight: 550; vertical-align: middle; }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.badge.good { background: var(--good-soft); color: var(--good); }

.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 65%, var(--surface)), var(--accent)); border-radius: 99px; transition: width 0.5s cubic-bezier(.3,.7,.3,1); }
.bar.good > i { background: var(--good); }

/* ---------- native text ---------- */
.nt { font-family: var(--nf), var(--ui); font-weight: 500; }
.nt.rtl { direction: rtl; unicode-bidi: isolate; }
.lang-ur .nt { line-height: 2.1; font-weight: 400; }
.roman { color: var(--muted); font-style: normal; }
.roman.tap { filter: blur(5px); cursor: pointer; user-select: none; transition: filter 0.2s; }
.roman.tap.shown { filter: none; }
.en { color: var(--text); }

/* ---------- home ---------- */

.lang-card { position: relative; min-height: 132px; display: flex !important; flex-direction: column; }
.lang-card .native { font-size: 1.9rem; line-height: 1.5; margin-bottom: 2px; }
.lang-card .meta { color: var(--muted); font-size: 0.85rem; margin-top: auto; }
.lang-card .bar { margin-top: 10px; }
.how { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.how .card h3 { font-size: 1rem; }

/* ---------- language home ---------- */
.lang-head { display: flex; gap: 18px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.lang-head .native { font-size: 2.6rem; line-height: 1.3; }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 16px 0; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 16px; min-width: 120px; }
.stat b { display: block; font-size: 1.35rem; font-weight: 650; }
.stat span { color: var(--muted); font-size: 0.82rem; }
.next-card {
  display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: linear-gradient(135deg, var(--accent-soft), var(--surface) 70%);
}
.unit-list { display: grid; gap: 8px; }
.unit-row {
  display: grid; grid-template-columns: 38px 1fr auto; gap: 14px; align-items: center; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
}
.unit-row:hover { border-color: var(--faint); }
button.unit-row { width: 100%; text-align: left; font: inherit; cursor: pointer; }
.unit-num { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); display: grid; place-items: center; font-weight: 650; font-size: 0.9rem; color: var(--muted); }
.unit-row.done .unit-num { background: var(--good-soft); color: var(--good); }
.unit-row.started .unit-num { background: var(--accent-soft); color: var(--accent); }
.unit-row .t { font-weight: 600; }
.unit-row .g { color: var(--muted); font-size: 0.88rem; }
.parts { display: flex; gap: 4px; }
.parts i { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.parts i.on { background: var(--good); }
.week { display: flex; gap: 6px; align-items: flex-end; height: 64px; }
.week div { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.week i { width: 100%; max-width: 28px; background: var(--accent); border-radius: 4px 4px 2px 2px; min-height: 2px; opacity: 0.85; }
.week i.zero { background: var(--line); }
.week span { font-size: 0.7rem; color: var(--faint); }

/* ---------- items ---------- */
.items { display: grid; gap: 8px; }
.item { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.item .nt { font-size: 1.35rem; line-height: 1.5; }
.lang-ur .item .nt { font-size: 1.45rem; }
.item .roman { font-size: 0.95rem; }
.item .en { font-size: 0.95rem; }
.item .note { font-size: 0.82rem; color: var(--faint); }
.item .line1 { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.item .pos { font-size: 0.72rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.04em; }
.item.phrase .nt { font-size: 1.2rem; }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 18px 0 20px; }
.tabs button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer; font-size: 0.92rem; }
.tabs button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.tabs button .tick { color: var(--good); margin-left: 4px; }
.tabs button.on .tick { color: inherit; }

.prose { max-width: 70ch; }
.prose p { margin: 0 0 0.9em; }
.prose ul { padding-left: 1.2em; margin: 0 0 0.9em; }
.prose code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 0.9em; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 0.85rem; }

.grammar { margin-bottom: 28px; }
.examples { margin-top: 10px; display: grid; gap: 6px; }
.ex { display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center; padding: 8px 12px; background: var(--surface-2); border-radius: 10px; }
.ex .nt { font-size: 1.15rem; }

.dialogue .line { display: grid; grid-template-columns: 88px 1fr auto; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: start; }
.dialogue .speaker { font-weight: 600; color: var(--muted); font-size: 0.9rem; padding-top: 4px; overflow-wrap: anywhere; }
.dialogue .nt { font-size: 1.25rem; display: block; }
.dialogue .line.active { background: var(--accent-soft); border-radius: 8px; }
.dialogue .en.hide, .dialogue .roman.hide { display: none; }

/* ---------- script ---------- */
.letters { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.letter {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 6px 8px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative;
}
.letter:hover { border-color: var(--faint); }
.letter .nt { font-size: 2rem; line-height: 1.4; }
.lang-ur .letter .nt { font-size: 1.9rem; line-height: 1.8; }
.letter .r { font-size: 0.85rem; color: var(--muted); }
.letter.seen::after { content: ''; position: absolute; top: 7px; right: 7px; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.letter-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 760px) { .letter-detail { grid-template-columns: 1fr; } }
.big-glyph { font-size: 7rem; line-height: 1.3; text-align: center; }
.lang-ur .big-glyph { line-height: 1.9; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 12px; font-size: 0.95rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

.write-pad { position: relative; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; touch-action: none; aspect-ratio: 1; max-width: 420px; width: 100%; }
.write-pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.write-pad .guide-lines { position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(var(--line) 1px, transparent 1px); background-size: 100% 25%; opacity: 0.6; }

/* ---------- practice ---------- */
.mode-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.mode-grid .card { display: flex; flex-direction: column; gap: 4px; }
.mode-grid .card .ico { width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; margin-bottom: 8px; }
.mode-grid .card .ico svg { width: 18px; height: 18px; }

.session { max-width: 640px; margin: 0 auto; }
.session-top { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.session-top .bar { flex: 1; }
.prompt { text-align: center; margin: 10px 0 26px; min-height: 120px; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 8px; }
.prompt .q { color: var(--muted); font-size: 0.92rem; }
.prompt .nt { font-size: 2.6rem; line-height: 1.45; }
.prompt .nt.long { font-size: 1.7rem; }
.lang-ur .prompt .nt { line-height: 2; }
.prompt .en-big { font-size: 1.6rem; font-weight: 600; }
.cloze { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0 0.35em; margin-top: 6px; }
.prompt .cloze .nt { font-size: 1.9rem; }
.cloze .gap { display: inline-block; min-width: 3.2em; border-bottom: 2px solid var(--accent); text-align: center; line-height: 1.3; }
.cloze .gap.good { border-color: var(--good); color: var(--good); }
.cloze .gap.bad { border-color: var(--bad, #b4513f); color: var(--accent); }
.cloze-roman .gap { display: inline-block; min-width: 3em; border-bottom: 1px solid var(--faint); }
.options { display: grid; gap: 10px; }
.options.two { grid-template-columns: 1fr 1fr; }
.opt {
  border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 14px 16px; cursor: pointer; text-align: left;
  font-size: 1.02rem; display: flex; align-items: center; gap: 12px; min-height: 56px;
}
.opt .k { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); font-size: 0.75rem; display: grid; place-items: center; color: var(--faint); flex: none; }
.opt .nt { font-size: 1.4rem; }
.opt:hover:not(:disabled) { border-color: var(--faint); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; }
.feedback { margin-top: 18px; padding: 14px 16px; border-radius: 12px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback .nt { font-size: 1.2rem; }
.answer-input { font-size: 1.15rem !important; padding: 14px !important; text-align: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 52px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; cursor: pointer; font-size: 1.25rem; }
.chip.used { visibility: hidden; }
.answer-line { border-bottom: 2px solid var(--line); min-height: 60px; margin-bottom: 18px; padding-bottom: 8px; }
.flash { border: 1px solid var(--line); background: var(--surface); border-radius: 18px; padding: 34px 22px; text-align: center; min-height: 260px; display: flex; flex-direction: column; justify-content: center; gap: 10px; align-items: center; }
.flash .nt { font-size: 2.8rem; line-height: 1.45; }
.flash .en-big { font-size: 1.5rem; font-weight: 600; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.grades .btn { flex-direction: column; gap: 2px; justify-content: center; }
.grades .btn small { font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.kbd-wrap { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.kbd-wrap button { min-width: 38px; height: 40px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; font-family: var(--nf), var(--ui); font-size: 1.15rem; }
.kbd-wrap button.wide { min-width: 70px; font-family: var(--ui); font-size: 0.85rem; }
.meter { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; width: 160px; }
.meter i { display: block; height: 100%; width: 0; background: var(--bad); transition: width 0.08s; }
.score-ring { font-size: 2.6rem; font-weight: 700; }
.result-list { text-align: left; }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.pair .side { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: flex; gap: 12px; align-items: center; }
.pair .side .nt { font-size: 1.4rem; }
.pair-note { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); margin-top: -4px; }

.callout { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; font-size: 0.95rem; }
.callout.accent { background: var(--accent-soft); }
.empty { text-align: center; padding: 40px 10px; color: var(--muted); }

.num-table { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 6px; }
.num { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 2px 8px; cursor: pointer; align-items: center; }
.num .n { font-weight: 650; color: var(--muted); font-size: 0.85rem; grid-row: span 2; }
.num .nt { font-size: 1.15rem; line-height: 1.4; }
.num > * { min-width: 0; overflow-wrap: anywhere; }
.num .roman { font-size: 0.8rem; }

/* ---------- misc ---------- */
.modal { border: 1px solid var(--line); border-radius: 16px; padding: 22px; max-width: 460px; width: calc(100% - 32px); background: var(--surface); color: var(--text); }
.modal::backdrop { background: rgba(0, 0, 0, 0.35); }
#toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 100; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 0.92rem; transition: opacity 0.4s, transform 0.4s; max-width: 90vw; }
.toast.out { opacity: 0; transform: translateY(8px); }
.loading { padding: 60px 0; text-align: center; color: var(--faint); }
.auth { max-width: 400px; margin: 30px auto; }
.crumbs { font-size: 0.88rem; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--text); }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
details.about summary { cursor: pointer; color: var(--muted); font-size: 0.95rem; margin-bottom: 8px; }
kbd { font: 0.78rem var(--ui); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--muted); }

@media (max-width: 600px) {
  h1 { font-size: 1.6rem; }
  main { padding-top: 20px; }
  .dialogue .line { grid-template-columns: 1fr auto; }
  .dialogue .speaker { grid-column: 1 / -1; padding: 0; }
  .options.two { grid-template-columns: 1fr; }
  .grades { grid-template-columns: repeat(2, 1fr); }
  .prompt .nt { font-size: 2.1rem; }
  .flash .nt { font-size: 2.3rem; }
  .big-glyph { font-size: 5.5rem; }
  .pair { grid-template-columns: 1fr; }
  .topbar .lang-pill { display: none; }
}
@media print {
  .topbar, .subnav, .footer, .icon-btn, .btn { display: none !important; }
  body { background: #fff; }
}

/* Nastaliq needs much more vertical room than other scripts */
#app.lang-ur .nt { line-height: 2.3; font-weight: 400; }
#app.lang-ur .prompt .nt, #app.lang-ur .flash .nt { line-height: 2.5; }
#app.lang-ur .big-glyph { line-height: 2; }
#app.lang-ur .item { padding-top: 6px; padding-bottom: 10px; }
#app.lang-ur .letter .nt { line-height: 2; }
@media (max-width: 600px) {
  .stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { min-width: 0; padding: 8px 10px; }
  .stat b { font-size: 1.1rem; }
  .stat span { font-size: 0.75rem; }
}
.prompt .nt.big-glyph { font-size: 5.5rem; line-height: 1.3; }
.options.two .opt .nt { font-size: 2rem; }

/* conversation */
.answer-box { flex: 1; width: 100%; min-height: 84px; resize: vertical; font: inherit; font-size: 1.05rem; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
.answer-box:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.roleplay-row { grid-template-columns: 38px 1fr; }
.roleplay-row > .row { grid-column: 2; gap: 6px; }
.chat { display: flex; flex-direction: column; gap: 10px; margin: 18px 0; }
.bubble { max-width: 85%; padding: 10px 14px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; gap: 2px; }
.bubble.them { align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.me { align-self: flex-end; border-bottom-right-radius: 4px; background: var(--accent-soft); border-color: transparent; }
.bubble .you { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.good-text { color: var(--good, #2e7d4f); }
.your-turn .answer-input { flex: 1; min-width: 0; text-align: left; }
.journal .turn { padding: 8px 0; border-top: 1px solid var(--line); }
.journal .journal-text { margin-top: 6px; font-size: 1.05rem; white-space: pre-wrap; }
.hide { display: none !important; }

/* ---------- monsoon sky (home header) ---------- */
.sky {
  position: relative; overflow: hidden; isolation: isolate;
  margin: 4px 0 8px; padding: 44px 32px 40px; border-radius: 24px; color: var(--sky-text);
  background:
    radial-gradient(120% 70% at 15% 0%, rgba(255, 255, 255, 0.13), transparent 60%),
    radial-gradient(90% 60% at 90% 10%, rgba(255, 255, 255, 0.08), transparent 55%),
    linear-gradient(170deg, var(--sky-1), var(--sky-2));
}
.sky canvas.rain { position: absolute; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
/* low mist drifting behind the rain */
.sky::before {
  content: ''; position: absolute; inset: 0 -30%; z-index: -2; pointer-events: none; opacity: 0.5;
  background:
    radial-gradient(40% 55% at 20% 100%, rgba(255, 255, 255, 0.12), transparent 70%),
    radial-gradient(35% 45% at 65% 95%, rgba(255, 255, 255, 0.09), transparent 70%),
    radial-gradient(30% 40% at 95% 100%, rgba(255, 255, 255, 0.1), transparent 70%);
  animation: mist 38s ease-in-out infinite alternate;
}
@keyframes mist { from { transform: translateX(-6%); } to { transform: translateX(6%); } }
.sky h1 { font-size: clamp(2rem, 5vw, 3rem); line-height: 1.12; max-width: 17ch; margin-bottom: 14px; color: var(--sky-text); }
.sky p { font-size: 1.08rem; max-width: 60ch; color: color-mix(in srgb, var(--sky-text) 80%, transparent); }
.sky .eyebrow { font-size: 0.95rem; letter-spacing: 0.02em; margin-bottom: 18px; color: color-mix(in srgb, var(--sky-text) 70%, transparent); display: flex; flex-wrap: wrap; gap: 4px 14px; }
.sky .eyebrow .nt { font-weight: 400; }
.sky .btn.primary { background: var(--sky-text); border-color: var(--sky-text); color: var(--sky-1); }
.sky .muted { color: color-mix(in srgb, var(--sky-text) 70%, transparent); }
.sky .hello { color: var(--sun); font-weight: 550; margin-bottom: 8px; }
@media (max-width: 600px) { .sky { padding: 30px 20px 28px; border-radius: 18px; } }
@media (prefers-reduced-motion: reduce) { .sky::before { animation: none; } }

/* a ripple when you get it right */
.opt.right.picked, .feedback.good { position: relative; overflow: hidden; }
.opt.right.picked::after, .feedback.good::before {
  content: ''; position: absolute; left: 50%; top: 50%; width: 0; height: 0; transform: translate(-50%, -50%); border-radius: 50%;
  border: 1.5px solid var(--good); opacity: 0; pointer-events: none; animation: ripple 1s ease-out;
}
@keyframes ripple { 0% { width: 0; height: 0; opacity: 0.7; } 100% { width: 640px; height: 640px; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .opt.right.picked::after, .feedback.good::before { animation: none; } }

.lang-card .native { color: var(--accent); }
.lang-card h3, .score-ring { font-family: var(--serif); font-weight: 560; }
.score-ring { color: var(--accent); }
.unit-row.done .unit-num { background: var(--good-soft); color: var(--good); }
.footer { border-top: 0; background-image: linear-gradient(90deg, transparent, var(--line) 20%, var(--line) 80%, transparent); background-size: 100% 1px; background-repeat: no-repeat; }
.session-top .bar { height: 8px; }

/* grammar handbook */
.topic-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 4px; }
.topic-jump a { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; font-size: 0.88rem; color: var(--text); text-decoration: none; }
.topic-jump a:hover { border-color: var(--faint); }
button.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* romanization: on the sentence tiles, and the switch in the session bar */
.chip { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; }
.chip-roman { font-size: 0.72rem; color: var(--muted); font-family: var(--sans, inherit); line-height: 1.1; }
.chip-r { font-size: 1.05rem; }
.roman-toggle { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 0.8rem; cursor: pointer; text-decoration: line-through; }
.roman-toggle.on { color: var(--accent); border-color: var(--accent); text-decoration: none; }

/* theme gallery */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 18px; }
.theme-card { display: flex; flex-direction: column; gap: 10px; padding: 10px; border: 1.5px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.theme-card:hover { border-color: var(--faint); }
.theme-card.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.theme-meta { display: grid; gap: 2px; padding: 0 4px 4px; }
.tp-split { display: grid; grid-template-columns: 1fr 1fr; border-radius: 10px; overflow: hidden; }
.tp-split .theme-preview { border-radius: 0; }
.theme-preview { background: var(--bg); color: var(--text); border-radius: 10px; overflow: hidden; border: 1px solid var(--line); }
.tp-split .theme-preview + .theme-preview { border-left: 0; }
.tp-sky { background: linear-gradient(160deg, var(--sky-1), var(--sky-2)); color: var(--sky-text); padding: 14px 10px; font-size: 0.78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tp-body { padding: 10px; background: var(--surface); }
.tp-line { height: 7px; border-radius: 4px; background: var(--surface-2); margin-bottom: 6px; }
.tp-line.short { width: 60%; }
.tp-btn { font-size: 0.7rem; padding: 3px 8px; border-radius: 6px; font-weight: 600; }
.tp-btn.primary { background: var(--text); color: var(--bg); }
.tp-btn.accent { background: var(--accent); color: var(--on-accent, #fff); }
.tp-dot { width: 10px; height: 10px; border-radius: 50%; }
.tp-dot.good { background: var(--good); }
.tp-dot.bad { background: var(--bad); }
.footer .share-link { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-decoration: underline; cursor: pointer; }

/* letter shapes (Perso-Arabic joining) */
.forms { display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin: 8px 0; }
.form { display: grid; justify-items: center; gap: 2px; min-width: 52px; padding: 6px 8px; border-radius: 10px; background: var(--surface-2); }
.form .nt { font-size: 1.9rem; line-height: 1.6; }
.forms-examples { display: flex; flex-wrap: wrap; gap: 12px; margin: 8px 0 12px; }
.forms-example { display: grid; justify-items: center; text-decoration: none; color: inherit; }
.nt-inline .nt { font-size: 1.4rem; }
.letter-intro .big-glyph { font-size: 4rem; }

/* ---------- the course path ---------- */
.part + .part { margin-top: 26px; }
.part-head { display: flex; flex-direction: column; gap: 2px; margin: 0 0 10px; }
.part-head h3 { margin: 0; font-size: 1.05rem; }
.unit-row.locked { opacity: 0.6; }
.unit-row.locked .unit-num { color: var(--faint); }
.unit-prog { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 56px; }
.bar.mini { width: 56px; height: 4px; }

.path { display: grid; gap: 0; margin: 18px 0 8px; max-width: 640px; position: relative; }
.path-step {
  display: grid; grid-template-columns: 40px 1fr; gap: 14px; align-items: center; text-decoration: none; color: inherit;
  padding: 10px 12px; border-radius: 12px; position: relative;
}
/* the thread joining one step to the next */
.path-step:not(:last-child)::after {
  content: ''; position: absolute; left: 31px; top: 48px; bottom: -8px; width: 2px; background: var(--line);
}
.path-step.done:not(:last-child)::after { background: color-mix(in srgb, var(--good) 45%, var(--line)); }
a.path-step:hover { background: var(--surface-2); }
.step-num {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 650; position: relative; z-index: 1;
  background: var(--surface); border: 2px solid var(--line); color: var(--muted);
}
.step-num svg { width: 18px; height: 18px; }
.path-step.done .step-num { background: var(--good-soft); border-color: transparent; color: var(--good); }
.path-step.next .step-num { background: var(--accent); border-color: var(--accent); color: var(--on-accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.path-step.next { background: color-mix(in srgb, var(--accent-soft) 55%, transparent); }
.path-step.locked { opacity: 0.55; cursor: default; }
.path-step .t { font-weight: 600; }
.step-sub { display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; margin-top: 2px; }
.tip-chip { font-size: 0.8rem; background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: 1px 9px; }

.extra-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card.extra { display: flex !important; gap: 12px; align-items: center; padding: 12px 14px; }
.card.extra .ico { flex: none; width: 32px; height: 32px; border-radius: 9px; background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.card.extra .ico svg { width: 17px; height: 17px; }

/* ---------- a lesson's tip ---------- */
.tip-card {
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); border-radius: 18px; padding: 22px 22px 18px;
  background: linear-gradient(160deg, var(--accent-soft), var(--surface) 60%);
}
.tip-card h2 { margin: 2px 0 10px; }
.tip-card ul { padding-left: 1.2em; margin: 0 0 10px; }
.tip-card li { margin-bottom: 6px; line-height: 1.55; }
.tip-label { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); font-weight: 650; }
.tip-pattern {
  font-family: var(--nf), var(--ui); font-size: 1.15rem; background: var(--surface); border: 1px dashed color-mix(in srgb, var(--accent) 50%, var(--line));
  border-radius: 10px; padding: 8px 12px; margin: 6px 0 4px; display: inline-block; max-width: 100%;
}
.tip-notes { margin-top: 14px; }
.tip-notes summary { cursor: pointer; color: var(--muted); font-size: 0.92rem; }
.tip-notes[open] summary { margin-bottom: 8px; }
mark { background: color-mix(in srgb, var(--sun) 28%, transparent); color: inherit; border-radius: 4px; padding: 0 2px; }
