/* STEP UP: design system "Target score" (2026 redesign).
   Neutral off-white / true black, electric lime for progress and primary actions,
   coral for mistakes, lavender for exams. Readex Pro for display + numbers + English,
   IBM Plex Sans Arabic for Arabic body text. Light and dark follow the device unless
   the student picks one (html[data-theme]). Class names are shared by every view. */

:root {
  --lime: #D4F53C;  --lime-ink: #0A0A0A;
  --coral: #FF6242; --coral-ink: #0A0A0A;
  --lav: #C8BBFF;   --lav-ink: #0A0A0A;
  --r-sm: 12px; --r-md: 18px; --r-lg: 24px; --r-xl: 32px; --r-pill: 999px;
  --font-display: 'Readex Pro', 'IBM Plex Sans Arabic', system-ui, sans-serif;
  --font-body: 'IBM Plex Sans Arabic', 'Readex Pro', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);

  /* light (default) */
  --bg: #F3F2EC;  --bg-2: #EAE8DF;  --tile: #FFFFFF;
  --ink: #0A0A0A; --ink-2: #55544E; --ink-3: #66655E;  /* ink-3 ≥ 4.5:1 on bg and tile */
  --line: #E2E0D6; --line-2: #CFCCC0;
  --lime-soft: #EEF9C2; --lime-line: #A9C91E;
  --coral-soft: #FFE6DF; --coral-text: #C23A1B;
  --lav-soft: #EEEAFF;
  --bar: #0A0A0A;
  --black: #0A0A0A; --on-black: #F3F2EC;
  --shadow: 0 1px 2px rgba(10,10,10,.04), 0 8px 24px rgba(10,10,10,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A0A0A;  --bg-2: #121211; --tile: #171716;
    --ink: #F3F2EC; --ink-2: #A9A8A0; --ink-3: #8E8D86;
    --line: #2A2A28; --line-2: #3A3A37;
    --lime-soft: rgba(212,245,74,.12); --lime-line: rgba(212,245,74,.55);
    --coral-soft: rgba(255,98,66,.14); --coral-text: #FF8A6E;
    --lav-soft: rgba(200,187,255,.12);
    --bar: #D4F53C;
    --black: #1F1F1E; --on-black: #F3F2EC;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A0A0A;  --bg-2: #121211; --tile: #171716;
  --ink: #F3F2EC; --ink-2: #A9A8A0; --ink-3: #8E8D86;
  --line: #2A2A28; --line-2: #3A3A37;
  --lime-soft: rgba(212,245,74,.12); --lime-line: rgba(212,245,74,.55);
  --coral-soft: rgba(255,98,66,.14); --coral-text: #FF8A6E;
  --lav-soft: rgba(200,187,255,.12);
  --bar: #D4F53C;
  --black: #1F1F1E; --on-black: #F3F2EC;
  --shadow: none;
  color-scheme: dark;
}

/* ---------- base ---------- */
* { -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, .font-display, .font-bold, .text-2xl, .text-3xl, .text-xl { font-family: var(--font-display); letter-spacing: -0.01em; }
[dir="ltr"], .font-latin, .num { font-family: var(--font-display); }
.num { font-feature-settings: "tnum"; direction: ltr; unicode-bidi: isolate; }
::selection { background: var(--lime); color: var(--lime-ink); }
:focus-visible { outline: 3px solid var(--lime-line); outline-offset: 2px; border-radius: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- layout ---------- */
.screen-center { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 32px 16px; }
.page { max-width: 48rem; margin: 0 auto; padding: 28px 20px calc(120px + env(safe-area-inset-bottom)); }
.page-wide { max-width: 1240px; }
@media (min-width: 900px) { .page { padding-bottom: 64px; } }

.card { background: var(--tile); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card.hero { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); box-shadow: none; }
.card.hero .muted { color: rgba(10,10,10,.65); }
.card.hero .pill { background: rgba(10,10,10,.08); border-color: transparent; color: var(--lime-ink); }
.border-accent { border: 2px solid var(--ink); }

.muted { color: var(--ink-2); }
.text-blush { color: var(--coral-text); }
.text-ember { color: var(--ink); }
.step-label { font-family: var(--font-display); color: var(--ink-3); font-size: .8rem; font-weight: 600; margin-bottom: 4px; }
.section-title { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; letter-spacing: -0.01em; }
.disclaimer { color: var(--ink-3); font-size: .75rem; text-align: center; line-height: 1.8; }

/* logo: STEP [UP] */
.brand { display: inline-flex; align-items: center; gap: 2px; font: 700 1.3rem/1 var(--font-display); letter-spacing: -.02em; color: var(--ink); direction: ltr; text-decoration: none; }
.brand b { background: var(--lime); color: var(--lime-ink); padding: 3px 7px 4px; border-radius: 8px; margin-left: 3px; }
.brand-lg { font-size: 2rem; }
.brand-lg b { border-radius: 11px; padding: 4px 10px 6px; }
.logo-mark { display: none; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-family: var(--font-display); font-weight: 600; font-size: .95rem; display: block; margin-bottom: 8px; }
.field > span:first-child { font-family: var(--font-display); font-weight: 600; font-size: .95rem; }
.field > span:not(.flex) { display: block; }
.input {
  width: 100%; min-height: 52px; padding: 12px 16px;
  border-radius: var(--r-md); border: 1.5px solid var(--line);
  background: var(--tile); color: var(--ink); font: inherit;
  transition: border-color 150ms, box-shadow 150ms;
}
.input::placeholder { color: var(--ink-3); }
.input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 4px var(--lime-soft); }
.input[aria-invalid="true"] { border-color: var(--coral); }
.field-error { color: var(--coral-text); font: 600 .88rem var(--font-display); margin-top: 8px; }
select.input { appearance: none; background-image: none; }
.code-input { text-align: center; font: 700 1.9rem var(--font-display); letter-spacing: .5em; }

.check { display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--ink); flex-shrink: 0; }

.choice {
  display: flex; gap: 12px; align-items: center;
  padding: 14px 16px; min-height: 52px;
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  background: var(--tile); cursor: pointer;
  transition: border-color 150ms, background-color 150ms, transform 120ms var(--ease);
}
.choice:hover { border-color: var(--line-2); }
.choice input { accent-color: var(--ink); width: 18px; height: 18px; flex-shrink: 0; }
.choice:has(input:checked) { border-color: var(--ink); background: var(--lime-soft); }
.choice-sm { justify-content: center; padding: 10px 8px; font-size: .9rem; font-family: var(--font-display); font-weight: 600; }
.choice-sm input { position: absolute; opacity: 0; pointer-events: none; }
.choice-sm:has(input:checked) { background: var(--ink); color: var(--bg); }
.choice-sm:has(input:focus-visible) { outline: 3px solid var(--lime-line); outline-offset: 2px; }
.range { width: 100%; accent-color: var(--ink); height: 32px; }

.notice { border: 1.5px solid var(--coral); border-radius: var(--r-md); padding: 14px 16px; background: var(--coral-soft); }

/* ---------- buttons ---------- */
.btn-primary, .btn-ghost, .btn-danger, .btn-small, .btn-dark {
  font: 700 1rem var(--font-display); cursor: pointer; white-space: nowrap;
  border-radius: var(--r-pill);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform 140ms var(--ease), filter 150ms, background-color 150ms, border-color 150ms;
}
.btn-primary { min-height: 54px; padding: 14px 26px; background: var(--lime); color: var(--lime-ink); border: none; }
.btn-primary:hover:not(:disabled) { filter: brightness(.96); }
.btn-primary:active:not(:disabled), .btn-ghost:active:not(:disabled), .btn-dark:active:not(:disabled) { transform: scale(.97); }
.btn-dark { min-height: 54px; padding: 14px 26px; background: var(--ink); color: var(--bg); border: none; }
.btn-ghost { min-height: 50px; padding: 12px 22px; background: transparent; color: var(--ink); border: 1.5px solid var(--line-2); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { min-height: 50px; padding: 12px 22px; background: transparent; color: var(--coral-text); border: 1.5px solid var(--coral); }
.btn-small { min-height: 40px; padding: 8px 16px; font-size: .9rem; background: var(--ink); color: var(--bg); border: none; }
button:disabled { opacity: .5; cursor: not-allowed; }
.link {
  background: none; border: none; padding: 4px 0; cursor: pointer; color: var(--ink);
  font: 600 1em var(--font-display); text-decoration: underline; text-decoration-color: var(--lime-line);
  text-decoration-thickness: 3px; text-underline-offset: 4px;
}
.link:disabled { color: var(--ink-3); text-decoration: none; }

/* ---------- pieces ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-pill);
  background: var(--tile); border: 1px solid var(--line);
  font: 600 .8rem var(--font-display); white-space: nowrap; color: var(--ink);
}
.pill-lime { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.pill-dark { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.stat { padding: 16px 12px; display: flex; flex-direction: column; align-items: flex-start; text-align: start; }
.stat-value { font: 700 2rem/1.05 var(--font-display); letter-spacing: -.03em; font-feature-settings: "tnum"; }
.stat-label { color: var(--ink-2); font-size: .8rem; margin-top: 4px; }

.bar { height: 10px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--bar); border-radius: inherit; transition: width 700ms var(--ease); }
.bar-warn > span { background: var(--coral); }
.bar-lime > span { background: var(--lime); }

.seg { display: flex; gap: 4px; }
.seg > span { flex: 1; height: 10px; border-radius: var(--r-pill); background: var(--line); }
.seg > span.on { background: var(--ink); }
.seg > span.now { background: var(--lime); }

.session-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--bg); border: 1px solid var(--line); }
.session-num { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 11px; background: var(--ink); color: var(--bg); font: 700 .95rem var(--font-display); }

.rule-row {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 12px 14px; min-height: 68px;
  background: var(--tile); border: 1px solid var(--line); border-radius: var(--r-lg);
  color: var(--ink); font: inherit; cursor: pointer; text-align: start;
  transition: border-color 150ms, transform 140ms var(--ease);
}
.rule-row:hover { border-color: var(--ink); }
.rule-row:active { transform: scale(.99); }
.rule-row[data-locked] { opacity: .55; }
.rule-num { display: grid; place-items: center; flex-shrink: 0; width: 46px; height: 46px; border-radius: 15px; background: var(--bg-2); font: 700 1.1rem var(--font-display); }
.rule-row.is-current { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.rule-row.is-current .rule-num { background: var(--lime-ink); color: var(--lime); }
.rule-row.is-current .muted { color: rgba(10,10,10,.65); }
.status { font: 600 .72rem var(--font-display); padding: 4px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.status-new { border: 1px solid var(--line-2); color: var(--ink-2); }
.status-doing { background: var(--lav); color: var(--lav-ink); }
.status-done { background: var(--ink); color: var(--lime); }
.status-locked, .status-paid { border: 1px dashed var(--line-2); color: var(--ink-3); }
.rule-row.is-current .status { background: var(--lime-ink); color: var(--lime); border-color: transparent; }

.lesson { line-height: 1.95; }
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.skeleton {
  border-radius: var(--r-lg);
  background: linear-gradient(90deg, var(--tile) 0%, var(--bg-2) 50%, var(--tile) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- question session ---------- */
.session-top { display: flex; align-items: center; gap: 12px; }
.stem { font: 600 1.45rem/1.55 var(--font-display); letter-spacing: -.01em; text-align: left; }
.blank { display: inline-block; min-width: 4.2em; height: 1.2em; margin: 0 6px; vertical-align: -0.2em; border-radius: 9px; background: var(--lime); }
.options { display: grid; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 60px; padding: 12px 16px;
  background: var(--tile); color: var(--ink);
  border: 1.5px solid var(--line); border-radius: var(--r-md);
  font: 500 1.08rem var(--font-display); text-align: left; cursor: pointer;
  transition: border-color 150ms, background-color 150ms, transform 140ms var(--ease);
}
.option:hover:not(:disabled) { border-color: var(--ink); }
.option:active:not(:disabled) { transform: scale(.985); }
.option:disabled { cursor: default; opacity: 1; }
.option-letter { display: grid; place-items: center; flex-shrink: 0; width: 34px; height: 34px; border-radius: 11px; background: var(--bg-2); font: 700 .9rem var(--font-display); }
.option.is-chosen { border-color: var(--ink); }
.option.is-correct { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.option.is-correct .option-letter { background: var(--lime-ink); color: var(--lime); }
.option.is-wrong { background: var(--coral); border-color: var(--coral); color: var(--coral-ink); }
.option.is-wrong .option-letter { background: var(--coral-ink); color: var(--coral); }
.option:disabled:not(.is-correct):not(.is-wrong) { opacity: .45; }

.feedback { border-radius: var(--r-xl); }
.feedback-good { background: var(--black); color: var(--on-black); border-color: var(--black); }
.feedback-bad { background: var(--black); color: var(--on-black); border-color: var(--black); }
.feedback-good strong.text-lg { color: var(--lime); }
.feedback-bad strong.text-lg { color: var(--coral); }
.feedback .muted { color: #B9B8B0; }
.feedback .pill { background: rgba(243,242,236,.1); border-color: transparent; color: var(--lime); }
.tutor { padding: 12px 16px; border-radius: var(--r-md); background: rgba(243,242,236,.07); border: 1px dashed rgba(243,242,236,.2); }
.card:not(.feedback) .tutor { background: var(--bg); border-color: var(--line-2); }
.tutor strong { color: var(--lav); font-size: .85rem; font-family: var(--font-display); }
.summary-score { font: 700 5.5rem/1 var(--font-display); letter-spacing: -.05em; margin: 10px 0; font-feature-settings: "tnum"; }

/* ---------- lesson page ---------- */
.lesson-step { padding: 22px; }
.step-title { display: flex; align-items: center; gap: 12px; font: 700 1.15rem var(--font-display); margin-bottom: 14px; }
.step-num { display: grid; place-items: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: 10px; background: var(--ink); color: var(--lime); font: 700 .9rem var(--font-display); }
.technique { background: var(--lav-soft); border-color: transparent; }
.video-box { border-radius: var(--r-md); overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.video-box video, .video-box iframe { width: 100%; height: 100%; display: block; border: 0; background: #000; }
.video-empty { height: 100%; display: grid; place-items: center; padding: 16px; text-align: center; color: #A9A8A0; font-size: .9rem; background: #121211; }

.upload { display: flex; align-items: center; justify-content: center; min-height: 72px; padding: 14px; border: 2px dashed var(--line-2); border-radius: var(--r-md); background: var(--bg); cursor: pointer; text-align: center; }
.upload:hover { border-color: var(--ink); }
.upload input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.upload:has(input:focus-visible) { outline: 3px solid var(--lime-line); outline-offset: 2px; }
.textarea { min-height: 130px; resize: vertical; line-height: 1.85; }

/* ---------- timed quiz ---------- */
.timer { font: 700 1.1rem var(--font-display); min-width: 76px; text-align: center; padding: 8px 12px; border-radius: var(--r-pill); background: var(--ink); color: var(--bg); font-variant-numeric: tabular-nums; }
.timer-low { background: var(--coral); color: var(--coral-ink); }
.quiz-dots { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.dot { width: 40px; height: 40px; border-radius: 13px; background: var(--tile); border: 1.5px solid var(--line); color: var(--ink-3); font: 700 .9rem var(--font-display); cursor: pointer; }
.dot.is-done { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.dot.is-here { border-color: var(--ink); background: var(--lime); color: var(--lime-ink); }
.result-icon { display: grid; place-items: center; margin: 0 auto 14px; width: 72px; height: 72px; border-radius: 24px; font: 700 2rem var(--font-display); }
.result-pass .result-icon { background: var(--lime); color: var(--lime-ink); }
.result-fail .result-icon { background: var(--coral); color: var(--coral-ink); }
.result-icon svg.i { width: 36px; height: 36px; stroke-width: 2.6; }
.pill svg.i { width: 15px; height: 15px; }
.rule-num svg.i { width: 22px; height: 22px; stroke-width: 2.6; }
.review-item { padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.review-item:last-child { border-bottom: 0; padding-bottom: 0; }

/* ---------- admin review ---------- */
.review-options { display: grid; gap: 8px; list-style: none; padding: 0; margin: 0; }
.review-options li { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); background: var(--bg); border: 1.5px solid var(--line); font-family: var(--font-display); }
.review-options li.is-answer { border-color: var(--lime); background: var(--lime-soft); }
.review-options li.is-answer .option-letter { background: var(--lime); color: var(--lime-ink); }
.edit-option { display: flex; align-items: center; gap: 10px; }
.edit-option .check { flex-shrink: 0; }
.bank-list { display: grid; gap: 10px; list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.bank-list li { display: grid; grid-template-columns: 1fr 72px 64px; align-items: center; gap: 10px; }
.bank-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bank-bar { height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.bank-bar > span { display: block; height: 100%; background: var(--bar); }
.bank-count { text-align: end; font-family: var(--font-display); }

/* ---------- cumulative review ---------- */
.review-card { background: var(--lav); color: var(--lav-ink); border-color: var(--lav); box-shadow: none; }
.review-card .muted { color: rgba(10,10,10,.65); }
.review-card .btn-primary, .review-card .btn-ghost { background: var(--lav-ink); color: var(--lav); border: none; }
.review-card.is-locked { background: var(--tile); color: var(--ink); border: 1.5px dashed var(--line-2); }
.review-card.is-locked .muted { color: var(--ink-2); }

.modal {
  width: min(28rem, calc(100vw - 32px)); padding: 28px;
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--tile); color: var(--ink);
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.modal::backdrop { background: rgba(10,10,10,.55); }

/* ---------- tabs ---------- */
.tabs { display: inline-flex; gap: 6px; padding: 0; background: transparent; }
.tabs button {
  min-height: 42px; padding: 8px 18px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--tile); color: var(--ink-2); font: 600 .95rem var(--font-display); cursor: pointer;
  transition: background-color 150ms, color 150ms;
}
.tabs button[aria-selected="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- reading ---------- */
.passage { padding: 18px 20px; margin-top: 16px; max-height: 46vh; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: smooth; }
.passage-body { font-family: var(--font-display); text-align: left; line-height: 1.9; font-size: 1.03rem; }
.passage-body p + p { margin-top: 12px; }
.passage-body strong { background: var(--lav-soft); padding: 0 4px; border-radius: 5px; }
.para-num { color: var(--ink-3); font-weight: 700; }
.passage-body mark { background: var(--lime); color: var(--lime-ink); padding: 2px 4px; border-radius: 6px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.passage-table { width: 100%; border-collapse: separate; border-spacing: 0; margin: 10px 0; font-size: .95rem; border: 1px solid var(--line); border-radius: var(--r-sm); overflow: hidden; }
.passage-table th, .passage-table td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.passage-table tr:last-child td { border-bottom: 0; }
.passage-table th { background: var(--bg-2); font-weight: 700; }
.passage-source { font-size: .72rem; color: var(--ink-3); margin-top: 12px; text-align: end; }
.evidence-note { color: var(--lime); }

/* ---------- chrome: top navigation ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1240px; margin: 0 auto; display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 72px; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav button {
  font: 600 .92rem var(--font-display); color: var(--ink-2); background: none; border: 0;
  padding: 10px 16px; border-radius: var(--r-pill); cursor: pointer; transition: background-color 150ms, color 150ms;
}
.topnav button:hover:not([aria-current="page"]) { background: var(--tile); color: var(--ink); }
.topnav button[aria-current="page"] { background: var(--ink); color: var(--bg); }
.topbar-end { display: flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.icon-btn {
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--r-pill);
  background: var(--tile); border: 1px solid var(--line); color: var(--ink); cursor: pointer;
  transition: border-color 150ms;
}
.icon-btn:hover { border-color: var(--ink); }
.icon-btn[aria-pressed="true"] { background: var(--coral-soft); border-color: var(--coral); color: var(--coral-text); }
.avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--lav); color: var(--lav-ink); display: grid; place-items: center; font: 700 1rem var(--font-display); border: 0; cursor: pointer; }
.hide-sm { display: none; }
@media (min-width: 900px) {
  .topnav { display: flex; }
  .hide-sm { display: inline-flex; }
}

/* mobile: floating pill tab bar */
.bottomnav {
  position: fixed; inset-inline: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 20;
  display: flex; justify-content: space-between; padding: 7px;
  background: #0A0A0A; border-radius: var(--r-pill);
  box-shadow: 0 12px 32px rgba(0,0,0,.25);
}
:root[data-theme="dark"] .bottomnav { background: #1F1F1E; border: 1px solid #2E2E2C; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .bottomnav { background: #1F1F1E; border: 1px solid #2E2E2C; } }
.bottomnav button {
  flex: 1; display: grid; place-items: center; gap: 2px; min-height: 52px; padding: 4px 2px;
  background: none; border: none; color: #A9A8A0; border-radius: var(--r-pill);
  font: 600 .76rem var(--font-display); cursor: pointer; transition: background-color 150ms, color 150ms;
}
.bottomnav button[aria-current="page"] { background: var(--lime); color: var(--lime-ink); }
@media (min-width: 900px) { .bottomnav { display: none; } }
/* during a test: no app navigation (it covered the buttons and invited leaving mid-section) */
body.in-exam .bottomnav, body.in-exam .topnav { display: none; }

.toast {
  position: fixed; z-index: 50;
  bottom: calc(92px + env(safe-area-inset-bottom)); inset-inline: 16px;
  max-width: 30rem; margin: 0 auto; padding: 14px 18px; border-radius: var(--r-md);
  background: #0A0A0A; color: #F3F2EC; border: 1px solid #2E2E2C;
  box-shadow: 0 12px 32px rgba(0,0,0,.3); font: 500 .95rem var(--font-body);
}
@media (min-width: 900px) { .toast { bottom: 28px; } }
.toast-error { background: var(--coral); color: var(--coral-ink); border-color: var(--coral); }

/* ---------- home dashboard (bento) ---------- */
.hello { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.hello-name { font: 600 1rem var(--font-display); color: var(--ink-2); }
.hello-title { font: 700 clamp(2rem, 5vw, 3.3rem)/1.08 var(--font-display); letter-spacing: -.035em; margin-top: 6px; }
.hl { background: var(--lime); color: var(--lime-ink); padding: 0 .22em; border-radius: .28em; }
.bento { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.tile { border-radius: var(--r-xl); padding: 24px; position: relative; overflow: hidden; min-width: 0; }
.tile-cap { font: 600 .82rem var(--font-display); opacity: .72; }
.tile-lime { background: var(--lime); color: var(--lime-ink); }
.tile-black { background: var(--black); color: var(--on-black); }
.tile-black .tile-cap { color: var(--lime); opacity: 1; }
.tile-coral { background: var(--coral); color: var(--coral-ink); }
.tile-lav { background: var(--lav); color: var(--lav-ink); }
.tile-plain { background: var(--tile); border: 1px solid var(--line); box-shadow: var(--shadow); }
.span-12 { grid-column: span 12; }
@media (min-width: 900px) {
  .md-7 { grid-column: span 7; } .md-5 { grid-column: span 5; } .md-4 { grid-column: span 4; }
  .md-3 { grid-column: span 3; } .md-2 { grid-column: span 2; } .md-6 { grid-column: span 6; }
  .md-row-2 { grid-row: span 2; }
}
@media (max-width: 899px) { .sm-6 { grid-column: span 6; } }

.score-big { font: 700 clamp(6rem, 16vw, 11.5rem)/.82 var(--font-display); letter-spacing: -.06em; direction: ltr; text-align: right; margin-top: 18px; font-feature-settings: "tnum"; }
.score-big small { font-size: .3em; letter-spacing: -.02em; opacity: .42; }
.track { height: 16px; background: rgba(10,10,10,.13); border-radius: var(--r-pill); position: relative; direction: ltr; }
.track > i { position: absolute; left: 0; top: 0; bottom: 0; background: #0A0A0A; border-radius: var(--r-pill); transition: width 900ms var(--ease); }
.track > em { position: absolute; top: -9px; width: 34px; height: 34px; margin-left: -17px; border-radius: 50%; background: #FFFFFF; border: 3px solid #0A0A0A; font: 700 .68rem/28px var(--font-display); text-align: center; font-style: normal; color: #0A0A0A; }
.stamp { position: absolute; top: 20px; left: 20px; transform: rotate(-7deg); background: #0A0A0A; color: var(--lime); font: 700 .85rem var(--font-display); padding: 7px 12px; border-radius: 10px; }
.tile-big { font: 700 3.8rem/1 var(--font-display); letter-spacing: -.05em; font-feature-settings: "tnum"; }
.tile-title { font: 700 clamp(1.5rem, 3vw, 2.1rem)/1.15 var(--font-display); letter-spacing: -.02em; }
.tile .btn-primary, .tile .btn-dark, .tile .btn-ghost { min-height: 50px; }
.tile-black .btn-ghost { color: var(--on-black); border-color: rgba(243,242,236,.35); }
.tile-lav .btn-dark, .tile-coral .btn-dark, .tile-lime .btn-dark { background: #0A0A0A; color: inherit; }
.tile-lav .btn-dark { color: var(--lav); }
.tile-coral .btn-dark { color: var(--coral); }
.tile-lime .btn-dark { color: var(--lime); }
.section-head { display: flex; justify-content: space-between; align-items: baseline; margin: 40px 0 16px; }
.section-head h2 { font: 700 1.6rem var(--font-display); letter-spacing: -.02em; }
.track-card { display: flex; flex-direction: column; gap: 10px; }
.track-ic { width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center; color: #0A0A0A; }

/* ---------- games ---------- */
.game-card { display: flex; flex-direction: column; gap: 12px; min-height: 250px; }
.game-card .game-go { align-self: flex-start; margin-top: auto; }
.tile-lime.game-card .seg > span { background: rgba(10,10,10,.14); }
.tile-lime.game-card .seg > span.on { background: #0A0A0A; }
.blitz-best { font: 700 1rem var(--font-display); color: var(--lime); }
.blitz-best .num { font-size: 2.4rem; letter-spacing: -.04em; margin-inline-start: 6px; }
.blitz-count { display: grid; place-items: center; min-height: 60vh; font: 700 9rem/1 var(--font-display); letter-spacing: -.06em; }
.blitz .timer { min-width: 64px; font-size: 1.4rem; }
.blitz-flash { min-height: 2rem; margin-top: 14px; text-align: center; font: 700 1.4rem var(--font-display); }
.blitz-flash.is-good { color: var(--ink); }
.blitz-flash.is-bad { color: var(--coral-text); }
.blitz-result { padding: 36px 24px; }

/* vocabulary: flashcard */
.flashcard {
  width: 100%; min-height: 340px; padding: 22px; border-radius: var(--r-xl);
  background: var(--tile); border: 1.5px solid var(--line); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; gap: 18px;
  cursor: pointer; font: inherit; text-align: center; transition: border-color 150ms;
}
.flashcard:hover { border-color: var(--ink); }
.flashcard-word { font: 700 clamp(2.4rem, 8vw, 3.6rem)/1.1 var(--font-display); letter-spacing: -.03em; }
.flashcard-back { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.flashcard-back[hidden] { display: none; }
.flashcard-meaning { font: 700 1.5rem var(--font-body); background: var(--lime); color: var(--lime-ink); padding: 4px 14px; border-radius: 12px; }
.flashcard-example { font: 500 1.05rem/1.7 var(--font-display); color: var(--ink-2); max-width: 32rem; }
mark { background: var(--lime); color: var(--lime-ink); padding: 0 4px; border-radius: 6px; }

/* word order (adjectives) */
.wo-sentence { line-height: 2.4; }
.wo-slot { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; vertical-align: middle;
           min-width: 9rem; min-height: 48px; margin: 0 6px; padding: 5px; border-radius: 14px;
           border: 2px dashed var(--line-2); background: var(--bg); }
.wo-slot.is-right { border: 2px solid var(--lime); background: var(--lime-soft); }
.wo-slot.is-wrong { border: 2px solid var(--coral); background: var(--coral-soft); }
.wo-empty { font: 500 .85rem var(--font-body); color: var(--ink-3); padding: 0 8px; direction: rtl; }
.wo-bank { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.wo-tile { min-height: 48px; padding: 8px 18px; border-radius: var(--r-pill); cursor: pointer;
           background: var(--tile); border: 1.5px solid var(--line-2); color: var(--ink);
           font: 600 1.05rem var(--font-display); transition: transform 120ms var(--ease), border-color 150ms; }
.wo-tile:hover:not(:disabled) { border-color: var(--ink); }
.wo-tile:active:not(:disabled) { transform: scale(.96); }
.wo-tile.is-placed { background: var(--ink); color: var(--bg); border-color: var(--ink); min-height: 38px; padding: 4px 14px; font-size: 1rem; }
.wo-answer { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.wo-cat { display: inline-flex; flex-direction: column; align-items: center; padding: 6px 12px; border-radius: 12px; background: rgba(243,242,236,.1); }
.wo-cat b { font: 700 1.05rem var(--font-display); }
.wo-cat small { font: 600 .75rem var(--font-body); color: var(--lime); }
.wo-arrow { opacity: .6; }
.rule-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.rule-chip { font: 600 .8rem var(--font-body); padding: 4px 10px; border-radius: var(--r-pill); background: var(--lime-soft); color: var(--ink); }
.rule-chip.is-noun { background: var(--ink); color: var(--bg); }
.rule-arrow { color: var(--ink-3); font-size: .8rem; }

/* vocabulary: matching */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.match-col { display: grid; gap: 10px; align-content: start; }
.match-tile {
  min-height: 58px; padding: 10px 12px; border-radius: var(--r-md);
  background: var(--tile); border: 1.5px solid var(--line); color: var(--ink);
  font: 600 1rem var(--font-display); cursor: pointer; transition: background-color 150ms, border-color 150ms, opacity 200ms;
}
.match-tile:hover:not(:disabled) { border-color: var(--ink); }
.match-tile.is-picked { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.match-tile.is-matched { background: var(--lime); color: var(--lime-ink); border-color: var(--lime); opacity: .55; cursor: default; }
.match-tile.is-miss { background: var(--coral); color: var(--coral-ink); border-color: var(--coral); }

/* ---------- sign-in landing ---------- */
.auth { min-height: 100dvh; display: flex; align-items: center; padding: 40px 20px; }
.auth-grid { width: 100%; max-width: 1240px; margin: 0 auto; display: grid; gap: 40px; align-items: center; }
.auth-title { font: 700 clamp(2.2rem, 5.2vw, 4rem)/1.08 var(--font-display); letter-spacing: -.04em; margin: 28px 0 16px; max-width: 16ch; }
.auth-lead { color: var(--ink-2); font-size: 1.08rem; max-width: 34rem; }
.auth-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 32px; max-width: 40rem; }
.auth-tiles .tile { padding: 18px; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; border-radius: var(--r-lg); }
.auth-tiles .tile-big { font-size: 3rem; }
.auth-tiles .tile-cap { opacity: .85; line-height: 1.5; }
.auth-card { padding: 32px; border-radius: var(--r-xl); }
.auth-side { width: 100%; max-width: 28rem; justify-self: center; }
@media (min-width: 960px) { .auth-grid { grid-template-columns: 1.25fr 1fr; gap: 64px; } .auth-side { justify-self: end; } }
@media (max-width: 560px) { .auth-tiles { grid-template-columns: 1fr 1fr 1fr; gap: 8px; } .auth-tiles .tile { min-height: 124px; padding: 14px; } .auth-tiles .tile-big { font-size: 2.2rem; } .auth-tiles .tile-cap { font-size: .72rem; } }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.rise > * { animation: rise 520ms var(--ease) both; }
html.seen .rise > * { animation: none; }  /* play once per visit, not on every tab switch */
.rise > *:nth-child(2) { animation-delay: 60ms; } .rise > *:nth-child(3) { animation-delay: 120ms; }
.rise > *:nth-child(4) { animation-delay: 180ms; } .rise > *:nth-child(5) { animation-delay: 240ms; }

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

/* ---------- admin insights ---------- */
.ins-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 700px) { .ins-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.ins-stat { display: flex; flex-direction: column; gap: 2px; padding: 12px; border-radius: 14px; background: var(--bg); min-width: 0; }
.ins-stat strong { font: 700 1.6rem/1.1 var(--font-display); letter-spacing: -.02em; }
.ins-table { display: grid; gap: 6px; font-size: .88rem; }
.ins-row { display: grid; grid-template-columns: 1.2fr repeat(4, minmax(0, 1fr)); gap: 8px; align-items: center; }
.ins-head { font-size: .75rem; color: var(--ink-3); }
.ins-hours { display: grid; grid-template-columns: repeat(24, 1fr); gap: 3px; height: 120px; align-items: end; }
.ins-hours > span { display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.ins-hours i { display: block; background: var(--lime); border-radius: 4px 4px 0 0; }
.ins-hours b { font: 500 .62rem var(--font-display); color: var(--ink-3); text-align: center; height: 14px; }
.ins-q { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.ins-flags { list-style: none; padding: 0; margin: 0; font-size: .82rem; display: grid; gap: 2px; }
.ins-flags strong { color: var(--coral); }
.ins-opts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: .88rem; }
.ins-opts li { display: grid; grid-template-columns: 18px 1fr 70px 40px; gap: 8px; align-items: center; }
.ins-opts li.is-right { font-weight: 700; }
.ins-opts li.is-right > span:first-child { color: var(--lime-ink); background: var(--lime); border-radius: 4px; text-align: center; }
.ins-pick { height: 8px; border-radius: var(--r-pill); background: var(--line); overflow: hidden; }
.ins-pick i { display: block; height: 100%; background: var(--coral); }
.ins-opts li.is-right .ins-pick i { background: var(--lime-line, var(--lime)); }
.ins-tips { display: grid; gap: 8px; padding-inline-start: 18px; font: 600 .92rem/1.6 var(--font-display); }

/* ---------- real STEP result card + helpful? buttons ---------- */
.result-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 700px) { .result-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.result-field { display: flex; flex-direction: column; gap: 4px; font: 600 .85rem var(--font-display); }
.result-field small { opacity: .65; font-weight: 500; }
.result-card .input { background: var(--tile); color: var(--ink); }
.result-card .btn-ghost { color: inherit; border-color: rgba(10,10,10,.35); }
.result-card .link { color: inherit; }
.rate { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: .8rem; color: var(--ink-3); }
.rate button { min-width: 36px; min-height: 32px; border-radius: var(--r-pill); border: 1px solid var(--line-2); background: transparent; font-size: .95rem; line-height: 1; cursor: pointer; transition: background .2s, border-color .2s; }
.rate button:hover { border-color: var(--ink); }
.rate button[aria-pressed="true"] { background: var(--lime); border-color: var(--lime); }
.ins-quotes { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.ins-quotes li { border-inline-start: 3px solid var(--coral); padding: 4px 12px; }
.result-card { margin-bottom: 16px; }
