/* ==========================================================================
   Akkredly design system
   Tokens → base → layout → components → screens → themes.
   Direction-aware: logical properties only; Russian study text is always
   marked lang="ru" dir="ltr" in markup and never inherits the UI direction.
   ========================================================================== */

:root {
  /* Dark is the default theme (existing users rely on it). */
  --bg: #0e1319;
  --bg-elev: #121820;
  --surface: #161d26;
  --surface-2: #1c2530;
  --surface-3: #232e3b;
  --line: rgba(214, 226, 240, .09);
  --line-strong: rgba(214, 226, 240, .16);
  --ink: #e9eef4;
  --ink-2: #c3ccd7;
  --muted: #8d9aaa;
  --primary: #5b9bf8;
  --primary-strong: #3f86f2;
  --primary-ink: #ffffff;
  --btn: #2f6fdc;
  --btn-hover: #285fc0;
  --primary-soft: rgba(91, 155, 248, .13);
  --ok: #3fc39b;
  --ok-soft: rgba(63, 195, 155, .12);
  --danger: #f07a83;
  --danger-soft: rgba(240, 122, 131, .12);
  --warn: #e8b35a;
  --warn-soft: rgba(232, 179, 90, .12);
  --premium: #b99cf6;
  --premium-soft: rgba(185, 156, 246, .13);
  --focus: rgba(91, 155, 248, .55);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25);
  --shadow-md: 0 10px 30px rgba(0, 0, 0, .35);
  --backdrop: rgba(4, 8, 13, .66);

  --font-ui: "Inter", "Vazirmatn", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --font-study: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  --header-h: 60px;
  --nav-h: 64px;
  --content-w: 1080px;
  --study-w: 760px;

  color-scheme: dark;
  font-family: var(--font-ui);
}

html[data-theme="light"] {
  --bg: #f4f6f8;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #f3f5f8;
  --surface-3: #e9edf2;
  --line: #e2e7ed;
  --line-strong: #cfd6df;
  --ink: #152030;
  --ink-2: #33414f;
  --muted: #5e6b7a;
  --primary: #1f62d6;
  --primary-strong: #1a55bc;
  --primary-ink: #ffffff;
  --btn: #1f62d6;
  --btn-hover: #1a55bc;
  --primary-soft: rgba(31, 98, 214, .09);
  --ok: #13815f;
  --ok-soft: rgba(19, 129, 95, .09);
  --danger: #c43b48;
  --danger-soft: rgba(196, 59, 72, .08);
  --warn: #9a6200;
  --warn-soft: rgba(154, 98, 0, .09);
  --premium: #6b45c9;
  --premium-soft: rgba(107, 69, 201, .08);
  --focus: rgba(31, 98, 214, .45);
  --shadow-sm: 0 1px 2px rgba(21, 32, 48, .06);
  --shadow-md: 0 12px 32px rgba(21, 32, 48, .12);
  --backdrop: rgba(21, 32, 48, .42);
  color-scheme: light;
  background: var(--bg);
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
h1, h2, h3, p { margin: 0; }
svg.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
[hidden] { display: none !important; }
[lang="ru"], [lang="en"] { font-family: var(--font-study); }
[dir="rtl"] .flip-rtl, html[dir="rtl"] .chev { transform: scaleX(-1); }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }

/* ---------- App shell ---------- */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  border-block-end: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: var(--content-w);
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 17px; letter-spacing: -.01em; direction: ltr; }
/* Brand: the symbol beside the live name in compact places; the full logo (symbol over wordmark) where there is
   room. The wordmark in the artwork is dark, so on the dark theme the compact form is used instead. */
.brand-logo { width: 40px; height: 40px; flex: none; object-fit: contain; }
.brand-full { display: none; height: auto; object-fit: contain; }
html[data-theme="light"] .brand-full { display: block; }
html[data-theme="light"] .brand-compact { display: none !important; }
.top-actions { margin-inline-start: auto; display: flex; align-items: center; gap: 6px; }

.chip-btn, .theme-toggle, .account-button, .header-language select {
  height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: border-color .15s ease, background-color .15s ease;
}
.theme-toggle, .account-button { width: 36px; padding: 0; flex: none; }
.theme-toggle:hover, .account-button:hover, .header-language select:hover { border-color: var(--line-strong); background: var(--surface-2); }
.theme-toggle .icon, .account-button .icon { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
html[data-theme="light"] .theme-toggle .i-sun { display: block; }
html[data-theme="light"] .theme-toggle .i-moon { display: none; }
.header-language { display: flex; align-items: center; }
.header-language select { padding: 0 8px; max-width: 104px; cursor: pointer; }
.header-language select option { background: var(--surface); color: var(--ink); }

.stats { display: flex; gap: 6px; }
.stats > span {
  height: 36px; padding: 0 10px; display: inline-flex; align-items: center; gap: 5px;
  border-radius: 10px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stats .icon { width: 16px; height: 16px; }
.stats .streak-chip .icon { color: var(--warn); }
.stats .xp-chip .icon { color: var(--primary); }

/* Primary navigation: bottom bar on phones, inline tabs in the header on wide screens. */
.bottom-nav {
  position: fixed;
  z-index: 40;
  inset-inline: 0;
  bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding: 6px 8px env(safe-area-inset-bottom);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg-elev);
  border-block-start: 1px solid var(--line);
}
.bottom-nav button {
  border: 0; background: transparent; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  border-radius: 12px; font-size: 11.5px; font-weight: 600; min-width: 0;
}
.bottom-nav button .icon { width: 22px; height: 22px; }
.bottom-nav button.active { color: var(--primary); }
.bottom-nav button:hover { color: var(--ink); }
body.signed-out .bottom-nav, body.in-session .bottom-nav { visibility: hidden; }

main { max-width: var(--content-w); margin: 0 auto; padding: 20px 16px 0; }
.view { display: none; }
.view.active { display: block; }
.view[hidden] { display: none; }

/* ---------- Primitives ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.eyebrow, .eyebrow-text {
  display: block;
  font-size: 12px; font-weight: 600; color: var(--muted);
  letter-spacing: .02em;
}
/* Home section headings: above card-row titles (15px), below the page headline (.section-heading h2). */
.group-title { font-size: 17px; font-weight: 600; line-height: 1.35; color: var(--ink); margin: 4px 4px 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap; background: var(--surface-3); color: var(--ink-2); flex: none;
}
.badge.free { background: var(--ok-soft); color: var(--ok); }
.badge.premium { background: var(--premium-soft); color: var(--premium); }
.badge.exam { background: var(--warn-soft); color: var(--warn); }

.action-btn {
  width: 100%;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: var(--btn);
  color: var(--primary-ink);
  font-weight: 600;
  font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: background-color .15s ease, border-color .15s ease, opacity .15s ease;
}
.action-btn:hover:not(:disabled) { background: var(--btn-hover); }
.action-btn.secondary { background: var(--surface-2); color: var(--ink); border-color: var(--line); }
.action-btn.secondary:hover:not(:disabled) { background: var(--surface-3); }
.action-btn.danger { background: transparent; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.action-btn.danger:hover:not(:disabled) { background: var(--danger-soft); }
.action-btn.ghost-btn { background: transparent; border-color: transparent; color: var(--primary); width: auto; min-height: 40px; padding-inline: 10px; }
.action-btn:disabled { opacity: .45; }
.text-btn { border: 0; background: none; color: var(--primary); font-weight: 600; padding: 4px 2px; font-size: 14px; }
.text-btn:hover { text-decoration: underline; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); display: inline-grid; place-items: center; flex: none; padding: 0;
}
.icon-btn:hover { background: var(--surface-2); }

.ghost { /* reset-all trigger keeps its id; styled as a list row below */ }

/* ---------- Welcome / loading (signed-out) ---------- */
.welcome {
  max-width: 520px; margin: 8vh auto 0; text-align: center; padding: 0 8px;
}
.welcome-logo { margin: 0 auto 16px; object-fit: contain; }
.welcome-logo.brand-full { width: 168px; }
.welcome-logo.brand-compact { display: block; width: 88px; height: 88px; }
.welcome h1 { font-size: 26px; line-height: 1.3; letter-spacing: -.01em; margin-bottom: 10px; }
.welcome p { color: var(--muted); line-height: 1.75; }
.welcome .action-btn { max-width: 280px; margin-top: 24px; }
.welcome-points { display: grid; gap: 10px; margin: 28px auto 0; max-width: 380px; text-align: start; padding: 0; list-style: none; }
.welcome-points li { display: flex; gap: 10px; align-items: flex-start; color: var(--ink-2); font-size: 14px; }
.welcome-points .icon { color: var(--ok); width: 18px; height: 18px; margin-top: 2px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--surface-3); border-top-color: var(--primary); margin: 0 auto 14px; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Home ---------- */
.home-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); }
.home-grid > * { min-width: 0; }

.resume-banner {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; margin-bottom: 20px;
  border-radius: var(--r-lg);
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  background: var(--warn-soft);
  color: var(--ink); text-align: start; font-weight: 600;
}
.resume-banner .icon { color: var(--warn); }
.resume-banner .chev { margin-inline-start: auto; }

/* Study track: a row of the profile form (label + current track) that opens the selection dialog. */
.track-bar { justify-items: stretch; }
.track-bar .text-btn { justify-self: start; }
.track-label { font-size: inherit; font-weight: inherit; color: inherit; }
.track-button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; max-width: 100%; min-height: 40px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 700;
}
.track-button:hover { border-color: var(--line-strong); background: var(--surface-2); }
.track-button > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-caret { width: 16px; height: 16px; color: var(--muted); transform: rotate(90deg); }
.track-bar[data-state="unselected"] .track-button { border-color: color-mix(in srgb, var(--warn) 55%, transparent); background: var(--warn-soft); }
.track-note { font-size: 13px; color: var(--muted); }
.track-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.track-option {
  width: 100%; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 12px; text-align: start;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600;
}
.track-option:hover:not(:disabled) { background: var(--surface-2); border-color: var(--line-strong); }
.track-option[aria-current] { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: var(--ok-soft); }
.track-option:disabled { cursor: default; background: var(--surface-2); color: var(--muted); }
.track-option .track-mark { width: 20px; height: 20px; flex: none; color: var(--ok); display: inline-flex; }
.track-option .track-title { flex: 1; min-width: 0; overflow-wrap: anywhere; }

.today-card { padding: 20px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.section-heading h2 { font-size: 22px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; margin-top: 2px; }
.home-controls { display: flex; align-items: center; gap: 8px; flex: none; }
.block-picker {
  height: 38px; display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 10px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; font-weight: 600;
}
html[dir="rtl"] .block-picker { padding: 0 10px 0 4px; }
.block-picker select { border: 0; outline: 0; background: transparent; color: var(--ink); font-weight: 700; font-size: 14px; cursor: pointer; max-width: 128px; direction: ltr; }
.block-picker select option { background: var(--surface); color: var(--ink); }

.block-status { margin: 0 0 16px; }
.block-status .bs-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.block-status .bs-row b { color: var(--ink); font-size: 15px; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--primary); transition: width .4s ease; }
.bar.ok > i { background: var(--ok); }
html[dir="rtl"] .bar > i { margin-inline-start: 0; }
.block-status .bs-hint { font-size: 13px; color: var(--muted); margin-top: 8px; }

.cta-stack { display: grid; gap: 10px; }
.cta-primary, .cta-secondary {
  width: 100%;
  display: flex; align-items: center; gap: 14px;
  padding: 14px 16px; min-height: 64px;
  border-radius: var(--r-md);
  text-align: start;
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.cta-primary { background: var(--btn); color: var(--primary-ink); }
.cta-primary:hover { background: var(--btn-hover); }
.cta-primary .badge { background: rgba(255, 255, 255, .18); color: #fff; }
.cta-primary .mode-icon { background: rgba(255, 255, 255, .16); color: #fff; }
.cta-primary small { color: rgba(255, 255, 255, .82); }
.cta-secondary { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.cta-secondary:hover { border-color: var(--line-strong); }
.cta-primary b, .cta-secondary b { display: block; font-size: 16px; font-weight: 650; line-height: 1.35; }
.cta-primary small, .cta-secondary small { display: block; font-size: 13px; line-height: 1.45; margin-top: 2px; }
.cta-secondary small { color: var(--muted); }
.mode-text { flex: 1; min-width: 0; }

.study-plan { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; gap: 14px; align-items: flex-start; font-size: 14px; color: var(--ink-2); }
.study-plan:empty { display: none; }
.plan-count { flex: none; min-width: 64px; padding: 8px 10px; border-radius: var(--r-md); background: var(--primary-soft); color: var(--primary); text-align: center; line-height: 1.2; }
.plan-count b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.plan-count span { font-size: 11px; font-weight: 600; }
.plan-body { min-width: 0; display: grid; gap: 3px; }
.plan-body .plan-main { color: var(--ink); font-weight: 600; }
.plan-body .plan-hint { font-size: 12.5px; color: var(--muted); }
.plan-body .text-btn { justify-self: start; }

.progress-card { padding: 20px; }
.progress-top { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.progress-top h1 { font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; }
.progress-top h1 small { font-size: 17px; color: var(--muted); font-weight: 600; }
.progress-top p { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 4px; }
.ring { --value: 0; width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--ok) calc(var(--value) * 1%), var(--surface-3) 0); position: relative; }
.ring::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; z-index: 1; font-weight: 700; font-size: 15px; direction: ltr; font-variant-numeric: tabular-nums; }
.progress-track { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin: 16px 0 14px; }
.progress-track i { display: block; height: 100%; width: 0; background: var(--ok); border-radius: inherit; transition: width .4s ease; }
.mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mini-stats > span { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); font-size: 13px; color: var(--ink-2); }
.mini-stats b { font-size: 16px; color: var(--ink); font-variant-numeric: tabular-nums; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.learning { background: var(--warn); }
.dot.weak { background: var(--danger); }

/* List rows: secondary tools, visibly lower priority than the primary CTA. */
.row-list { display: grid; overflow: hidden; }
.row-list > * + * { border-top: 1px solid var(--line); }
.mode-row {
  width: 100%;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: 60px;
  border: 0; background: transparent; color: var(--ink);
  text-align: start;
  transition: background-color .15s ease;
}
.mode-row:hover:not(:disabled) { background: var(--surface-2); }
.mode-row:disabled { opacity: .5; }
.mode-row b { display: block; font-size: 15px; font-weight: 600; line-height: 1.35; }
.mode-row small { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.45; margin-top: 1px; }
.mode-row .chev { color: var(--muted); width: 18px; height: 18px; }
.mode-row.danger-row b, .mode-row.danger-row .mode-icon { color: var(--danger); }
.mode-icon {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.mode-icon .icon { width: 20px; height: 20px; }
.mode-icon.tone-ok { background: var(--ok-soft); color: var(--ok); }
.mode-icon.tone-warn { background: var(--warn-soft); color: var(--warn); }
.mode-icon.tone-danger { background: var(--danger-soft); color: var(--danger); }
.mode-icon.tone-premium { background: var(--premium-soft); color: var(--premium); }
.mode-icon.tone-neutral { background: var(--surface-3); color: var(--ink-2); }

.exam-card { padding: 16px; display: flex; align-items: center; gap: 14px; }
.exam-card .mode-row { padding: 0; min-height: 0; }
.exam-card .mode-row:hover { background: transparent; }
.exam-facts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

.data-note { display: flex; align-items: center; gap: 12px; padding: 4px 4px 8px; color: var(--muted); font-size: 12.5px; }
.data-note > span { font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.data-note p { margin: 0; line-height: 1.6; }
.data-note b { font-weight: 600; color: var(--ink-2); }
.data-note.is-error { padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent); background: var(--danger-soft); color: var(--ink); font-size: 14px; }
.data-note.is-error #retryCatalog { margin-inline-start: 8px; }
#retryCatalog { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 8px; padding: 4px 12px; font-weight: 600; }

.install-card { margin-top: 16px; padding: 14px 16px; display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center; }
.install-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.install-card b { display: block; font-size: 15px; }
.install-card p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.install-card button { min-height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--btn); color: #fff; font-weight: 600; }

/* ---------- Study session ---------- */
#sessionView { max-width: var(--study-w); margin: 0 auto; }
.session-top { display: flex; align-items: center; gap: 12px; height: 44px; }
.session-progress { flex: 1; height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.session-progress i { display: block; height: 100%; width: 0; background: var(--primary); border-radius: inherit; transition: width .3s ease; }
#sessionCounter { font-size: 13px; font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; direction: ltr; min-width: 40px; text-align: center; }
#examTimer {
  font-variant-numeric: tabular-nums; direction: ltr; font-weight: 700; font-size: 14px;
  padding: 5px 10px; border-radius: 8px; background: var(--warn-soft); color: var(--warn); min-width: 62px; text-align: center;
}
.session-label { display: flex; align-items: center; gap: 8px; margin: 10px 2px 12px; font-size: 12.5px; color: var(--muted); min-height: 20px; }
.session-label #modeLabel { font-weight: 700; color: var(--ink-2); white-space: nowrap; }
.session-label #topicLabel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-label #topicLabel:not(:empty)::before { content: "·"; margin-inline-end: 8px; color: var(--muted); }

.question-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; }
.q-number { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; font-weight: 600; }
.q-meta { display: flex; align-items: center; gap: 8px; min-width: 0; }
.status-pill { display: inline-flex; height: 22px; align-items: center; padding: 0 8px; border-radius: 99px; background: var(--primary-soft); color: var(--primary); font-size: 11.5px; font-weight: 600; }
.status-pill.exam-neutral { background: var(--warn-soft); color: var(--warn); }
.q-tools { display: flex; gap: 4px; flex: none; }
.tool-btn {
  height: 34px; min-width: 34px; padding: 0 8px; border-radius: 9px; border: 1px solid transparent; background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12.5px; font-weight: 600;
}
.tool-btn:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.tool-btn[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.tool-btn:disabled { opacity: .4; }
.tool-btn .icon { width: 18px; height: 18px; }
.tool-btn .tool-label { display: none; }

.question-ru {
  font-family: var(--font-study);
  direction: ltr; text-align: left;
  font-size: 19px; line-height: 1.55; font-weight: 600;
  letter-spacing: -.003em;
  margin: 14px 0 18px;
  overflow-wrap: anywhere;
  hyphens: auto;
}
.options { display: grid; gap: 10px; }
.option {
  width: 100%;
  min-height: 56px;
  display: flex; align-items: flex-start; gap: 12px;
  padding: 13px 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  text-align: left; direction: ltr;
  font-family: var(--font-study);
  font-size: 16px; line-height: 1.5;
  transition: border-color .12s ease, background-color .12s ease;
  overflow-wrap: anywhere;
}
.option:hover { border-color: color-mix(in srgb, var(--primary) 55%, var(--line-strong)); background: var(--surface-2); }
.option > span:last-child { padding-top: 2px; min-width: 0; }
.option-letter {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2);
  font-weight: 700; font-size: 13px; font-family: var(--font-study);
}
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option.selected .option-letter { background: var(--btn); color: #fff; }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.correct .option-letter { background: var(--ok); color: #fff; }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.option.wrong .option-letter { background: var(--danger); color: #fff; }
.options.locked .option { cursor: default; }
.options.locked .option:not(.correct):not(.wrong) { opacity: .72; }

.answer-panel { margin-top: 16px; padding: 14px 16px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.answer-banner { display: flex; align-items: center; gap: 8px; font-size: 16px; font-weight: 700; }
.answer-banner.good { color: var(--ok); }
.answer-banner.bad { color: var(--danger); }
.answer-panel .question-fa { margin: 6px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.7; }
.answer-panel .question-fa span[lang="ru"] { font-weight: 600; color: var(--ink); }

.exam-note { margin: 16px 0 0; color: var(--muted); font-size: 12.5px; line-height: 1.6; text-align: center; }
#speechNotice { margin: 12px 0 0; font-size: 12px; color: var(--muted); line-height: 1.6; }
#speechNotice:empty { display: none; }

/* Action bar: sticks to the bottom edge on phones (thumb reach) and never floats over content. */
.session-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex; gap: 10px;
  margin: 16px -16px 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, color-mix(in srgb, var(--bg) 0%, transparent));
}
.session-actions:empty { display: none; }
.session-actions .action-btn { min-height: 52px; font-size: 16px; }
.session-actions #previousQuestion { flex: 0 0 auto; width: auto; min-width: 52px; padding-inline: 14px; }
.session-actions #previousQuestion .btn-label { display: none; }

/* Learning (entitled study layer) */
.study-learning { margin-top: 20px; display: grid; gap: 12px; overflow-wrap: anywhere; }
.study-learning > details, .study-block {
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); overflow: hidden;
}
.study-learning summary {
  list-style: none; cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: 14px;
  display: flex; align-items: center; gap: 8px; color: var(--ink);
}
.study-learning summary::-webkit-details-marker { display: none; }
.study-learning summary::after { content: ""; margin-inline-start: auto; width: 8px; height: 8px; border: solid var(--muted); border-width: 0 2px 2px 0; transform: rotate(45deg); transition: transform .15s ease; }
.study-learning details[open] > summary::after { transform: rotate(-135deg); }
.study-learning .details-body { padding: 0 14px 14px; display: grid; gap: 12px; }
.study-learning p { white-space: pre-wrap; line-height: 1.8; font-size: 14.5px; color: var(--ink-2); }
.study-language-note { padding: 8px 12px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--warn) !important; font-size: 13px !important; line-height: 1.6 !important; }
.study-field { display: grid; gap: 4px; }
.study-provenance { padding: 8px 12px; border-radius: var(--r-sm); background: var(--surface-3); color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.study-distractors { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 14.5px; line-height: 1.7; }
.study-distractors li { display: flex; gap: 8px; align-items: baseline; }
.study-field > .field-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .02em; }
.study-field > .field-body { font-size: 15px; line-height: 1.8; color: var(--ink); white-space: pre-wrap; }
.study-field.tone-warn { padding: 12px; border-radius: var(--r-sm); background: var(--warn-soft); }
.study-field.tone-warn > .field-label { color: var(--warn); }
.option-translations { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.option-translations li { display: grid; gap: 2px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--line); }
.option-translations .ot-ru { font-size: 13.5px; color: var(--muted); direction: ltr; text-align: left; }
.option-translations .ot-tr { font-size: 15px; color: var(--ink); line-height: 1.7; }
.study-translation { padding: 14px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--line); }
.study-translation h3 { font-size: 15.5px; line-height: 1.65; font-weight: 600; margin-bottom: 10px; }
.study-translation ol { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.study-translation li { display: flex; gap: 10px; font-size: 14.5px; line-height: 1.6; color: var(--ink-2); }
.study-translation .tr-letter { flex: none; width: 22px; height: 22px; border-radius: 6px; background: var(--surface-3); display: grid; place-items: center; font-size: 12px; font-weight: 700; font-family: var(--font-study); }
.translation-fallback { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--muted); font-size: 13px; }
.terms { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.terms-head, .term { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 9px 12px; font-size: 13.5px; }
.terms-head { background: var(--surface-3); font-size: 11.5px; font-weight: 700; color: var(--muted); }
.term { background: var(--surface); border-top: 1px solid var(--line); overflow-wrap: anywhere; }
.term span[lang="ru"], .term span[lang="en"] { text-align: left; }
.term span[lang="fa"] { text-align: right; }
.term span[lang="en"] { color: var(--primary); font-weight: 600; }
.terms-bridge .terms-head, .terms-bridge .term { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.study-visual { padding: 14px; border: 1px solid var(--line); border-inline-start: 3px solid var(--study-accent, var(--primary)); border-radius: var(--r-md); background: var(--surface); overflow-wrap: anywhere; display: grid; gap: 12px; }
.study-visual header { display: flex; gap: 12px; align-items: center; }
.study-visual header > span { font-size: 1.6rem; line-height: 1; }
.study-visual h3 { margin: 0; font-size: 16px; }
.study-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.study-chips:empty, .study-diagram:empty { display: none; }
.study-chips span { padding: 4px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; }
.study-diagram { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; counter-reset: step; }
.study-diagram li { flex: 1 1 140px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px 12px; font-size: 13.5px; background: var(--surface-2); counter-increment: step; }
.study-diagram li::before { content: counter(step); display: inline-grid; place-items: center; width: 20px; height: 20px; margin-inline-end: 8px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 700; }
.study-visual p { font-size: 14px; }

/* Connect / Words self-assessment */
.activity-note { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }
.word-prompt { text-align: center; padding: 28px 8px 20px; overflow-wrap: anywhere; }
.word-prompt strong { display: block; font-size: 30px; line-height: 1.3; font-weight: 700; font-family: var(--font-study); }
.word-prompt p { color: var(--muted); margin-top: 10px; font-size: 14px; }

/* Exam result */
.exam-result-summary { display: grid; grid-template-columns: 124px 1fr; gap: 20px; align-items: center; margin-bottom: 20px; }
.exam-score-ring { --exam-score: 0; width: 124px; height: 124px; border-radius: 50%; display: grid; place-items: center; align-content: center; position: relative;
  background: conic-gradient(var(--ok) calc(var(--exam-score) * 1%), var(--surface-3) 0); }
.exam-score-ring::before { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--surface); }
.exam-score-ring strong, .exam-score-ring span { position: relative; }
.exam-score-ring strong { font-size: 28px; direction: ltr; font-variant-numeric: tabular-nums; }
.exam-score-ring span { font-size: 12px; color: var(--muted); }
.exam-result-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.exam-result-numbers div { padding: 12px 8px; border-radius: var(--r-md); background: var(--surface-2); text-align: center; }
.exam-result-numbers b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.exam-result-numbers div:nth-child(1) b { color: var(--ok); }
.exam-result-numbers div:nth-child(2) b { color: var(--danger); }
.exam-result-numbers div:nth-child(3) b { color: var(--warn); }
.exam-result-numbers span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.exam-review-title { font-size: 16px; margin: 8px 0 12px; }
.exam-review-list { display: grid; gap: 10px; }
.exam-review-item { padding: 14px; border-radius: var(--r-md); border: 1px solid var(--line); border-inline-start: 3px solid var(--danger); background: var(--surface); }
.exam-review-item.unanswered { border-inline-start-color: var(--warn); }
.exam-review-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; }
.exam-review-head span { color: var(--danger); font-weight: 700; }
.exam-review-question { direction: ltr; text-align: left; line-height: 1.6; font-weight: 600; margin-bottom: 8px; }
.exam-review-item p { font-size: 14px; line-height: 1.7; margin-top: 4px; }
.exam-correct-answer b { color: var(--ok); }
.exam-perfect { padding: 18px; border-radius: var(--r-md); background: var(--ok-soft); color: var(--ok); font-weight: 700; text-align: center; }

/* ---------- Dialogs (bottom sheet on phones, centred modal on wide screens) ---------- */
.stats-dialog, .auth-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: min(88dvh, 820px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--bg-elev);
  color: var(--ink);
  padding: 24px;
  box-shadow: var(--shadow-md);
}
.stats-dialog::backdrop, .auth-dialog::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.stats-dialog h2 { font-size: 20px; line-height: 1.35; margin: 2px 0 18px; padding-inline-end: 44px; }
.stats-dialog h3 { font-size: 15px; margin: 22px 0 10px; }
.stats-dialog > p, .stats-dialog form > p { color: var(--ink-2); font-size: 14px; line-height: 1.7; }
.dialog-close {
  position: absolute; inset-inline-end: 16px; top: 16px;
  width: 36px; height: 36px; border-radius: 10px; border: 0;
  background: var(--surface-2); color: var(--ink-2); display: grid; place-items: center; padding: 0;
}
.dialog-close:hover { background: var(--surface-3); }
.dialog-kicker { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.dialog-footer { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.dialog-footer .action-btn { flex: 1 1 140px; width: auto; }
.dialog-message { min-height: 0; font-size: 13.5px; color: var(--ink-2); }
.dialog-message:empty { display: none; }
.dialog-context { font-size: 13px !important; color: var(--muted) !important; margin: -10px 0 14px; }
.list-stack { display: grid; gap: 8px; }
.list-stack:empty { display: none; }
.pager { display: flex; gap: 8px; margin-top: 12px; }
.pager:empty { display: none; }
.pager .action-btn { min-height: 40px; font-size: 14px; }
.empty-state { padding: 26px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-md); font-size: 14px; }

/* Forms */
.auth-field { display: grid; gap: 6px; margin: 0 0 14px; color: var(--ink-2); font-size: 13.5px; font-weight: 600; }
.auth-field input, .auth-field select, .auth-field textarea {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-weight: 400; font-size: 15px;
}
.auth-field textarea { min-height: 8rem; resize: vertical; line-height: 1.6; }
.auth-field input:focus, .auth-field select:focus, .auth-field textarea:focus { outline: 2px solid var(--focus); outline-offset: 0; border-color: var(--primary); }
.field-hint { font-size: 12.5px !important; color: var(--muted) !important; line-height: 1.6; margin: -6px 0 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .auth-field.full { grid-column: 1 / -1; }
.danger-zone { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.stat-tile { padding: 12px 14px; border-radius: var(--r-md); background: var(--surface-2); min-width: 0; }
.stat-tile b { display: block; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-tile span { font-size: 12.5px; color: var(--muted); }
.stats-foot { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin: 18px 0 0; }
#examHistoryList { display: grid; gap: 8px; margin-top: 8px; }
#examHistoryList h3 { margin-bottom: 2px; }
#examHistoryList > p { color: var(--muted); font-size: 14px; }
.history-row, .list-row {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); text-align: start; font-size: 14px;
}
.history-row:hover, .list-row:hover { background: var(--surface-2); }
.history-row .hr-score { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; }
.history-row .hr-meta { color: var(--muted); font-size: 13px; }
.history-row .chev, .list-row .chev { margin-inline-start: auto; color: var(--muted); width: 16px; height: 16px; }
.list-row .lr-body { min-width: 0; display: grid; gap: 2px; }
.list-row .lr-title { font-weight: 600; font-size: 13.5px; }
.list-row .lr-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#notesList .action-btn, #reviewList .action-btn { white-space: normal; overflow-wrap: anywhere; text-align: start; justify-content: flex-start; }

/* Mistakes */
.mistakes-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.mistakes-summary:empty { display: none; }
.mistakes-summary span { padding: 10px 6px; border-radius: var(--r-md); background: var(--surface-2); color: var(--muted); font-size: 12px; text-align: center; }
.mistakes-summary b { display: block; color: var(--ink); font-size: 20px; font-variant-numeric: tabular-nums; }
.mistakes-list { display: grid; gap: 8px; margin-top: 14px; }
.mistake-item { padding: 12px 14px; border-radius: var(--r-md); border: 1px solid var(--line); background: var(--surface); display: grid; gap: 6px; }
.mistake-item-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13.5px; font-weight: 600; }
.mistake-item-head b { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--danger-soft); color: var(--danger); }
.mistake-item.resolved .mistake-item-head b { background: var(--ok-soft); color: var(--ok); }
.mistake-item > p { font-size: 13px; color: var(--muted); }
.mistake-item > p[lang="ru"] { color: var(--ink); font-size: 14.5px; line-height: 1.55; }
.practice-one-mistake { min-height: 40px !important; font-size: 14px !important; margin-top: 4px; }
.mistakes-empty { padding: 26px 14px; text-align: center; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--r-md); }
.block-q-head { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.block-q-head .badge.done { background: var(--ok-soft); color: var(--ok); }

#reviewDetail, #reviewList { overflow-wrap: anywhere; }
#reviewList { display: grid; gap: 8px; margin-top: 12px; }
#reviewDetail { display: grid; gap: 8px; margin: 12px 0; }
#reviewDetail:empty { display: none; }
#reviewDetail p { padding: 10px 12px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 14px; }
#noteText, #reportDetails, #reviewNote { width: 100%; max-width: 100%; min-height: 9rem; }

/* Toast: fully hidden when idle (no sliver). */
.toast {
  position: fixed; z-index: 60; left: 50%; top: calc(12px + env(safe-area-inset-top));
  max-width: min(440px, calc(100% - 32px));
  transform: translate(-50%, -12px);
  opacity: 0; visibility: hidden; pointer-events: none;
  padding: 11px 16px; border-radius: 12px;
  background: var(--ink); color: var(--bg);
  font-weight: 600; font-size: 14px; line-height: 1.5; text-align: center;
  box-shadow: var(--shadow-md);
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition: opacity .2s ease, transform .2s ease; }

/* ---------- Responsive ---------- */
@media (max-width: 479px) {
  .brand-name { display: none; }
  .topbar-inner { padding: 0 12px; gap: 8px; }
  .top-actions { gap: 5px; }
  .stats > span { padding: 0 8px; }
  .header-language select { max-width: 100px; padding: 0 5px; }
  main { padding: 14px 12px 0; }
  .today-card, .progress-card { padding: 16px; }
  .section-heading { flex-direction: column; gap: 10px; }
  .home-controls { width: 100%; }
  .block-picker { flex: 1; }
  .block-picker select { max-width: none; flex: 1; }
  .section-heading h2 { font-size: 20px; }
  .question-card { padding: 16px; border-radius: 14px; }
  .question-ru { font-size: 18px; }
  .option { font-size: 15.5px; padding: 12px; }
  .session-actions { margin-inline: -12px; padding-inline: 12px; }
  .exam-result-summary { grid-template-columns: 1fr; justify-items: center; }
  .exam-result-numbers { width: 100%; }
  .stats-dialog, .auth-dialog { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .form-grid { grid-template-columns: 1fr; }
  .terms-head { display: none; }
  .term { grid-template-columns: 1fr 1fr; }
  .term span[lang="fa"] { grid-column: 1 / -1; }
}
@media (max-width: 719px) {
  /* Dialogs become bottom sheets on phones. */
  .stats-dialog, .auth-dialog {
    width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0;
    border-bottom: 0; max-height: 92dvh;
  }
  /* iOS Safari zooms the page when a focused control's text is below 16px. The code field keeps its larger size. */
  input:not(#authCode), select, textarea { font-size: 16px !important; }
  /* 44px touch targets for the primary icon controls; the icons keep their size. */
  .theme-toggle, .account-button, .icon-btn, .dialog-close { width: 44px; height: 44px; }
  .dialog-close { top: 12px; inset-inline-end: 12px; }
  .block-picker { height: 46px; }
  .block-picker select { align-self: stretch; }
}
@media (min-width: 480px) {
  .tool-btn .tool-label { display: inline; }
  .session-actions #previousQuestion .btn-label { display: inline; }
}
@media (min-width: 720px) {
  .question-card { padding: 28px; }
  .question-ru { font-size: 21px; }
  .session-actions { position: static; margin: 16px 0 0; padding: 0; background: none; }
  .session-actions .action-btn { flex: 1; }
}
@media (min-width: 960px) {
  :root { --header-h: 64px; }
  .app-shell { padding-bottom: 48px; }
  main { padding-top: 28px; }
  .bottom-nav {
    position: static; height: auto; padding: 0; background: none; border: 0;
    display: grid; grid-auto-flow: column; grid-template-columns: none; gap: 4px; margin-inline-start: 24px;
  }
  .bottom-nav button { flex-direction: row; gap: 8px; height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
  .bottom-nav button .icon { width: 18px; height: 18px; }
  .bottom-nav button.active { background: var(--primary-soft); }
  body.in-session .bottom-nav { visibility: visible; }
  .home-grid {
    grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
    grid-template-areas:
      "today progress"
      "today review"
      "exam review"
      "tools block"
      "account block"
      "note note";
    align-items: start;
  }
  .area-today { grid-area: today; }
  .area-progress { grid-area: progress; }
  .area-review { grid-area: review; }
  .area-exam { grid-area: exam; }
  .area-tools { grid-area: tools; }
  .area-block { grid-area: block; }
  .area-account { grid-area: account; }
  .area-note { grid-area: note; }
  .today-card { padding: 24px; }
  .section-heading h2 { font-size: 24px; }
  .group-title { font-size: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* Shell states */
.welcome[data-state="loading"] .welcome-signed-out, .welcome[data-state="signed-out"] .welcome-loading { display: none; }
.welcome[data-state="loading"] > .welcome-logo { display: none !important; }
.welcome-loading { padding-top: 10vh; color: var(--muted); }
.home-grid.catalog-error > :not(.data-note) { display: none; }
.home-grid.catalog-error { grid-template-columns: minmax(0, 1fr); grid-template-areas: none; }
.home-grid.catalog-error > .data-note { grid-area: auto; }
.exam-unanswered { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.exam-unanswered > summary { cursor: pointer; padding: 12px 14px; font-weight: 700; font-size: 14px; color: var(--warn); }
.exam-unanswered > .exam-review-list { padding: 0 10px 10px; }
.exam-review-item.unanswered .exam-review-head span { color: var(--warn); }
.study-locked { padding: 10px 12px; border: 1px dashed var(--line-strong); border-radius: var(--r-sm); color: var(--muted); font-size: 13px !important; line-height: 1.6 !important; }
.study-explanation { display: grid; gap: 12px; }
.welcome-about { margin-top: 16px; font-size: 14px; }
.welcome-about a { color: var(--primary); font-weight: 600; }

/* Access status (home strip + study-plan dialog) */
.access-status { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.access-status .access-text { display: grid; gap: 2px; flex: 1; min-width: 0; font-size: 14px; color: var(--ink-2); }
.access-status .access-text b { color: var(--ink); font-size: 15px; }
.access-status[data-state="ending"], .access-status[data-state="ended"] { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-soft); }
.access-status .text-btn { flex: none; }
.access-reason { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--r-sm); background: var(--warn-soft); color: var(--ink); font-size: 14px; line-height: 1.6; }
.access-state { margin: 0 0 14px; font-weight: 600; color: var(--ink); }
.access-compare { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 14px; }
.access-compare section { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--surface-2); }
.access-compare section.premium { border-color: color-mix(in srgb, var(--primary) 40%, transparent); }
.access-compare h3 { margin: 0 0 8px; font-size: 14px; }
.access-compare ul { margin: 0; padding-inline-start: 18px; display: grid; gap: 6px; font-size: 14px; line-height: 1.55; color: var(--ink-2); }
.access-price { margin: 0 0 6px; font-weight: 700; color: var(--ink); }
a.action-btn { text-decoration: none; }

/* Daily plan: today's progress */
.plan-today { font-weight: 600; color: var(--ink); }
.plan-today.done { color: var(--ok); }
.plan-meter { display: block; height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; max-width: 240px; }
.plan-meter i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
