/* ---------- Tokens ---------- */
:root {
  --bg: #f7f5f0;
  --surface: #ffffff;
  --surface-2: #f1eee7;
  --border: #e4dfd4;
  --text: #1f1d1a;
  --text-2: #4a463f;
  --muted: #67625a;
  --accent: #c15f3c;
  --accent-soft: #f6e4dc;
  --accent-text: #a14a2b;
  --tip: #2f6b4f;
  --tip-soft: #e3f1e9;
  --warn: #8a5a00;
  --warn-soft: #fbefd2;
  --code-bg: #24221f;
  --code-text: #f3efe7;
  --shadow: 0 1px 2px rgb(31 29 26 / .05), 0 2px 8px rgb(31 29 26 / .04);
  --shadow-hover: 0 2px 4px rgb(31 29 26 / .06), 0 10px 28px rgb(31 29 26 / .08);
  --radius: 14px;
  --radius-sm: 8px;
  --sidebar-w: 264px;
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171614; --surface: #201f1c; --surface-2: #2a2825; --border: #353330;
    --text: #f0ece4; --text-2: #d3cec4; --muted: #aca79d;
    --accent: #e08563; --accent-soft: #3a2a22; --accent-text: #f0a383;
    --tip: #8fd3ad; --tip-soft: #1e2f26; --warn: #f2c467; --warn-soft: #362c17;
    --code-bg: #121110; --code-text: #efeae0;
    --shadow: 0 1px 2px rgb(0 0 0 / .3); --shadow-hover: 0 8px 28px rgb(0 0 0 / .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171614; --surface: #201f1c; --surface-2: #2a2825; --border: #353330;
  --text: #f0ece4; --text-2: #d3cec4; --muted: #aca79d;
  --accent: #e08563; --accent-soft: #3a2a22; --accent-text: #f0a383;
  --tip: #8fd3ad; --tip-soft: #1e2f26; --warn: #f2c467; --warn-soft: #362c17;
  --code-bg: #121110; --code-text: #efeae0;
  --shadow: 0 1px 2px rgb(0 0 0 / .3); --shadow-hover: 0 8px 28px rgb(0 0 0 / .45);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15.5px/1.6 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); padding: .1em .35em; border-radius: 5px; }
kbd { font-family: var(--mono); font-size: 11px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; color: var(--muted); background: var(--surface); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--accent); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  html { scroll-behavior: auto; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border);
  background: var(--surface); padding: 7px 12px; border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 500; transition: background .15s, border-color .15s, transform .1s;
  color: var(--text); text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); padding: 20px 14px;
  display: flex; flex-direction: column; gap: 18px; border-right: 1px solid var(--border);
  background: var(--bg); overflow-y: auto; z-index: 30;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 0 8px; }
.brand strong { display: block; font-size: 15px; letter-spacing: -.01em; }
.logo {
  width: 32px; height: 32px; border-radius: 9px; background: var(--accent); flex: none; position: relative;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 11 5 5-5 5M17 21h6'/%3E%3C/svg%3E");
}
.nav { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.nav-extra { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.nav-link {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--text-2); text-decoration: none; font-size: 14px; border: 0; background: none; cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link.active { background: color-mix(in srgb, var(--sec, var(--accent)) 14%, transparent); color: var(--text); font-weight: 600; }
.nav-link .nav-icon { color: var(--sec, var(--muted)); }
.nav-icon { width: 20px; text-align: center; flex: none; }
.nav-link .count { margin-left: auto; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.nav-link.empty { opacity: .45; }
.sidebar-foot { margin-top: auto; }
.theme-icon::before { content: "☾"; }
:root[data-theme="dark"] .theme-icon::before { content: "☀"; }

/* ---------- Shell / Topbar ---------- */
.shell { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  padding: 16px 40px 10px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px);
}
.menu-btn { display: none; font-size: 18px; }
.search {
  flex: 1; max-width: 620px; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { flex: 1; border: 0; outline: 0; background: none; padding: 10px 0; font-size: 15px; min-width: 0; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.filters {
  position: sticky; top: 62px; z-index: 19; display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 40px 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); padding: 3px 10px;
  border-radius: 999px; font-size: 12.5px; cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--muted); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip.clear { border-style: dashed; }

/* ---------- Sections ---------- */
main { padding: 8px 40px 120px; outline: none; }
.site-footer { padding: 20px 40px 32px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.local-note { color: var(--muted); font-size: 13.5px; margin: 6px 0 0; }
.section { padding-top: 34px; }
.section[hidden] { display: none; }
.section-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.section-head h2 { margin: 0; font-size: 26px; letter-spacing: -.02em; line-height: 1.2; display: flex; align-items: center; gap: 10px; }
.section-head .num { font-size: 12px; font-weight: 600; color: var(--accent-text); font-family: var(--mono); }
.section-head p { margin: 4px 0 0; color: var(--text-2); max-width: 70ch; }
.section-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.empty-state { padding: 60px 20px; text-align: center; color: var(--muted); }
.empty-state strong { display: block; color: var(--text); font-size: 17px; margin-bottom: 4px; }

/* ---------- Cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.card {
  background: var(--surface); border: 0; border-top: 3px solid color-mix(in srgb, var(--sec, var(--accent)) 70%, transparent); border-radius: var(--radius); padding: 20px 20px 14px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  transition: box-shadow .2s, transform .2s, border-color .2s; animation: rise .35s ease both;
}
.card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }
.card.is-fav { box-shadow: var(--shadow), 0 0 0 2px color-mix(in srgb, #e3a008 35%, transparent); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.card-head { display: flex; align-items: flex-start; gap: 8px; }
.card-head h3 { margin: 0; font-size: 16.5px; line-height: 1.3; letter-spacing: -.01em; flex: 1; }
.role-badge { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--accent-text); display: block; margin-bottom: 2px; }
.star {
  border: 0; background: none; cursor: pointer; font-size: 18px; line-height: 1; padding: 2px 4px; color: var(--border);
  transition: color .15s, transform .2s;
}
.star:hover { color: var(--muted); }
.star[aria-pressed="true"] { color: #e3a008; transform: scale(1.1); }
.what { margin: 0; font-size: 15px; line-height: 1.6; color: var(--text); }
.how { margin: 0; padding-left: 18px; color: var(--text-2); font-size: 15px; line-height: 1.6; display: grid; gap: 5px; }
.how li::marker { color: var(--accent); }
.label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.snippet { border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.snippet-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0 12px; }
.snippet-head .label { color: #a8a295; }
.snippet pre { margin: 0; padding: 6px 12px 12px; overflow-x: auto; }
.snippet code { background: none; padding: 0; color: var(--code-text); font-size: 12.8px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.snippet.text { background: var(--surface-2); }
.snippet.text .snippet-head .label { color: var(--muted); }
.snippet.text code { color: var(--text); font-family: var(--font); font-size: 13.5px; }
.copy {
  border: 1px solid rgb(255 255 255 / .14); background: rgb(255 255 255 / .06); color: #d8d2c6; font-size: 11.5px;
  padding: 3px 9px; border-radius: 6px; cursor: pointer; transition: background .15s;
}
.copy:hover { background: rgb(255 255 255 / .14); }
.copy.done { background: var(--tip); border-color: var(--tip); color: #fff; }
.snippet.text .copy { border-color: var(--border); background: var(--surface); color: var(--text-2); }

.compare { display: grid; gap: 6px; }
.compare .bad, .compare .good { border-radius: 10px; padding: 8px 12px; font-size: 13.5px; }
.compare .bad { background: var(--surface-2); color: var(--text-2); }
.compare .bad .label { color: var(--muted); }
.compare .good { background: var(--tip-soft); }
.compare .good .label { color: var(--tip); }
.compare .row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }

.tip { margin: 0; font-size: 13.5px; line-height: 1.55; color: var(--muted); display: flex; gap: 6px; }
.tip-icon { font-size: 12px; line-height: 1.75; flex: none; filter: grayscale(.4); }

details.more { border-top: 1px dashed var(--border); padding-top: 8px; }
details.more summary {
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--text-2); list-style: none; display: inline-flex; align-items: center; gap: 6px;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "›"; display: inline-block; transition: transform .2s; font-size: 16px; line-height: 1; }
details.more[open] summary::before { transform: rotate(90deg); }
details.more[open] .more-body { animation: rise .25s ease both; }
.more-body { display: grid; gap: 8px; margin-top: 8px; }
.more-body ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.6; color: var(--text-2); display: grid; gap: 3px; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 2px; font-size: 11.5px; color: var(--muted); }
.tag { background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 1px 8px; font-size: 11.5px; border: 0; cursor: pointer; }
.tag:hover { color: var(--text); }
.verify { background: var(--warn-soft); color: var(--warn); border-radius: 999px; padding: 1px 8px; font-weight: 600; font-size: 11px; }
.meta .spacer { flex: 1; }
.meta a { color: var(--muted); text-decoration: none; }
.meta a:hover { color: var(--accent-text); text-decoration: underline; }
/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); background: var(--text); color: var(--bg);
  padding: 8px 16px; border-radius: 999px; font-size: 13px; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-hover); }
  .sidebar.open { transform: none; }
  .shell { margin-left: 0; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px 8px; }
  .filters { padding: 4px 16px 10px; top: 58px; flex-wrap: nowrap; overflow-x: auto; }
  .chip { flex: none; }
  main { padding: 4px 16px 100px; }
  .site-footer { padding: 16px; }
  .grid { grid-template-columns: 1fr; }
  .search kbd { display: none; }
}

/* ---------- Groups, tables, level chips ---------- */
.group-head { grid-column: 1 / -1; margin: 14px 0 -4px; font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--accent-text); }
.group-head:first-child { margin-top: 0; }
.card.wide { grid-column: 1 / -1; }
.table-wrap { overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table-wrap th { text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 10px; border-bottom: 1px solid var(--border); }
.table-wrap td { padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; color: var(--text-2); }
.table-wrap tr:last-child td { border-bottom: 0; }
.table-wrap td.cmd { white-space: nowrap; }
.table-wrap td.cmd code { color: var(--text); }
.table-wrap td.cmd .copy { margin-left: 8px; border-color: var(--border); background: var(--surface); color: var(--text-2); opacity: 0; }
.table-wrap tr:hover .copy, .table-wrap .copy:focus-visible, .table-wrap .copy.done { opacity: 1; }
.table-wrap .copy.done { color: #fff; }
.table-wrap p { margin: 6px 0 0; }
.chip.level { border-color: var(--accent); color: var(--accent-text); }
.chip.level[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 4px; flex: none; }
@media (hover: none) { .table-wrap td.cmd .copy { opacity: 1; } }

/* ---------- Routed views ---------- */
.view { --prose: 720px; padding-top: 28px; max-width: 1180px; animation: rise .3s ease both; }
/* One prose width; only card grids go wider. */
.view > *, .view-main > * { max-width: var(--prose); }
.view > :is(.grid, .paths, .home-grid, .beyond-results, .view-main), .view-main > .grid, .search-view > * { max-width: none; }
.view-head { margin-bottom: 22px; }
.view-head h1 { margin: 0; font-size: 30px; letter-spacing: -.02em; line-height: 1.2; display: flex; align-items: center; gap: 12px; }
.sec-icon { color: var(--sec, var(--accent)); }
.lead { margin: 8px 0 0; color: var(--text-2); font-size: 16px; max-width: 70ch; }
.kicker { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--sec, var(--accent-text)); }
.h-sub { font-size: 14px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--text-2); margin: 36px 0 12px; }
.h-sub a { color: inherit; text-decoration: none; }
.back { display: inline-block; margin-bottom: 14px; color: var(--muted); text-decoration: none; }
.back:hover { color: var(--text); }
.center { text-align: center; margin-top: 18px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.btn.small { padding: 4px 10px; font-size: 12.5px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.head-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; max-width: 520px; }
.head-actions .bar { flex: 1; }

/* Progress bar */
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--sec, var(--accent)); border-radius: inherit; transition: width .5s ease; }

/* Home */
.hero { padding: 28px 0 8px; }
.hero h1 { font-size: clamp(30px, 4vw, 42px); margin: 6px 0 0; letter-spacing: -.03em; line-height: 1.1; }
.paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.path-card {
  display: flex; flex-direction: column; gap: 8px; padding: 20px; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: box-shadow .2s, transform .2s;
}
.path-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }
.path-card strong { font-size: 17px; }
.path-card .bar { margin-top: auto; }
.path-icon { font-size: 22px; }
.beyond-link { margin: 18px 0 0; font-size: 13.5px; }
.beyond-link a { color: var(--text-2); font-weight: 500; }
.home-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-top: 36px; align-items: start; }
.panel { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); display: grid; gap: 10px; }
.panel-title { font-size: 16px; }
.tip-big { margin: 0; font-size: 17px; line-height: 1.5; }

/* Path view */
.steps { list-style: none; display: flex; gap: 8px; padding: 0; margin: 0 0 22px; flex-wrap: wrap; }
.steps a { display: block; width: 28px; height: 8px; border-radius: 999px; background: var(--surface-2); transition: background .2s, transform .2s; }
.steps a.done { background: color-mix(in srgb, var(--sec) 45%, var(--surface-2)); }
.steps a.current { background: var(--sec); transform: scaleY(1.4); }
.path-card-wrap { max-width: 720px; }
.path-card-wrap .card { animation: rise .3s ease both; }
.path-nav { display: flex; justify-content: space-between; align-items: center; gap: 10px; max-width: 720px; margin-top: 18px; }
.path-nav .btn[data-learn] { padding: 10px 22px; font-size: 14.5px; }
.path .center { max-width: 720px; }

/* Card additions */
.also-app { margin: 0; font-size: 13px; color: var(--text-2); padding-top: 8px; border-top: 1px dashed var(--border); }
.learn { border: 0; background: var(--surface-2); color: var(--text-2); border-radius: 999px; padding: 2px 10px; font-size: 11.5px; cursor: pointer; }
.learn:hover { color: var(--text); }
.learn[aria-pressed="true"] { background: var(--tip-soft); color: var(--tip); font-weight: 600; }
.card.is-learned .card-head h3::after { content: " ✓"; color: var(--tip); font-size: .8em; }
.card.flash { animation: flash 1.6s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 3px var(--sec, var(--accent)), var(--shadow-hover); } 100% { box-shadow: var(--shadow); } }

/* Topics & diagrams */
.topic { margin-bottom: 28px; }
.topic-intro { font-size: 16px; max-width: 72ch; margin: 0 0 16px; }
.topic-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px 24px; }
.topic-sections h3 { font-size: 14.5px; margin: 0 0 4px; }
.topic-sections p { margin: 0; color: var(--text-2); font-size: 14px; }
.diagram { margin: 0 0 20px; }
.diagram figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.diagram-scroll { overflow-x: auto; padding-bottom: 4px; }
.diagram svg { width: 100%; min-width: var(--min); max-width: 720px; display: block; height: auto; }
.d-box { fill: color-mix(in srgb, var(--sec, var(--accent)) 10%, var(--surface)); stroke: color-mix(in srgb, var(--sec, var(--accent)) 35%, transparent); stroke-width: 1.2; }
.d-box.layer { fill-opacity: var(--o); }
.d-label { fill: var(--text); font: 600 14px var(--font); }
.d-sub { fill: var(--text-2); font: 12px var(--font); }
.d-arrow { stroke: var(--sec, var(--accent)); stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.d-item { animation: rise .4s ease both; animation-delay: calc(var(--i) * 70ms); }

/* Terminal */
.term { background: var(--code-bg); border-radius: var(--radius); overflow: hidden; margin-bottom: 24px; max-width: 720px; box-shadow: var(--shadow); }
.term-bar { display: flex; align-items: center; gap: 6px; padding: 9px 12px; background: rgb(255 255 255 / .04); }
.term-bar > span { width: 10px; height: 10px; border-radius: 50%; background: rgb(255 255 255 / .16); }
.term-replay { margin-left: auto; border: 0; background: none; color: #a8a295; font-size: 12px; cursor: pointer; }
.term-replay:hover { color: #fff; }
.term-body { margin: 0; padding: 14px 16px 18px; color: var(--code-text); font: 13.5px/1.7 var(--mono); white-space: pre-wrap; min-height: 3.4em; }
.term-body .p { color: var(--sec, var(--accent)); filter: brightness(1.4); }
.term-body .c { color: #8d877c; }
.cursor { display: inline-block; width: 8px; height: 1.1em; vertical-align: text-bottom; background: var(--code-text); animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Beyond */
.beyond-group { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--border); }
.beyond-group summary { cursor: pointer; list-style: none; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); padding: 4px 10px; display: flex; align-items: center; gap: 6px; }
.beyond-group summary::-webkit-details-marker { display: none; }
.beyond-group summary::before { content: "›"; font-size: 15px; transition: transform .2s; }
.beyond-group[open] summary::before { transform: rotate(90deg); }
.beyond-group .nav-link { font-size: 13.5px; opacity: .85; }
.beyond-group .nav-link .nav-icon { color: var(--muted); }
.beyond-list { display: grid; gap: 10px; max-width: 820px; }
.beyond-item { display: flex; align-items: center; gap: 14px; padding: 14px 18px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); text-decoration: none; transition: box-shadow .2s, transform .2s; }
.beyond-item:hover { box-shadow: var(--shadow-hover); transform: translateX(2px); }
.beyond-item > span:nth-child(2) { display: grid; flex: 1; gap: 2px; font-size: 14px; }
.beyond-item .sec-icon { font-size: 20px; width: 26px; text-align: center; }
.beyond-results { margin-top: 40px; padding-top: 8px; border-top: 1px solid var(--border); opacity: .92; }
.area-head { font-size: 18px; margin: 16px 0 0; color: var(--text-2); }
.palette-hint { justify-content: space-between; color: var(--muted); }

/* Progress */
.prog-list { display: grid; gap: 6px; max-width: 720px; }
.prog-row { display: grid; grid-template-columns: 200px 1fr 50px; align-items: center; gap: 14px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.prog-row:hover { background: var(--surface); }
.prog-list.quiet { opacity: .8; }
.tree { display: grid; gap: 6px; max-width: 720px; }
.tree-row { display: grid; grid-template-columns: 200px repeat(3, 1fr); gap: 6px; align-items: center; }
.tree-head span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; }
.tree-row > a { color: var(--text); text-decoration: none; font-size: 14px; }
.node { text-align: center; padding: 6px; border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.node.part { background: color-mix(in srgb, var(--sec) 18%, var(--surface)); }
.node.full { background: var(--sec); color: #fff; font-weight: 600; }
.node.none { background: none; box-shadow: none; color: var(--border); }

/* Quiz */
.questions { display: grid; gap: 18px; padding-left: 20px; max-width: 720px; }
.question p { margin: 0 0 8px; }
.options { display: grid; gap: 6px; }
.option { text-align: left; padding: 10px 14px; border-radius: var(--radius-sm); border: 0; background: var(--surface); box-shadow: var(--shadow); cursor: pointer; transition: background .15s, transform .1s; }
.option:hover:not(:disabled) { background: color-mix(in srgb, var(--sec) 10%, var(--surface)); }
.option:disabled { cursor: default; }
.option.right { background: var(--tip-soft); color: var(--tip); font-weight: 600; }
.option.wrong { background: #f9dcdc; color: #9b2c2c; }
:root[data-theme="dark"] .option.wrong { background: #3a1f1f; color: #f2a5a5; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .option.wrong { background: #3a1f1f; color: #f2a5a5; } }
.option.dim { opacity: .55; }
.score { margin-top: 22px; max-width: 720px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* Mode toggle */
.mode { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; margin-left: auto; flex: none; }
.mode button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.mode button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }

/* Palette */
.palette { border: 0; padding: 0; width: min(600px, calc(100vw - 32px)); border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 24px 80px rgb(0 0 0 / .3); margin-top: 12vh; }
.palette::backdrop { background: rgb(0 0 0 / .35); }
.palette input { width: 100%; border: 0; outline: 0; padding: 16px 18px; font-size: 16px; background: none; border-bottom: 1px solid var(--border); }
.palette ul { list-style: none; margin: 0; padding: 6px; max-height: 50vh; overflow-y: auto; }
.palette li a { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-size: 14px; }
.palette li[aria-selected="true"] a { background: var(--accent-soft); }
.pal-empty { padding: 12px; }

@media (max-width: 900px) {
  .view-head h1 { font-size: 24px; }
  .prog-row, .tree-row { grid-template-columns: 120px 1fr 44px; }
  .tree-row { grid-template-columns: 110px repeat(3, 1fr); }
  .mode button { padding: 5px 8px; }
  .result-count { display: none; }
}

/* ---------- UX cleanup ---------- */
.topic-title { font-size: 20px; letter-spacing: -.01em; margin: 0 0 8px; }
.topic-intro { max-width: none; }
.path .kicker { margin: 0 0 10px; }
.path-card-wrap .card-head h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.02em; flex: 1; }
.path-card-wrap .card { padding: 26px 28px 18px; gap: 14px; }
.path-card-wrap .topic { margin: 4px 0; }
.meta:not(:has(> :not(.spacer))) { display: none; }
.more-body .meta { margin-top: 4px; }
.steps a { position: relative; }
.steps a::after {
  content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 10px); transform: translateX(-50%);
  white-space: nowrap; background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px;
  opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5;
}
.steps a:is(:hover, :focus-visible)::after { opacity: 1; }
.steps a.current::after { transform: translateX(-50%) scaleY(.714); }
.tabs { display: grid; gap: 8px; }
.tablist { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tablist [role=tab] { border: 0; background: none; padding: 6px 10px; font-size: 13px; color: var(--text-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tablist [role=tab]:hover { color: var(--text); }
.tablist [role=tab][aria-selected=true] { color: var(--text); font-weight: 600; border-bottom-color: var(--sec, var(--accent)); }
.toc { display: none; }
@media (min-width: 1280px) {
  .view.section { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 40px; max-width: 1240px; }
  .toc { display: block; position: sticky; top: 84px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; font-size: 13px; }
  .toc ul { list-style: none; margin: 8px 0 0; padding: 0 0 0 10px; border-left: 1px solid var(--border); display: grid; gap: 2px; }
  .toc a { display: block; color: var(--muted); text-decoration: none; padding: 3px 0; line-height: 1.35; }
  .toc a:hover { color: var(--text); }
  .toc .toc-sub { display: block; margin-top: 14px; }
}
