/* =========================================================================
   Offensive Security Academy — design system
   Light-first "clean docs" palette with a per-course accent and a dark mode.
   Tokens live on :root; every surface reads from them, so a course changes
   colour by swapping one class on <html>.
   ========================================================================= */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;

  --bg:        #ffffff;
  --bg-sub:    #f6f7f9;
  --bg-card:   #ffffff;
  --bg-inset:  #f1f3f6;
  --line:      #e4e7ec;
  --line-soft: #eef0f4;

  --fg:        #14161a;
  --fg-mid:    #4a5160;
  --fg-mut:    #737b8c;

  --accent:      #6d4aff;
  --accent-ink:  #4b28e0;
  --accent-soft: #f0ecff;
  --accent-line: #d9d0ff;
  --on-accent:   #ffffff;

  --ok:      #17864a;
  --ok-soft: #e6f6ed;
  --warn:    #a4610a;
  --danger:  #c4362f;

  --code-bg:   #f7f8fa;
  --code-fg:   #253046;
  --code-line: #e6e9ef;

  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", SFMono-Regular, Menlo,
          Consolas, "Liberation Mono", monospace;

  --r-sm: 6px;
  --r:    10px;
  --r-lg: 16px;
  --r-xl: 22px;

  --sh-sm: 0 1px 2px rgba(16, 20, 30, .06);
  --sh:    0 2px 8px rgba(16, 20, 30, .07), 0 1px 2px rgba(16, 20, 30, .05);
  --sh-lg: 0 18px 50px -12px rgba(16, 20, 30, .22);

  --rail: 292px;
  --doc:  760px;
  --top:  58px;
}

/* per-course accents — one class on <html> retints the whole page */
.accent-violet { --accent: #6d4aff; --accent-ink: #4b28e0; --accent-soft: #f0ecff; --accent-line: #d9d0ff; }
.accent-amber  { --accent: #c2760a; --accent-ink: #9a5c05; --accent-soft: #fdf3e3; --accent-line: #f2ddb6; }
.accent-teal   { --accent: #0b8a86; --accent-ink: #076c69; --accent-soft: #e4f6f5; --accent-line: #b6e3e1; }
.accent-rose   { --accent: #c62b62; --accent-ink: #a11a4c; --accent-soft: #fdeaf1; --accent-line: #f6c6d8; }
.accent-lime   { --accent: #52820f; --accent-ink: #3f660a; --accent-soft: #eff7e0; --accent-line: #d3e6ae; }
.accent-sky    { --accent: #0a6ec4; --accent-ink: #0857a0; --accent-soft: #e6f2fd; --accent-line: #bcdcf7; }

/* ---------- dark ---------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg:        #0e1014;
    --bg-sub:    #14171d;
    --bg-card:   #171a21;
    --bg-inset:  #1c2027;
    --line:      #262b34;
    --line-soft: #1e222a;
    --fg:        #e8eaef;
    --fg-mid:    #a8b0bf;
    --fg-mut:    #7b8494;
    --on-accent: #ffffff;
    --ok:        #4ecb85;
    --ok-soft:   #10291c;
    --warn:      #e0a944;
    --danger:    #f2695f;
    --code-bg:   #12151b;
    --code-fg:   #cfd7e6;
    --code-line: #262b34;
    --sh-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --sh:    0 2px 10px rgba(0, 0, 0, .45);
    --sh-lg: 0 20px 60px -12px rgba(0, 0, 0, .7);
  }
  :root:not([data-theme="light"]).accent-violet { --accent: #a08cff; --accent-ink: #c0b2ff; --accent-soft: #1d1a33; --accent-line: #35305c; }
  :root:not([data-theme="light"]).accent-amber  { --accent: #e3a447; --accent-ink: #f0bd72; --accent-soft: #2a2113; --accent-line: #4d3c1e; }
  :root:not([data-theme="light"]).accent-teal   { --accent: #45c4bd; --accent-ink: #6ed6d0; --accent-soft: #10262a; --accent-line: #1d454a; }
  :root:not([data-theme="light"]).accent-rose   { --accent: #f0759f; --accent-ink: #f79bba; --accent-soft: #2c1520; --accent-line: #4f2438; }
  :root:not([data-theme="light"]).accent-lime   { --accent: #9dc95c; --accent-ink: #b6d982; --accent-soft: #1c2413; --accent-line: #35441f; }
  :root:not([data-theme="light"]).accent-sky    { --accent: #5aaef0; --accent-ink: #86c4f5; --accent-soft: #101f2c; --accent-line: #1c3a52; }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg:        #0e1014;
  --bg-sub:    #14171d;
  --bg-card:   #171a21;
  --bg-inset:  #1c2027;
  --line:      #262b34;
  --line-soft: #1e222a;
  --fg:        #e8eaef;
  --fg-mid:    #a8b0bf;
  --fg-mut:    #7b8494;
  --on-accent: #ffffff;
  --ok:        #4ecb85;
  --ok-soft:   #10291c;
  --warn:      #e0a944;
  --danger:    #f2695f;
  --code-bg:   #12151b;
  --code-fg:   #cfd7e6;
  --code-line: #262b34;
  --sh-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --sh:    0 2px 10px rgba(0, 0, 0, .45);
  --sh-lg: 0 20px 60px -12px rgba(0, 0, 0, .7);
}
:root[data-theme="dark"].accent-violet { --accent: #a08cff; --accent-ink: #c0b2ff; --accent-soft: #1d1a33; --accent-line: #35305c; }
:root[data-theme="dark"].accent-amber  { --accent: #e3a447; --accent-ink: #f0bd72; --accent-soft: #2a2113; --accent-line: #4d3c1e; }
:root[data-theme="dark"].accent-teal   { --accent: #45c4bd; --accent-ink: #6ed6d0; --accent-soft: #10262a; --accent-line: #1d454a; }
:root[data-theme="dark"].accent-rose   { --accent: #f0759f; --accent-ink: #f79bba; --accent-soft: #2c1520; --accent-line: #4f2438; }
:root[data-theme="dark"].accent-lime   { --accent: #9dc95c; --accent-ink: #b6d982; --accent-soft: #1c2413; --accent-line: #35441f; }
:root[data-theme="dark"].accent-sky    { --accent: #5aaef0; --accent-ink: #86c4f5; --accent-soft: #101f2c; --accent-line: #1c3a52; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
/* Any explicit `display` beats the hidden attribute's UA rule — restore it,
   since several components below are display:grid/flex *and* toggled by
   [hidden] from JS. */
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--top) + 18px); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { animation: none !important; transition: none !important; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5 { margin: 0; line-height: 1.2; letter-spacing: -.02em; font-weight: 660; }
p { margin: 0 0 1em; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
img { max-width: 100%; height: auto; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
kbd {
  font: 500 11px/1 var(--mono); padding: 3px 5px; border-radius: 5px;
  background: var(--bg-inset); border: 1px solid var(--line); color: var(--fg-mid);
}
::selection { background: var(--accent-soft); color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: 1140px; margin: 0 auto; padding: 0 24px; }
.skip {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--on-accent); padding: 10px 16px; border-radius: 0 0 var(--r) 0;
}
.skip:focus { left: 0; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: var(--top);
  display: flex; align-items: center; gap: 22px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 700; letter-spacing: -.02em; color: var(--fg); font-size: 15px;
}
.brand:hover { text-decoration: none; }
.brand .mark {
  display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent); font-size: 13px;
}
.topnav { display: flex; gap: 4px; margin-right: auto; }
.topnav a {
  padding: 7px 12px; border-radius: var(--r-sm); font-size: 14px;
  font-weight: 500; color: var(--fg-mid);
}
.topnav a:hover { background: var(--bg-inset); color: var(--fg); text-decoration: none; }
.topnav a.on { color: var(--accent-ink); background: var(--accent-soft); }
.topright { display: flex; align-items: center; gap: 8px; }

.kbtn {
  display: flex; align-items: center; gap: 10px;
  height: 34px; padding: 0 8px 0 12px;
  background: var(--bg-sub); border: 1px solid var(--line); border-radius: 999px;
  color: var(--fg-mut); font: 500 13px var(--sans); cursor: pointer;
}
.kbtn:hover { border-color: var(--accent-line); color: var(--fg); }
.iconbtn {
  display: grid; place-items: center; width: 34px; height: 34px;
  background: none; border: 1px solid transparent; border-radius: 9px;
  color: var(--fg-mut); cursor: pointer; font-size: 17px;
}
.iconbtn:hover { background: var(--bg-inset); color: var(--fg); border-color: var(--line); }
.iconbtn svg { width: 17px; height: 17px; }
[data-theme-toggle] .i-moon { display: none; }
:root[data-theme="dark"] [data-theme-toggle] .i-sun { display: none; }
:root[data-theme="dark"] [data-theme-toggle] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) [data-theme-toggle] .i-sun { display: none; }
  :root:not([data-theme="light"]) [data-theme-toggle] .i-moon { display: block; }
}

@media (max-width: 720px) {
  .topbar { gap: 12px; padding: 0 14px; }
  .topnav a { padding: 7px 9px; }
  .kbtn span { display: none; }
  .kbtn { padding: 0 10px; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 18px; border-radius: 999px;
  font: 600 14.5px var(--sans); cursor: pointer;
  border: 1px solid transparent; transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: var(--sh); }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: var(--bg-card); color: var(--fg); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent-line); background: var(--bg-sub); }
.btn.ghost.danger:hover { border-color: var(--danger); color: var(--danger); }
.btn.file { position: relative; overflow: hidden; }

/* ---------- progress bars ---------- */
.bar { height: 6px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.bar.big { height: 10px; }
.bar i {
  display: block; height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--ok)));
  transition: width .45s cubic-bezier(.2, .8, .2, 1);
}

/* ---------- hero (hub) ---------- */
.hero {
  position: relative; overflow: hidden;
  padding: 84px 24px 68px;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse 70% 60% at 18% -10%, var(--accent-soft), transparent 70%),
    radial-gradient(ellipse 50% 50% at 92% 0%, var(--accent-soft), transparent 70%),
    var(--bg);
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px),
                    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, #000, transparent 75%);
}
.hero-in { position: relative; z-index: 1; max-width: 1140px; margin: 0 auto; }
.pill {
  display: inline-block; padding: 6px 13px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--accent-line);
  color: var(--accent-ink); font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  box-shadow: var(--sh-sm);
}
.hero h1 {
  margin: 20px 0 0; font-size: clamp(2.4rem, 6.2vw, 4.2rem);
  letter-spacing: -.045em; font-weight: 700;
}
.hero h1 em {
  font-style: normal; color: var(--accent);
  background: linear-gradient(transparent 62%, var(--accent-soft) 62%);
}
.lede { margin: 18px 0 0; max-width: 62ch; font-size: clamp(1rem, 1.6vw, 1.18rem); color: var(--fg-mid); }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.hero-cta kbd { margin-left: 2px; }

.hero-stats { display: flex; flex-wrap: wrap; gap: 44px; margin: 46px 0 0; }
.hero-stats div { margin: 0; }
.hero-stats dt { font-size: 12px; text-transform: uppercase; letter-spacing: .1em; color: var(--fg-mut); font-weight: 600; }
.hero-stats dd { margin: 4px 0 0; font-size: 1.85rem; font-weight: 680; letter-spacing: -.03em; }

/* ---------- your-stats band ---------- */
.band { border-bottom: 1px solid var(--line); background: var(--bg-sub); }
.band-in {
  max-width: 1140px; margin: 0 auto; padding: 22px 24px;
  display: flex; align-items: center; gap: 40px; flex-wrap: wrap;
}
.stat { display: flex; flex-direction: column; }
.stat-n { font-size: 1.55rem; font-weight: 680; letter-spacing: -.03em; color: var(--accent-ink); }
.stat-l { font-size: 12px; color: var(--fg-mut); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 3px; margin-left: auto; }
.heat b { width: 10px; height: 10px; border-radius: 2.5px; background: var(--bg-inset); display: block; }
.heat b[data-l="1"] { background: color-mix(in srgb, var(--accent) 28%, var(--bg-inset)); }
.heat b[data-l="2"] { background: color-mix(in srgb, var(--accent) 55%, var(--bg-inset)); }
.heat b[data-l="3"] { background: color-mix(in srgb, var(--accent) 78%, var(--bg-inset)); }
.heat b[data-l="4"] { background: var(--accent); }
@media (max-width: 860px) { .heat { display: none; } .band-in { gap: 26px; } }

/* ---------- section titles ---------- */
.sec-title {
  font-size: 1.5rem; margin: 64px 0 24px; letter-spacing: -.03em;
  display: flex; align-items: center; gap: 14px;
}
.sec-title::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- course cards ---------- */
.course-grid { display: grid; gap: 20px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }
.course-card {
  position: relative; display: flex; flex-direction: column;
  padding: 24px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--line);
  color: var(--fg); box-shadow: var(--sh-sm);
  transition: transform .16s, box-shadow .16s, border-color .16s;
  overflow: hidden;
}
.course-card::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 3px;
  background: linear-gradient(90deg, var(--accent), transparent 85%);
}
.course-card:hover {
  text-decoration: none; transform: translateY(-3px);
  box-shadow: var(--sh-lg); border-color: var(--accent-line);
}
.cc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cc-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px;
  background: var(--accent-soft); color: var(--accent); flex: none;
}
.cc-icon svg { width: 21px; height: 21px; stroke-width: 1.6; }
.cc-icon.big { width: 54px; height: 54px; border-radius: 15px; margin-bottom: 18px; }
.cc-icon.big svg { width: 29px; height: 29px; stroke-width: 1.5; }
.cc-level {
  font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--fg-mut); background: var(--bg-inset); padding: 4px 9px; border-radius: 999px;
}
.course-card h3 { font-size: 1.22rem; margin-bottom: 8px; }
.course-card p { color: var(--fg-mid); font-size: 14.5px; line-height: 1.6; margin-bottom: 18px; }
.cc-stats { display: flex; gap: 16px; font-size: 13px; color: var(--fg-mut); margin-top: auto; }
.cc-stats b { color: var(--fg); font-weight: 640; }
.cc-prog { display: flex; align-items: center; gap: 12px; margin: 16px 0 18px; }
.cc-prog .bar { flex: 1; }
.cc-pct { font-size: 12.5px; font-weight: 600; color: var(--fg-mut); white-space: nowrap; }
.cc-go { display: inline-flex; align-items: center; gap: 7px; font-size: 14px; font-weight: 600; color: var(--accent-ink); }
.cc-go svg { width: 15px; height: 15px; transition: transform .16s; }
.course-card:hover .cc-go svg { transform: translateX(4px); }

/* ---------- features ---------- */
.features { padding-bottom: 90px; }
.feat-grid { display: grid; gap: 2px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  background: var(--line); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.feat { background: var(--bg-card); padding: 26px 24px; }
.feat .fi {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent); font-size: 16px; margin-bottom: 14px;
}
.feat h4 { font-size: 1rem; margin-bottom: 7px; }
.feat p { color: var(--fg-mid); font-size: 14px; line-height: 1.62; margin: 0; }

/* ---------- course page ---------- */
.course-hero {
  padding: 44px 0 40px; border-bottom: 1px solid var(--line);
  background: radial-gradient(ellipse 60% 90% at 12% 0%, var(--accent-soft), transparent 70%), var(--bg);
}
.crumbs { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--fg-mut); margin-bottom: 18px; }
.crumbs a { color: var(--fg-mut); font-weight: 500; }
.crumbs a:hover { color: var(--accent-ink); }
.crumbs b { color: var(--fg); font-weight: 600; }
.course-hero h1 { font-size: clamp(1.9rem, 4.2vw, 2.7rem); }
.course-prog { display: flex; align-items: center; gap: 14px; max-width: 520px; margin: 26px 0 10px; }
.course-prog .bar { flex: 1; }
.course-prog span { font-size: 13.5px; font-weight: 600; color: var(--fg-mid); white-space: nowrap; }
.course-meta { font-size: 13.5px; color: var(--fg-mut); margin: 0; }

.modules { padding: 34px 0 90px; display: flex; flex-direction: column; gap: 12px; }
.module {
  background: var(--bg-card); border: 1px solid var(--line);
  border-radius: var(--r-lg); overflow: hidden;
}
.module > summary {
  display: flex; align-items: center; gap: 16px; padding: 17px 20px;
  cursor: pointer; list-style: none; user-select: none;
}
.module > summary::-webkit-details-marker { display: none; }
.module > summary:hover { background: var(--bg-sub); }
.mnum { font: 640 12px var(--mono); color: var(--accent); background: var(--accent-soft);
  padding: 5px 8px; border-radius: 7px; letter-spacing: .02em; }
.mname { font-weight: 640; font-size: 1.02rem; letter-spacing: -.015em; }
.mmeta { font-size: 12.5px; color: var(--fg-mut); margin-left: auto; white-space: nowrap; }
.mpct { font-size: 12.5px; font-weight: 640; color: var(--accent-ink); min-width: 62px; text-align: right; }
.chev { width: 17px; height: 17px; color: var(--fg-mut); transition: transform .2s; flex: none; }
.module[open] .chev { transform: rotate(180deg); }
.rooms { list-style: none; margin: 0; padding: 0 10px 10px; }
.rooms a {
  display: grid; grid-template-columns: 22px 1fr auto 88px; align-items: center; gap: 14px;
  padding: 11px 12px; border-radius: var(--r); color: var(--fg); font-size: 14.5px;
}
.rooms a:hover { background: var(--accent-soft); text-decoration: none; }
.rk {
  width: 18px; height: 18px; border-radius: 999px; border: 1.8px solid var(--line);
  display: grid; place-items: center; font-size: 11px; color: transparent;
}
.rk.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.rk.part { border-color: var(--accent); box-shadow: inset 0 0 0 3.5px var(--accent-soft); }
.rn { font-weight: 520; }
.rc { font-size: 12.5px; color: var(--fg-mut); white-space: nowrap; }
.rb { height: 5px; border-radius: 999px; background: var(--bg-inset); overflow: hidden; }
.rb i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; transition: width .4s; }
@media (max-width: 700px) {
  .rooms a { grid-template-columns: 22px 1fr; }
  .rc, .rb { display: none; }
  .mmeta { display: none; }
}

/* ---------- room: two-column shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); align-items: start; }
.rail {
  position: sticky; top: var(--top); height: calc(100vh - var(--top));
  border-right: 1px solid var(--line); background: var(--bg-sub);
  overflow-y: auto; overscroll-behavior: contain;
}
.rail-in { padding: 26px 22px 40px; }
.rail-mod { font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--accent); font-weight: 700; margin-bottom: 8px; }
.rail-title { font-size: 1.24rem; margin-bottom: 18px; }
.rail-prog { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; }
.rail-prog .bar { flex: 1; }
.rail-prog span { font-size: 12px; font-weight: 640; color: var(--fg-mut); white-space: nowrap; }
.srclink { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 560; }
.srclink svg { width: 13px; height: 13px; }

.toc { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 18px; }
.toc ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.toc a {
  display: grid; grid-template-columns: 16px 20px 1fr; align-items: start; gap: 9px;
  padding: 7px 9px; border-radius: var(--r-sm); font-size: 13.4px; line-height: 1.45;
  color: var(--fg-mid);
}
.toc a:hover { background: var(--bg-inset); color: var(--fg); text-decoration: none; }
.toc a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.toc .tk { width: 14px; height: 14px; border-radius: 999px; border: 1.6px solid var(--line); margin-top: 3px; }
.toc a.done .tk { background: var(--ok); border-color: var(--ok); }
.toc .tn { font: 600 12px var(--mono); color: var(--fg-mut); margin-top: 1px; }
.toc a.active .tn { color: var(--accent-ink); }

.doc { max-width: var(--doc); padding: 40px 32px 120px; margin: 0 auto; }
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail-in { padding: 20px; }
  .toc { max-height: 300px; overflow-y: auto; }
  .doc { padding: 28px 20px 90px; }
}

/* ---------- task ---------- */
.task { scroll-margin-top: calc(var(--top) + 20px); padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--line-soft); }
.task:last-of-type { border-bottom: 0; }
.task-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 22px; }
.th-text { flex: 1; min-width: 0; }
.tlabel {
  display: block; font: 700 11.5px var(--mono); letter-spacing: .1em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 5px;
}
.task-head h2 { font-size: 1.62rem; letter-spacing: -.03em; }
.task.done .task-head h2 { color: var(--fg-mid); }

.tick { flex: none; cursor: pointer; margin-top: 6px; }
.tick input { position: absolute; opacity: 0; width: 0; height: 0; }
.tick .box {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 8px;
  border: 1.8px solid var(--line); background: var(--bg-card); transition: all .15s;
}
.tick .box svg { width: 14px; height: 14px; color: #fff; opacity: 0; transform: scale(.6); transition: all .15s; }
.tick:hover .box { border-color: var(--accent); }
.tick input:checked + .box { background: var(--ok); border-color: var(--ok); }
.tick input:checked + .box svg { opacity: 1; transform: scale(1); }
.tick input:focus-visible + .box { outline: 2px solid var(--accent); outline-offset: 2px; }

.task-tools { display: flex; gap: 2px; flex: none; }
.task-tools .iconbtn.on { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
.task-tools .iconbtn.on svg { fill: currentColor; }

/* ---------- prose (extracted lesson content) ---------- */
.task-body { font-size: 16.2px; line-height: 1.75; color: var(--fg); }
.task-body > :first-child { margin-top: 0; }
.task-body h1, .task-body h2, .task-body h3, .task-body h4 {
  margin: 2em 0 .6em; letter-spacing: -.02em; scroll-margin-top: calc(var(--top) + 20px);
}
.task-body h1 { font-size: 1.42rem; }
.task-body h2 { font-size: 1.26rem; }
.task-body h3 { font-size: 1.1rem; }
.task-body h4 { font-size: 1rem; }
.task-body p { margin: 0 0 1.05em; }
.task-body ul, .task-body ol { margin: 0 0 1.15em; padding-left: 1.5em; }
.task-body li { margin: .38em 0; }
.task-body li::marker { color: var(--accent); }
.task-body strong { font-weight: 660; }
.task-body hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
.task-body blockquote {
  margin: 1.4em 0; padding: 2px 0 2px 18px;
  border-left: 3px solid var(--accent-line); color: var(--fg-mid);
}
.task-body img {
  display: block; margin: 1.6em auto; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--bg-sub); box-shadow: var(--sh-sm);
}
.task-body code {
  font: 500 .875em/1.5 var(--mono);
  background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--code-line); border-radius: var(--r-sm);
  padding: .12em .38em; word-break: break-word;
}
.task-body pre {
  margin: 1.4em 0; padding: 16px 18px; overflow-x: auto;
  background: var(--code-bg); border: 1px solid var(--code-line);
  border-radius: var(--r); font: 500 13.6px/1.62 var(--mono); color: var(--code-fg);
  -webkit-overflow-scrolling: touch;
}
.task-body pre code { background: none; border: 0; padding: 0; font-size: 1em; }
.task-body table {
  width: 100%; margin: 1.5em 0; border-collapse: collapse; font-size: 14.6px;
  display: block; overflow-x: auto;
}
.task-body th, .task-body td { padding: 10px 13px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.task-body th { background: var(--bg-sub); font-weight: 640; }
.task-body a { text-decoration: underline; text-decoration-color: var(--accent-line); text-underline-offset: 2px; }
.task-body abbr { text-decoration: underline dotted var(--accent); cursor: help; }
mark, .task-body mark {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit; border-radius: 3px; padding: .05em .1em;
}
.task-body mark.hl { background: color-mix(in srgb, var(--accent) 26%, transparent); box-shadow: 0 1px 0 var(--accent-line); cursor: pointer; }

/* ---------- questions ---------- */
.questions {
  margin: 26px 0 0; padding: 18px 20px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r);
}
.questions h4 {
  display: flex; align-items: center; gap: 9px; margin-bottom: 10px;
  font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--accent-ink);
}
.questions h4 span {
  display: grid; place-items: center; width: 19px; height: 19px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font-size: 11px;
}
.questions ol { margin: 0; padding-left: 1.3em; font-size: 14.6px; color: var(--fg-mid); }
.questions li { margin: .4em 0; }

/* ---------- per-task note ---------- */
.note { margin-top: 20px; border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-sub); overflow: hidden; }
.note-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 14px; border-bottom: 1px solid var(--line);
  font-size: 12px; font-weight: 640; text-transform: uppercase; letter-spacing: .07em; color: var(--fg-mut);
}
.note-state { text-transform: none; letter-spacing: 0; font-weight: 500; color: var(--ok); opacity: 0; transition: opacity .3s; }
.note-state.show { opacity: 1; }
.note textarea {
  display: block; width: 100%; border: 0; resize: vertical; min-height: 92px;
  padding: 14px; background: var(--bg-card); color: var(--fg);
  font: 400 14.6px/1.65 var(--sans);
}
.note textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--accent-soft); }
.task.has-note .note { border-color: var(--accent-line); }

/* ---------- pager ---------- */
.pager-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 20px; }
.pager {
  display: flex; flex-direction: column; gap: 3px; padding: 15px 18px;
  border: 1px solid var(--line); border-radius: var(--r); background: var(--bg-card); color: var(--fg);
  transition: border-color .15s, transform .15s;
}
.pager:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-2px); }
.pager span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--fg-mut); font-weight: 640; }
.pager b { font-size: 14.6px; font-weight: 600; letter-spacing: -.015em; }
.pager.next { text-align: right; grid-column: 2; }
.pager.prev:only-child { grid-column: 1; }
@media (max-width: 620px) { .pager-row { grid-template-columns: 1fr; } .pager.next { grid-column: 1; text-align: left; } }

.totop {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  display: grid; place-items: center; width: 42px; height: 42px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--line); color: var(--fg-mid);
  box-shadow: var(--sh); cursor: pointer; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.totop.show { opacity: 1; pointer-events: auto; }
.totop:hover { color: var(--accent); border-color: var(--accent-line); transform: translateY(-2px); }
.totop svg { width: 18px; height: 18px; }

/* ---------- highlight popover ---------- */
.hl-pop {
  position: absolute; z-index: 70; display: flex; gap: 1px; padding: 3px;
  background: var(--fg); border-radius: 9px; box-shadow: var(--sh-lg);
}
.hl-pop button {
  background: none; border: 0; color: var(--bg); font: 600 12.5px var(--sans);
  padding: 6px 11px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.hl-pop button:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); }

/* ---------- command palette ---------- */
.palette {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: start center;
  padding: 10vh 20px 20px;
  background: color-mix(in srgb, #0b0d12 45%, transparent);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.palette-box {
  width: min(660px, 100%); max-height: 74vh; display: flex; flex-direction: column;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--sh-lg); overflow: hidden;
}
.palette-input { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.palette-input svg { width: 18px; height: 18px; color: var(--fg-mut); flex: none; }
.palette-input input {
  flex: 1; border: 0; background: none; color: var(--fg); font: 400 16px var(--sans); outline: none;
}
.palette-input input::-webkit-search-cancel-button { display: none; }
.palette-results { overflow-y: auto; padding: 8px; }
.pgroup { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--fg-mut); padding: 12px 10px 6px; }
.phit {
  display: block; padding: 9px 11px; border-radius: var(--r-sm); color: var(--fg); cursor: pointer;
}
.phit:hover, .phit.sel { background: var(--accent-soft); text-decoration: none; }
.phit .pwhere { font-size: 11.5px; color: var(--fg-mut); display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.phit .pwhere b { color: var(--accent-ink); font-weight: 640; }
.phit .ptitle { font-size: 14.6px; font-weight: 580; letter-spacing: -.01em; }
.phit .psnip { font-size: 12.8px; color: var(--fg-mut); margin-top: 3px; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.palette-foot {
  display: flex; gap: 18px; padding: 10px 18px; border-top: 1px solid var(--line);
  background: var(--bg-sub); font-size: 11.5px; color: var(--fg-mut);
}
.palette-foot span { display: flex; align-items: center; gap: 5px; }
.pempty { padding: 34px 16px; text-align: center; color: var(--fg-mut); font-size: 14px; }

/* ---------- notebook / review pages ---------- */
.page { padding-top: 44px; padding-bottom: 100px; }
.page-head h1 { font-size: clamp(1.9rem, 4vw, 2.5rem); }
.page-head .lede { margin-bottom: 26px; }
.page-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 30px; }
.page-tools .spacer { flex: 1; }
.page-tools input[type="search"] {
  height: 42px; padding: 0 15px; min-width: 200px;
  background: var(--bg-card); border: 1px solid var(--line); border-radius: 999px;
  color: var(--fg); font: 400 14px var(--sans); outline: none;
}
.page-tools input[type="search"]:focus { border-color: var(--accent); }
.filter { display: flex; gap: 2px; padding: 3px; background: var(--bg-inset); border-radius: 999px; }
.filter button {
  border: 0; background: none; padding: 7px 15px; border-radius: 999px;
  font: 600 13.5px var(--sans); color: var(--fg-mut); cursor: pointer;
}
.filter button.on { background: var(--bg-card); color: var(--fg); box-shadow: var(--sh-sm); }

.notebook { display: flex; flex-direction: column; gap: 14px; }
.nb-course { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .09em;
  color: var(--accent); margin: 26px 0 4px; }
.nb-item {
  display: block; padding: 18px 20px; border-radius: var(--r-lg);
  background: var(--bg-card); border: 1px solid var(--line); color: var(--fg);
  transition: border-color .15s, transform .15s;
}
.nb-item:hover { border-color: var(--accent-line); text-decoration: none; transform: translateY(-1px); }
.nb-meta { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 12px; color: var(--fg-mut); margin-bottom: 8px; }
.nb-tag {
  font-size: 10.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink);
}
.nb-tag.mark { background: var(--ok-soft); color: var(--ok); }
.nb-item h3 { font-size: 1.02rem; margin-bottom: 8px; }
.nb-body { font-size: 14.6px; color: var(--fg-mid); white-space: pre-wrap; line-height: 1.6; }
.nb-body.quote { border-left: 3px solid var(--accent); padding-left: 14px; font-style: italic; }
.empty-state { text-align: center; padding: 80px 20px; color: var(--fg-mut); }
.empty-state .es-icon { font-size: 40px; opacity: .35; display: block; margin-bottom: 14px; }
.empty-state h3 { font-size: 1.1rem; color: var(--fg); margin-bottom: 8px; }

.review-stats { display: flex; gap: 40px; flex-wrap: wrap; padding: 22px 24px; margin-bottom: 30px;
  background: var(--bg-sub); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card {
  padding: 34px; border-radius: var(--r-xl); background: var(--bg-card);
  border: 1px solid var(--line); box-shadow: var(--sh); text-align: center;
}
.card .c-where { font-size: 12px; color: var(--fg-mut); margin-bottom: 14px; }
.card .c-front { font-size: 1.35rem; font-weight: 620; letter-spacing: -.025em; margin-bottom: 22px; }
.card .c-back { border-top: 1px solid var(--line); padding-top: 22px; margin-top: 22px;
  font-size: 15px; color: var(--fg-mid); white-space: pre-wrap; text-align: left; line-height: 1.65; }
.card-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; margin-top: 26px; }
.grade { min-width: 92px; justify-content: center; }
.grade.again { border-color: var(--danger); color: var(--danger); }
.grade.good  { border-color: var(--ok); color: var(--ok); }

/* ---------- footer ---------- */
.foot { border-top: 1px solid var(--line); background: var(--bg-sub); }
.foot-in {
  max-width: 1140px; margin: 0 auto; padding: 44px 24px 26px;
  display: flex; gap: 40px; flex-wrap: wrap; justify-content: space-between;
}
.foot-in strong { font-size: 15px; letter-spacing: -.02em; }
.foot-in p { margin: 7px 0 0; font-size: 13.6px; color: var(--fg-mut); max-width: 46ch; }
.foot-links { display: flex; gap: 22px; font-size: 13.6px; }
.foot-links a { color: var(--fg-mid); }
.foot-fine {
  max-width: 1140px; margin: 0 auto; padding: 18px 24px 34px;
  border-top: 1px solid var(--line); font-size: 12.5px; color: var(--fg-mut);
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px); z-index: 300;
  padding: 11px 18px; border-radius: 999px; background: var(--fg); color: var(--bg);
  font: 600 13.5px var(--sans); box-shadow: var(--sh-lg); opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media print {
  .topbar, .rail, .foot, .totop, .palette, .task-tools, .tick { display: none !important; }
  .doc { max-width: none; padding: 0; }
  .task { break-inside: avoid; }
}
