/* ==========================================================================
   310S Study Hub — stylesheet
   Clean, professional exam-prep visual system.
   ========================================================================== */

:root {
  /* Clean neutral dark with gold as highlight only */
  --bg: #101114;
  --bg-elev: #191b20;
  --bg-elev-2: #21242a;
  --border: #2e3138;
  --text: #e8eaed;
  --text-dim: #9ba0a8;
  --muted: #6b7078;
  --accent: #d0a050;          /* brand gold — used sparingly */
  --accent-2: #e0b868;        /* lighter gold for hover / emphasis */
  --accent-deep: #8c6a2f;     /* darker gold for gradient ends */
  --silver: #9ea0a0;          /* logo gray */
  --good: #5cb85c;
  --bad: #d9534f;
  --info: #9ba0a8;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.22);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

/* ---------- Light mode overrides ---------- */
[data-theme="light"] {
  --bg: #f4f5f7;
  --bg-elev: #ffffff;
  --bg-elev-2: #ebedf0;
  --border: #d1d5db;
  --text: #1a1c20;
  --text-dim: #4b5058;
  --muted: #7a7f88;
  --accent: #9e7a3c;
  --accent-2: #7a5c22;
  --accent-deep: #5c4318;
  --silver: #6e7070;
  --good: #2e8b2e;
  --bad: #c0392b;
  --info: #4b5058;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.07);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

body {
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.25s ease, color 0.15s ease;
}

[data-theme="light"] body {
  background: var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; letter-spacing: -0.01em; margin: 0 0 0.4em; }
h1 { font-size: clamp(1.8rem, 2.5vw + 1rem, 3rem); }
h2 { font-size: 1.6rem; margin-top: 1em; }
h3 { font-size: 1.2rem; color: var(--text); }

p { color: var(--text-dim); }

/* ---------- Layout ---------- */
.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

.nav {
  position: sticky; top: 0; z-index: 5000;
  backdrop-filter: saturate(1.4) blur(12px);
  background: rgba(16, 17, 20, 0.78);
  border-bottom: 1px solid var(--border);
  transition: background 0.25s ease;
  isolation: isolate;
  overflow: visible;
}
[data-theme="light"] .nav {
  background: rgba(244, 245, 247, 0.85);
}
.nav-inner {
  display: flex; align-items: center;
  gap: 16px;
  padding: 12px 24px; max-width: 1180px; margin: 0 auto;
  width: 100%;
  min-width: 0;
  position: relative;
  z-index: 1;
  overflow: visible;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 800; letter-spacing: -0.02em; color: var(--text);
  flex-shrink: 0;
}
.logo span:not(.logo-badge) {
  font-size: 0.98rem;
}
.logo-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-deep));
  color: #1a1814; font-weight: 900; font-size: 0.78rem;
  box-shadow: 0 6px 14px rgba(208,160,96,.35);
  letter-spacing: -0.03em;
}
/* ---------- Trade switcher ---------- */
.trade-switcher {
  position: relative;
  margin-left: 6px;
  padding-left: 14px;
  border-left: 1px solid var(--border);
  flex-shrink: 0;
}
.trade-switcher-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font-size: 0.82rem; font-weight: 600;
  padding: 5px 10px; cursor: pointer; transition: border-color .15s;
}
.trade-switcher-btn:hover { border-color: var(--accent); }
.trade-active-badge {
  color: var(--accent); font-weight: 700;
}
.trade-switcher-btn svg { opacity: .5; transition: transform .15s; }
.trade-switcher.open .trade-switcher-btn svg { transform: rotate(180deg); }
.trade-dropdown {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 220px; background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); z-index: 200;
  padding: 4px; overflow: hidden;
}
.trade-switcher.open .trade-dropdown { display: block; }
.trade-option {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: none; padding: 10px 12px; cursor: pointer;
  color: var(--text); font-size: 0.85rem; text-align: left; border-radius: var(--radius-sm);
  transition: background .12s;
}
.trade-option:hover { background: var(--bg-elev-2); }
.trade-option.active { background: var(--bg-elev-2); }
.trade-option.active strong { color: var(--accent); }
.trade-option strong { font-size: 0.9rem; min-width: 36px; }
.trade-option span { color: var(--text-dim); font-size: 0.82rem; }

.nav ul {
  list-style: none;
  display: flex;
  gap: 2px;
  margin: 0 12px;
  padding: 0;
  align-items: center;
  flex: 1 1 auto;
  justify-content: flex-start;
}
.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
  min-width: 0;
  position: relative;
  z-index: 2;
  overflow: visible;
}
.auth-slot {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  position: relative;
  z-index: 2;
  overflow: visible;
}

/* ---------- User menu (logged in) ---------- */
.user-menu {
  position: relative;
  z-index: 3;
}
.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
  font-family: inherit;
}
.user-menu-btn:hover {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.user-menu.open .user-menu-btn {
  border-color: var(--accent);
  background: var(--bg-elev-2);
}
.user-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-deep));
  color: #1a1814;
  font-weight: 800;
  font-size: 0.85rem;
  letter-spacing: -0.02em;
  box-shadow: 0 4px 10px rgba(208,160,96,.35);
}
.user-menu-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 260px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  z-index: 1000;
}
.user-menu.open .user-menu-panel,
.user-menu-panel.is-open { display: block; }
.user-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 2147483646;
}
.user-menu-overlay.is-open {
  display: block;
}
.user-menu-panel.user-menu-portal {
  position: fixed;
  top: 0;
  left: 0;
  right: auto;
  z-index: 2147483647;
}
.user-menu-header {
  padding: 10px 12px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.user-menu-email {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-menu-license {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  margin-top: 6px;
  border-radius: 999px;
  background: rgba(208,160,80,0.12);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.user-menu-license.is-empty {
  background: var(--bg-elev-2);
  color: var(--text-dim);
}
.user-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  text-align: left;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none !important;
  transition: background .12s ease, color .12s ease;
}
.user-menu-item:hover {
  background: var(--bg-elev-2);
  color: var(--text);
  text-decoration: none;
}
.user-menu-item-value {
  color: var(--text-dim);
  font-size: 1rem;
}
.user-menu-theme .icon-sun { display: none; }
[data-theme="light"] .user-menu-theme .icon-sun { display: inline; }
[data-theme="light"] .user-menu-theme .icon-moon { display: none; }
.user-menu-logout {
  color: var(--text-dim);
  border-top: 1px solid var(--border);
  margin-top: 4px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.user-menu-logout:hover {
  color: var(--bad);
  background: rgba(217, 83, 79, 0.08);
}

/* Hide the standalone theme toggle whenever the user-menu is active (theme lives inside the menu then). */
.nav-controls:has(.user-menu) .theme-toggle {
  display: none;
}

/* Utility */
.is-hidden { display: none !important; }
.btn-sm {
  padding: 8px 10px;
  font-size: 0.82rem;
  border-radius: 8px;
}
.nav-menu-toggle {
  display: none;
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
}
.nav-menu-toggle .bars {
  width: 16px;
  height: 12px;
  position: relative;
  display: inline-block;
}
.nav-menu-toggle .bars::before,
.nav-menu-toggle .bars::after,
.nav-menu-toggle .bars span {
  content: "";
  position: absolute;
  left: 0;
  width: 16px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-menu-toggle .bars::before { top: 0; }
.nav-menu-toggle .bars span { top: 5px; }
.nav-menu-toggle .bars::after { top: 10px; }

.nav.nav-open .nav-menu-toggle .bars::before { transform: translateY(5px) rotate(45deg); }
.nav.nav-open .nav-menu-toggle .bars span { opacity: 0; }
.nav.nav-open .nav-menu-toggle .bars::after { transform: translateY(-5px) rotate(-45deg); }
.nav a.link {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-weight: 500;
  font-size: 0.92rem;
  letter-spacing: 0.01em;
  transition: color .15s ease, background .15s ease;
}
.nav a.link:hover { background: var(--bg-elev); color: var(--text); text-decoration: none; }
.nav a.link.active {
  color: var(--text);
  background: var(--bg-elev-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

/* ---------- Hero ---------- */
.hero { padding: 64px 0 24px; }
.hero .tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
}
.hero p.lead { font-size: 1.1rem; color: var(--text-dim); max-width: 720px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 16px; border-radius: 8px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: transform .08s ease, background .15s ease, border-color .15s ease;
  font-family: inherit; font-size: 0.95rem;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: #111; font-weight: 700; }
.btn-primary:hover { background: var(--accent-2); color: #111; text-decoration: none; }
.btn-lg {
  padding: 14px 28px;
  font-size: 1.1rem;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
.btn-lg:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-elev); text-decoration: none; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }

/* ---------- Cards / Grid ---------- */
.grid { display: grid; gap: 18px; }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 900px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card .icon {
  min-width: 40px;
  width: fit-content;
  height: 24px;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  border: 1px solid var(--border);
  margin-bottom: 10px;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  padding: 0 10px;
}
.card a.cta { display: inline-block; margin-top: 10px; color: var(--accent); font-weight: 600; }

/* ---------- Home template ---------- */
.home-template { padding: 20px 0 80px; }
.home-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.8fr);
  gap: 18px;
  align-items: stretch;
}
.home-hero-copy {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.home-hero-copy h1 {
  max-width: 16ch;
  line-height: 1.12;
}
.home-hero-copy .btn-row { margin-top: 18px; }

.home-snapshot {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.home-snapshot h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  color: var(--text-dim);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.snapshot-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}
.snapshot-row:last-child { border-bottom: none; }
.snapshot-row span {
  color: var(--text-dim);
  font-size: 0.9rem;
}
.snapshot-row strong {
  color: var(--text);
  font-size: 0.95rem;
}

.home-feature-list {
  margin-top: 16px;
  display: grid;
  gap: 12px;
}
.feature-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 14px;
  padding: 16px 18px;
}
.feature-row .icon { margin: 2px 0 0; }
.feature-row h3 { margin: 0 0 6px; font-size: 1.05rem; }
.feature-row p { margin: 0; }
.feature-row .cta {
  margin-top: 0;
  align-self: center;
  white-space: nowrap;
}

.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 12px; margin-top: 28px;
}
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2, 1fr); } }
.stat {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.stat .n { font-size: 1.6rem; font-weight: 800; color: var(--text); }
.stat .l { color: var(--text-dim); font-size: 0.85rem; }

/* ---------- Study page ---------- */
.study-layout { display: grid; grid-template-columns: 260px 1fr; gap: 28px; padding: 30px 0 80px; }
@media (max-width: 900px) { .study-layout { grid-template-columns: 1fr; } }
.toc {
  position: sticky; top: 80px; align-self: start;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
  max-height: calc(100vh - 100px); overflow-y: auto;
}
.toc h4 { margin: 6px 10px; color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }
.toc a {
  display: block; padding: 8px 10px; border-radius: 8px;
  color: var(--text-dim); font-size: 0.92rem;
}
.toc a:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.toc a.active { background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border); }

.topic {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
  scroll-margin-top: 90px;
}
.topic h2 { margin-top: 0; color: var(--text); display: flex; align-items: center; gap: 10px; }
.topic .pct { font-size: 0.8rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: rgba(158, 160, 160, 0.12); color: var(--info); border: 1px solid rgba(158,160,160,.3); }
.topic ul { padding-left: 1.2em; }
.topic li { margin: 6px 0; color: var(--text-dim); }
.topic li strong { color: var(--text); font-weight: 600; }
.topic .kv { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
@media (max-width: 700px) { .topic .kv { grid-template-columns: 1fr; } }
.topic .kv div { background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; }

.hot-take {
  border-left: 3px solid var(--accent);
  background: var(--bg-elev-2);
  padding: 10px 14px; border-radius: 0 8px 8px 0;
  margin: 12px 0; color: var(--text);
}
.hot-take strong { color: var(--accent); }

/* ---------- Quiz page ---------- */
.quiz-shell { padding: 30px 0 80px; }
.quiz-setup, .quiz-runner, .quiz-results {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; margin-bottom: 20px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 16px; }
.quick-starts { margin: 14px 0 18px; }
.quick-start-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.quick-start-btn { white-space: nowrap; }
.chip {
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  background: var(--bg-elev-2); border: 1px solid var(--border);
  color: var(--text-dim); font-size: 0.9rem; user-select: none;
}
.chip.active { background: var(--bg-elev); border-color: var(--accent); color: var(--text); }
.chip:hover { color: var(--text); }

.field { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.field label { min-width: 140px; color: var(--text-dim); font-size: 0.92rem; }
.field input[type="number"], .field select {
  background: var(--bg-elev-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; color: var(--text);
  font-family: inherit; font-size: 0.95rem;
}
.quiz-tip {
  margin-top: 18px;
  padding: 16px 18px;
}
.quiz-tip h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}
.quiz-tip p {
  margin: 0;
  color: var(--text-dim);
}

.progress-bar {
  height: 6px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden; margin: 10px 0 18px;
}
.progress-bar > div { height: 100%; background: linear-gradient(90deg, var(--accent-deep), var(--accent-2)); width: 0%; transition: width .25s ease; }
.q-meta { display: flex; justify-content: space-between; color: var(--text-dim); font-size: 0.85rem; margin-bottom: 8px; }
.q-text { font-size: 1.12rem; font-weight: 600; margin: 8px 0 16px; }

.quiz-diagram {
  margin: 0 0 18px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: auto;
}

.quiz-diagram--compact {
  margin: 10px 0 14px;
  padding: 10px;
}

.quiz-diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
  color: var(--text);
}
.q-topic { display: inline-block; margin-left: 6px; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
  background: rgba(158,160,160,.12); color: var(--info); border: 1px solid rgba(158,160,160,.3); vertical-align: middle; }

.options { display: grid; gap: 10px; }
.option {
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text);
  display: flex; align-items: flex-start; gap: 10px; transition: border-color .1s ease, background .1s ease;
}
.option:hover { border-color: var(--accent); }
.option .k {
  flex: 0 0 28px; height: 28px; border-radius: 8px;
  background: var(--bg-elev); display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; color: var(--text-dim); font-family: var(--mono); font-size: 0.85rem;
}
.option.selected { border-color: var(--accent); background: rgba(155, 160, 168, 0.10); }
.option.correct { border-color: var(--good); background: rgba(139, 179, 106, 0.12); }
.option.correct .k { background: var(--good); color: #0f1a08; }
.option.incorrect { border-color: var(--bad); background: rgba(215, 103, 103, 0.12); }
.option.incorrect .k { background: var(--bad); color: #2a0a0a; }

.explain {
  margin-top: 14px; padding: 12px 14px;
  background: rgba(158,160,160,.07); border: 1px solid rgba(158,160,160,.25);
  border-radius: 10px; color: var(--text);
}
.explain-shell { margin-top: 14px; }
.explain-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(158,160,160,.07);
  border: 1px solid rgba(158,160,160,.25);
  border-radius: 10px;
  color: var(--text);
}
.explain strong { color: var(--accent); }

.quiz-ctl { display: flex; gap: 10px; justify-content: space-between; margin-top: 18px; }

.result-big { font-size: 3rem; font-weight: 900; }
.result-big.pass { color: var(--good); }
.result-big.fail { color: var(--bad); }
.result-breakdown { margin-top: 18px; }
.result-breakdown .row {
  display: grid; grid-template-columns: 1fr 80px 120px;
  gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border);
}
.result-breakdown .row:last-child { border-bottom: none; }
.bar-tiny {
  height: 6px; background: var(--bg-elev-2); border-radius: 999px; overflow: hidden;
}
.bar-tiny > div { height: 100%; background: var(--good); }

/* ---------- Cheatsheet ---------- */
.cheat-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 24px 0 12px; }
.cheat-doc {
  background: white; color: #111;
  border-radius: var(--radius); padding: 28px 32px; margin-bottom: 40px;
  box-shadow: var(--shadow);
}
.cheat-doc h1, .cheat-doc h2, .cheat-doc h3 { color: #111; }
.cheat-doc h1 { border-bottom: 3px solid #d0a060; padding-bottom: 8px; }
.cheat-doc h2 {
  background: #1a1814; color: #e8c589; padding: 6px 12px; border-radius: 6px;
  font-size: 1.1rem; margin-top: 20px;
  border-left: 4px solid #d0a060;
}
.cheat-doc h3 { color: #8c6a2f; margin-top: 12px; font-size: 1rem; }
.cheat-doc p, .cheat-doc li { color: #222; }
.cheat-doc ul { padding-left: 1.2em; margin: 6px 0 10px; }
.cheat-doc li { margin: 2px 0; font-size: 0.93rem; }
.cheat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 700px) { .cheat-grid { grid-template-columns: 1fr; } }
.cheat-reminders {
  columns: 2;
  column-gap: 30px;
  margin-top: 6px;
}
@media (max-width: 700px) { .cheat-reminders { columns: 1; } }
.cheat-box {
  border: 1px solid #ddd; border-radius: 8px; padding: 10px 14px; background: #fafafa;
}
.cheat-box h3 { margin-top: 0; }
.cheat-kbd {
  display: inline-block; font-family: var(--mono); font-size: 0.8rem;
  background: #eee; color: #111; padding: 2px 6px; border-radius: 4px; border: 1px solid #ccc;
}
.cheat-footer { margin-top: 20px; border-top: 1px dashed #bbb; padding-top: 10px;
  font-size: 0.8rem; color: #666; display: flex; justify-content: space-between; }

/* ---------- Mobile-first refinements ---------- */
@media (max-width: 900px) {
  .container { padding: 0 16px; }

  .nav-inner {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 16px;
    overflow: visible;
  }
  .logo { order: 1; }
  .trade-switcher {
    order: 2;
    margin-left: 4px;
    padding-left: 10px;
  }
  .trade-dropdown { left: 0; right: auto; }
  .nav-controls {
    order: 3;
    margin-left: auto;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
  }
  .auth-slot {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
  .user-menu-panel {
    min-width: 240px;
    max-width: min(280px, calc(100vw - 24px));
    z-index: 9999;
  }
  .user-menu-overlay.is-open {
    background: rgba(0, 0, 0, 0.24);
  }
  .user-menu-panel.user-menu-portal {
    left: 12px;
    right: 12px;
    width: auto;
    max-width: none;
    border-radius: 14px;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
  }
  .nav-menu-toggle { display: inline-flex; }
  .nav ul {
    order: 4;
    width: 100%;
    display: none;
    margin: 4px 0 0;
    padding: 8px;
    gap: 2px;
    flex-direction: column;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
  }
  .nav.nav-open ul { display: flex; }
  .nav a.link {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    font-size: 0.95rem;
  }
  .nav a.link.active {
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .hero { padding: 36px 0 14px; }
  .hero p.lead { font-size: 1rem; }

  .home-template { padding: 12px 0 50px; }
  .home-hero-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  .home-hero-copy {
    padding: 18px 16px;
  }
  .home-hero-copy h1 {
    max-width: none;
    font-size: clamp(1.55rem, 7vw, 2rem);
  }
  .home-snapshot {
    padding: 16px;
  }
  .feature-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .feature-row .cta {
    justify-self: start;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-elev-2);
  }

  .btn-row .btn {
    width: 100%;
    justify-content: center;
  }

  .study-layout {
    gap: 16px;
    padding: 14px 0 50px;
  }
  .toc {
    position: static;
    top: auto;
    max-height: none;
  }
  .topic { padding: 18px; }

  .quiz-shell { padding: 16px 0 50px; }
  .quiz-setup, .quiz-runner, .quiz-results { padding: 16px; }
  .field {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }
  .field label { min-width: 0; }
  .field input[type="number"],
  .field select { width: 100%; }
  .q-meta {
    flex-wrap: wrap;
    gap: 8px;
  }
  .q-text { font-size: 1.02rem; }
  .quiz-ctl {
    flex-direction: column;
    gap: 8px;
  }
  .quiz-ctl .btn {
    width: 100%;
    justify-content: center;
  }
  .result-breakdown .row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .cheat-topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .cheat-topbar .btn {
    width: 100%;
    justify-content: center;
  }
  .cheat-doc {
    padding: 18px 16px;
    border-radius: 10px;
  }
  .cheat-footer {
    display: block;
  }
  .cheat-footer span {
    display: block;
    margin-bottom: 6px;
  }
}

@media (max-width: 520px) {
  .stats { grid-template-columns: 1fr; }
  .purchase-two-col { grid-template-columns: 1fr; }
}

/* ---------- Login portal ---------- */
.auth-page {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  padding: 24px 0 60px;
}
.auth-card {
  width: 100%;
  max-width: 460px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.auth-card h1 {
  font-size: 1.7rem;
  margin-bottom: 10px;
}
.auth-help {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.auth-form {
  display: grid;
  gap: 12px;
}
.auth-form label {
  font-size: 0.9rem;
  color: var(--text-dim);
}
.auth-form input {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}
.auth-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.auth-status {
  min-height: 22px;
  font-size: 0.88rem;
  color: var(--text-dim);
}
.auth-status-inline {
  margin: 8px 0 4px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev-2);
  min-height: 0;
}
.auth-status-inline.error {
  border-color: rgba(217, 83, 79, 0.45);
  color: var(--bad);
  background: rgba(217, 83, 79, 0.08);
}
.auth-status-inline.success {
  border-color: rgba(92, 184, 92, 0.45);
  color: var(--good);
  background: rgba(92, 184, 92, 0.08);
}
.auth-status.error { color: var(--bad); }
.auth-status.success { color: var(--good); }

/* Member portal (single column) */
.auth-portal-single {
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
}
.auth-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.auth-help-tight {
  margin-bottom: 14px;
  line-height: 1.45;
}
.auth-card-login h1 {
  margin-bottom: 8px;
}
.auth-portal-divider {
  height: 1px;
  background: var(--border);
  margin: 22px 0;
}
.auth-h2 {
  font-size: 1.2rem;
  margin: 0 0 8px;
  font-weight: 700;
}
.auth-card-minimal {
  padding: 18px 22px;
}
.auth-full-btn {
  display: flex;
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}
.nav-controls-login {
  margin-left: auto;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
}
.purchase-nav-links {
  list-style: none;
  display: flex;
  gap: 2px;
  margin: 0 0 0 8px;
  padding: 0;
  align-items: center;
  flex: 1 1 auto;
}
@media (max-width: 640px) {
  .purchase-nav-links {
    display: none;
  }
}

/* Purchase page layout */
.purchase-main {
  padding-bottom: 56px;
  max-width: 1040px;
  min-width: 0;
}
/* Full-bleed hero glow (purchase page only): wide layer aligned to viewport so radial doesn’t clip at column edges */
.purchase-main:has(.landing-hero) {
  position: relative;
  overflow-x: hidden;
}
.purchase-main:has(.landing-hero)::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 320px;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(
      ellipse 78% 88% at 50% 0%,
      rgba(208,160,80,0.13) 0%,
      rgba(208,160,80,0.055) 34%,
      rgba(208,160,80,0.02) 54%,
      transparent 76%
    );
}
[data-theme="light"] .purchase-main:has(.landing-hero)::before {
  background:
    radial-gradient(
      ellipse 78% 88% at 50% 0%,
      rgba(158,122,60,0.1) 0%,
      rgba(158,122,60,0.04) 34%,
      rgba(158,122,60,0.015) 54%,
      transparent 76%
    );
}
.purchase-main:has(.landing-hero) > * {
  position: relative;
  z-index: 1;
}
.purchase-status-banner {
  margin: 16px 0 0;
  min-height: 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  font-size: 0.9rem;
  color: var(--text-dim);
}
.purchase-status-banner.error {
  border-color: rgba(217, 83, 79, 0.45);
  color: var(--bad);
  background: rgba(217, 83, 79, 0.08);
}
.purchase-status-banner.success {
  border-color: rgba(92, 184, 92, 0.45);
  color: var(--good);
  background: rgba(92, 184, 92, 0.08);
}
.purchase-zone-status:empty {
  display: none;
  margin: 0;
  padding: 0;
  border: none;
  min-height: 0;
  background: transparent;
}
.purchase-zone-status:not(:empty) {
  margin-top: 10px;
  margin-bottom: 14px;
}
#purchase-checkout-status:not(:empty) {
  margin-top: 20px;
  margin-bottom: 6px;
}
.purchase-hero {
  padding-top: 28px;
  padding-bottom: 8px;
}
.purchase-lead {
  max-width: 640px;
}
.purchase-account-card {
  margin-top: 10px;
  margin-bottom: 18px;
}
.purchase-signup-form {
  margin-top: 8px;
}
.purchase-card-desc {
  color: var(--text-dim);
  margin: 0 0 10px;
  font-size: 0.95rem;
}
.auth-help-foot {
  margin-top: 14px;
  margin-bottom: 0;
  font-size: 0.82rem;
}

/* ---------- Landing / purchase page hero ---------- */
.landing-hero {
  position: relative;
  padding: 64px 0 32px;
  text-align: left;
  max-width: 780px;
  min-width: 0;
  overflow: visible;
  isolation: isolate;
}
.landing-kicker {
  display: inline-block;
  padding: 4px 12px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.landing-title {
  font-size: clamp(2rem, 3.4vw + 1rem, 3.6rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  max-width: 18ch;
  color: var(--text);
}
.landing-title-accent {
  background: linear-gradient(120deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.landing-lead {
  font-size: 1.08rem;
  color: var(--text-dim);
  max-width: 62ch;
  margin: 0 0 24px;
}
.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 32px;
}
.landing-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
  min-width: 0;
}
.landing-stat {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  min-width: 0;
}
.landing-stat-n {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.landing-stat-l {
  display: block;
  color: var(--text-dim);
  font-size: 0.82rem;
  margin-top: 2px;
}
@media (max-width: 780px) {
  .landing-stats { grid-template-columns: repeat(2, 1fr); }
  .landing-hero { padding: 36px 0 24px; }
}

/* ---------- Purchase page ---------- */
.purchase-grid,
.purchase-secondary {
  margin-top: 28px;
}
.purchase-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.purchase-code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 68px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(208,160,80,0.35);
  background: rgba(208,160,80,0.1);
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 0.04em;
}
.purchase-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-dim);
}
.purchase-list li {
  margin: 8px 0;
}
.purchase-request-card {
  margin-top: 18px;
}
.purchase-card.is-owned {
  border-color: rgba(92, 184, 92, 0.45);
  background: linear-gradient(180deg, rgba(92,184,92,0.06), transparent 70%), var(--bg-elev);
}
.purchase-owned-badge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 4px;
}
.purchase-owned-tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(92, 184, 92, 0.14);
  color: var(--good);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.01em;
}
.purchase-owned-card {
  margin-top: 18px;
  border-color: rgba(92, 184, 92, 0.45);
  background: linear-gradient(180deg, rgba(92,184,92,0.07), transparent 80%), var(--bg-elev);
}

/* ---------- Plan cards with preview ---------- */
.plan-card {
  padding: 0;
  overflow: hidden;
  transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.plan-card:hover {
  border-color: rgba(208,160,80,0.45);
  box-shadow: 0 12px 32px rgba(0,0,0,.28);
}
.plan-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 22px 22px 16px;
  background: linear-gradient(135deg, rgba(208,160,80,0.12), transparent 70%);
  border-bottom: 1px solid var(--border);
  min-width: 0;
  max-width: 100%;
}
.plan-head-text {
  min-width: 0;
}
.plan-310t .plan-head {
  background: linear-gradient(135deg, rgba(155,160,168,0.14), transparent 70%);
}
.plan-310j .plan-head {
  background: linear-gradient(135deg, rgba(230,110,60,0.14), transparent 70%);
}
.plan-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent-deep));
  color: #1a1814;
  font-weight: 900;
  font-size: 1rem;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 20px rgba(208,160,96,.35);
  flex-shrink: 0;
}
.plan-310t .plan-badge {
  background: linear-gradient(135deg, #cfd3d9, #7a7f88);
  color: #1a1c20;
  box-shadow: 0 8px 20px rgba(158,160,160,.28);
}
.plan-310j .plan-badge {
  background: linear-gradient(135deg, #f59f6c, #e06c3a);
  color: #1a1005;
  box-shadow: 0 8px 20px rgba(224,108,58,.28);
}
.plan-head-text h2 {
  margin: 0 0 2px;
  font-size: 1.2rem;
  line-height: 1.2;
}
.plan-head-text .purchase-card-desc {
  margin: 0;
}
.plan-price {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 22px 0;
  min-width: 0;
}
.plan-price-amount {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
}
.plan-price-interval {
  color: var(--text-dim);
  font-weight: 500;
}
.plan-price-note {
  margin-left: auto;
  font-size: 0.78rem;
  color: var(--text-dim);
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
}
.plan-features {
  margin: 12px 22px 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  min-width: 0;
}
.plan-features li {
  position: relative;
  padding-left: 22px;
  color: var(--text-dim);
  font-size: 0.94rem;
  line-height: 1.45;
}
.plan-features li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.55em;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(208,160,80,0.2);
  box-shadow: inset 0 0 0 2px var(--accent);
}

/* Preview block */
.plan-preview {
  position: relative;
  margin: 18px 22px 0;
  padding: 16px 16px 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev-2);
  overflow: hidden;
  min-width: 0;
}
.plan-preview-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.plan-preview-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(208,160,80,0.14);
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.plan-preview-title {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
}
.plan-preview-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.preview-topic-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
}
.preview-notes-head,
.preview-q-head {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin: 12px 0 6px;
}
.preview-notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}
.preview-notes-list li {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-dim);
}
.preview-notes-list li strong {
  color: var(--text);
  font-weight: 700;
  white-space: normal;
}
.preview-notes-list li span strong {
  color: var(--accent);
  white-space: normal;
}
.plan-preview-question {
  margin-top: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
}
.preview-q-text {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 0.92rem;
}
.preview-q-options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 4px;
  counter-reset: none;
}
.preview-q-options li {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.88rem;
  background: var(--bg-elev-2);
}
.preview-q-options li.is-correct {
  background: rgba(92, 184, 92, 0.12);
  color: var(--text);
}
.preview-q-key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
}
.preview-q-options li.is-correct .preview-q-key {
  background: var(--good);
  color: #0f1a08;
}
.preview-q-why {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.5;
}
.preview-q-why strong {
  color: var(--accent);
  margin-right: 4px;
}
.plan-preview-fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: linear-gradient(180deg, transparent, var(--bg-elev-2));
  pointer-events: none;
}

/* CTA strip */
.plan-cta {
  padding: 18px 22px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.plan-cta .btn {
  justify-content: center;
  padding: 13px 18px;
  font-size: 1rem;
}
.plan-cta-note {
  text-align: center;
  color: var(--muted);
  font-size: 0.78rem;
}

/* Owned state tweaks for plan cards */
.plan-card.is-owned .plan-preview-fade { background: linear-gradient(180deg, transparent, rgba(92,184,92,0.08)); }
.plan-card.is-owned .purchase-owned-badge {
  padding: 18px 22px 22px;
  margin: 0;
  border-top: 1px solid var(--border);
  background: rgba(92,184,92,0.05);
}

/* ---------- Trust strip ---------- */
.landing-trust {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 32px 0 12px;
  min-width: 0;
}
.landing-trust-item {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.landing-trust-item strong {
  color: var(--text);
  font-size: 0.95rem;
}
.landing-trust-item span {
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.4;
}
@media (max-width: 780px) {
  .landing-trust { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .landing-trust { grid-template-columns: 1fr; }
}

/* ---------- Purchase / landing mobile refinements ---------- */
@media (max-width: 900px) {
  .purchase-main {
    padding-bottom: 40px;
  }

  /* Hero */
  .landing-hero {
    padding: 32px 0 20px;
  }
  .landing-title {
    font-size: clamp(1.6rem, 6vw, 2.4rem);
    max-width: none;
  }
  .landing-lead {
    font-size: 0.95rem;
  }
  .landing-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
  .landing-stat {
    padding: 10px 12px;
  }
  .landing-stat-n {
    font-size: 1.25rem;
  }
  .landing-stat-l {
    font-size: 0.75rem;
  }

  /* Account card */
  .purchase-account-card {
    max-width: none;
    padding: 18px 16px;
    margin-top: 6px;
    margin-bottom: 14px;
  }

  /* Plan cards grid → single column */
  .purchase-grid {
    margin-top: 18px;
  }

  /* Plan card internals */
  .plan-head {
    padding: 16px 16px 14px;
    gap: 10px;
  }
  .plan-badge {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    font-size: 0.88rem;
  }
  .plan-head-text h2 {
    font-size: 1.05rem;
  }
  .plan-price {
    padding: 12px 16px 0;
    gap: 4px;
  }
  .plan-price-amount {
    font-size: 1.75rem;
  }
  .plan-features {
    margin: 10px 16px 0;
    gap: 6px;
  }
  .plan-features li {
    font-size: 0.88rem;
    padding-left: 20px;
  }
  .plan-preview {
    margin: 14px 16px 0;
    padding: 12px 12px 36px;
  }
  .plan-cta {
    padding: 14px 16px 18px;
  }

  /* Trust strip */
  .landing-trust {
    gap: 8px;
    margin: 20px 0 8px;
  }
  .landing-trust-item {
    padding: 10px 12px;
  }
  .landing-trust-item strong {
    font-size: 0.88rem;
  }
  .landing-trust-item span {
    font-size: 0.78rem;
  }
}

@media (max-width: 480px) {
  .landing-hero {
    padding: 24px 0 16px;
  }
  .landing-hero::before { display: none; }
  .landing-stats { grid-template-columns: 1fr; }
  .landing-kicker {
    font-size: 0.68rem;
    padding: 3px 10px;
  }

  .plan-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 14px 12px;
  }
  .plan-badge {
    width: 38px;
    height: 38px;
    font-size: 0.82rem;
    border-radius: 8px;
  }
  .plan-price {
    padding: 10px 14px 0;
    flex-wrap: wrap;
  }
  .plan-price-amount {
    font-size: 1.5rem;
  }
  .plan-features {
    margin: 8px 14px 0;
  }
  .plan-preview {
    margin: 12px 14px 0;
    padding: 10px 10px 32px;
  }
  .preview-topic-chip {
    font-size: 0.72rem;
    padding: 3px 8px;
  }
  .plan-cta {
    padding: 12px 14px 16px;
  }
}
.purchase-form {
  margin-top: 14px;
}
.purchase-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.purchase-form select {
  width: 100%;
  background: var(--bg-elev-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
}
.account-card {
  margin-top: 18px;
}
.account-grid {
  margin-top: 10px;
  gap: 16px;
}
.account-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.account-panel h3,
.account-license-card h3 {
  margin: 0;
}
.account-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.account-license-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.account-license-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.admin-card {
  margin-top: 18px;
}
.admin-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 12px;
}
.admin-action-grid {
  margin-top: 10px;
}
@media (max-width: 640px) {
  .account-summary {
    align-items: stretch;
  }
}

.trade-option.locked {
  opacity: 0.55;
  cursor: not-allowed;
}
.trade-option.locked:hover {
  background: transparent;
}
/* ========== Interactive Bookshelf ========== */
.bookshelf {
  padding: 24px 0 36px;
  overflow: visible;
}
.bookshelf-header {
  text-align: center;
  margin-bottom: 36px;
}
.bookshelf-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0 0 6px;
  color: var(--text);
}
.bookshelf-sub {
  color: var(--text-dim);
  font-size: 0.88rem;
  margin: 0;
}
.bookshelf-row {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 56px;
  flex-wrap: wrap;
  width: 100%;
  overflow: visible;
  margin-top: 10px;
  padding-top: 22px;
}

/* --- Book item --- */
.book-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  padding-top: 0;
}
.book-item-label {
  display: block;
  margin-top: 18px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  transition: color 0.3s ease;
}
.book-item:hover .book-item-label { color: var(--accent); }

/* --- 3D container --- */
.book-3d {
  width: 240px;
  height: 340px;
  perspective: 1200px;
  filter: drop-shadow(0 18px 24px rgba(0,0,0,0.4));
  overflow: visible;
}
[data-theme="light"] .book-3d {
  filter: drop-shadow(0 18px 24px rgba(0,0,0,0.15));
}
.book-body {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(-25deg);
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: visible;
}
.book-item:hover .book-body {
  transform: rotateY(-30deg) translateY(-12px);
}
.book-item.is-open .book-body {
  transform: rotateY(-8deg) translateY(-4px);
}

/* --- Front cover --- */
.book-cover {
  position: absolute;
  inset: 0;
  border-radius: 2px 6px 6px 2px;
  background: linear-gradient(160deg, #3e3a34 0%, #2c2924 50%, #252118 100%);
  transform-style: preserve-3d;
  transform-origin: left center;
  transform: translateZ(0);
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1) 0.08s;
  z-index: 3;
  box-shadow:
    2px 4px 16px rgba(0,0,0,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.06);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 20px 22px;
}
/* Ensure elements fade out smoothly when opening to hide mirrored text */
.book-cover > * {
  transition: opacity 0.2s ease 0.3s;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
/* subtle texture overlay */
.book-cover::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='4' height='4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect width='1' height='1' fill='rgba(255,255,255,0.02)'/%3E%3C/svg%3E") repeat;
  pointer-events: none;
  border-radius: inherit;
}
.book-cover::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #23201b; /* dark inside */
  transform: rotateY(180deg) translateZ(0.5px);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.book-item.is-open .book-cover {
  transform: rotateY(-155deg) translateZ(0);
  transition: transform 0.75s cubic-bezier(0.4, 0, 0.2, 1) 0s;
}
.book-item.is-open .book-cover > * {
  opacity: 0;
  transition: opacity 0.2s ease 0s;
}

/* 310T variant: cooler slate tones */
.book-cover--t {
  background: linear-gradient(160deg, #3a3d42 0%, #2a2d32 50%, #1e2024 100%);
}
.book-cover--t::after {
  background: #1f2125;
}
/* 310J variant: rust / amber tones */
.book-cover--j {
  background: linear-gradient(160deg, #422d25 0%, #302018 50%, #21150f 100%);
}
.book-cover--j::after {
  background: #251812;
}

/* --- Cover content --- */
.book-cover-pub {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
}
.book-cover-year {
  font-size: 5.5rem;
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: rgba(255,255,255,0.12);
  margin: 12px 0 0;
}
.book-cover-shapes {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 10px;
}
.bk-graphic {
  width: 130px;
  height: 130px;
  color: #dfb265;
  opacity: 0.55;
  transition: opacity 0.3s ease;
}
.book-cover--t .bk-graphic {
  color: #c9d0d8;
  opacity: 0.45;
}
.book-cover--j .bk-graphic {
  color: #e06c3a;
  opacity: 0.45;
}
.book-item:hover .bk-graphic {
  opacity: 0.9;
}
.book-cover-foot {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
}
.book-cover-trade {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  line-height: 1.3;
  max-width: 60%;
}
.book-cover-code {
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: -0.02em;
  color: rgba(255,255,255,0.35);
}

/* --- Spine (3D left edge) --- */
.book-spine {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 28px;
  background: linear-gradient(to right, #221f1a, #332e28);
  transform: rotateY(90deg) translateX(-14px);
  transform-origin: left center;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px 0 0 4px;
}
.book-spine--t {
  background: linear-gradient(to right, #1e2024, #2a2d32);
}
.book-spine--j {
  background: linear-gradient(to right, #21150f, #302018);
}
.book-spine-text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
  text-transform: uppercase;
}

/* --- Page edges (right side): dark theme matches site; light = paper --- */
.book-edge-right {
  position: absolute;
  right: -4px;
  top: 4px;
  bottom: 4px;
  width: 22px;
  background:
    repeating-linear-gradient(to bottom,
      var(--bg-elev-2) 0px,
      var(--border) 1px,
      var(--bg-elev-2) 2px
    );
  border-radius: 0 3px 3px 0;
  transform: translateZ(-1px);
  z-index: 1;
  box-shadow: 1px 0 6px rgba(0,0,0,0.35);
}
[data-theme="light"] .book-edge-right {
  background:
    repeating-linear-gradient(to bottom,
      #f5f3ee 0px,
      #ece9e2 1px,
      #f5f3ee 2px
    );
  box-shadow: 1px 0 4px rgba(0,0,0,0.15);
}
.book-edge-bottom {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: -3px;
  height: 8px;
  background: linear-gradient(to bottom, var(--bg-elev), var(--border));
  border-radius: 0 0 3px 3px;
  transform: rotateX(90deg) translateY(4px);
  transform-origin: bottom center;
  z-index: 1;
}
[data-theme="light"] .book-edge-bottom {
  background: linear-gradient(to bottom, #e8e5de, #d8d5ce);
}

/* --- Pages behind cover --- */
.book-pages {
  position: absolute;
  inset: 0;
  background: var(--bg-elev);
  border-radius: 2px 6px 6px 2px;
  border: 1px solid var(--border);
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease 0.5s;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateZ(-0.5px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04);
}
[data-theme="light"] .book-pages {
  background: #f8f6f1;
  border: 1px solid #e0ddd6;
  box-shadow: none;
}
.book-item.is-open .book-pages {
  opacity: 1;
  transition: opacity 0.1s ease 0s;
}
.book-pages-stamp {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
}
[data-theme="light"] .book-pages-stamp {
  color: #b0a998;
}

/* --- Hover shadow --- */
.book-item:hover .book-cover {
  box-shadow:
    4px 8px 28px rgba(0,0,0,0.55),
    inset 0 0 0 1px rgba(255,255,255,0.08);
}

/* ========== Bookshelf Detail Panel ========== */
.bookshelf-detail {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.6s cubic-bezier(0.2, 0.8, 0.2, 1),
              margin 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  margin: 0;
  min-width: 0;
}
.bookshelf-detail.is-expanded {
  grid-template-rows: 1fr;
  margin: 28px 0 0;
}
.bookshelf-detail-inner {
  overflow: hidden;
}
.book-detail-panel {
  display: none;
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow);
  animation: detailFadeIn 0.35s ease forwards;
}
@keyframes detailFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.book-detail-panel.is-visible {
  display: block;
}

/* Close button */
.book-detail-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}
.book-detail-close:hover {
  background: var(--border);
  color: var(--text);
}

/* Content styling */
.book-detail-heading {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0 0 18px;
  color: var(--text);
}
.book-detail-heading strong {
  color: var(--accent);
}
.book-detail-section {
  margin-bottom: 18px;
}
.book-detail-section h4 {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin: 0 0 8px;
}

/* Topic chips */
.book-detail-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.book-detail-topics span {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Notes */
.book-detail-notes {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}
.book-detail-notes li {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text-dim);
  padding-left: 16px;
  border-left: 3px solid var(--border);
}
.book-detail-notes li strong {
  color: var(--text);
  font-weight: 700;
}
.book-detail-notes li em {
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
}

/* Practice question */
.book-detail-q {
  padding: 16px;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.book-detail-qtext {
  font-weight: 600;
  color: var(--text);
  margin: 0 0 10px;
  font-size: 0.94rem;
}
.book-detail-opts {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 5px;
  counter-reset: q-letter;
}
.book-detail-opts li {
  counter-increment: q-letter;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text-dim);
  font-size: 0.88rem;
}
.book-detail-opts li::before {
  content: counter(q-letter, upper-alpha);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--bg-elev-2);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
}
.book-detail-opts li.is-answer {
  background: rgba(92, 184, 92, 0.12);
  color: var(--text);
}
.book-detail-opts li.is-answer::before {
  background: var(--good);
  color: #0f1a08;
}
.book-detail-why {
  margin: 10px 0 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-dim);
}
.book-detail-why strong {
  color: var(--accent);
  margin-right: 4px;
}

/* CTA */
.book-detail-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.book-detail-cta .btn {
  padding: 12px 32px;
  font-size: 1rem;
}

/* --- Bookshelf mobile --- */
@media (max-width: 900px) {
  .bookshelf,
  .bookshelf-row {
    overflow-x: hidden;
  }
  .bookshelf-row { gap: 32px; }
  .book-3d {
    width: 200px;
    height: 280px;
  }
  .book-cover {
    padding: 16px 18px;
  }
  .book-cover-year { font-size: 4.2rem; }
  .book-cover-shapes {
    flex: 0 0 112px;
    min-height: 112px;
    padding-bottom: 0;
  }
  .bk-graphic {
    width: 112px;
    height: 112px;
    display: block;
    margin: 0 auto;
  }
  .book-cover-foot {
    align-items: flex-end;
  }
  .book-spine { width: 22px; }
  .book-spine-text { font-size: 0.52rem; }
  .book-detail-panel { padding: 20px 16px 18px; }
  .book-detail-heading { font-size: 1.05rem; }
}
@media (max-width: 480px) {
  .bookshelf-row { gap: 24px; padding-top: 16px; }
  .book-3d {
    width: 170px;
    height: 240px;
  }
  .book-item {
    max-width: 100%;
  }
  .book-cover { padding: 14px 16px; }
  .book-cover-pub { font-size: 0.55rem; }
  .book-cover-year { font-size: 3.2rem; }
  .book-cover-shapes {
    flex: 0 0 92px;
    min-height: 92px;
    padding-bottom: 0;
  }
  .bk-graphic {
    width: 92px;
    height: 92px;
    display: block;
    margin: 0 auto;
  }
  .book-cover-trade { font-size: 0.64rem; }
  .book-cover-code { font-size: 0.88rem; }
  .book-spine { width: 18px; }
  .book-edge-right { width: 14px; }
  .bookshelf-detail.is-expanded { margin-top: 20px; }
  .book-detail-topics span { font-size: 0.72rem; padding: 4px 8px; }
}

@media (max-width: 560px) {
  .purchase-main,
  .landing-hero,
  .purchase-grid,
  .landing-trust,
  .bookshelf,
  .bookshelf-detail,
  .book-detail-panel {
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }

  .bookshelf-row {
    display: grid;
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 20px;
    padding-top: 14px;
  }

  .book-item {
    width: 100%;
    max-width: 190px;
    padding-top: 8px;
  }

  .book-3d {
    width: min(170px, calc(100vw - 96px));
    height: auto;
    aspect-ratio: 17 / 24;
    overflow: visible;
  }

  .book-item-label {
    max-width: 170px;
    margin-top: 14px;
  }
}

/* Print styles: one clean printable cheatsheet */
@media print {
  body { background: white !important; color: #111 !important; }
  .nav, .cheat-topbar, footer, .no-print { display: none !important; }
  .container { max-width: none; padding: 0; }
  .cheat-doc {
    box-shadow: none; border-radius: 0; padding: 0; margin: 0;
  }
  .cheat-doc h2 { background: #1a1814 !important; color: #e8c589 !important; border-left-color: #d0a060 !important; }
  .cheat-grid { gap: 10px; }
  @page { size: letter; margin: 14mm; }
}

/* ---------- Footer ---------- */
footer {
  border-top: 1px solid var(--border); padding: 30px 0;
  color: var(--muted); font-size: 0.88rem; text-align: center;
}
footer a { color: var(--text-dim); }
footer .powered {
  display: block; margin-top: 6px; font-size: 0.8rem;
  color: var(--muted);
}
footer .powered a { color: var(--accent); }
footer .legal-note {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
}
footer .legal-note a { color: var(--text-dim); }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg-elev); color: var(--text-dim); cursor: pointer;
  font-size: 1.15rem; transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0; padding: 0; font-family: inherit;
}
.theme-toggle:hover { background: var(--bg-elev-2); color: var(--text); }
.theme-toggle .icon-sun,
.theme-toggle .icon-moon { pointer-events: none; }
.theme-toggle .icon-sun { display: none; }
[data-theme="light"] .theme-toggle .icon-sun { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ---------- Light-mode cheatsheet doc adjustments ---------- */
[data-theme="light"] .cheat-doc {
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}
[data-theme="light"] .cheat-box {
  background: #f9f7f3;
  border-color: #d5cfc4;
}

/* ---------- Light-mode button primary text contrast ---------- */
[data-theme="light"] .btn-primary { color: #fff; }
[data-theme="light"] .btn-primary:hover { color: #fff; }
[data-theme="light"] .logo-badge { color: #fff; }

/* ---------- Light-mode quiz feedback ---------- */
[data-theme="light"] .option.correct { background: rgba(62,122,30,0.08); }
[data-theme="light"] .option.correct .k { color: #fff; }
[data-theme="light"] .option.incorrect { background: rgba(179,51,51,0.08); }
[data-theme="light"] .option.incorrect .k { color: #fff; }

/* ---------- Misc ---------- */
.kbd { font-family: var(--mono); background: var(--bg-elev-2); padding: 1px 6px; border-radius: 4px; border: 1px solid var(--border); font-size: 0.85em; }
.tag-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; vertical-align: middle; margin-right: 6px; }
.hidden { display: none !important; }
