:root {
  --bg: #f7f1e6;
  --panel: #fffaf1;
  --ink: #2b2118;
  --muted: #7a6a58;
  --line: #e4d7c2;
  --accent: #b5532c;
  --accent-soft: #f3dccd;
  --chip: #efe4d2;
  --sel: #2b2118;
  --sel-ink: #fffaf1;
  --plate: #ece2d0;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1713;
    --panel: #231e19;
    --ink: #f1e7d8;
    --muted: #a8977f;
    --line: #3a3129;
    --accent: #e48a5c;
    --accent-soft: #4a2e20;
    --chip: #322a22;
    --sel: #f1e7d8;
    --sel-ink: #1b1713;
    --plate: #2c251f;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.shell { display: grid; grid-template-columns: 300px 1fr; min-height: 100%; }

/* ---------------------------------------------------------------- sidebar */
.sidebar {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 20px 16px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; font: 600 24px/1 var(--serif); letter-spacing: -0.01em;
}
.brand svg { width: 30px; height: 30px; }
.search input {
  width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  font: inherit;
}
.search input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  border: 0; cursor: pointer; font: 12px/1 var(--sans);
  padding: 5px 9px; border-radius: 999px; background: var(--chip); color: var(--muted);
}
.tag:hover { color: var(--ink); }
.tag[aria-pressed="true"] { background: var(--accent); color: #fff; }

.list { display: flex; flex-direction: column; gap: 4px; }
.item {
  display: block; text-decoration: none; padding: 10px 12px; border-radius: 10px;
}
.item:hover { background: var(--chip); }
.item[aria-current="page"] { background: var(--sel); color: var(--sel-ink); }
.item-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.item-title { font: 600 16px/1.25 var(--serif); }
.item-ver { font: 11px var(--mono); opacity: 0.7; }
.item-tags { font-size: 12px; opacity: 0.7; margin-top: 2px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 12px; }

/* ---------------------------------------------------------------- detail */
.detail { padding: 36px 44px 60px; max-width: 1100px; outline: none; }
.detail h1 { font: 600 40px/1.1 var(--serif); margin: 0; letter-spacing: -0.015em; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; color: var(--muted); font-size: 13px; }
.slug { font-family: var(--mono); background: var(--chip); padding: 3px 8px; border-radius: 6px; }
.meta .tag { cursor: pointer; }

.stage {
  display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 28px; margin-top: 28px;
  align-items: start;
}
.plate {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 14px 8px; position: relative;
}
.plate-bar { display: flex; justify-content: flex-end; gap: 6px; }
.toggle {
  font: 12px var(--sans); cursor: pointer; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); padding: 5px 10px; border-radius: 999px;
}
.toggle[aria-pressed="true"] { background: var(--sel); color: var(--sel-ink); border-color: var(--sel); }
.diagram { width: 100%; height: auto; display: block; overflow: visible; }

.layer, .label, .shadow { transition: transform 420ms cubic-bezier(.3,.7,.2,1), opacity 160ms; }
.leader { transition: d 420ms cubic-bezier(.3,.7,.2,1); }
.label text { font: 16px var(--sans); fill: var(--ink); }
.label .kind { font-size: 11px; fill: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; }
.leader { fill: none; stroke: var(--muted); stroke-width: 1; opacity: 0.55; }
.shadow { fill: var(--plate); }
.diagram.hovering .layer:not(.hot),
.diagram.hovering .label:not(.hot) { opacity: 0.35; }
.label.hot text { font-weight: 600; }
.leader.hot { opacity: 1; stroke: var(--accent); }

/* ---------------------------------------------------------------- side column */
.side h2 {
  font: 600 12px var(--sans); text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin: 0 0 8px;
}
.side section + section { margin-top: 26px; }
.recipe { margin: 0; padding: 0; list-style: none; counter-reset: n; }
.recipe li {
  display: flex; align-items: center; gap: 10px; padding: 5px 6px; border-radius: 8px;
  counter-increment: n; cursor: default;
}
.recipe li::before { content: counter(n); font: 11px var(--mono); color: var(--muted); width: 16px; text-align: right; }
.recipe li.hot { background: var(--accent-soft); }
.swatch { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }

.versions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.version {
  display: block; text-decoration: none; padding: 9px 11px; border-radius: 10px;
  border: 1px solid var(--line);
}
.version:hover { border-color: var(--muted); }
.version[aria-current="page"] { border-color: var(--accent); background: var(--accent-soft); }
.version-head { display: flex; justify-content: space-between; font-size: 13px; }
.version-head b { font-family: var(--mono); }
.version-head span { color: var(--muted); }
.version p { margin: 3px 0 0; font-size: 13px; color: var(--muted); }
.diff { margin-top: 4px; font: 12px var(--mono); }
.diff .add { color: #3f8a3a; }
.diff .del { color: #c2361f; }
.notice {
  margin-top: 14px; font-size: 13px; padding: 8px 12px; border-radius: 10px;
  background: var(--accent-soft);
}
.notice a { color: var(--accent); }

.welcome { max-width: 520px; margin-top: 12vh; }
.welcome p { color: var(--muted); font-size: 17px; }

/* ---------------------------------------------------------------- narrow */
@media (max-width: 1180px) {
  .stage { grid-template-columns: 1fr; }
  .side { display: grid; grid-template-columns: 1fr 1fr; gap: 26px; }
  .side section + section { margin-top: 0; }
}
@media (max-width: 560px) {
  .side { grid-template-columns: 1fr; }
}
/* Breadcrumbs are a phone-only affordance; on wider screens the list is always visible. */
.crumbs { display: none; }

/* Phones: the list and the detail are two separate pages. */
@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; border-right: 0; padding: 18px 16px 32px; }
  .route-detail .sidebar { display: none; }
  .route-home .detail { display: none; }

  .tag-cloud { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 2px; scrollbar-width: none; }
  .tag-cloud::-webkit-scrollbar { display: none; }
  .tag { flex: none; padding: 7px 11px; font-size: 13px; }

  .list { gap: 0; margin: 0 -16px; border-top: 1px solid var(--line); }
  .item { border-radius: 0; padding: 14px 16px; border-bottom: 1px solid var(--line); position: relative; padding-right: 36px; }
  .item::after { content: '›'; position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 22px; color: var(--muted); }
  .item[aria-current="page"] { background: none; color: inherit; }
  .item-title { font-size: 18px; }

  .crumbs {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    font-size: 14px; color: var(--muted); margin-bottom: 14px;
  }
  .crumbs a { color: var(--accent); text-decoration: none; padding: 6px 0; }
  .crumbs a:first-child::before { content: '‹ '; }
  .crumbs [aria-current] { color: var(--ink); }
  .crumbs .sep { opacity: 0.6; }

  .detail { padding: 14px 16px 48px; }
  .detail h1 { font-size: 30px; }
  .welcome { margin-top: 2vh; }
}
@media (prefers-reduced-motion: reduce) {
  .layer, .label, .leader { transition: none; }
}
