:root {
  --bg: #f5f7fa;
  --bg-alt: #eef2f7;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --muted-strong: #475569;
  --brand: #2563eb;
  --brand-hover: #1d4ed8;
  --brand-soft: #dbeafe;
  --grey: #64748b;
  --grey-hover: #475569;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --ok: #16a34a;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 8px 24px rgba(15,23,42,0.06);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }

.nav {
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px);
  background: rgba(255,255,255,0.92);
  border-bottom: 1px solid var(--border);
}
.nav-inner { display: flex; align-items: center; gap: 18px; padding: 12px 20px; max-width: 1200px; margin: 0 auto; }
.brand { font-weight: 700; letter-spacing: .2px; color: var(--text); font-size: 18px; }
.brand span { color: var(--brand); }
.nav-links { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-links a { padding: 6px 12px; border-radius: 8px; color: var(--muted-strong); font-size: 14px; font-weight: 500; }
.nav-links a:hover, .nav-links a.active { color: var(--brand); background: var(--brand-soft); text-decoration: none; }
.nav-right { display: flex; gap: 10px; align-items: center; }

.lang-toggle { display: inline-flex; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.lang-toggle button {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600;
}
.lang-toggle button.active { background: var(--brand); color: white; }

.btn {
  display: inline-block; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--brand); color: white; font-weight: 600; cursor: pointer; transition: transform .08s, background .15s;
  text-decoration: none; font-size: 14px;
}
.btn:hover { background: var(--brand-hover); text-decoration: none; }
.btn.secondary { background: var(--grey); color: white; }
.btn.secondary:hover { background: var(--grey-hover); }
.btn.outline { background: transparent; color: var(--brand); border: 1px solid var(--brand); }
.btn.outline:hover { background: var(--brand-soft); }
.btn.ghost { background: transparent; color: var(--muted-strong); }
.btn.ghost:hover { background: var(--bg-alt); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.success { background: var(--ok); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.hero { padding: 70px 0 40px; text-align: center; }
.hero h1 { font-size: clamp(30px, 4vw, 48px); margin: 0 0 14px; line-height: 1.15; letter-spacing: -0.02em; }
.hero p { font-size: 18px; color: var(--muted-strong); max-width: 720px; margin: 0 auto 26px; }
.hero .cta { display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.hero-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 18px;
  padding: 8px 20px;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  color: #166534;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.status-dot.pulse {
  animation: dot-pulse 2s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 8px; font-size: 18px; }
.card p { color: var(--muted-strong); margin: 0; font-size: 14px; }
.section { padding: 40px 0; }
.section h2 { font-size: 26px; margin: 0 0 18px; letter-spacing: -0.01em; }

.pricing-card { text-align: center; padding: 30px; }
.pricing-card .price { font-size: 44px; font-weight: 700; color: var(--brand); }
.pricing-card ul { list-style: none; padding: 0; margin: 18px 0; text-align: left; }
.pricing-card li { padding: 6px 0; color: var(--muted-strong); font-size: 14px; }
.pricing-card li::before { content: "✓ "; color: var(--ok); font-weight: 700; }

.auth-wrap { min-height: calc(100vh - 70px); display: grid; place-items: center; padding: 30px 20px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h1 { margin: 0 0 6px; }
.auth-card .subtitle { color: var(--muted); margin: 0 0 22px; }
.form-row { display: block; margin-bottom: 14px; }
.form-row label { display: block; font-size: 13px; color: var(--muted-strong); margin-bottom: 6px; font-weight: 500; }
.form-row input, .form-row select {
  width: 100%; padding: 11px 14px; border-radius: 10px;
  background: white; border: 1px solid var(--border-strong); color: var(--text);
  font-size: 15px;
}
.form-row input:focus, .form-row select:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }
.form-error { background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c; padding: 10px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.form-success { background: #f0fdf4; border: 1px solid #86efac; color: #166534; padding: 10px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }
.form-ok { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; padding: 10px; border-radius: 10px; font-size: 13px; margin-bottom: 12px; }

.demo-box {
  background: var(--brand-soft); border: 1px solid #bfdbfe; border-radius: 10px;
  padding: 12px 14px; margin-top: 16px; font-size: 13px;
}
.demo-box strong { color: var(--brand); }
.demo-box code { background: white; padding: 1px 6px; border-radius: 4px; font-size: 12px; }

.quiz-container { max-width: 780px; margin: 0 auto; }
.question { font-size: 20px; margin: 0 0 14px; font-weight: 600; }
.options { display: grid; gap: 10px; }
.option {
  display: block; padding: 14px 16px 14px 44px; border: 1px solid var(--border-strong); border-radius: 10px; background: white;
  cursor: pointer; transition: all .12s; font-size: 15px; color: var(--text); width: 100%; text-align: left;
  font-family: inherit; position: relative;
}
.option:hover { border-color: var(--brand); background: var(--brand-soft); }
.option.selected { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.option.disabled { cursor: default; pointer-events: none; }

/* Checkbox-style indicator at the left of each option. Empty while answering,
   fills with a coloured dot once the user picks that option. Stays visible in
   review mode so "what did I pick" reads at a glance. */
.option .opt-box {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; border: 2px solid var(--border-strong);
  border-radius: 4px; background: white; box-sizing: border-box;
}
.option.selected .opt-box,
.option.picked .opt-box { border-color: currentColor; }
.option.selected .opt-box::after,
.option.picked .opt-box::after {
  content: ''; display: block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); margin: 3px auto;
}

/* Review coloring: each row is tinted by whether YOUR decision on it matched
   the truth. Green if your action was right (picked a correct option, OR
   correctly skipped a wrong one); red if your action disagreed (picked a
   wrong option, OR missed a correct one). The dot (if present) shows which
   options you actually chose. Light hues so a row of three reds stays calm. */
.option.row-right { background: #f0fdf4; border-color: #86efac; color: #14532d; }
.option.row-wrong { background: #fef2f2; border-color: #fca5a5; color: #7f1d1d; }
.option.row-right.picked .opt-box::after { background: var(--ok); }
.option.row-wrong.picked  .opt-box::after { background: var(--danger); }
.progress-bar { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 14px 0; }
.progress-bar > div { height: 100%; background: var(--brand); transition: width .3s; }
.quiz-nav { display: flex; justify-content: space-between; margin-top: 18px; gap: 10px; }

.score-hero { text-align: center; padding: 30px 0; }
.score-hero .score { font-size: 68px; font-weight: 800; color: var(--brand); }

.flash-card {
  perspective: 1200px;
  max-width: 520px;
  margin: 0 auto;
  height: 280px;
  cursor: pointer;
}
.flash-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .5s; }
.flash-card.flipped .flash-inner { transform: rotateY(180deg); }
.flash-front, .flash-back {
  position: absolute; inset: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; display: grid; place-items: center; text-align: center; font-size: 22px; font-weight: 600;
  backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.flash-back { transform: rotateY(180deg); font-size: 16px; font-weight: 400; line-height: 1.6; color: var(--muted-strong); }
.flash-controls { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.reference-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 22px; }
@media (max-width: 820px) { .reference-wrap { grid-template-columns: 1fr; } }
.reference-list { max-height: calc(100vh - 180px); overflow-y: auto; padding-right: 6px; }
.reference-list .ref-item { padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--muted-strong); }
.reference-list .ref-item:hover, .reference-list .ref-item.active { background: var(--brand-soft); color: var(--brand); }
.reference-body { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; max-height: calc(100vh - 180px); overflow-y: auto; white-space: pre-wrap; font-size: 14px; box-shadow: var(--shadow); }

.search-input {
  width: 100%; padding: 10px 14px; border-radius: 10px;
  background: white; border: 1px solid var(--border-strong); color: var(--text); margin-bottom: 10px;
  font-size: 14px;
}
.search-input:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: transparent; }

.footer { padding: 40px 0; text-align: center; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); margin-top: 50px; background: var(--card); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11px; background: var(--bg-alt); border: 1px solid var(--border); color: var(--muted-strong); font-weight: 600; }
.badge.ok { color: var(--ok); background: #f0fdf4; border-color: #bbf7d0; }
.badge.warn { color: #c2410c; background: #fff7ed; border-color: #fed7aa; }
.badge.brand { color: var(--brand); background: var(--brand-soft); border-color: #bfdbfe; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
.table th { background: var(--bg-alt); color: var(--muted-strong); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:hover td { background: var(--bg-alt); }

.hide { display: none !important; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 700; color: var(--text); margin-top: 4px; }

.teaser-card {
  background: linear-gradient(135deg, var(--brand-soft), white);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 26px;
}

/* ---- Study curriculum ---- */

.study-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 32px;
  padding: 30px 20px 60px;
  align-items: start;
}

.study-toc {
  position: sticky;
  top: 70px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 14px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.study-toc h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.08em;
}

#toc-nav { display: flex; flex-direction: column; gap: 2px; }

.toc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.toc-item:hover {
  background: var(--bg-alt);
  color: var(--text);
  text-decoration: none;
  border-left-color: var(--mcolor);
}

.toc-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.toc-text { line-height: 1.35; }

.study-main h1 { margin: 0 0 8px; }

.study-intro {
  color: var(--muted-strong);
  margin: 0 0 24px;
  font-size: 15px;
  max-width: 70ch;
}

.module-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--mcolor);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  scroll-margin-top: 80px;
}

.module-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.module-badge {
  color: white;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.module-title {
  margin: 0;
  font-size: 22px;
  color: var(--text);
}

.module-summary {
  color: var(--muted-strong);
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.6;
}

.subheading {
  margin: 18px 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
}

.objectives {
  margin: 0 0 8px;
  padding-left: 20px;
  color: var(--text);
}

.objectives li { margin-bottom: 4px; }

.para-card {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-left: 3px solid var(--mcolor);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.para-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.para-ref {
  color: white;
  font-weight: 700;
  font-size: 13px;
  padding: 3px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.para-title {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
}

.para-body { display: flex; flex-direction: column; gap: 10px; }

.para-block {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
}

.para-block .label {
  color: var(--muted-strong);
  margin-right: 6px;
}

.para-block.example {
  background: white;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 10px 12px;
}

.btn.small { padding: 6px 12px; font-size: 12px; }

.act-text {
  margin-top: 10px;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.act-lang-note {
  font-size: 11px;
  color: #94a3b8;
  margin-bottom: 8px;
  font-style: italic;
}

.act-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  color: #e2e8f0;
}

@media (max-width: 900px) {
  .study-layout { grid-template-columns: 1fr; }
  .study-toc {
    position: static;
    max-height: none;
  }
}

/* ===== Landing "study first" block ===== */
.study-first {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 22px 26px;
  box-shadow: var(--shadow);
}
.study-first h2 {
  margin: 0 0 10px;
  font-size: 22px;
  color: var(--text);
}
.study-first p {
  margin: 0;
  color: var(--muted-strong);
  font-size: 15px;
  line-height: 1.65;
}

/* ===== Learn page layout ===== */
.learn-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 22px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 22px 20px 60px;
  align-items: start;
}

.learn-toc {
  position: sticky;
  top: 70px;
  max-height: calc(100vh - 90px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.learn-toc h3 {
  margin: 0 0 10px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
.search-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 10px;
  background: var(--bg-alt);
  color: var(--text);
}
.search-input:focus { outline: none; border-color: var(--brand); background: white; }

.toc-filters {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.chip {
  background: var(--bg-alt);
  border: 1px solid var(--border);
  color: var(--muted-strong);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chip:hover { background: var(--brand-soft); color: var(--brand); }
.chip.active { background: var(--brand); color: white; border-color: var(--brand); }

#toc-nav {
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}

.toc-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted-strong);
  border-left: 3px solid transparent;
  line-height: 1.35;
}
.toc-link:hover { background: var(--bg-alt); text-decoration: none; color: var(--text); }
.toc-link.toc-active {
  background: var(--brand-soft);
  color: var(--brand);
  border-left-color: var(--brand);
  font-weight: 600;
}
.toc-link.important { font-weight: 600; color: var(--text); }
.toc-link.hl-green { background: #dcfce7; border-left-color: #22c55e; color: #14532d; }
.toc-link.hl-green:hover { background: #bbf7d0; }
.toc-ref {
  font-weight: 700;
  font-size: 11px;
  color: var(--muted);
  min-width: 42px;
}
.toc-link.important .toc-ref, .toc-link.hl-green .toc-ref { color: inherit; }
.toc-t {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
  word-break: break-word;
}
.toc-note-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--brand);
  display: inline-block;
  flex-shrink: 0;
}

/* ===== Learn main column ===== */
.learn-main { min-width: 0; }
.learn-head {
  margin-bottom: 18px;
}
.learn-head h1 {
  margin: 0 0 6px;
  font-size: 28px;
}
.learn-intro {
  margin: 0;
  color: var(--muted-strong);
  font-size: 14px;
}

.learn-section {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-left: 3px solid var(--mcolor, transparent);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  transition: background .2s, border-color .2s;
}
.learn-section.hl-green {
  background: #dcfce7;
  border-color: #86efac;
  border-left-color: #22c55e;
}
.learn-section.hl-grey {
  opacity: 0.45;
  background: var(--bg-alt);
}
.learn-section.hl-grey:hover {
  opacity: 0.7;
}
.toc-link.hl-grey {
  opacity: 0.45;
  color: var(--muted);
}
.toc-link.hl-grey:hover {
  opacity: 0.7;
}
.learn-section.flash {
  box-shadow: 0 0 0 3px var(--brand-soft);
  animation: flash 1.2s ease;
}
@keyframes flash {
  0% { box-shadow: 0 0 0 0 var(--brand-soft); }
  30% { box-shadow: 0 0 0 4px var(--brand-soft); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.learn-grid {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 18px;
  align-items: start;
}

.learn-body { min-width: 0; }

.learn-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.sec-ref {
  display: inline-block;
  background: var(--bg-alt);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 3px 10px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
  margin-right: 8px;
}
.important-badge {
  display: inline-block;
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sec-title {
  margin: 6px 0 12px;
  font-size: 18px;
  color: var(--text);
  line-height: 1.3;
}

.meta-block {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.meta-block.example {
  border-style: dashed;
  background: #fefce8;
  border-color: #fde68a;
}
.meta-label {
  color: var(--muted-strong);
  margin-right: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sec-body {
  margin: 8px 0 0;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
}
.law-subsection {
  margin-bottom: 6px;
}
.law-num {
  color: var(--brand);
  font-weight: 700;
  margin-right: 2px;
}
.law-item {
  padding-left: 28px;
  margin-bottom: 4px;
}
.law-item-num {
  color: var(--muted-strong);
  font-weight: 700;
  margin-right: 2px;
}
.law-gap {
  height: 10px;
}
.law-para {
  margin-bottom: 4px;
}

.learn-notes {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  position: sticky;
  top: 90px;
}
.notes-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}
.note-area {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 140px;
  background: var(--bg-alt);
  color: var(--text);
}
.note-area:focus { outline: none; border-color: var(--brand); background: white; }
.note-status {
  margin-top: 6px;
  font-size: 11px;
  min-height: 14px;
  color: var(--muted);
}
.note-status.saving { color: var(--muted); }
.note-status.saved { color: var(--ok); }
.note-status.error { color: var(--danger); }

.highlight-btn { white-space: nowrap; }

/* ===== Topic tags on learn sections ===== */
.topic-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.topic-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ===== Landing page features grid ===== */
.section-heading {
  margin: 0 0 6px;
  font-size: 24px;
  color: var(--text);
}
.section-sub {
  margin: 0 0 16px;
  color: var(--muted-strong);
  font-size: 15px;
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.feature-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.feature-icon {
  font-size: 28px;
  margin-bottom: 10px;
}
.feature-card h3 {
  margin: 0 0 6px;
  font-size: 16px;
}
.feature-card p {
  margin: 0;
  font-size: 14px;
  color: var(--muted-strong);
  line-height: 1.5;
}

/* Topic chips on landing */
.topic-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.topic-chip-landing {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ===== Exam page ===== */
.exam-config { margin-top: 20px; }
.config-section { margin-bottom: 20px; }
.config-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.config-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--bg-alt);
  color: var(--text);
}
.topic-check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.topic-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.topic-check-item:hover { background: var(--bg-alt); }
.topic-check-color {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.exam-progress {
  width: 100%;
  height: 6px;
  background: var(--bg-alt);
  border-radius: 99px;
  margin-bottom: 12px;
  overflow: hidden;
}
.exam-progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 99px;
  transition: width .3s;
  width: 0;
}

/* ===== Exam layout with navigator ===== */
.exam-layout {
  display: grid;
  grid-template-columns: 60px 1fr;
  gap: 14px;
  align-items: start;
}
.exam-q-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.q-nav-btn {
  width: 40px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.q-nav-btn:hover { border-color: var(--brand); color: var(--brand); }
.q-nav-btn.active { background: var(--brand); color: white; border-color: var(--brand); }
.q-nav-btn.answered { background: var(--brand-soft); color: var(--brand); border-color: var(--brand); }
.q-nav-btn.active.answered { background: var(--brand); color: white; }
.exam-q-main { min-width: 0; }

@media (max-width: 600px) {
  .exam-layout { grid-template-columns: 1fr; }
  .exam-q-nav { flex-direction: row; flex-wrap: wrap; position: static; max-height: none; }
}

/* ===== Guidance page ===== */
.guide-step {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: flex-start;
}
.guide-step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.guide-step-body h3 { margin: 0 0 4px; font-size: 16px; }
.guide-step-body p { margin: 0; color: var(--muted-strong); font-size: 14px; line-height: 1.55; }
.memo-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.memo-card h4 { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.memo-card p { margin: 0; color: var(--muted-strong); font-size: 13px; line-height: 1.55; }

/* ===== Exam stats ===== */
.cat-stat-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.cat-stat-row:last-child { border-bottom: none; }
.cat-bar { flex: 1; height: 8px; background: var(--bg-alt); border-radius: 99px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 99px; transition: width .3s; }
.history-grid { display: flex; flex-direction: column; gap: 6px; }
.history-row {
  display: flex; align-items: center; gap: 14px;
  padding: 8px 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}

/* ===== Dashboard ===== */
.dash-header { margin-bottom: 20px; }
.dash-header h1 { margin: 0; font-size: 26px; }

.dash-sub-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 15px;
}
.dash-sub-card.sub-active {
  background: #f0fdf4;
  border: 1px solid #86efac;
  color: #166534;
}
.dash-sub-card.sub-inactive {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
}
.sub-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sub-dot.active { background: #22c55e; }
.sub-dot.inactive { background: #f97316; }

.dash-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.dash-stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  text-align: center;
  box-shadow: var(--shadow);
}
.dash-stat-card .num {
  font-size: 32px;
  font-weight: 800;
  color: var(--brand);
  line-height: 1;
}
.dash-stat-card .label {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 6px;
}

.dash-section-title {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--text);
}

.dash-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}

.dash-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.dash-action-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.dash-action-card:hover {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  text-decoration: none;
}
.dash-action-icon { font-size: 28px; }
.dash-action-card strong { display: block; font-size: 15px; margin-bottom: 2px; }
.dash-action-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.4; }

@media (max-width: 768px) {
  .dash-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .dash-columns { grid-template-columns: 1fr; }
  .dash-actions { grid-template-columns: 1fr; }
}

.hide { display: none !important; }

/* ===== Back to top button ===== */
.back-to-top {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--brand);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 40;
}
.back-to-top.visible {
  opacity: 1;
  pointer-events: auto;
}
.back-to-top:hover {
  background: var(--brand-hover);
  transform: scale(1.08);
}

/* ===== Text highlight toolbar ===== */
.text-hl-toolbar {
  position: absolute;
  z-index: 100;
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.text-hl-btn {
  width: 24px;
  height: 24px;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
}
.text-hl-btn[data-color="#fef08a"] { color: #ca8a04; }
.text-hl-btn[data-color="#bbf7d0"] { color: #16a34a; }
.text-hl-btn[data-color="#bfdbfe"] { color: #2563eb; }
.text-hl-btn:hover { transform: scale(1.15); }
.text-hl-remove { font-size: 11px; color: var(--danger); }
.text-hl-fade { font-size: 14px; color: var(--muted); }
.text-faded { opacity: 0.25; transition: opacity 0.15s; }
.text-faded:hover { opacity: 0.5; }

.cq-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

@media (max-width: 1100px) {
  .learn-grid { grid-template-columns: 1fr; }
  .learn-notes { position: static; }
}
@media (max-width: 900px) {
  .learn-layout { grid-template-columns: 1fr; }
  .learn-toc {
    position: static;
    max-height: none;
  }
  #toc-nav { max-height: 320px; }
}

/* Showcase alternating rows */
.showcase-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 56px;
}
.showcase-row.reverse {
  grid-template-columns: 1fr;
}
.showcase-row.reverse .showcase-img {
  order: unset;
}
.showcase-row.reverse .showcase-text {
  order: unset;
}
.showcase-img {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: box-shadow .2s;
}
.showcase-img:hover {
  box-shadow: 0 6px 28px rgba(0,0,0,0.14);
}
.showcase-img img {
  width: 100%;
  height: auto;
  display: block;
}
.showcase-text {
  text-align: left;
}
.showcase-text h3 {
  margin: 0 0 6px;
  font-size: 22px;
  color: var(--text);
}
.showcase-text p {
  margin: 0;
  font-size: 15px;
  color: var(--muted-strong);
  line-height: 1.6;
}

/* Image lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lightbox-overlay img {
  max-width: 92vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.4);
}
.lightbox-close {
  position: fixed;
  top: 16px;
  right: 20px;
  z-index: 10000;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 28px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* Landing pricing grid */
.landing-plans {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 20px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}
@media (max-width: 600px) { .landing-plans { grid-template-columns: 1fr; } }
.landing-plan-card {
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 24px;
  text-align: center;
  position: relative;
  transition: border-color .2s, box-shadow .2s;
}
.landing-plan-card:hover { border-color: var(--brand); box-shadow: 0 4px 16px rgba(37,99,235,0.08); }
.landing-plan-card.popular { border-color: var(--brand); }
.landing-plan-badge {
  position: absolute;
  top: -11px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 14px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.landing-plan-name { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.landing-plan-price { font-size: 34px; font-weight: 800; color: var(--brand); }
.landing-plan-price span { font-size: 14px; color: var(--muted); font-weight: 500; }
.landing-plan-interval { font-size: 13px; color: var(--muted-strong); margin-bottom: 16px; }
.landing-plan-features { list-style: none; padding: 0; margin: 0 0 20px; text-align: left; }
.landing-plan-features li {
  padding: 5px 0; font-size: 14px; color: var(--text);
  display: flex; gap: 8px; align-items: flex-start;
}
.landing-plan-features li::before { content: '\2713'; color: var(--ok); font-weight: 700; flex-shrink: 0; }

/* Subscription nav badge */
.nav-sub-active { color: var(--ok) !important; }
.nav-sub-badge {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: var(--ok);
  border-radius: 50%;
  margin-left: 4px;
  vertical-align: top;
  margin-top: 2px;
}

/* Paywall overlay */
.paywall-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 50vh;
  padding: 60px 20px;
}
.paywall-card {
  background: var(--card);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 48px 40px;
  max-width: 480px;
  width: 100%;
}
.paywall-card .paywall-icon {
  width: 56px;
  height: 56px;
  background: #fef2f2;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 20px;
}
.paywall-card h2 {
  font-size: 22px;
  margin: 0 0 10px;
  color: var(--danger);
}
.paywall-card p {
  color: var(--muted-strong);
  font-size: 15px;
  margin: 0 0 28px;
  line-height: 1.6;
}
.paywall-card .btn-paywall {
  display: inline-block;
  background: var(--danger);
  color: #fff;
  padding: 12px 32px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: background .15s;
}
.paywall-card .btn-paywall:hover {
  background: #b91c1c;
}

/* Mobile hamburger nav */
.nav-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text);
}
.nav-hamburger svg { display: block; }
@media (max-width: 768px) {
  .nav-hamburger { display: block; }
  .nav-links, .nav-right { display: none; }
  .nav-inner { flex-wrap: wrap; }
  .nav-inner.open .nav-links,
  .nav-inner.open .nav-right {
    display: flex;
    flex-direction: column;
    width: 100%;
    gap: 4px;
    padding-top: 8px;
  }
  .nav-inner.open .nav-links a { padding: 10px 12px; }
  .nav-inner.open .nav-right { flex-direction: row; flex-wrap: wrap; padding-bottom: 8px; }
}

/* Loading spinner on buttons */
.btn.loading { pointer-events: none; opacity: 0.7; position: relative; color: transparent; }
.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  top: 50%; left: 50%;
  margin: -8px 0 0 -8px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.btn.outline.loading::after,
.btn.ghost.loading::after { border-color: rgba(37,99,235,0.3); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

/* Toast notifications */
.toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: toastIn .3s ease;
  max-width: 360px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--ok); }
.toast.info { background: var(--brand); }
.toast.fade-out { animation: toastOut .3s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* ===== Mobile-first responsive fixes ===== */
@media (max-width: 480px) {
  body { font-size: 14px; }
  .container { padding-left: 12px; padding-right: 12px; }

  /* Nav */
  .nav-inner.open .nav-right { flex-direction: column; }
  .nav-inner.open .nav-right .btn { width: 100%; text-align: center; }

  /* Stats */
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 22px; }
  .dash-stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dash-stat-card { padding: 12px; }
  .dash-stat-card .num { font-size: 24px; }

  /* Dashboard columns */
  .dash-columns { grid-template-columns: 1fr; gap: 12px; }
  .dash-actions { grid-template-columns: 1fr; }

  /* Cards */
  .card { padding: 14px; }

  /* Tables */
  .table th, .table td { padding: 8px 6px; font-size: 12px; white-space: nowrap; }

  /* Forms */
  .form-row input, .form-row select, .form-row textarea {
    font-size: 16px; /* prevents iOS zoom on focus */
  }

  /* Hero */
  .hero h1 { font-size: 26px; }
  .hero p { font-size: 15px; }

  /* Landing features */
  .landing-features { grid-template-columns: 1fr; }
  .landing-plans { grid-template-columns: 1fr; }

  /* Exam layout */
  .exam-q-nav { gap: 4px; }
  .q-nav-btn { width: 32px; height: 32px; font-size: 12px; }

  /* History rows */
  .history-row { font-size: 12px; gap: 6px; }

  /* Footer */
  .footer { padding: 16px 12px; font-size: 12px; }

  /* Toast */
  .toast-container { top: 10px; right: 10px; left: 10px; }
  .toast { max-width: 100%; }

  /* Subscription banner */
  .dash-sub-card { padding: 12px; font-size: 13px; }

  /* Study/Learn */
  .study-first { padding: 16px; }
  .study-first h2 { font-size: 18px; }

  /* Guide steps */
  .guide-step { gap: 10px; }
  .guide-step-num { width: 28px; height: 28px; font-size: 13px; }

  /* Question cards (manager) */
  .q-card { padding: 12px; }
  .q-card-footer { flex-wrap: wrap; gap: 6px; }
  .q-edit-grid { grid-template-columns: 1fr !important; }
  .q-opt-row input[type="text"] { min-width: 0; }

  /* Manager tabs */
  .mgr-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mgr-tab { padding: 8px 14px; font-size: 13px; white-space: nowrap; }

  /* Manager "add client" form */
  #new-client-form { grid-template-columns: 1fr !important; }

  /* Filter pills */
  .q-filters { gap: 4px; }
  .q-filter-group { flex-wrap: wrap; }
  .q-pill { padding: 4px 8px; font-size: 11px; }

  /* Paywall */
  .paywall-card { padding: 20px; }
  .paywall-card h2 { font-size: 20px; }
}

@media (max-width: 360px) {
  .dash-stats-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 22px; }
}

/* ===== Page loading spinner ===== */
.page-loader {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .25s;
}
.page-loader.fade-out { opacity: 0; pointer-events: none; }
.page-loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* Hide gated content until JS decides */
.gated-content { display: none; }
.gated-content.unlocked { display: block; }
/* For learn page grid layout */
main.learn-layout.gated-content.unlocked { display: grid; }
