:root {
  --bg: #f8fafc;
  --ink: #0f172a;
  --muted: #475569;
  --line: #e2e8f0;
  --paper: #ffffff;
  --supply: #2563eb;
  --supply-soft: #eff6ff;
  --state: #0d9488;
  --state-soft: #f0fdfa;
  --health: #4f46e5;
  --health-soft: #eef2ff;
  --accent: #2563eb;
  --accent-soft: #eff6ff;
  --good: #047857;
  --bad: #be123c;
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
  --serif: "Plus Jakarta Sans", Inter, "Segoe UI", sans-serif;
  --sans: Inter, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: #f8fafc;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
body[data-theme="supply"] { --accent: var(--supply); --accent-soft: var(--supply-soft); }
body[data-theme="state"] { --accent: var(--state); --accent-soft: var(--state-soft); }
body[data-theme="health"] { --accent: var(--health); --accent-soft: var(--health-soft); }
a { color: var(--accent); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.skip {
  position: absolute; left: 12px; top: -40px; background: var(--ink); color: white;
  padding: 8px 12px; z-index: 80;
}
.skip:focus { top: 12px; }
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: rgba(248, 250, 252, 0.94);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.header-inner, .wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.header-row { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 14px 0; }
.brand { display: flex; gap: 10px; align-items: center; text-decoration: none; color: inherit; }
.brand strong { display: block; font-family: var(--serif); font-size: 1.15rem; letter-spacing: -0.03em; }
.brand small { color: var(--muted); letter-spacing: 0; text-transform: none; font-size: 0.72rem; display: block; white-space: nowrap; line-height: 1.3; }
.mark {
  width: 36px; height: 36px; border-radius: 10px; position: relative;
  background: var(--accent);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.28);
}
.mark:before {
  content: ""; position: absolute; inset: 8px 7px;
  border: 1.5px solid #fff; border-radius: 3px; transform: rotate(-8deg);
}
.nav { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.nav a { color: var(--ink); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.nav a:hover { color: var(--accent); }
.header-search { position: relative; margin: 0; }
.header-search input {
  width: 230px; padding: 7px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: white; font-size: 0.9rem;
}
.search-results {
  position: absolute; right: 0; top: calc(100% + 6px); width: min(420px, 90vw); z-index: 40;
  list-style: none; margin: 0; padding: 6px; background: white; border: 1px solid var(--line);
  border-radius: 12px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.14);
}
.search-results[hidden] { display: none; }
.search-results a { display: block; padding: 8px 10px; border-radius: 8px; color: var(--ink); text-decoration: none; font-size: 0.9rem; line-height: 1.3; }
.search-results a:hover, .search-results a.is-active { background: var(--accent-soft); }
.search-results small { display: block; color: var(--muted); font-size: 0.75rem; margin-top: 2px; }
.search-results .empty { padding: 8px 10px; color: var(--muted); font-size: 0.88rem; }
.print-btn, .btn, .cat, .pill, .mode, .tile, .option {
  border: 1px solid var(--line); background: white; border-radius: 999px;
}
.print-btn, .btn { padding: 8px 14px; font-weight: 650; }
.print-btn { background: var(--ink); color: white; border-color: var(--ink); }
.mode.is-active { background: #0f172a; color: white; border-color: #0f172a; }
.wrap { padding-bottom: 56px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.live-head { margin: 0 0 8px; }
.live-title { font-size: clamp(1.25rem, 2vw, 1.7rem); margin: 0; }
.live-desc { margin: 2px 0 0; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.eyebrow, .kicker {
  margin: 0 0 6px; color: var(--accent); font-weight: 750;
  letter-spacing: 0.12em; text-transform: uppercase; font-size: 0.74rem;
}
h1, h2, h3 { font-family: var(--serif); letter-spacing: -0.03em; line-height: 1.15; }
h1 { font-size: clamp(2.1rem, 4vw, 3.5rem); margin: 0 0 12px; }
.lede, .live-desc { color: var(--muted); max-width: 68ch; }
#study-desk { scroll-margin-top: 76px; padding-top: 14px; }
.mega { background: #0b1120; color: #cbd5e1; padding: 48px 0; scroll-margin-top: 64px; }
.mega-inner { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.mega-label {
  margin: 0 0 16px; padding-bottom: 10px; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase; color: #94a3b8; border-bottom: 1px solid #1e293b;
}
.mega-label.gold { color: #f59e0b; }
.cat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px 24px; margin: 0 0 44px; padding: 0; list-style: none; }
.cat-grid a { color: #cbd5e1; text-decoration: none; font-size: 0.88rem; line-height: 1.35; }
.cat-grid a:hover { color: #ffffff; }
.path-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 32px 24px; }
.path-grid h3 { color: #f59e0b; font-family: var(--sans); font-size: 0.95rem; font-weight: 700; letter-spacing: 0; margin: 0 0 12px; }
.path-grid ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.path-grid li a { color: #94a3b8; font-size: 0.86rem; line-height: 1.35; text-decoration: none; }
.path-grid li a:hover { color: #ffffff; }
.path-grid li.all a { color: #fbbf24; font-size: 0.84rem; font-weight: 600; }
.path-grid li.all a:hover { color: #fde68a; }
.cat-page { padding: 24px 0 8px; }
.cat-page h1 { font-size: clamp(1.8rem, 3vw, 2.5rem); }
.cat-group { margin-top: 26px; }
.cat-group h2 { font-size: 1.2rem; margin: 0 0 10px; }
.cat-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px 24px; }
.cat-list a { font-weight: 600; text-decoration: none; }
.cat-list span { color: var(--muted); font-size: 0.85rem; }
.chip { background: white; border: 1px solid var(--line); border-radius: 999px; padding: 6px 10px; font-size: 0.85rem; }
.ad { margin: 16px 0; }
.ad span { display: block; font-size: 0.68rem; letter-spacing: 0.14em; text-transform: uppercase; color: #8a8175; margin-bottom: 4px; }
.ad-slot {
  display: grid; place-items: center; text-align: center; color: #8a8175; font-size: 0.8rem;
  border: 1px dashed #cbd5e1; background: #fff; border-radius: 12px; color: #64748b;
}
.ad-leaderboard .ad-slot { height: 90px; }
.ad-box .ad-slot { width: 300px; height: 250px; }
.ad-inline .ad-slot { height: 100px; }
.pill-exam { color: var(--accent); font-size: 0.72rem; font-weight: 750; letter-spacing: 0.06em; text-transform: uppercase; }
.pill-name { font-weight: 700; }
.pill-meta, .hint, .fine, .status-line { color: var(--muted); font-size: 0.82rem; }
.desk-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  grid-template-areas: "study side" "corpus side";
  gap: 22px; align-items: start;
}
.study { grid-area: study; background: transparent; }
.corpus { grid-area: corpus; }
.sidebar { grid-area: side; position: sticky; top: 96px; }
.side-card, .study-panel, .entry, .catalog-card, .prose {
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow);
}
.side-card, .study-panel { padding: 16px; }
.side-card h2 { font-size: 1.15rem; margin: 0 0 8px; }
.meter { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin: 10px 0; }
.meter span { display: block; height: 100%; background: var(--accent); }
.flow { margin: 0 0 10px; }
.flow-bar { height: 4px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.flow-bar span { display: block; height: 100%; background: var(--accent); }
.streak { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; }
.unit-complete h3 { margin: 0 0 8px; font-size: 1.8rem; }
.modebar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.mode { padding: 8px 12px; font-weight: 700; }
.study-top { display: flex; justify-content: space-between; gap: 12px; align-items: end; margin-bottom: 10px; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.8rem; letter-spacing: -0.04em; margin: 0; font-weight: 750; }
.scene { perspective: 1200px; min-height: 360px; }
.flipper {
  position: relative; min-height: 360px; transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.flipper.is-flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center;
  padding: 28px; border-radius: 18px; background: var(--paper); border: 1px solid var(--line);
  box-shadow: var(--shadow); backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: auto;
}
.face.back { transform: rotateY(180deg); justify-content: flex-start; }
.face h3 { font-family: var(--serif); font-size: clamp(1.7rem, 3vw, 2.4rem); margin: 0; }
.pron { margin: 6px 0 0; color: var(--muted); }
.callout { border-radius: 12px; padding: 10px 12px; margin: 8px 0 0; }
.mnemonic { background: #eff6ff; }
.tip { background: #fef2f2; }
.badge { display: inline-block; margin-bottom: 8px; padding: 3px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 0.75rem; font-weight: 750; }
.study-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn.primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn.good { background: #e7f6ee; border-color: #b7e0c8; color: var(--good); }
.btn.warn { background: #fff4df; border-color: #efd3a4; }
.btn.ghost { background: white; }
.match-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tile {
  min-height: 112px; max-height: 148px; overflow: hidden; border-radius: 14px; padding: 10px;
  text-align: left; font-size: 0.82rem; line-height: 1.35;
}
.tile-term { background: var(--accent-soft); }
.tile.is-selected { outline: 2px solid var(--accent); }
.tile.is-matched { background: #e7f6ee; color: var(--good); }
.tile.is-miss { background: #fdecee; }
.quiz-q { font-size: 1.35rem; margin: 0 0 10px; }
.options { display: grid; gap: 8px; }
.option { border-radius: 14px; padding: 12px 14px; text-align: left; }
.option.is-right { background: #e7f6ee; border-color: var(--good); }
.option.is-wrong { background: #fdecee; border-color: var(--bad); }
.explain { margin-top: 12px; }
.win { background: #e7f6ee; border-radius: 12px; padding: 10px 12px; }
.section-head h2 { margin-bottom: 4px; }
.entries { display: grid; gap: 12px; }
.entry { padding: 16px 18px; scroll-margin-top: 88px; }
.entry.is-target { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.entry-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.entry h3 { margin: 0; font-size: 1.35rem; }
.related-terms { margin: 12px 0 0; font-size: 0.92rem; }
.related-terms a { font-weight: 700; }
.catalog { margin-top: 28px; }
.catalog-block { margin-top: 22px; scroll-margin-top: 96px; }
.catalog-grid, .related-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.catalog-card, .related-links a {
  display: block; padding: 16px; text-decoration: none; color: inherit;
}
.catalog-card h3 { margin: 6px 0; font-size: 1.2rem; }
.catalog-card p { color: var(--muted); margin: 0 0 8px; }
.more { font-weight: 700; color: var(--accent); font-size: 0.88rem; }
.related { margin-top: 22px; }
.related-links a { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; font-weight: 700; }
.crumb { font-size: 0.88rem; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.disclaimer { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; }
.prose { padding: 28px; max-width: 820px; }
.prose h1 { font-size: clamp(2rem, 4vw, 3rem); }
.prose h2 { margin-top: 1.4em; font-size: 1.45rem; }
.prose p, .prose li { color: var(--muted); }
.prose ul { padding-left: 1.2rem; }
.site-footer { border-top: 1px solid var(--line); padding: 28px 0 40px; background: #f1f5f9; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 12px; }
.footer-links a { color: var(--ink); font-weight: 700; text-decoration: none; }
#print-root { display: none; }
@page { size: A4; margin: 8mm; }
@media print {
  body { background: white !important; }
  .no-print { display: none !important; }
  #print-root { display: block !important; }
  .print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6mm; }
  .cut { border: 1.25pt dashed #222; min-height: 72mm; display: flex; flex-direction: column; break-inside: avoid; page-break-inside: avoid; }
  .half { padding: 5mm; }
  .half + .half { border-top: 1pt dashed #222; }
  .cut h3 { font-family: "Segoe UI", sans-serif; font-size: 16pt; margin: 0 0 2mm; }
  .cut p { margin: 0 0 2mm; font-size: 10.5pt; line-height: 1.35; }
  .label { font-size: 8pt; letter-spacing: .12em; text-transform: uppercase; margin: 0 0 1mm; }
}
@media (max-width: 980px) {
  .desk-layout { grid-template-columns: 1fr; grid-template-areas: "study" "side" "corpus"; }
  .sidebar { position: static; }
  .ad-box .ad-slot { width: 100%; }
  .match-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .footer-grid { grid-template-columns: 1fr; }
  .header-row { flex-wrap: wrap; gap: 8px 14px; padding: 10px 0; }
  .nav { width: 100%; flex-wrap: nowrap; gap: 10px; }
  .header-search { flex: 1; min-width: 0; }
  .header-search input { width: 100%; }
  .print-btn { padding: 7px 10px; font-size: 0.82rem; white-space: nowrap; }
  .cat-grid, .path-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .nav > a[href$="about.html"], .nav > a[href$="contact.html"] { display: none; }
  .cat-grid, .path-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  .flipper { transition: none; }
}
