:root {
  color-scheme: light dark;
  --bg: #fbfaf7;
  --fg: #1d1d1b;
  --muted: #5f5e59;
  --line: #e2dfd6;
  --card: #ffffff;
  --accent: #b5471e;
  --accent-soft: #f6e6dd;
  --tech: #1f5f8b;
  --tech-soft: #e1eef7;
  --pre: #4c7a34;
  --pre-soft: #e6f1df;
  --code-bg: #f1efe8;
  --max: 46rem;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  font-size: 1.0625rem;
  line-height: 1.6;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171716;
    --fg: #ece9e1;
    --muted: #a5a29a;
    --line: #34332f;
    --card: #1f1f1d;
    --accent: #e6864f;
    --accent-soft: #3a2519;
    --tech: #7fb6dc;
    --tech-soft: #18303f;
    --pre: #9ccc7a;
    --pre-soft: #1f3117;
    --code-bg: #24241f;
  }
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--fg); background: var(--bg); padding: 0 1rem; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

.site-header { max-width: calc(var(--max) + 20rem); margin: 0 auto; padding: 1rem 0 0; }
.crumbs { font-family: system-ui, sans-serif; font-size: 0.85rem; color: var(--muted); }
.crumbs .sep { margin: 0 0.5em; opacity: 0.6; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }

.layout { max-width: calc(var(--max) + 20rem); margin: 0 auto; display: grid; grid-template-columns: minmax(0, var(--max)) 17rem; gap: 3rem; padding: 1.5rem 0 3rem; }
main { min-width: 0; }
aside { font-family: system-ui, sans-serif; font-size: 0.9rem; }
aside:empty { display: none; }
@media (max-width: 64rem) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 2rem; }
  aside { border-top: 1px solid var(--line); padding-top: 1.5rem; }
}

h1 { font-size: 2.2rem; line-height: 1.15; margin: 0.2em 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: 1.45rem; margin: 2em 0 0.6em; line-height: 1.25; }
h3 { font-size: 1.15rem; margin: 1.6em 0 0.5em; }
h4 { font-size: 1rem; margin: 1.4em 0 0.4em; }
p, ul, ol { margin: 0 0 1em; }
li { margin: 0.25em 0; }
.lede { font-size: 1.2rem; color: var(--muted); line-height: 1.5; }
.kind { font-family: system-ui, sans-serif; font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0; }
.page.technique header .kind { color: var(--tech); }
.page.prerequisite header .kind { color: var(--pre); }

blockquote { margin: 1.2em 0; padding: 0.6em 1em; border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 6px 6px 0; }
blockquote p:last-child { margin-bottom: 0; }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }

code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace; font-size: 0.9em; }
code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 4px; }
pre { background: var(--code-bg); padding: 0.9em 1.1em; border-radius: 8px; overflow-x: auto; line-height: 1.45; }
pre code { background: none; padding: 0; }

table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: 0.95em; display: block; overflow-x: auto; }
th, td { text-align: left; padding: 0.45em 0.7em; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: system-ui, sans-serif; font-size: 0.8rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }

.katex-display { overflow-x: auto; overflow-y: hidden; padding: 0.3em 0; }

/* cards */
ul.cards, ul.clusters { list-style: none; padding: 0; margin: 0.6em 0 1.2em; display: grid; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); gap: 0.7rem; }
.card a, .clusters a { display: flex; flex-direction: column; gap: 0.25rem; height: 100%; padding: 0.8rem 0.95rem; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--fg); font-family: system-ui, sans-serif; }
.card a:hover, .clusters a:hover { border-color: var(--accent); }
.card .kind { font-size: 0.68rem; }
.card.kind-technique .kind { color: var(--tech); }
.card.kind-prerequisite .kind { color: var(--pre); }
.card strong, .clusters strong { font-size: 1rem; line-height: 1.3; }
.card .summary, .clusters .summary { font-size: 0.86rem; color: var(--muted); line-height: 1.4; }
.clusters .count { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
.clusters { grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); }

.before, .after { margin: 1.8em 0; padding: 1em 1.2em; border: 1px dashed var(--line); border-radius: 10px; }
.before h2, .after h2 { margin: 0 0 0.4em; font-size: 1.1rem; font-family: system-ui, sans-serif; }
.before p, .after p { margin-bottom: 0.4em; color: var(--muted); font-size: 0.95em; }
.back { margin-top: 2.5em; font-family: system-ui, sans-serif; font-size: 0.9rem; }

/* learning path */
.learning-path { margin-top: 3em; }
.level { display: grid; grid-template-columns: 6.5rem 1fr; gap: 0.8rem; align-items: start; margin: 0.4em 0; padding-top: 0.6em; border-top: 1px solid var(--line); }
.level-label { font-family: system-ui, sans-serif; font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); padding-top: 0.9rem; }
.level ul.cards { margin: 0; }
@media (max-width: 40rem) { .level { grid-template-columns: 1fr; } .level-label { padding-top: 0; } }

/* sidebar */
.cluster-nav h3 { margin: 0 0 0.8em; font-size: 1rem; }
.cluster-nav h3 a { color: var(--fg); text-decoration: none; }
.cluster-nav h4 { margin: 1.2em 0 0.4em; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.cluster-nav ul { list-style: none; padding: 0; margin: 0; }
.cluster-nav li { margin: 0.15em 0; }
.cluster-nav a { color: var(--fg); text-decoration: none; }
.cluster-nav a:hover { color: var(--accent); }

/* demos */
.demo { margin: 1.5em 0; padding: 1em; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-family: system-ui, sans-serif; font-size: 0.9rem; }
.demo canvas { display: block; width: 100%; max-width: 100%; height: auto; image-rendering: pixelated; border-radius: 6px; background: #000; }
.demo .controls { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; align-items: center; margin: 0.7em 0 0; }
.demo label { display: inline-flex; gap: 0.4em; align-items: center; }
.demo button { font: inherit; padding: 0.35em 0.9em; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); cursor: pointer; }
.demo button:hover { border-color: var(--accent); }
.demo .readout { color: var(--muted); }
.demo .seq { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 0.6em; }
.demo .seq span { width: 1.6em; height: 1.6em; border-radius: 4px; display: inline-grid; place-items: center; font-size: 0.75rem; color: #fff; }
.demo table { display: table; width: auto; margin: 0.6em 0 0; }
.demo td input { width: 4em; font: inherit; }

.site-footer { max-width: calc(var(--max) + 20rem); margin: 0 auto; padding: 1.2rem 0 calc(1.2rem + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 1.2rem; font-family: system-ui, sans-serif; font-size: 0.8rem; color: var(--muted); }
.site-footer a { color: var(--muted); }
