:root {
  --bg: #fbfaf7;
  --panel: #f3f1ea;
  --ink: #1d2320;
  --muted: #5d6762;
  --line: #e0ddd3;
  --accent: #176b5b;
  --accent-soft: #dcefe9;
  --code-bg: #f0eee6;
  --warn: #8a5a00;
  --radius: 10px;
  --measure: 72ch;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614;
    --panel: #1a201d;
    --ink: #e4e8e5;
    --muted: #9aa6a0;
    --line: #2b3430;
    --accent: #5ec4a9;
    --accent-soft: #1d3530;
    --code-bg: #1b221f;
    --warn: #e0b45c;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614;
  --panel: #1a201d;
  --ink: #e4e8e5;
  --muted: #9aa6a0;
  --line: #2b3430;
  --accent: #5ec4a9;
  --accent-soft: #1d3530;
  --code-bg: #1b221f;
  --warn: #e0b45c;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.65 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Roboto, sans-serif;
}
a { color: var(--accent); text-underline-offset: 2px; }
code, pre { font-family: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace; font-size: 0.88em; }
:not(pre) > code { background: var(--code-bg); padding: 0.1em 0.35em; border-radius: 5px; }
pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.45;
}

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.01em; color: var(--ink); text-decoration: none; display: flex; align-items: center; gap: 9px; }
.mark { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); display: inline-block;
  mask: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><rect width='32' height='32' rx='7'/></svg>"); }
.links { display: flex; align-items: center; gap: 16px; }
.links a { color: var(--muted); text-decoration: none; font-size: 15px; }
.links a:hover { color: var(--accent); }
.theme { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 999px; width: 32px; height: 32px; cursor: pointer; font-size: 16px; }

/* Frame */
.frame { display: grid; grid-template-columns: 290px minmax(0, 1fr); gap: 40px; max-width: 1200px; margin: 0 auto; padding: 28px 20px 40px; }
main { min-width: 0; max-width: var(--measure); }
.side { position: sticky; top: 72px; align-self: start; max-height: calc(100vh - 90px); overflow-y: auto; font-size: 14.5px; }
.side ol { list-style: none; padding: 0; margin: 6px 0 0; }
.side li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0 3px 12px; border-left: 2px solid var(--line); }
.side li a { color: var(--muted); text-decoration: none; }
.side li span { color: var(--muted); opacity: 0.7; font-size: 12.5px; }
.side li.done a { color: var(--ink); opacity: 0.7; }
.side li.here { border-left-color: var(--accent); }
.side li.here a { color: var(--accent); font-weight: 650; }
.side li[aria-current="page"] a { color: var(--accent); font-weight: 650; }
.journey { margin-bottom: 22px; }
.journey h2 { font-size: 15px; margin: 0; }
.journey h2 a { color: var(--ink); text-decoration: none; }
.journey.other { display: none; }
.all summary { cursor: pointer; color: var(--muted); font-size: 13.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.meta { color: var(--muted); font-size: 13.5px; margin: 2px 0 6px; }

/* Article */
article h1 { font-size: clamp(28px, 4.2vw, 40px); line-height: 1.15; letter-spacing: -0.015em; margin: 0 0 10px; }
article h2 { font-size: 24px; margin: 2.1em 0 0.5em; letter-spacing: -0.01em; }
article h3 { font-size: 19px; margin: 1.7em 0 0.4em; }
article h1 + p > em:only-child { color: var(--muted); }
.anchor { margin-left: -1.1em; padding-right: 0.3em; color: var(--line); text-decoration: none; font-weight: 400; }
h2:hover .anchor, h3:hover .anchor { color: var(--accent); }
blockquote { margin: 1.2em 0; padding: 10px 16px; background: var(--accent-soft); border-left: 3px solid var(--accent); border-radius: 0 var(--radius) var(--radius) 0; }
blockquote p { margin: 0.4em 0; }
.table { overflow-x: auto; margin: 1.1em 0; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--panel); text-align: left; font-weight: 650; }
tr:last-child td { border-bottom: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip { font-size: 12.5px; padding: 2px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); text-decoration: none; }
.chip.current { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 40px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
.pager .which { grid-column: 1 / -1; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }
.pager a { display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--panel); }
.pager a:hover { border-color: var(--accent); }
.pager a small { display: block; color: var(--muted); font-size: 12.5px; }
.pager .next { text-align: right; }
.pager.other { display: none; }

/* Landing */
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.card { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 16px 18px; }
.card h3 { margin: 0 0 4px; font-size: 18px; }
.card h3 a { color: var(--ink); text-decoration: none; }
.card:hover { border-color: var(--accent); }
.card p { margin: 4px 0; font-size: 15px; }
.card ol { list-style: none; padding-left: 0; margin: 8px 0; font-size: 14.5px; }
.card ol span { color: var(--muted); font-size: 12.5px; }
.landing .more { color: var(--muted); }

footer { max-width: 1200px; margin: 0 auto; padding: 20px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }

@media (max-width: 900px) {
  .frame { grid-template-columns: 1fr; gap: 0; padding: 20px 16px 32px; }
  .side { position: static; max-height: none; order: 2; margin-top: 32px; border-top: 1px solid var(--line); padding-top: 16px; }
  main { order: 1; }
  .top { padding: 10px 16px; }
  .links { gap: 12px; }
  .anchor { display: none; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}
