/* ============================================================
 * theme.css — GrammarHub v3
 * Editorial-minimal design system inspired by satstation.io.
 * Near-white canvas, near-black ink, single royal-blue accent,
 * one dark-card punctuation. Serif display + clean sans body.
 * ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Instrument+Serif:ital@0;1&family=Inter+Tight:wght@400;500;600;700&display=swap');

:root {
  /* ── palette ─────────────────────────────────────── */
  --ink:          #0B0B0C;
  --ink-2:        #1A1A1C;
  --ink-soft:     #3A3A3E;
  --muted:        #6B6B72;
  --muted-2:      #9A9AA2;
  --line:         #E6E4DE;
  --line-2:       #EFEDE7;
  --canvas:       #F7F6F2;
  --canvas-2:     #FBFAF6;
  --card:         #FFFFFF;
  --accent:       #2E48FF;
  --accent-ink:   #1A2DCC;
  --accent-soft:  #EEF0FF;
  --success:      #0B9A5A;
  --warn:         #C8801F;
  --danger:       #C23B4E;

  /* dark-card punctuation (for Premium-style panels) */
  --dark-bg:      #0E0E11;
  --dark-bg-2:    #16161B;
  --dark-line:    #2A2A31;
  --dark-ink:     #F2F1EC;
  --dark-muted:   #8E8E96;

  /* ── typography ──────────────────────────────────── */
  --font-display: 'Instrument Serif', 'Times New Roman', Georgia, serif;
  --font-body:    'Inter Tight', -apple-system, BlinkMacSystemFont, sans-serif;

  --fs-hero:   clamp(2.75rem, 8vw, 5.25rem);
  --fs-h1:     clamp(2rem, 5.5vw, 3.25rem);
  --fs-h2:     clamp(1.5rem, 4vw, 2.25rem);
  --fs-h3:     1.375rem;
  --fs-lg:     1.0625rem;
  --fs-body:   0.9375rem;
  --fs-sm:     0.8125rem;
  --fs-xs:     0.6875rem;

  /* ── geometry ────────────────────────────────────── */
  --r-sm: 8px;
  --r:    14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --r-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(11,11,12,0.04), 0 0 0 1px rgba(11,11,12,0.04);
  --shadow:    0 2px 8px rgba(11,11,12,0.05), 0 0 0 1px rgba(11,11,12,0.05);
  --shadow-lg: 0 12px 40px rgba(11,11,12,0.08), 0 0 0 1px rgba(11,11,12,0.06);

  --maxw: 720px;  /* mobile-first single column */
  --maxw-wide: 1120px;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4.5rem;
  --space-9: 6rem;
}

/* ── reset ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; text-rendering: optimizeLegibility; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "ss01", "cv11";
}
img, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
input, textarea, select { font: inherit; color: inherit; }

/* ── type ─────────────────────────────────────────── */
.display {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: -0.02em;
}
.display em { font-style: italic; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.015em;
  margin: 0 0 var(--space-4);
}
h1 { font-size: var(--fs-h1); }
h2 { font-size: var(--fs-h2); }
h3 { font-size: var(--fs-h3); font-family: var(--font-body); font-weight: 600; letter-spacing: -0.01em; }

p { margin: 0 0 var(--space-4); }
small, .sm { font-size: var(--fs-sm); color: var(--muted); }
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.lede {
  font-size: var(--fs-lg);
  color: var(--ink-soft);
  max-width: 32em;
  margin-inline: auto;
}

/* ── layout primitives ────────────────────────────── */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.container-wide {
  width: 100%;
  max-width: var(--maxw-wide);
  margin-inline: auto;
  padding-inline: var(--space-5);
}
.section { padding-block: var(--space-8); }
.section-tight { padding-block: var(--space-7); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--space-4); }
.stack-lg > * + * { margin-top: var(--space-6); }

/* ── header ───────────────────────────────────────── */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  background: rgba(247, 246, 242, 0.82);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease, background .2s ease;
}
.site-header.is-scrolled {
  border-bottom-color: var(--line);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  max-width: var(--maxw-wide);
  margin-inline: auto;
}
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
}
.brand__dot {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: var(--ink);
  position: relative;
  margin-right: 6px;
  transform: translateY(4px);
}
.brand__dot::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 999px;
  background: var(--accent);
}
.brand__name { }
.brand__name em {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-soft);
  margin-left: 2px;
}

.nav-cta {
  background: var(--ink);
  color: var(--card);
  padding: 0.6rem 1.05rem;
  border-radius: var(--r-pill);
  border: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: transform .15s ease, background .2s ease;
  white-space: nowrap;
}
.nav-cta:hover { background: var(--accent); transform: translateY(-1px); color: var(--card); }

/* ── buttons ──────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.95rem 1.5rem;
  border-radius: var(--r);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--card);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: transform .15s ease, background .2s ease, border-color .2s ease;
  min-height: 48px;
}
.btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--card);
  transform: translateY(-1px);
}
.btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
.btn--ghost:hover {
  background: var(--card);
  border-color: var(--ink);
  color: var(--ink);
}
.btn--accent {
  background: var(--accent);
  border-color: var(--accent);
}
.btn--accent:hover {
  background: var(--accent-ink);
  border-color: var(--accent-ink);
}
.btn--sm {
  padding: 0.55rem 1rem;
  min-height: 38px;
  font-size: var(--fs-sm);
  border-radius: var(--r-pill);
}
.btn--wide { width: 100%; }
.btn--big {
  padding: 1.1rem 1.75rem;
  font-size: var(--fs-lg);
  min-height: 56px;
}

/* ── cards ────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  transition: border-color .2s ease, transform .2s ease;
}
.card--flush { padding: 0; overflow: hidden; }
.card--dark {
  background: var(--dark-bg);
  color: var(--dark-ink);
  border-color: var(--dark-line);
  background-image:
    radial-gradient(1200px 300px at 80% -10%, rgba(46,72,255,0.18), transparent 60%),
    linear-gradient(180deg, var(--dark-bg) 0%, var(--dark-bg-2) 100%);
}
.card--dark .muted, .card--dark small { color: var(--dark-muted); }
.card:hover { border-color: #D9D6CC; }

/* ── pills / chips ────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--r-pill);
  border: 1px solid var(--line);
  background: var(--card);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  font-weight: 500;
}
.pill__dot {
  width: 6px; height: 6px; border-radius: 999px; background: var(--success);
}
.pill--popular {
  background: var(--accent);
  color: var(--card);
  border-color: var(--accent);
  font-size: var(--fs-xs);
  padding: 0.3rem 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.pill--accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: transparent;
}

/* ── tiny label row ───────────────────────────────── */
.label-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--fs-sm);
  color: var(--muted);
}

/* ── hero ─────────────────────────────────────────── */
.hero { padding-block: var(--space-8) var(--space-7); text-align: center; }
.hero__title {
  font-family: var(--font-display);
  font-size: var(--fs-hero);
  line-height: 0.92;
  letter-spacing: -0.025em;
  margin: 0 0 var(--space-5);
  color: var(--ink);
}
.hero__title em {
  font-style: italic;
  background: linear-gradient(180deg, var(--ink) 65%, var(--accent) 65%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding-right: 0.06em;
}
.hero__sub {
  font-size: var(--fs-lg);
  color: var(--ink-soft);
  max-width: 34em;
  margin: 0 auto var(--space-6);
  line-height: 1.5;
}

/* ── section heading ──────────────────────────────── */
.section-head { text-align: center; margin-bottom: var(--space-6); }
.section-head h2 {
  font-family: var(--font-display);
  font-size: var(--fs-h1);
  line-height: 1;
  letter-spacing: -0.02em;
}
.section-head p { color: var(--muted); max-width: 30em; margin-inline: auto; }

/* ── stat card (used on landing demo + dashboard) ── */
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-5);
}
.stat-card__top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: var(--space-5);
}
.stat-num {
  font-family: var(--font-display);
  font-size: clamp(3rem, 12vw, 4.5rem);
  line-height: 0.9;
  letter-spacing: -0.03em;
  color: var(--ink);
}
.stat-num__unit { font-size: 0.35em; color: var(--muted); margin-left: 0.25em; vertical-align: super; }
.stat-delta {
  display: inline-flex; align-items: center; gap: 0.3rem;
  font-size: var(--fs-sm); color: var(--success);
  background: #E7F5EC; padding: 0.25rem 0.55rem; border-radius: var(--r-pill);
}
.stat-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3);
  margin-top: var(--space-5);
}
.stat-tile {
  background: var(--canvas-2);
  border: 1px solid var(--line-2);
  border-radius: var(--r);
  padding: var(--space-4) var(--space-3);
  text-align: center;
}
.stat-tile__num {
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.stat-tile__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: var(--space-2);
}
.stat-tile--accent { background: var(--accent-soft); border-color: transparent; }
.stat-tile--accent .stat-tile__num { color: var(--accent-ink); }

/* ── progress bar ─────────────────────────────────── */
.bar {
  position: relative;
  height: 6px;
  background: var(--line-2);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.bar__fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: var(--ink);
  border-radius: var(--r-pill);
  transition: width .5s cubic-bezier(.22,1,.36,1);
}
.bar__fill--accent { background: var(--accent); }

/* ── list rows (unit list) ────────────────────────── */
.row-list { display: flex; flex-direction: column; }
.row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line-2);
  transition: background .15s ease;
  text-decoration: none;
  color: inherit;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--canvas-2); color: inherit; }
.row__num {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--canvas);
  border: 1px solid var(--line-2);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 1.05rem;
  color: var(--ink-soft);
}
.row__body { flex: 1; min-width: 0; }
.row__title {
  font-weight: 500;
  color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.row__meta { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }
.row__cta {
  flex: 0 0 auto;
  padding: 0.5rem 1rem;
  border-radius: var(--r-pill);
  background: var(--ink);
  color: var(--card);
  font-size: var(--fs-sm);
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--ink);
  transition: background .2s ease;
}
.row:hover .row__cta { background: var(--accent); border-color: var(--accent); }
.row__cta--resume { background: var(--accent); border-color: var(--accent); }
.row__cta--done {
  background: transparent;
  color: var(--success);
  border-color: #BFE3CD;
}
.row.is-completed .row__num { background: #E7F5EC; border-color: #BFE3CD; color: var(--success); }

/* ── step cards ───────────────────────────────────── */
.step-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  text-align: left;
}
.step-card__num {
  font-family: var(--font-display);
  font-size: 3rem;
  line-height: 0.9;
  color: var(--accent);
  margin-bottom: var(--space-3);
}

/* ── faq ──────────────────────────────────────────── */
.faq { border-top: 1px solid var(--line); }
.faq details {
  border-bottom: 1px solid var(--line);
  padding: var(--space-5) 0;
}
.faq summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  font-weight: 500;
  font-size: var(--fs-lg);
  color: var(--ink);
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: '+';
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--muted);
  transition: transform .3s ease;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > p {
  margin-top: var(--space-3);
  color: var(--ink-soft);
  font-size: var(--fs-body);
  line-height: 1.65;
}

/* ── footer ───────────────────────────────────────── */
.site-footer {
  background: var(--card);
  border-top: 1px solid var(--line);
  padding: var(--space-7) 0 var(--space-5);
  margin-top: var(--space-8);
}
.site-footer__brand { margin-bottom: var(--space-5); }
.site-footer__cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.site-footer h4 {
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 var(--space-3);
}
.site-footer ul { list-style: none; padding: 0; margin: 0; }
.site-footer li + li { margin-top: var(--space-2); }
.site-footer li a { font-size: var(--fs-sm); color: var(--ink-soft); }
.site-footer__bottom {
  padding-top: var(--space-5);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--fs-sm);
  color: var(--muted);
}
.status-dot {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: var(--fs-sm); color: var(--muted);
}
.status-dot::before {
  content: ''; width: 6px; height: 6px; border-radius: 999px;
  background: var(--success); box-shadow: 0 0 0 3px rgba(11,154,90,0.2);
}

/* ── category tiles (grammar sections grid) ──────── */
.cat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}
.cat-tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: var(--space-4);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: transform .2s ease, border-color .2s ease;
}
.cat-tile:hover { border-color: var(--ink); transform: translateY(-2px); color: inherit; }
.cat-tile__label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.cat-tile__title { font-weight: 500; margin-top: 2px; font-size: var(--fs-sm); }
.cat-tile__progress { margin-top: var(--space-3); }

/* ── word/vocab card (blue gradient) ─────────────── */
.word-card {
  background: linear-gradient(135deg, #2E48FF 0%, #4D3CE8 100%);
  color: var(--card);
  border-radius: var(--r-lg);
  padding: var(--space-5);
  position: relative;
  overflow: hidden;
}
.word-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(600px 200px at 100% 0%, rgba(255,255,255,0.15), transparent 60%);
  pointer-events: none;
}
.word-card__label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.8;
  margin-bottom: var(--space-3);
  position: relative;
}
.word-card__word {
  font-family: var(--font-display);
  font-size: 2.6rem;
  line-height: 1;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-3);
  position: relative;
}
.word-card__def {
  font-size: var(--fs-body);
  opacity: 0.92;
  position: relative;
  line-height: 1.5;
}
.word-card__meta {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.2);
  font-size: var(--fs-sm);
  opacity: 0.85;
  position: relative;
}

/* ── MCQ option buttons (grammar practice) ───────── */
.mcq {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--space-5);
}
.mcq__q {
  font-size: var(--fs-lg);
  color: var(--ink);
  font-weight: 500;
  margin-bottom: var(--space-5);
  line-height: 1.45;
}
.mcq__options {
  display: flex; flex-direction: column; gap: var(--space-3);
}
.mcq__option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--canvas-2);
  text-align: left;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
  width: 100%;
  color: var(--ink);
  font-size: var(--fs-body);
}
.mcq__option:hover:not(:disabled) {
  border-color: var(--ink);
  background: var(--card);
}
.mcq__option:active:not(:disabled) { transform: scale(0.995); }
.mcq__letter {
  flex: 0 0 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}
.mcq__option.is-correct {
  background: #E7F5EC;
  border-color: #BFE3CD;
  color: #0B6B40;
}
.mcq__option.is-correct .mcq__letter { background: var(--success); color: #fff; border-color: var(--success); }
.mcq__option.is-wrong {
  background: #FBEBEE;
  border-color: #F3C8D0;
  color: #9A2536;
}
.mcq__option.is-wrong .mcq__letter { background: var(--danger); color: #fff; border-color: var(--danger); }
.mcq__option:disabled { cursor: default; }
.mcq__explain {
  margin-top: var(--space-4);
  padding: var(--space-4);
  background: var(--canvas);
  border-radius: var(--r);
  border-left: 3px solid var(--accent);
  font-size: var(--fs-sm);
  color: var(--ink-soft);
  line-height: 1.55;
}

/* ── progress header (grammar/vocab reader) ──────── */
.reader-top {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 57px; z-index: 20;
  background: rgba(247, 246, 242, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.reader-top__inner {
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.reader-top__title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  line-height: 1.15;
  flex: 1;
  min-width: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.reader-top__count {
  font-family: var(--font-display);
  font-size: 1.6rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

/* ── theory content (injected HTML from unit.sections) ── */
.theory {
  font-size: var(--fs-lg);
  line-height: 1.7;
  color: var(--ink-soft);
}
.theory h1, .theory h2, .theory h3, .theory h4 {
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 400;
  margin-top: var(--space-6);
  margin-bottom: var(--space-3);
  line-height: 1.15;
}
.theory h2 { font-size: 1.85rem; }
.theory h3 { font-size: 1.35rem; font-family: var(--font-body); font-weight: 600; }
.theory p { margin: 0 0 var(--space-4); }
.theory strong { color: var(--ink); font-weight: 600; }
.theory em { color: var(--accent-ink); font-style: italic; }
.theory ul, .theory ol { padding-left: 1.25rem; margin: 0 0 var(--space-4); }
.theory li { margin-bottom: var(--space-2); }
.theory code {
  background: var(--canvas);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9em;
}
.theory blockquote {
  border-left: 3px solid var(--accent);
  padding: var(--space-2) var(--space-4);
  margin: var(--space-4) 0;
  background: var(--canvas-2);
  border-radius: 0 var(--r) var(--r) 0;
  color: var(--ink);
}
.theory table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-4) 0;
  font-size: var(--fs-body);
}
.theory th, .theory td {
  padding: var(--space-3);
  text-align: left;
  border-bottom: 1px solid var(--line-2);
}
.theory th { font-weight: 600; color: var(--ink); background: var(--canvas-2); }

/* ── section tabs ─────────────────────────────────── */
.tabs {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-1);
  background: var(--line-2);
  border-radius: var(--r-pill);
  margin-bottom: var(--space-5);
}
.tab {
  flex: 1;
  padding: 0.55rem 0.9rem;
  border-radius: var(--r-pill);
  background: transparent;
  border: none;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
  text-align: center;
}
.tab.is-active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ── toast (minimal) ──────────────────────────────── */
.mini-toast {
  position: fixed;
  bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--card);
  padding: 0.75rem 1.25rem;
  border-radius: var(--r-pill);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity .3s ease, transform .3s ease;
  z-index: 100;
  pointer-events: none;
}
.mini-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── responsive: small breakpoint for 2-col layouts ─ */
@media (min-width: 760px) {
  .site-footer__cols { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ══════════════════════════════════════════════════
 * DESKTOP LAYOUT (≥ 960px)
 *
 * The whole thing is mobile-first editorial. On desktop we widen the
 * main column and run the dashboard / reader as a two-column layout
 * where sensible. Content stays capped so reading measure stays good.
 * ══════════════════════════════════════════════════ */
@media (min-width: 960px) {
  :root {
    --maxw: 760px;
  }

  .hero { padding-block: var(--space-9) var(--space-8); }
  .hero__title { font-size: clamp(3.5rem, 6vw, 6.5rem); }
  .section { padding-block: var(--space-9); }

  /* Dashboard: sidebar-left + content-right */
  .dash-grid {
    display: grid;
    grid-template-columns: minmax(260px, 320px) 1fr;
    gap: var(--space-6);
    max-width: var(--maxw-wide);
    margin-inline: auto;
    padding-inline: var(--space-5);
    align-items: start;
  }
  .dash-grid > .dash-sidebar { position: sticky; top: 88px; }

  /* Grammar/vocab reader: unit list on the left, content right */
  .reader-grid {
    display: grid;
    grid-template-columns: minmax(240px, 300px) 1fr;
    gap: var(--space-6);
    max-width: var(--maxw-wide);
    margin-inline: auto;
    padding-inline: var(--space-5);
    align-items: start;
  }
  .reader-grid > .reader-sidebar {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 110px);
    overflow-y: auto;
    padding-right: 4px;
  }
  .reader-sidebar::-webkit-scrollbar { width: 6px; }
  .reader-sidebar::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }

  /* Landing pricing side-by-side */
  .pricing-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5);
  }

  /* Landing step cards side-by-side */
  .steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
  }
  .steps-grid > .step-card { margin: 0 !important; }

  /* Reader top bar stays centered even in grid layout */
  .reader-top__inner { max-width: var(--maxw-wide); }

  .reader-sidebar--desktop-only { display: block; }
}

/* Mobile: hide desktop-only sidebar by default */
.reader-sidebar--desktop-only { display: none; }

@media (min-width: 1200px) {
  .hero__title { font-size: 7rem; }
}

/* ══════════════════════════════════════════════════
 * DARK MODE
 * Uses [data-theme="dark"] on <html>. Default follows
 * prefers-color-scheme via a tiny script. Overrides only
 * the tokens — all components inherit correctly.
 * ══════════════════════════════════════════════════ */
:root[data-theme="dark"] {
  --ink:          #F4F3EE;
  --ink-2:        #E9E8E2;
  --ink-soft:     #C8C7C0;
  --muted:        #8C8C92;
  --muted-2:      #6A6A70;
  --line:         #24242A;
  --line-2:       #1C1C22;
  --canvas:       #0B0B0E;
  --canvas-2:     #111116;
  --card:         #17171D;
  --accent:       #6B82FF;
  --accent-ink:   #A2B3FF;
  --accent-soft:  #1A1F3D;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.04);
  --shadow:    0 2px 8px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.06);
}

:root[data-theme="dark"] body { background: var(--canvas); color: var(--ink); }

:root[data-theme="dark"] .site-header {
  background: rgba(11, 11, 14, 0.82);
}
:root[data-theme="dark"] .brand__dot { background: var(--ink); }
:root[data-theme="dark"] .brand__dot::after { background: var(--accent); }

:root[data-theme="dark"] .nav-cta {
  background: var(--ink);
  color: var(--canvas);
}
:root[data-theme="dark"] .nav-cta:hover { background: var(--accent); color: var(--card); }

:root[data-theme="dark"] .btn {
  background: var(--ink);
  color: var(--canvas);
  border-color: var(--ink);
}
:root[data-theme="dark"] .btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--card);
}
:root[data-theme="dark"] .btn--ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}
:root[data-theme="dark"] .btn--ghost:hover {
  background: var(--card);
  color: var(--ink);
}
:root[data-theme="dark"] .btn--accent {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--canvas);
}

:root[data-theme="dark"] .row__num {
  background: var(--canvas-2);
  border-color: var(--line);
  color: var(--ink-soft);
}
:root[data-theme="dark"] .row__cta {
  background: var(--ink);
  color: var(--canvas);
  border-color: var(--ink);
}
:root[data-theme="dark"] .row:hover { background: var(--canvas-2); }
:root[data-theme="dark"] .row.is-completed .row__num {
  background: #0F2A1C;
  border-color: #1E4D36;
  color: #4ADE80;
}
:root[data-theme="dark"] .row__cta--done {
  background: transparent;
  color: #4ADE80;
  border-color: #1E4D36;
}

:root[data-theme="dark"] .mcq__option {
  background: var(--canvas-2);
  border-color: var(--line);
  color: var(--ink);
}
:root[data-theme="dark"] .mcq__option:hover:not(:disabled) {
  background: var(--card);
  border-color: var(--ink-soft);
}
:root[data-theme="dark"] .mcq__letter {
  background: var(--card);
  border-color: var(--line);
  color: var(--muted);
}
:root[data-theme="dark"] .mcq__option.is-correct {
  background: #0F2A1C;
  border-color: #1E4D36;
  color: #86EFAC;
}
:root[data-theme="dark"] .mcq__option.is-correct .mcq__letter {
  background: #1E4D36;
  color: #86EFAC;
  border-color: #1E4D36;
}
:root[data-theme="dark"] .mcq__option.is-wrong {
  background: #2A1115;
  border-color: #4D1E26;
  color: #FCA5A5;
}
:root[data-theme="dark"] .mcq__option.is-wrong .mcq__letter {
  background: #4D1E26;
  color: #FCA5A5;
  border-color: #4D1E26;
}
:root[data-theme="dark"] .mcq__explain {
  background: var(--canvas-2);
  color: var(--ink-soft);
}

:root[data-theme="dark"] .stat-tile {
  background: var(--canvas-2);
  border-color: var(--line);
}
:root[data-theme="dark"] .stat-tile--accent {
  background: var(--accent-soft);
}
:root[data-theme="dark"] .stat-tile--accent .stat-tile__num {
  color: var(--accent-ink);
}
:root[data-theme="dark"] .stat-delta {
  background: #0F2A1C;
  color: #4ADE80;
}
:root[data-theme="dark"] .bar { background: var(--line); }

:root[data-theme="dark"] .pill {
  background: var(--card);
  border-color: var(--line);
  color: var(--ink-soft);
}
:root[data-theme="dark"] .pill--accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

:root[data-theme="dark"] .faq details { border-color: var(--line); }
:root[data-theme="dark"] .faq { border-color: var(--line); }

:root[data-theme="dark"] .site-footer {
  background: var(--card);
  border-color: var(--line);
}
:root[data-theme="dark"] .site-footer__bottom { border-color: var(--line); }

:root[data-theme="dark"] .tabs { background: var(--canvas-2); }
:root[data-theme="dark"] .tab.is-active {
  background: var(--card);
  color: var(--ink);
}

:root[data-theme="dark"] .reader-top {
  background: rgba(11, 11, 14, 0.92);
}

:root[data-theme="dark"] .theory strong { color: var(--ink); }
:root[data-theme="dark"] .theory blockquote {
  background: var(--canvas-2);
  color: var(--ink);
}
:root[data-theme="dark"] .theory code {
  background: var(--canvas-2);
}
:root[data-theme="dark"] .theory th { background: var(--canvas-2); }
:root[data-theme="dark"] .theory th, :root[data-theme="dark"] .theory td {
  border-color: var(--line);
}

/* Dark card stays dark in both themes (it's always the punctuation card) */
:root[data-theme="dark"] .card--dark {
  background: #1C1C24;
  border-color: #2A2A33;
}

/* ══════════════════════════════════════════════════
 * THEME TOGGLE BUTTON
 * ══════════════════════════════════════════════════ */
.theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
  color: var(--ink-soft);
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--ink);
  color: var(--ink);
}
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ══════════════════════════════════════════════════
 * SEARCH MODAL
 * ══════════════════════════════════════════════════ */
.search-btn {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid var(--line);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-soft);
  transition: border-color .2s ease, color .2s ease;
  flex-shrink: 0;
}
.search-btn:hover { border-color: var(--ink); color: var(--ink); }
.search-btn svg { width: 18px; height: 18px; }

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(11, 11, 12, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-6) var(--space-4);
  overflow-y: auto;
}
.search-overlay.is-open { display: flex; }
:root[data-theme="dark"] .search-overlay { background: rgba(0, 0, 0, 0.7); }

.search-modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 640px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  margin-top: 6vh;
  animation: search-pop .2s cubic-bezier(.22,1,.36,1);
}
@keyframes search-pop {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.search-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--line);
}
.search-input-wrap svg {
  width: 18px; height: 18px; color: var(--muted); flex-shrink: 0;
}
.search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-family: var(--font-body);
  font-size: var(--fs-lg);
  color: var(--ink);
  padding: var(--space-2) 0;
}
.search-input::placeholder { color: var(--muted-2); }
.search-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: var(--fs-xs);
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  background: var(--canvas);
  border: 1px solid var(--line);
  color: var(--muted);
}

.search-results {
  max-height: 60vh;
  overflow-y: auto;
  padding: var(--space-3) 0;
}
.search-section-label {
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  padding: var(--space-3) var(--space-5) var(--space-2);
}
.search-result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  cursor: pointer;
  transition: background .15s ease;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  color: var(--ink);
  text-decoration: none;
}
.search-result:hover, .search-result.is-active {
  background: var(--canvas-2);
}
.search-result__num {
  flex: 0 0 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--canvas);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--ink-soft);
}
.search-result__body { flex: 1; min-width: 0; }
.search-result__title {
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.search-result__meta {
  font-size: var(--fs-xs);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 2px;
}
.search-result mark {
  background: var(--accent-soft);
  color: var(--accent-ink);
  padding: 0 0.15em;
  border-radius: 2px;
}
:root[data-theme="dark"] .search-result mark {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.search-empty {
  padding: var(--space-6) var(--space-5);
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ══════════════════════════════════════════════════
 * BOOKMARKS
 * ══════════════════════════════════════════════════ */
.bookmark-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: color .2s ease, border-color .2s ease, background .2s ease;
  flex-shrink: 0;
}
.bookmark-btn:hover {
  color: var(--ink);
  border-color: var(--ink);
}
.bookmark-btn.is-active {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.bookmark-btn svg { width: 16px; height: 16px; }

.mcq__header {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.mcq__header .label-row { flex: 1; margin-bottom: 0; }

.bookmark-list { display: flex; flex-direction: column; gap: var(--space-3); }
.bookmark-item {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--r);
  padding: var(--space-4);
}
.bookmark-item__text {
  color: var(--ink);
  font-size: var(--fs-body);
  font-style: italic;
  line-height: 1.55;
  margin-bottom: var(--space-3);
}
.bookmark-item__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--fs-sm);
}
.bookmark-item__meta a {
  color: var(--accent);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bookmark-item__remove {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0 0.4rem;
  flex-shrink: 0;
}
.bookmark-item__remove:hover { color: var(--danger); }

.bookmark-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* ── reduced motion ───────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── focus ────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
