/* ============================================================================
   ELDERVALE REALM — Compendio (Wiki) · Sistema de diseño
   Escena: jugador nuevo, de noche, eligiendo qué sistema aprender.
   Superficie oscura templada (sala a la luz de antorchas), acento oro
   desaturado, display serif romana, cuerpo sans limpio, mono para comandos.
   Color en OKLCH, neutros tintados al hue cálido. Estrategia: Committed.
   ========================================================================== */

/* ---- Tokens --------------------------------------------------------------- */
:root {
  /* Superficies (warm charcoal, candlelit hall) */
  --bg:            oklch(0.165 0.012 70);
  --bg-raised:     oklch(0.205 0.013 70);
  --bg-reading:    oklch(0.185 0.011 70);
  --bg-inset:      oklch(0.225 0.014 72);
  --bg-hover:      oklch(0.255 0.016 72);

  /* Texto */
  --ink:           oklch(0.935 0.010 82);
  --ink-soft:      oklch(0.80 0.012 82);
  --ink-muted:     oklch(0.66 0.013 80);
  --ink-faint:     oklch(0.52 0.012 78);

  /* Bordes / líneas */
  --line:          oklch(0.31 0.012 74);
  --line-soft:     oklch(0.26 0.011 74);
  --line-strong:   oklch(0.40 0.014 76);

  /* Acento — oro Eldervale (chroma < 0.13, no neón) */
  --gold:          oklch(0.815 0.108 85);
  --gold-deep:     oklch(0.715 0.115 80);
  --gold-dim:      oklch(0.62 0.085 82);
  --gold-glow:     oklch(0.815 0.108 85 / 0.14);

  /* Audiencias (desaturadas, distinguibles) */
  --aud-player:    oklch(0.80 0.105 85);   /* oro    */
  --aud-staff:     oklch(0.74 0.075 215);  /* acero  */
  --aud-admin:     oklch(0.70 0.105 18);   /* granate*/
  --aud-player-bg: oklch(0.80 0.105 85 / 0.12);
  --aud-staff-bg:  oklch(0.74 0.075 215 / 0.13);
  --aud-admin-bg:  oklch(0.70 0.105 18 / 0.13);

  /* Callouts */
  --note:    oklch(0.74 0.075 215);
  --tip:     oklch(0.76 0.105 155);
  --warn:    oklch(0.80 0.110 75);
  --danger:  oklch(0.70 0.115 22);

  /* Tipografía */
  --font-display: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --font-body: "Geist", "Inter var", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", "Geist Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  /* Métrica */
  --measure: 72ch;
  --sidebar-w: 19rem;
  --toc-w: 15rem;
  --topbar-h: 4rem;
  --radius: 0.7rem;
  --radius-sm: 0.4rem;
  --radius-lg: 1.1rem;

  /* Motion (ease-out exponencial, sin rebote) */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shadow: 0 18px 40px -22px oklch(0.05 0.02 70 / 0.8);
  --shadow-soft: 0 6px 18px -12px oklch(0.05 0.02 70 / 0.7);
}

/* ---- Reset ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  font-feature-settings: "ss01", "cv05";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-wrap: break-word;
}

/* Grano sutil fijo (no en contenedores que scrollean) */
body::before {
  content: "";
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

::selection { background: var(--gold-glow); color: var(--ink); }

a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--gold-deep); }

/* ---- Layout shell --------------------------------------------------------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

/* Topbar ------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  grid-column: 1 / -1;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1.25rem;
  padding: 0 1.5rem;
  background: oklch(0.165 0.012 70 / 0.82);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 0.7rem; min-width: var(--sidebar-w); }
.brand__mark {
  width: 2.1rem; height: 2.1rem; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 0.55rem;
  background: linear-gradient(160deg, var(--bg-inset), var(--bg-raised));
  box-shadow: var(--shadow-soft);
}
.brand__mark svg { width: 1.25rem; height: 1.25rem; }
.brand__text { line-height: 1.05; }
.brand__title {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.32rem; letter-spacing: 0.01em;
  color: var(--ink);
}
.brand__sub { font-size: 0.62rem; letter-spacing: 0.32em; text-transform: uppercase; color: var(--gold-dim); }

.topbar__spacer { flex: 1; }

/* Search ------------------------------------------------------------------- */
.search {
  position: relative; flex: 1; max-width: 30rem;
}
.search__input {
  width: 100%; height: 2.5rem;
  padding: 0 2.6rem 0 2.6rem;
  background: var(--bg-inset);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink); font-family: var(--font-body); font-size: 0.9rem;
  transition: border-color 0.25s var(--ease), box-shadow 0.25s var(--ease);
}
.search__input::placeholder { color: var(--ink-faint); }
.search__input:focus { outline: none; border-color: var(--gold-dim); box-shadow: 0 0 0 3px var(--gold-glow); }
.search__icon { position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%); width: 1.05rem; height: 1.05rem; color: var(--ink-faint); pointer-events: none; }
.search__kbd { position: absolute; right: 0.7rem; top: 50%; transform: translateY(-50%); }

.search__results {
  position: absolute; top: calc(100% + 0.5rem); left: 0; right: 0;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-height: 60vh; overflow-y: auto;
  padding: 0.4rem;
  display: none;
}
.search__results.is-open { display: block; }
.search__hit {
  display: block; padding: 0.6rem 0.75rem; border-radius: var(--radius-sm);
  cursor: pointer;
}
.search__hit:hover, .search__hit.is-active { background: var(--bg-hover); }
.search__hit-title { font-weight: 600; font-size: 0.92rem; color: var(--ink); }
.search__hit-cat { font-size: 0.7rem; color: var(--ink-faint); margin-left: 0.5rem; }
.search__hit-snip { font-size: 0.78rem; color: var(--ink-muted); margin-top: 0.1rem; }
.search__hit mark { background: var(--gold-glow); color: var(--gold); border-radius: 2px; }
.search__empty { padding: 1rem 0.75rem; color: var(--ink-muted); font-size: 0.85rem; }

/* Audience switch ---------------------------------------------------------- */
.aud-switch { display: flex; gap: 0.25rem; padding: 0.22rem; background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--radius); }
.aud-switch__btn {
  appearance: none; border: 0; background: transparent;
  color: var(--ink-muted); font-family: var(--font-body); font-size: 0.78rem; font-weight: 600;
  padding: 0.32rem 0.7rem; border-radius: var(--radius-sm); cursor: pointer;
  display: flex; align-items: center; gap: 0.4rem;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.aud-switch__btn:hover { color: var(--ink); }
.aud-switch__btn.is-active { background: var(--bg-hover); color: var(--ink); }
.aud-switch__dot { width: 0.5rem; height: 0.5rem; border-radius: 50%; }
.aud-switch__btn[data-aud="player"] .aud-switch__dot { background: var(--aud-player); }
.aud-switch__btn[data-aud="staff"] .aud-switch__dot { background: var(--aud-staff); }
.aud-switch__btn[data-aud="admin"] .aud-switch__dot { background: var(--aud-admin); }

.topbar__menu-btn { display: none; }

/* Sidebar ------------------------------------------------------------------ */
.sidebar {
  position: sticky; top: var(--topbar-h);
  height: calc(100dvh - var(--topbar-h));
  overflow-y: auto;
  border-right: 1px solid var(--line-soft);
  padding: 1.6rem 0.9rem 4rem;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.nav-group { margin-bottom: 1.5rem; }
.nav-group__label {
  display: flex; align-items: center; gap: 0.55rem;
  font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-faint); font-weight: 700;
  padding: 0 0.7rem; margin-bottom: 0.5rem;
}
.nav-group__label svg { width: 0.95rem; height: 0.95rem; color: var(--gold-dim); }
.nav-link {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.7rem; border-radius: var(--radius-sm);
  color: var(--ink-soft); font-size: 0.875rem;
  position: relative;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}
.nav-link:hover { background: var(--bg-raised); color: var(--ink); }
.nav-link.is-active { background: var(--bg-inset); color: var(--ink); font-weight: 600; }
.nav-link.is-active::before {
  content: ""; position: absolute; left: -0.9rem; top: 50%; transform: translateY(-50%);
  width: 0.18rem; height: 1.1rem; border-radius: 2px; background: var(--gold);
}
.nav-link__aud { margin-left: auto; display: flex; gap: 0.2rem; }
.nav-link__aud i { width: 0.4rem; height: 0.4rem; border-radius: 50%; opacity: 0.85; }
.nav-link__aud i.player { background: var(--aud-player); }
.nav-link__aud i.staff { background: var(--aud-staff); }
.nav-link__aud i.admin { background: var(--aud-admin); }

/* Mobile-nav scrim: hidden (and out of the grid flow) on desktop */
.scrim { display: none; }

/* Content ------------------------------------------------------------------ */
.main { position: relative; z-index: 2; min-width: 0; }
.content-wrap {
  display: grid; grid-template-columns: minmax(0, 1fr) var(--toc-w);
  gap: 3rem; max-width: 70rem; margin: 0 auto;
  padding: 2.6rem 2.4rem 6rem;
}
.article { min-width: 0; animation: fade-rise 0.5s var(--ease); }
@keyframes fade-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Breadcrumb + page head */
.crumb { font-size: 0.78rem; color: var(--ink-faint); margin-bottom: 1.1rem; display: flex; gap: 0.45rem; align-items: center; }
.crumb a { color: var(--ink-muted); }
.crumb svg { width: 0.8rem; height: 0.8rem; opacity: 0.6; }

.page-head { margin-bottom: 2.2rem; padding-bottom: 1.6rem; border-bottom: 1px solid var(--line-soft); }
.page-head__auds { display: flex; gap: 0.4rem; margin-bottom: 0.9rem; }
.page-head__icon {
  width: 2.6rem; height: 2.6rem; border-radius: var(--radius);
  display: grid; place-items: center; margin-bottom: 1rem;
  background: linear-gradient(160deg, var(--bg-inset), var(--bg-raised));
  border: 1px solid var(--line); color: var(--gold);
}
.page-head__icon svg { width: 1.4rem; height: 1.4rem; }

/* ---- Typography (markdown body) ------------------------------------------ */
.article h1 {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(2.1rem, 4vw, 2.9rem); line-height: 1.04; letter-spacing: 0.005em;
  margin: 0 0 0.6rem; color: var(--ink);
}
.article .lede { font-size: 1.12rem; color: var(--ink-soft); max-width: var(--measure); margin: 0; }

.article h2 {
  font-family: var(--font-display); font-weight: 600;
  font-size: 1.72rem; line-height: 1.15; letter-spacing: 0.005em;
  margin: 2.8rem 0 0.9rem; padding-top: 0.4rem; color: var(--ink);
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
.article h3 {
  font-weight: 650; font-size: 1.16rem; line-height: 1.3;
  margin: 1.9rem 0 0.6rem; color: var(--ink);
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
.article h4 { font-weight: 650; font-size: 0.96rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gold-dim); margin: 1.5rem 0 0.5rem; }

.article p { max-width: var(--measure); margin: 0 0 1.05rem; color: var(--ink-soft); }
.article strong { color: var(--ink); font-weight: 650; }
.article em { color: var(--ink); }

.article ul, .article ol { max-width: var(--measure); margin: 0 0 1.15rem; padding-left: 1.3rem; color: var(--ink-soft); }
.article li { margin: 0.35rem 0; }
.article li::marker { color: var(--gold-dim); }

.article a.xlink { border-bottom: 1px solid var(--line-strong); transition: border-color 0.2s var(--ease); }
.article a.xlink:hover { border-color: var(--gold); }

.article hr { border: 0; border-top: 1px solid var(--line-soft); margin: 2.4rem 0; }

.article blockquote {
  margin: 0 0 1.2rem; padding: 0.2rem 0 0.2rem 1.1rem;
  border-left: 2px solid var(--line-strong);
  color: var(--ink-muted); font-style: italic; max-width: var(--measure);
}

/* Inline code + key caps */
.article :not(pre) > code {
  font-family: var(--font-mono); font-size: 0.86em;
  background: var(--bg-inset); border: 1px solid var(--line-soft);
  padding: 0.1em 0.4em; border-radius: var(--radius-sm); color: var(--gold);
}
kbd, .kbd {
  font-family: var(--font-mono); font-size: 0.78em; font-weight: 600;
  display: inline-flex; align-items: center; min-width: 1.5em; justify-content: center;
  padding: 0.12em 0.45em;
  background: linear-gradient(180deg, var(--bg-inset), var(--bg-raised));
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm); color: var(--ink);
  line-height: 1.4;
}

/* Code blocks */
.article pre {
  position: relative;
  margin: 0 0 1.4rem; padding: 1rem 1.1rem;
  background: var(--bg-reading);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow-x: auto; font-size: 0.85rem; line-height: 1.6;
  scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent;
}
.article pre code { font-family: var(--font-mono); color: var(--ink); background: none; border: 0; padding: 0; }
.code-copy {
  position: absolute; top: 0.55rem; right: 0.55rem;
  appearance: none; border: 1px solid var(--line); background: var(--bg-inset);
  color: var(--ink-muted); border-radius: var(--radius-sm);
  width: 1.9rem; height: 1.9rem; display: grid; place-items: center; cursor: pointer;
  opacity: 0; transition: opacity 0.2s var(--ease), color 0.2s var(--ease), transform 0.1s var(--ease);
}
.article pre:hover .code-copy { opacity: 1; }
.code-copy:hover { color: var(--gold); }
.code-copy:active { transform: scale(0.92); }
.code-copy svg { width: 0.95rem; height: 0.95rem; }
.code-copy.is-done { color: var(--tip); }

/* Tables */
.article .table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--line); border-radius: var(--radius); }
.article table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.article thead th {
  text-align: left; font-weight: 650; color: var(--ink); white-space: nowrap;
  padding: 0.7rem 0.95rem; background: var(--bg-raised);
  border-bottom: 1px solid var(--line); font-size: 0.78rem; letter-spacing: 0.03em; text-transform: uppercase;
}
.article tbody td { padding: 0.65rem 0.95rem; border-bottom: 1px solid var(--line-soft); color: var(--ink-soft); vertical-align: top; }
.article tbody tr:last-child td { border-bottom: 0; }
.article tbody tr:hover td { background: var(--bg-raised); }
.article table code { white-space: nowrap; }

/* ---- Custom components (markdown extensions) ----------------------------- */

/* Audience badge */
.aud-badge {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.72rem; font-weight: 650; letter-spacing: 0.02em;
  padding: 0.25rem 0.6rem; border-radius: 100px; border: 1px solid;
}
.aud-badge .dot { width: 0.45rem; height: 0.45rem; border-radius: 50%; }
.aud-badge.player { color: var(--aud-player); border-color: oklch(0.80 0.105 85 / 0.4); background: var(--aud-player-bg); }
.aud-badge.player .dot { background: var(--aud-player); }
.aud-badge.staff { color: var(--aud-staff); border-color: oklch(0.74 0.075 215 / 0.4); background: var(--aud-staff-bg); }
.aud-badge.staff .dot { background: var(--aud-staff); }
.aud-badge.admin { color: var(--aud-admin); border-color: oklch(0.70 0.105 18 / 0.4); background: var(--aud-admin-bg); }
.aud-badge.admin .dot { background: var(--aud-admin); }

/* Callouts:  > [!note] / [!tip] / [!warning] / [!danger] / [!key] */
.callout {
  display: grid; grid-template-columns: auto 1fr; gap: 0.85rem;
  margin: 0 0 1.4rem; padding: 0.95rem 1.1rem;
  background: var(--bg-raised); border: 1px solid var(--line);
  border-radius: var(--radius); max-width: var(--measure);
}
.callout__icon { width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; flex: none; }
.callout__body { min-width: 0; }
.callout__body > :last-child { margin-bottom: 0; }
.callout__title { font-weight: 650; color: var(--ink); margin-bottom: 0.2rem; font-size: 0.92rem; }
.callout.note   { border-color: oklch(0.74 0.075 215 / 0.35); } .callout.note   .callout__icon { color: var(--note); }
.callout.tip    { border-color: oklch(0.76 0.105 155 / 0.32); } .callout.tip    .callout__icon { color: var(--tip); }
.callout.warning{ border-color: oklch(0.80 0.110 75 / 0.35); }  .callout.warning .callout__icon { color: var(--warn); }
.callout.danger { border-color: oklch(0.70 0.115 22 / 0.4); }   .callout.danger .callout__icon { color: var(--danger); }
.callout.key    { border-color: var(--line-strong); }           .callout.key    .callout__icon { color: var(--gold); }

/* Steps list:  ::: steps ... ::: (ordered list inside) */
.steps { counter-reset: step; list-style: none; padding: 0; margin: 0 0 1.5rem; max-width: var(--measure); }
.steps > li {
  position: relative; counter-increment: step;
  padding: 0 0 1.3rem 3rem; margin: 0;
}
.steps > li::before {
  content: counter(step);
  position: absolute; left: 0; top: -0.1rem;
  width: 1.9rem; height: 1.9rem; border-radius: 50%;
  display: grid; place-items: center;
  font-family: var(--font-mono); font-size: 0.85rem; font-weight: 600;
  color: var(--gold); background: var(--bg-inset); border: 1px solid var(--line-strong);
}
.steps > li::after {
  content: ""; position: absolute; left: 0.95rem; top: 2rem; bottom: 0.3rem;
  width: 1px; background: var(--line);
}
.steps > li:last-child { padding-bottom: 0; }
.steps > li:last-child::after { display: none; }
.steps > li > strong:first-child { display: block; color: var(--ink); margin-bottom: 0.15rem; }

/* Quick-facts box at top of a system page:  ::: facts ... ::: */
.facts {
  margin: 0 0 2rem; padding: 1.1rem 1.25rem;
  background: var(--bg-reading); border: 1px solid var(--line);
  border-radius: var(--radius-lg); max-width: var(--measure);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: 1rem 1.4rem;
}
.facts__item { display: flex; flex-direction: column; gap: 0.15rem; }
.facts__k { font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.facts__v { font-size: 0.92rem; color: var(--ink); }
.facts__v code { font-size: 0.85em; }

/* Command chip:  inline command with copy.  rendered from `cmd:/foo` token */
.cmd {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--font-mono); font-size: 0.84em;
  background: var(--bg-inset); border: 1px solid var(--line);
  padding: 0.12em 0.55em; border-radius: var(--radius-sm); color: var(--gold);
  cursor: pointer; transition: border-color 0.18s var(--ease);
}
.cmd:hover { border-color: var(--gold-dim); }
.cmd:active { transform: translateY(1px); }
.cmd svg { width: 0.8rem; height: 0.8rem; opacity: 0.5; }

/* Related pages grid (no identical-card-grid: 2-col, leading marker) */
.related { margin-top: 3rem; padding-top: 1.6rem; border-top: 1px solid var(--line-soft); }
.related__h { font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; margin-bottom: 0.9rem; }
.related__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.7rem; }
.related__card {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.85rem 1rem;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-raised);
  transition: border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.related__card:hover { border-color: var(--gold-dim); transform: translateY(-2px); }
.related__card svg { width: 1.1rem; height: 1.1rem; color: var(--gold-dim); flex: none; }
.related__card-t { color: var(--ink); font-weight: 600; font-size: 0.9rem; }
.related__card-d { color: var(--ink-faint); font-size: 0.76rem; }

/* Page footer nav (prev / next) */
.page-nav { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 2.5rem; }
.page-nav a { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.9rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); transition: border-color 0.2s var(--ease); }
.page-nav a:hover { border-color: var(--gold-dim); }
.page-nav a.next { text-align: right; }
.page-nav__dir { font-size: 0.72rem; color: var(--ink-faint); }
.page-nav__t { color: var(--ink); font-weight: 600; }

/* ---- ToC ----------------------------------------------------------------- */
.toc { position: sticky; top: calc(var(--topbar-h) + 2.6rem); align-self: start; max-height: calc(100dvh - var(--topbar-h) - 4rem); overflow-y: auto; }
.toc__h { font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; margin-bottom: 0.8rem; }
.toc__list { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line-soft); }
.toc__link {
  display: block; padding: 0.3rem 0 0.3rem 0.9rem; margin-left: -1px;
  border-left: 1px solid transparent;
  font-size: 0.82rem; color: var(--ink-muted);
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}
.toc__link:hover { color: var(--ink); }
.toc__link.lvl-3 { padding-left: 1.7rem; font-size: 0.78rem; }
.toc__link.is-active { color: var(--gold); border-left-color: var(--gold); }

/* ---- Landing (home) ------------------------------------------------------- */
.home { max-width: 70rem; margin: 0 auto; padding: 0 2.4rem 6rem; }
.hero {
  display: grid; grid-template-columns: 1.4fr 1fr; gap: 3rem; align-items: center;
  padding: 4rem 0 3.4rem; border-bottom: 1px solid var(--line-soft);
}
.hero__eyebrow { font-size: 0.7rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--gold-dim); font-weight: 700; margin-bottom: 1rem; }
.hero__title { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.6rem, 5.5vw, 4.2rem); line-height: 0.98; letter-spacing: 0.01em; margin: 0 0 1.1rem; }
.hero__title em { color: var(--gold); font-style: normal; }
.hero__lede { font-size: 1.15rem; color: var(--ink-soft); max-width: 44ch; margin: 0 0 1.8rem; }
.hero__cta { display: flex; gap: 0.8rem; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 600; font-size: 0.92rem; padding: 0.7rem 1.2rem; border-radius: var(--radius);
  border: 1px solid var(--line-strong); color: var(--ink); background: var(--bg-raised);
  cursor: pointer; transition: transform 0.12s var(--ease), border-color 0.2s var(--ease), background 0.2s var(--ease);
}
.btn:hover { border-color: var(--gold-dim); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--gold); color: oklch(0.2 0.02 75); border-color: var(--gold); }
.btn--primary:hover { background: var(--gold-deep); color: oklch(0.18 0.02 75); }
.btn svg { width: 1.05rem; height: 1.05rem; }

.hero__aside { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--bg-reading); padding: 1.4rem; box-shadow: var(--shadow); }
.hero__aside h3 { margin: 0 0 0.9rem; font-size: 0.7rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.hero__path { display: flex; gap: 0.7rem; padding: 0.6rem 0; border-bottom: 1px solid var(--line-soft); }
.hero__path:last-child { border-bottom: 0; }
.hero__path-n { font-family: var(--font-mono); color: var(--gold-dim); font-size: 0.8rem; }
.hero__path-t { color: var(--ink); font-size: 0.9rem; }
.hero__path-d { color: var(--ink-faint); font-size: 0.78rem; }

.home__section { margin-top: 3.4rem; }
.home__section-h { display: flex; align-items: baseline; gap: 0.8rem; margin-bottom: 1.4rem; }
.home__section-h h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.7rem; margin: 0; }
.home__section-h span { font-size: 0.8rem; color: var(--ink-faint); }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); gap: 0.9rem; }
.cat-card {
  display: block; padding: 1.2rem 1.3rem; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-raised); transition: border-color 0.22s var(--ease), transform 0.22s var(--ease);
}
.cat-card:hover { border-color: var(--gold-dim); transform: translateY(-3px); }
.cat-card__top { display: flex; align-items: center; gap: 0.65rem; margin-bottom: 0.7rem; }
.cat-card__icon { width: 2.1rem; height: 2.1rem; border-radius: 0.5rem; display: grid; place-items: center; background: var(--bg-inset); border: 1px solid var(--line); color: var(--gold); }
.cat-card__icon svg { width: 1.15rem; height: 1.15rem; }
.cat-card__title { font-weight: 650; color: var(--ink); font-size: 1.02rem; }
.cat-card__desc { color: var(--ink-muted); font-size: 0.84rem; margin-bottom: 0.85rem; }
.cat-card__list { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.cat-card__chip { font-size: 0.74rem; color: var(--ink-soft); background: var(--bg-inset); border: 1px solid var(--line-soft); padding: 0.15rem 0.5rem; border-radius: 100px; }
.cat-card__more { font-size: 0.74rem; color: var(--gold-dim); padding: 0.15rem 0.3rem; }

/* ---- Misc utilities ------------------------------------------------------- */
.is-hidden { display: none !important; }
.loading { padding: 3rem 0; color: var(--ink-muted); }
.skeleton { background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-inset) 50%, var(--bg-raised) 75%); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--radius-sm); }
@keyframes shimmer { to { background-position: -200% 0; } }
.skeleton.line { height: 0.9rem; margin-bottom: 0.7rem; }
.skeleton.line.w-60 { width: 60%; } .skeleton.line.w-80 { width: 80%; } .skeleton.line.w-40 { width: 40%; }
.skeleton.title { height: 2.4rem; width: 50%; margin-bottom: 1.4rem; }

.error-state { padding: 3rem 0; max-width: var(--measure); }
.error-state h2 { font-family: var(--font-display); }

/* Scrollbars (webkit) */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 100px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

/* ---- Responsive ----------------------------------------------------------- */
@media (max-width: 1180px) {
  .content-wrap { grid-template-columns: minmax(0, 1fr); }
  .toc { display: none; }
}
@media (max-width: 920px) {
  :root { --sidebar-w: 17rem; }
  .hero { grid-template-columns: 1fr; gap: 2rem; }
  .hero__aside { order: -1; }
}
@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .brand { min-width: auto; }
  .brand__sub { display: none; }
  .search { max-width: none; }
  .aud-switch__btn span { display: none; }
  .topbar__menu-btn {
    display: grid; place-items: center; width: 2.4rem; height: 2.4rem; flex: none;
    background: var(--bg-inset); border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); cursor: pointer;
  }
  .topbar__menu-btn svg { width: 1.2rem; height: 1.2rem; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: min(82vw, 21rem);
    background: var(--bg); z-index: 35; transform: translateX(-105%);
    transition: transform 0.3s var(--ease); box-shadow: var(--shadow);
  }
  .sidebar.is-open { transform: none; }
  .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0; background: oklch(0.1 0.01 70 / 0.55); z-index: 34; opacity: 0; pointer-events: none; transition: opacity 0.3s var(--ease); }
  .scrim.is-open { opacity: 1; pointer-events: auto; }
  .content-wrap, .home { padding-left: 1.25rem; padding-right: 1.25rem; }
}
@media (max-width: 540px) {
  .search__kbd { display: none; }
  .cat-grid { grid-template-columns: 1fr; }
  .page-nav { grid-template-columns: 1fr; }
}

/* ── Screenshots (::: shot) ─────────────────────────────────────────────── */
.shot { margin: 1.8rem 0; }
.shot__img { display: none; width: 100%; height: auto; border-radius: var(--radius);
  border: 1px solid var(--line); box-shadow: var(--shadow-soft); }
.shot__cap { display: none; margin-top: .55rem; font-size: .86rem; color: var(--ink-muted);
  font-style: italic; text-align: center; }
.shot--has .shot__img { display: block; }
.shot--has .shot__cap { display: block; }
.shot--has .shot__ph { display: none; }

.shot__ph { display: flex; gap: 1rem; align-items: flex-start;
  padding: 1.4rem 1.5rem; border-radius: var(--radius);
  border: 1.5px dashed var(--gold-dim); background: var(--gold-glow); }
.shot__cam { flex: none; width: 2.2rem; height: 2.2rem; color: var(--gold);
  opacity: .9; margin-top: .1rem; }
.shot__ph-body { min-width: 0; }
.shot__ph-label { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--gold-deep); margin-bottom: .3rem; }
.shot__ph-desc { font-size: .96rem; color: var(--ink-soft); line-height: 1.5; }
.shot__ph-id { display: inline-block; margin-top: .55rem; font-family: var(--font-mono);
  font-size: .72rem; color: var(--ink-faint); background: var(--bg-inset);
  border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: .1rem .45rem; }
