:root {
  --bg: #ffffff;
  --bg-soft: #f7f8fb;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e6e9f0;
  --card: #ffffff;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 2px 4px rgba(15, 23, 42, .04), 0 24px 48px -20px rgba(15, 23, 42, .18);
  --radius: 18px;
  --indigo: #4f46e5; --indigo-soft: #eef2ff;
  --violet: #7c3aed; --violet-soft: #f5f3ff;
  --sky: #0284c7;    --sky-soft: #f0f9ff;
  --emerald: #059669; --emerald-soft: #ecfdf5;
  --amber: #b45309; --amber-soft: #fffbeb;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 84px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: 'Inter', system-ui, sans-serif; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { line-height: 1.15; letter-spacing: -0.02em; margin: 0; }
.wrap { max-width: 1160px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--muted); }
:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; border-radius: 6px; }

/* scroll progress */
.progress-bar { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 100; background: transparent; }
.progress-bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--indigo), var(--violet), var(--sky)); }

/* top bar */
.top { position: sticky; top: 0; z-index: 50; background: rgba(255,255,255,.78); backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px); border-bottom: 1px solid var(--line); }
.top-inner { max-width: 1160px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-family: 'JetBrains Mono', monospace; background: linear-gradient(135deg, var(--indigo), var(--violet)); box-shadow: 0 6px 16px -6px rgba(79,70,229,.6); }
.top-links { display: flex; align-items: center; gap: 22px; font-size: 14px; font-weight: 500; color: var(--ink-2); }
.top-links a:hover { color: var(--indigo); }
.top-links .ghost { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; }
.top-links .ghost:hover { border-color: var(--indigo); }

/* hero */
.hero { position: relative; overflow: hidden; padding: 96px 0 72px; }
.hero-bg { position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(600px 300px at 12% 0%, rgba(79,70,229,.14), transparent 70%),
    radial-gradient(560px 320px at 88% 10%, rgba(2,132,199,.14), transparent 70%),
    radial-gradient(500px 300px at 50% 100%, rgba(124,58,237,.08), transparent 70%),
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 56px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 56px 100%;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
  opacity: .9; }
.hero-inner { position: relative; z-index: 1; text-align: center; }
.eyebrow { margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--indigo); }
.hero h1 { font-size: clamp(40px, 7vw, 76px); font-weight: 800; letter-spacing: -0.04em; }
.grad { background: linear-gradient(100deg, var(--indigo), var(--violet) 50%, var(--sky)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lede { max-width: 680px; margin: 20px auto 0; font-size: 19px; color: var(--ink-2); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 28px; }
.chip { font-size: 13px; font-weight: 500; padding: 6px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink-2); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; max-width: 760px; margin: 40px auto 0; }
.stat { background: rgba(255,255,255,.85); border: 1px solid var(--line); border-radius: 16px; padding: 16px 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 30px; font-weight: 800; letter-spacing: -0.03em; }
.stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hero-cta { display: flex; gap: 12px; justify-content: center; margin-top: 32px; flex-wrap: wrap; }

.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font: 600 14px 'Inter', sans-serif; color: var(--ink); cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.btn:hover { border-color: #cbd2e0; box-shadow: var(--shadow); transform: translateY(-1px); }
.btn.primary { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary:hover { background: #1e293b; }
.btn.small { padding: 8px 14px; font-size: 13px; border-radius: 10px; }

/* sections */
section.wrap { padding-top: 56px; padding-bottom: 24px; }
.section-head { margin-bottom: 28px; max-width: 720px; }
.section-head h2 { font-size: clamp(28px, 4vw, 40px); font-weight: 800; }
.section-head .muted { margin: 12px 0 0; }

/* roadmap */
.roadmap { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; position: relative; counter-reset: none; }
.rm-card { position: relative; display: block; height: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s, border-color .2s; }
.rm-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.rm-num { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-family: 'JetBrains Mono', monospace; margin-bottom: 14px; }
.rm-card h3 { font-size: 17px; font-weight: 700; }
.rm-card p { font-size: 13.5px; color: var(--muted); margin: 8px 0 14px; }
.rm-meta { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.rm-card .rm-arrow { position: absolute; top: 24px; right: 22px; color: #cbd2e0; font-size: 18px; }
.rm-card:not(:last-child)::after { content: ''; position: absolute; top: 40px; right: -17px; width: 18px; height: 2px; background: var(--line); }
.a-indigo .rm-num, .a-indigo .badge { background: var(--indigo-soft); color: var(--indigo); }
.a-violet .rm-num, .a-violet .badge { background: var(--violet-soft); color: var(--violet); }
.a-sky .rm-num, .a-sky .badge { background: var(--sky-soft); color: var(--sky); }
.a-emerald .rm-num, .a-emerald .badge { background: var(--emerald-soft); color: var(--emerald); }
.a-amber .rm-num, .a-amber .badge { background: var(--amber-soft); color: var(--amber); }
.a-indigo { --ac: var(--indigo); --ac-soft: var(--indigo-soft); }
.a-violet { --ac: var(--violet); --ac-soft: var(--violet-soft); }
.a-sky { --ac: var(--sky); --ac-soft: var(--sky-soft); }
.a-emerald { --ac: var(--emerald); --ac-soft: var(--emerald-soft); }
.a-amber { --ac: var(--amber); --ac-soft: var(--amber-soft); }

/* toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 16px; position: sticky; top: 68px; z-index: 20; }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; color: var(--muted); }
.search:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; padding: 11px 0; font: 500 14px 'Inter', sans-serif; color: var(--ink); }
.seg { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 12px; border-radius: 9px; font: 600 13px 'Inter', sans-serif; color: var(--muted); cursor: pointer; }
.seg button:hover { color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.actions { display: flex; gap: 8px; }
.result-count { font-size: 13px; margin: 12px 4px 0; min-height: 20px; }

/* layout */
.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 32px; margin-top: 12px; align-items: start; }
.side { position: sticky; top: 150px; }
.side-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.side-title { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.meter { height: 8px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; margin: 12px 0 8px; border: 1px solid var(--line); }
.meter span { display: block; height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--indigo), var(--violet), var(--sky)); transition: width .4s ease; }
.side-num { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; }
.side-num b { font-size: 24px; letter-spacing: -0.03em; }
.toc { list-style: none; margin: 18px 0 8px; padding: 0; display: grid; gap: 2px; }
.toc a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; font-size: 13.5px; font-weight: 500; color: var(--ink-2); }
.toc a:hover { background: var(--bg-soft); }
.toc a.active { background: var(--ac-soft); color: var(--ac); font-weight: 600; }
.toc .n { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; font: 600 11px 'JetBrains Mono', monospace; background: var(--ac-soft); color: var(--ac); flex: none; }
.toc .t { flex: 1; line-height: 1.3; }
.toc .p { font-size: 11px; color: var(--muted); font-family: 'JetBrains Mono', monospace; }
.link-btn { margin-top: 8px; background: none; border: 0; padding: 4px 0; color: var(--muted); font: 500 12px 'Inter', sans-serif; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link-btn:hover { color: #dc2626; }

/* phase */
.phase { margin-bottom: 56px; }
.phase-head { display: flex; gap: 18px; align-items: flex-start; padding: 26px; border-radius: var(--radius); background: linear-gradient(135deg, var(--ac-soft), #fff 70%); border: 1px solid var(--line); }
.phase-head .rm-num { margin: 0; width: 48px; height: 48px; font-size: 20px; background: #fff; color: var(--ac); box-shadow: var(--shadow); flex: none; }
.phase-head h3 { font-size: clamp(22px, 3vw, 28px); font-weight: 800; }
.phase-head p { margin: 8px 0 0; color: var(--ink-2); font-size: 15px; }
.phase-head .ph-prog { margin-top: 14px; display: flex; align-items: center; gap: 10px; font-size: 12px; font-weight: 600; color: var(--muted); }
.phase-head .ph-prog .meter { flex: 0 0 160px; margin: 0; height: 6px; }
.phase-head .ph-prog .meter span { background: var(--ac); }

.section { margin-top: 32px; }
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 0 0 14px; padding-left: 4px; }
.section-title .num { font: 600 13px 'JetBrains Mono', monospace; color: var(--ac); }
.section-title h4 { font-size: 20px; font-weight: 700; }

.topic { background: var(--card); border: 1px solid var(--line); border-radius: 16px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(15,23,42,.03); transition: box-shadow .2s, border-color .2s; overflow: hidden; }
.topic:hover { border-color: #d5dae6; }
.topic[open] { box-shadow: var(--shadow); border-color: #d5dae6; }
.topic summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.topic summary::-webkit-details-marker { display: none; }
.ring { --p: 0; width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center; background: conic-gradient(var(--ac) calc(var(--p) * 1%), var(--line) 0); position: relative; }
.ring::before { content: ''; position: absolute; inset: 4px; border-radius: 50%; background: #fff; }
.ring span { position: relative; font: 600 10px 'JetBrains Mono', monospace; color: var(--ink-2); }
.topic.done .ring { background: var(--ac); }
.topic.done .ring::before { background: var(--ac); }
.topic.done .ring span { color: #fff; }
.sum-body { flex: 1; min-width: 0; }
.sum-body h5 { margin: 0; font-size: 16.5px; font-weight: 650; font-weight: 600; letter-spacing: -0.01em; }
.sum-body p { margin: 3px 0 0; font-size: 13.5px; color: var(--muted); }
.sum-meta { font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.chev { width: 20px; height: 20px; flex: none; color: var(--muted); transition: transform .25s; }
.topic[open] .chev { transform: rotate(180deg); }
.topic-body { padding: 0 20px 22px 72px; display: grid; gap: 18px; }
.sub-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.sub { display: flex; gap: 12px; padding: 10px 12px; margin: 0 -12px; border-radius: 12px; cursor: pointer; transition: background .15s; }
.sub:hover { background: var(--bg-soft); }
.sub input { appearance: none; -webkit-appearance: none; width: 20px; height: 20px; margin: 2px 0 0; flex: none; border: 1.5px solid #c3cada; border-radius: 6px; background: #fff; cursor: pointer; display: grid; place-items: center; transition: all .15s; }
.sub input:checked { background: var(--ac); border-color: var(--ac); }
.sub input:checked::after { content: ''; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.sub .st { font-weight: 600; font-size: 14.5px; }
.sub .sd { display: block; font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.sub input:checked ~ div .st { color: var(--muted); text-decoration: line-through; text-decoration-color: #c3cada; }
.practice { background: var(--bg-soft); border: 1px dashed #d5dae6; border-radius: 14px; padding: 14px 16px; }
.practice h6 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ac); font-weight: 700; }
.practice ul { margin: 0; padding-left: 18px; font-size: 13.5px; color: var(--ink-2); display: grid; gap: 4px; }
mark { background: #fef08a; color: inherit; border-radius: 3px; padding: 0 1px; }

.empty { text-align: center; padding: 48px 0; color: var(--muted); }

/* books */
.books { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.book { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; transition: transform .2s, box-shadow .2s; }
.book:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.book .badge { align-self: flex-start; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 4px 10px; border-radius: 99px; }
.book h3 { font-size: 17px; font-weight: 700; margin-top: 8px; }
.book .au { font-size: 13.5px; color: var(--ink-2); }
.book .fo { font-size: 13.5px; color: var(--muted); margin-top: auto; padding-top: 10px; border-top: 1px solid var(--line); }
.book .ph { font-size: 12px; font-weight: 600; color: var(--muted); }

.foot { margin-top: 72px; border-top: 1px solid var(--line); background: var(--bg-soft); }
.foot-inner { display: flex; justify-content: space-between; gap: 16px; padding: 28px 24px; font-size: 14px; color: var(--muted); }
.foot-inner a:hover { color: var(--indigo); }

.to-top { position: fixed; right: 20px; bottom: 20px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow-lg); font-size: 18px; cursor: pointer; z-index: 40; }
.to-top:hover { border-color: var(--indigo); color: var(--indigo); }

/* responsive */
@media (max-width: 1000px) {
  .roadmap { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rm-card:not(:last-child)::after { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .books { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .top-links a:not(.ghost) { display: none; }
  .hero { padding: 64px 0 48px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .roadmap, .books { grid-template-columns: minmax(0, 1fr); }
  .toolbar { position: static; }
  .seg { width: 100%; overflow-x: auto; }
  .topic-body { padding-left: 20px; }
  .sum-meta { display: none; }
  .phase-head { flex-direction: column; padding: 20px; }
  .foot-inner { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
@media print {
  .top, .toolbar, .side, .to-top, .progress-bar, .hero-bg { display: none !important; }
  .topic { break-inside: avoid; }
  .layout { grid-template-columns: 1fr; }
}

/* lesson links on the outline page */
.lesson-link { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-radius: 12px; background: linear-gradient(135deg, var(--ac-soft), #fff); border: 1px solid var(--line); font-size: 14px; font-weight: 600; color: var(--ink); transition: border-color .2s, transform .2s; }
.lesson-link:hover { border-color: var(--ac); transform: translateY(-1px); }
.lesson-link .lt { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ac); }
.lesson-badge { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ac); background: var(--ac-soft); padding: 2px 8px; border-radius: 99px; margin-right: 6px; }
.phase { scroll-margin-top: 150px; }
@media (max-width: 640px) { .phase { scroll-margin-top: 84px; } }

/* phase 0 extras */
.section-title .sec-time { margin-left: auto; font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.checklist { margin-top: 16px; padding: 14px 16px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 12px; }
.checklist h6 { margin: 0 0 8px; font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ac); }
.checklist ul { margin: 0; padding-left: 18px; font-size: 14px; color: var(--ink-2); }
