/* Layout: terminal-style sidebar (project tree) + article + sticky "on this page".
   Tokens are the portfolio's own: :root = "cafe" (default), [data-theme="moon"] = dark,
   set on <html> like css/style.css. */
:root {
  --bg-base: #f8f4ed;
  --bg-sidebar: #f0e9df;
  --bg-main: #faf7f2;
  --bg-card: #ffffff;
  --bg-muted: #e8dfd3;
  --text-primary: #2a2118;
  --text-secondary: #524638;
  --text-muted: #7d6e5c;
  --accent-brown: #6b4f2d;
  --accent-caramel: #b07d4a;
  --accent-cream: #d4c4a8;
  --accent-terracotta: #a85d42;
  --accent-green: #5a7a52;
  --border-light: rgba(107, 79, 45, 0.15);
  --border-medium: rgba(107, 79, 45, 0.25);
  --border-accent: rgba(176, 125, 74, 0.5);
  --shadow-sm: 0 1px 3px rgba(42, 33, 24, 0.08);
  --theme-glow: 0 2px 8px rgba(176, 125, 74, 0.3);
  /* Theme switch (.theme-dock); moon values are lighter so the pill stands out on the dark page */
  --dock-bg: var(--bg-card);
  --dock-border: var(--border-light);
  --toggle-track: var(--bg-muted);
  --toggle-border: var(--border-medium);
  --toggle-icon: var(--text-muted);
  --dock-label: var(--text-muted);
  --bar-bg: rgba(250, 246, 241, 0.9);
  --code-bg: #2a2118;
  --code-fg: #f3e9d8;
  --code-muted: #a89a85;
  --syn-keyword: #e5a46b;
  --syn-string: #b5c99a;
  --syn-number: #e8957a;
  --syn-func: #f2cc8f;
  --syn-var: #e3b8c8;
  --syn-attr: #9fc5c0;
  --syn-punct: #d4c4a8;
  --tbc-bg: rgba(168, 93, 66, 0.1);
  --zoom-backdrop: rgba(42, 33, 24, 0.55);
  --glow-a: rgba(196, 149, 106, 0.07);
  --glow-b: rgba(176, 125, 74, 0.05);
  --grid-line: rgba(107, 79, 45, 0.06);
  --grid-size: 24px;
  /* Depth: layered shadows, a 1px top highlight on cards, film grain, squared-paper grid */
  --shadow-md: 0 1px 2px rgba(42, 33, 24, 0.05), 0 5px 14px -4px rgba(42, 33, 24, 0.1), 0 16px 34px -12px rgba(107, 79, 45, 0.2);
  --shadow-lg: 0 2px 4px rgba(42, 33, 24, 0.05), 0 12px 26px -6px rgba(42, 33, 24, 0.13), 0 28px 54px -16px rgba(107, 79, 45, 0.26);
  --edge-hi: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --side-shadow: 8px 0 28px -18px rgba(107, 79, 45, 0.22);
  --spot: rgba(176, 125, 74, 0.1);
  --grain: 0.08;
  --grad-accent: linear-gradient(90deg, var(--accent-caramel), var(--accent-terracotta));
  /* Home cards: one accent per category (params.kinds); a new kind needs its token here. */
  --kind-project: var(--accent-green);
  --kind-incident: var(--accent-terracotta);
  --kind-other: var(--accent-caramel);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --font-main: 'Space Grotesk', 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', ui-monospace, Menlo, Consolas, monospace;
  --radius-sm: 5px;
  --radius-md: 8px;
}
[data-theme="moon"] {
  --bg-base: #1e1e24;
  --bg-sidebar: #252530;
  --bg-main: #1a1a20;
  --bg-card: #2a2a32;
  --bg-muted: #353540;
  --text-primary: #e8e8ed;
  --text-secondary: #b8b8c0;
  --text-muted: #888898;
  --accent-brown: #d4a574;
  --accent-caramel: #e8b889;
  --accent-cream: #4a4a55;
  --accent-terracotta: #d4826a;
  --accent-green: #7fc9a5;
  --border-light: rgba(232, 184, 137, 0.1);
  --border-medium: rgba(232, 184, 137, 0.18);
  --border-accent: rgba(232, 184, 137, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.2);
  --theme-glow: 0 2px 8px rgba(232, 184, 137, 0.3);
  --dock-bg: #393944;
  --dock-border: rgba(232, 184, 137, 0.34);
  --toggle-track: #4b4b58;
  --toggle-border: rgba(232, 184, 137, 0.4);
  --toggle-icon: #bdbdc8;
  --dock-label: #cfcfd8;
  --bar-bg: rgba(30, 30, 36, 0.9);
  --code-bg: #121217;
  --code-fg: #dcdce3;
  --code-muted: #7d7d8c;
  --syn-keyword: #e8b889;
  --syn-string: #7fc9a5;
  --syn-number: #e0907a;
  --syn-func: #f0d39b;
  --syn-var: #c9a6e8;
  --syn-attr: #8ec5e6;
  --syn-punct: #a8a8b8;
  --tbc-bg: rgba(212, 130, 106, 0.12);
  --zoom-backdrop: rgba(10, 10, 14, 0.7);
  --glow-a: rgba(232, 184, 137, 0.04);
  --glow-b: rgba(232, 184, 137, 0.03);
  --grid-line: rgba(232, 184, 137, 0.035);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px -6px rgba(0, 0, 0, 0.4), 0 18px 40px -14px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.35), 0 14px 30px -8px rgba(0, 0, 0, 0.48), 0 32px 60px -16px rgba(0, 0, 0, 0.6);
  --edge-hi: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  --side-shadow: 10px 0 30px -18px rgba(0, 0, 0, 0.45);
  --spot: rgba(232, 184, 137, 0.08);
  --grain: 0.09;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-base);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-brown); }
a:focus-visible, button:focus-visible, summary:focus-visible { outline: 2px solid var(--accent-caramel); outline-offset: 2px; }

/* Background: squared paper (1px lines every --grid-size) under two soft glows, plus grain (::after). */
.bg-pattern {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(circle at 25% 25%, var(--glow-a) 0%, transparent 50%),
    radial-gradient(circle at 75% 75%, var(--glow-b) 0%, transparent 50%),
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: auto, auto, var(--grid-size) var(--grid-size), var(--grid-size) var(--grid-size);
}
/* Film grain: a greyscale noise tile, its strength set per theme by --grain. */
.bg-pattern::after {
  content: ""; position: absolute; inset: 0; opacity: var(--grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 1.4 -.2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- shell ---------- */
/* min-height: the sidebar column runs to the bottom of the window even on short pages. */
.shell { position: relative; z-index: 1; display: block; min-height: 100vh; }
.main { min-width: 0; }
.side { background: var(--bg-sidebar); border-bottom: 1px solid var(--border-light); }
.side-inner {
  padding-block: 20px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
/* Sidebar width follows the portfolio's --sidebar-width (css/style.css): 320px, 280px up to 1024px. */
@media (min-width: 960px) {
  .shell { display: grid; grid-template-columns: 320px minmax(0, 1fr); }
  .side { position: relative; z-index: 2; border-bottom: 0; border-right: 1px solid var(--border-light); box-shadow: var(--side-shadow); }
  .side-inner {
    position: sticky; top: env(safe-area-inset-top, 0px);
    display: flex; flex-direction: column;
    height: 100vh; overflow-y: auto; padding: 24px;
  }
  .side-d > summary { pointer-events: none; cursor: default; }
  .chev { display: none; }
}
@media (min-width: 960px) and (max-width: 1024px) {
  .shell { grid-template-columns: 280px minmax(0, 1fr); }
}
/* the terminal title bar folds the sidebar on narrow screens */
.side-d > summary { list-style: none; cursor: pointer; }
.side-d > summary::-webkit-details-marker { display: none; }
.side-d:not([open]) > summary { margin-bottom: 0; }
.chev { margin-left: auto; font: 400 .8rem var(--font-mono); color: var(--text-muted); }
.chev::before { content: "▾"; }
.side-d:not([open]) .chev::before { content: "▸"; }

/* ---------- sidebar ---------- */
.term-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin-bottom: 22px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-muted) 140%);
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  box-shadow: var(--edge-hi), var(--shadow-sm);
}
.dots { display: flex; gap: 6px; }
.dots i { width: 12px; height: 12px; border-radius: 50%; display: block; }
.dots .r { background: #e8a19a; } .dots .y { background: #e8cf8a; } .dots .g { background: #9ec89e; }
.term-title { font: 400 .8rem var(--font-mono); letter-spacing: .5px; color: var(--text-muted); }

.term { font-family: var(--font-mono); font-size: .8rem; }
.tl { display: flex; gap: 8px; }
.pr { color: var(--accent-green); }
.cmd { color: var(--text-primary); }
.tag { font: 500 .62rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); margin-left: 8px; }

/* Navigation: groups by kind, projects as accordions, pages numbered */
.nav { margin-top: 6px; }
.nav-k { margin: 20px 0 6px; font: 500 .68rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.nav-l, .nav-c { list-style: none; margin: 0; padding: 0; }
.nav-i {
  position: relative;
  display: flex; align-items: baseline; gap: 10px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  font-size: .9rem; line-height: 1.4; color: var(--text-secondary); text-decoration: none;
}
/* accent bar on the left edge: grows on hover, stays on the current page */
a.nav-i::before, .nav-i.cur::before {
  content: ""; position: absolute; left: 0; top: 22%; bottom: 22%; width: 2px; border-radius: 2px;
  background: var(--grad-accent); transform: scaleY(0); opacity: 0;
}
a.nav-i:hover { background: var(--bg-muted); color: var(--text-primary); }
a.nav-i:hover::before { transform: scaleY(.6); opacity: .7; }
.nav-i.cur { background: var(--bg-card); color: var(--accent-brown); font-weight: 600; box-shadow: var(--edge-hi), var(--shadow-md); }
.nav-i.cur::before { transform: scaleY(1); opacity: 1; }
a.nav-i:hover .nav-n { color: var(--accent-caramel); }
.soon .nav-i { color: var(--text-muted); }
.nav-n { flex: none; min-width: 2.2em; font: 500 .72rem var(--font-mono); color: var(--text-muted); }
.nav-i.cur .nav-n { color: var(--accent-terracotta); }
.nav-p > summary { display: flex; align-items: center; list-style: none; cursor: pointer; border-radius: var(--radius-sm); }
.nav-p > summary::-webkit-details-marker { display: none; }
.nav-p > summary::before {
  content: "▸"; flex: none; width: 14px; margin-right: -4px;
  font: 400 .72rem var(--font-mono); color: var(--text-muted);
}
.nav-p[open] > summary::before { content: "▾"; }
.nav-p > summary .nav-i { flex: 1; min-width: 0; }
/* single pages line up with project titles (after the chevron) */
.nav-l > li > .nav-i { margin-left: 10px; }
.nav-c { margin: 2px 0 6px 17px; padding-left: 8px; border-left: 1px solid var(--border-medium); }
.nav-c .nav-i { font-size: .85rem; padding-block: 4px; }

/* Foot of the sidebar: back link, booking CTA, theme switch (pushed to the bottom on wide screens) */
.side-foot { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
@media (min-width: 960px) { .side-foot { margin-top: auto; padding-top: 24px; } }
.side-d:not([open]) + .side-foot { display: none; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 14px; border-radius: var(--radius-md);
  border: 1px solid var(--border-accent); background: var(--bg-card);
  color: var(--accent-brown); font: 500 .85rem var(--font-main); text-decoration: none;
  box-shadow: var(--edge-hi), var(--shadow-sm);
}
.btn:hover { background: var(--bg-muted); border-color: var(--accent-caramel); }
/* Same as the portfolio's .cta-btn.primary (css/style.css), plus a sheen that sweeps across on hover */
.btn-cta {
  position: relative; overflow: hidden; isolation: isolate;
  padding: 10px 18px; border-color: var(--accent-caramel);
  background: linear-gradient(135deg, var(--accent-caramel), color-mix(in srgb, var(--accent-caramel) 78%, var(--accent-terracotta)));
  color: #fff; font-weight: 600; font-size: .9rem; box-shadow: var(--edge-hi), var(--theme-glow);
}
.btn-cta::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .28) 50%, transparent 65%);
  transform: translateX(-120%);
}
.btn-cta:hover { background: linear-gradient(135deg, var(--accent-caramel), color-mix(in srgb, var(--accent-caramel) 78%, var(--accent-terracotta))); filter: brightness(1.06); box-shadow: var(--edge-hi), var(--theme-glow), var(--shadow-md); }
.btn-cta:hover::after { transform: translateX(120%); }
[data-theme="moon"] .btn-cta { color: var(--bg-base); }

@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color .2s var(--ease), border-color .2s var(--ease), box-shadow .2s var(--ease); }
  .btn-cta { transition: all .15s cubic-bezier(0.4, 0, 0.2, 1); }
  .btn-cta:hover { transform: translateY(-2px); }
  .btn-cta::after { transition: transform .7s var(--ease); }
  .nav-i { transition: background-color .2s var(--ease), color .2s var(--ease), box-shadow .2s var(--ease); }
  .nav-i::before { transition: transform .25s var(--ease), opacity .25s var(--ease); }
  .nav-n { transition: color .2s var(--ease); }
}

/* Theme switch: one pill fixed bottom right, knob slides cafe (left) / moon (right).
   Same component as the portfolio's (.theme-dock in css/style.css): change one, report in the other.
   Knob and label follow data-theme on <html>; .anim (set by notes.js after load) enables the slide. */
.theme-dock {
  position: fixed; z-index: 60;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 10px; padding: 5px 5px 5px 14px;
  background: var(--dock-bg); border: 1px solid var(--dock-border); border-radius: 999px;
  box-shadow: var(--edge-hi), var(--shadow-md);
}
.td-name { font: 500 .7rem/1 var(--font-mono); letter-spacing: .12em; text-transform: uppercase; color: var(--dock-label); }
.td-moon, [data-theme="moon"] .td-cafe { display: none; }
[data-theme="moon"] .td-moon { display: inline; }
.theme-toggle {
  position: relative; flex: none; width: 56px; height: 28px; padding: 0; cursor: pointer;
  background: var(--toggle-track); border: 1px solid var(--toggle-border); border-radius: 999px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, .08);
}
.theme-toggle:hover { border-color: var(--accent-caramel); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent-caramel); outline-offset: 3px; }
.tt-knob, .tt-i { position: absolute; top: 2px; width: 22px; height: 22px; border-radius: 50%; }
.tt-knob { left: 2px; background: var(--grad-accent); box-shadow: var(--edge-hi), var(--theme-glow); }
[data-theme="moon"] .tt-knob { transform: translateX(28px); }
.tt-i { display: flex; align-items: center; justify-content: center; font-size: .7rem; color: var(--toggle-icon); }
.tt-cafe { left: 2px; }
.tt-moon { right: 2px; }
.tt-cafe, [data-theme="moon"] .tt-moon { color: #fff; }
[data-theme="moon"] .tt-moon { color: var(--bg-base); }
[data-theme="moon"] .tt-cafe { color: var(--toggle-icon); }
@media (prefers-reduced-motion: no-preference) {
  .theme-dock.anim .tt-knob { transition: transform .25s var(--ease); }
  .theme-dock.anim .tt-i { transition: color .25s var(--ease); }
}
@media (max-width: 768px) {
  .td-name { display: none; }
  .theme-dock { padding: 4px; }
}
@media print { .theme-dock { display: none; } }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  min-height: 63px; /* same height as the portfolio tab bar (.nav-tabs in css/style.css) */
  padding-block: 10px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  background: var(--bar-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
}
@media (min-width: 960px) { .topbar { padding-inline: 32px; } }
/* Reading progress: a thin accent line on the bottom edge of the top bar, set by notes.js (--p, 0 to 1). */
.readbar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; }
.readbar span {
  display: block; height: 100%; background: var(--grad-accent);
  transform-origin: 0 50%; transform: scaleX(var(--p, 0));
  box-shadow: 0 0 8px var(--accent-caramel);
}
.readbar[hidden] { display: none; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font: 400 .78rem var(--font-mono); color: var(--text-muted); min-width: 0; }
.crumbs a { color: var(--text-muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent-brown); text-decoration: underline; }
.crumbs .here { color: var(--text-primary); }
.ctrls { display: flex; gap: 8px; }
.seg { display: inline-flex; background: var(--bg-card); border: 1px solid var(--border-medium); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--edge-hi), var(--shadow-sm); }
.seg a:not([aria-current="true"]):hover { color: var(--accent-brown); background: var(--bg-main); }
.seg button, .seg a {
  font: 500 .75rem var(--font-mono); padding: 6px 11px; border: 0; background: transparent;
  color: var(--text-secondary); cursor: pointer; text-decoration: none;
}
.seg > * + * { border-left: 1px solid var(--border-light); }
.seg button[aria-pressed="true"], .seg a[aria-current="true"] { background: var(--bg-muted); color: var(--accent-brown); }
.seg button:focus-visible, .seg a:focus-visible { outline-offset: -3px; }

/* ---------- article ---------- */
.content {
  padding-top: 28px; padding-bottom: 56px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
@media (min-width: 960px) { .content { padding: 44px 32px 72px; } }
/* --measure: 80ch of body text. .doc takes the .prose font size so that ch matches it
   (everything else inside sizes in rem). The article column never exceeds it; the block is centred. */
.doc { font-size: 1.03rem; --measure: 80ch; display: grid; grid-template-columns: minmax(0, 1fr); gap: 40px; max-width: var(--measure); margin-inline: auto; }
.toc { display: none; }
@media (min-width: 1380px) {
  .doc { grid-template-columns: minmax(0, var(--measure)) 220px; max-width: calc(var(--measure) + 260px); }
  .toc { display: block; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 100px); align-self: start; }
}
.art { min-width: 0; }

.eyebrow { font: 500 .74rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-terracotta); margin: 0 0 14px; }
.art h1 { font-size: clamp(1.7rem, 3.4vw, 2.25rem); line-height: 1.15; font-weight: 700; letter-spacing: -.01em; margin: 0 0 14px; text-wrap: balance; }
.lede { font-size: 1.05rem; color: var(--text-secondary); max-width: 62ch; margin: 0 0 18px; }
.chips { list-style: none; margin: 0 0 34px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.chips li { font: 500 .72rem var(--font-mono); padding: 4px 10px; border: 1px solid var(--border-medium); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-secondary); box-shadow: var(--edge-hi), var(--shadow-sm); }

.prose { font-size: 1.03rem; line-height: 1.75; color: var(--text-secondary); }
.prose > p, .prose > ul, .prose > ol { max-width: 80ch; }
.prose p { margin: 0 0 1em; }
.prose h2 { font-size: 1.45rem; line-height: 1.25; color: var(--text-primary); margin: 2.4em 0 .6em; scroll-margin-top: 106px; text-wrap: balance; }
.prose h2:first-child { margin-top: 0; }
.prose h3 { font-size: 1.1rem; line-height: 1.3; color: var(--text-primary); margin: 1.9em 0 .5em; scroll-margin-top: 106px; }
.prose strong { color: var(--text-primary); font-weight: 600; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: .35em 0; }
.prose li::marker { color: var(--accent-caramel); }
.prose li:has(> input[type=checkbox]) { list-style: none; margin-left: -1.3em; }
.prose li > input[type=checkbox] { margin: 0 .5em 0 0; accent-color: var(--accent-green); vertical-align: -.1em; }
.prose details { margin: -.9em 0 1.5em; }
.prose details > summary { cursor: pointer; width: fit-content; font: 500 .72rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.prose details > summary:hover { color: var(--text-secondary); }
.prose details[open] > summary { margin-bottom: 8px; }
.prose code { font-family: var(--font-mono); font-size: .86em; color: var(--text-primary); background: var(--bg-muted); padding: .12em .4em; border-radius: var(--radius-sm); overflow-wrap: anywhere; }

.prose blockquote { position: relative; margin: 0 0 1.6em; padding: 14px 16px 14px 19px; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--edge-hi), var(--shadow-md); font-size: .93rem; line-height: 1.65; overflow: hidden; }
/* accent edge on the left of every callout */
.prose blockquote::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: linear-gradient(180deg, var(--accent-caramel), var(--accent-terracotta)); }
.prose blockquote p { margin: 0; }
.prose blockquote::before { display: block; margin-bottom: 6px; font: 500 .68rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.prose blockquote[data-label]::before { content: attr(data-label); }

.tbc, .tbc-legend { display: inline-block; margin-top: 2px; padding: 2px 8px; font: 500 .78rem/1.5 var(--font-mono); color: var(--accent-terracotta); background: var(--tbc-bg); border: 1px dashed var(--accent-terracotta); border-radius: var(--radius-sm); }
.tbc b, .tbc-legend b { font-weight: 600; text-transform: uppercase; letter-spacing: .06em; margin-right: 6px; }

.tablewrap { overflow-x: auto; margin: 0 0 1.5em; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--edge-hi), var(--shadow-md); }
.prose tbody tr:hover td { background: var(--bg-main); }
.prose table { width: 100%; min-width: 520px; border-collapse: collapse; font-size: .92rem; line-height: 1.5; }
.prose th { text-align: left; padding: 10px 14px; font: 500 .7rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--text-muted); background: var(--bg-muted); border-bottom: 1px solid var(--border-medium); }
.prose td { padding: 10px 14px; vertical-align: top; border-bottom: 1px solid var(--border-light); }
.prose td:first-child { font: 400 .8rem var(--font-mono); white-space: nowrap; color: var(--text-primary); }
.prose tr:last-child td { border-bottom: 0; }

/* Code blocks are dark in both themes: the white overlays below are theme-independent. */
.codeblock { margin: 0 0 1.5em; background: var(--code-bg); border: 1px solid var(--border-medium); border-radius: var(--radius-md); overflow: hidden; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .06), var(--shadow-md); }
.cb-head { display: flex; justify-content: space-between; align-items: center; padding: 5px 8px 5px 14px; font: 500 .68rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--code-muted); background: linear-gradient(180deg, rgba(255, 255, 255, .05), rgba(255, 255, 255, .02)); border-bottom: 1px solid rgba(255, 255, 255, .08); }
.cb-copy { font: 500 .68rem var(--font-mono); letter-spacing: .06em; text-transform: uppercase; color: var(--code-muted); background: transparent; border: 1px solid rgba(255, 255, 255, .16); border-radius: var(--radius-sm); padding: 3px 9px; cursor: pointer; }
.cb-copy:hover { color: var(--code-fg); border-color: rgba(255, 255, 255, .35); background: rgba(255, 255, 255, .05); }
/* "copied" state, set by notes.js for 1.5 s */
.cb-copy.done { color: var(--syn-string); border-color: var(--syn-string); }
.cb-copy.done::before { content: "✓ "; display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .cb-copy { transition: color .2s var(--ease), border-color .2s var(--ease), background-color .2s var(--ease); }
  .cb-copy.done::before { animation: cb-pop .35s var(--ease); }
}
@keyframes cb-pop { from { transform: scale(.2) rotate(-30deg); opacity: 0; } }
.codeblock pre { margin: 0; padding: 14px; overflow-x: auto; }
.prose .codeblock code { display: block; background: none; padding: 0; color: var(--code-fg); font-size: .8rem; line-height: 1.65; white-space: pre; border-radius: 0; }
/* Syntax highlighting: Chroma classes (markup.highlight.noClasses = false) mapped to --syn-* tokens.
   Code blocks are dark in both themes, so both palettes are light-on-dark. */
.chroma .k, .chroma .kc, .chroma .kd, .chroma .kn, .chroma .kp, .chroma .kr, .chroma .kt, .chroma .ow { color: var(--syn-keyword); }
.chroma .s, .chroma .sa, .chroma .sb, .chroma .sc, .chroma .dl, .chroma .sd, .chroma .s2, .chroma .sh, .chroma .si, .chroma .sx, .chroma .sr, .chroma .s1, .chroma .ss { color: var(--syn-string); }
.chroma .m, .chroma .mb, .chroma .mf, .chroma .mh, .chroma .mi, .chroma .il, .chroma .mo, .chroma .se { color: var(--syn-number); }
.chroma .nb, .chroma .bp, .chroma .nf, .chroma .fm, .chroma .nc { color: var(--syn-func); }
.chroma .nv, .chroma .vc, .chroma .vg, .chroma .vi, .chroma .vm { color: var(--syn-var); }
.chroma .nt, .chroma .na, .chroma .nl, .chroma .nd { color: var(--syn-attr); }
.chroma .o, .chroma .p { color: var(--syn-punct); }
.chroma .c, .chroma .ch, .chroma .cm, .chroma .c1, .chroma .cs, .chroma .cp, .chroma .cpf { color: var(--code-muted); font-style: italic; }
.chroma .gi { color: var(--syn-string); }
.chroma .gd { color: var(--syn-number); }
.chroma .err { color: inherit; background: none; }

.fig { margin: 0 0 1.7em; padding: 14px; background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--edge-hi), var(--shadow-md); }
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .fig-img > a { display: block; overflow: hidden; border-radius: var(--radius-sm); }
  .fig-img > a img { transition: transform .4s var(--ease); }
  .fig-img > a:hover img { transform: scale(1.015); }
}
.fig .scroll { overflow-x: auto; }
.fig svg { display: block; width: 100%; min-width: 600px; height: auto; }
.fig figcaption { margin-top: 10px; font: 400 .76rem var(--font-mono); color: var(--text-muted); }
.fig-img img { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); }
.fig-img figcaption a { color: inherit; }
.fig-img > a { cursor: zoom-in; }
/* Raster diagram zoom: a modal <dialog> filled by notes.js; the image fits within --zoom % of the viewport. */
.zoom { --zoom: 85; --pad: 10px; max-width: calc(var(--zoom) * 1vw); max-height: calc(var(--zoom) * 1vh); padding: var(--pad); overflow: visible; color: var(--text-primary); background: var(--bg-card); border: 1px solid var(--border-light); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.zoom::backdrop { background: var(--zoom-backdrop); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
.zoom img { display: block; width: auto; height: auto; max-width: calc(var(--zoom) * 1vw - 2 * var(--pad) - 2px); max-height: calc(var(--zoom) * 1vh - 2 * var(--pad) - 2px); object-fit: contain; border-radius: var(--radius-sm); }
.zoom-x { position: absolute; top: -14px; right: -14px; width: 32px; height: 32px; padding: 0; font: 500 1.2rem/1 var(--font-mono); color: var(--text-primary); background: var(--bg-card); border: 1px solid var(--border-medium); border-radius: 50%; box-shadow: var(--shadow-sm); cursor: pointer; }
.zoom-x:hover { color: var(--accent-terracotta); border-color: var(--accent-terracotta); }
body:has(.zoom[open]) { overflow: hidden; }
@media (prefers-reduced-motion: no-preference) {
  .zoom[open] { animation: zoom-in .18s ease-out; }
  .zoom[open]::backdrop { animation: zoom-fade .18s ease-out; }
}
@keyframes zoom-in { from { opacity: 0; transform: scale(.96); } }
@keyframes zoom-fade { from { opacity: 0; } }
@media (max-width: 959px) { .zoom { --zoom: 94; } .zoom-x { top: 6px; right: 6px; } }

.svg-zone-k { fill: var(--bg-main); stroke: var(--border-accent); stroke-width: 1.2; }
.svg-zone-x { fill: var(--bg-sidebar); stroke: var(--border-medium); stroke-width: 1.2; stroke-dasharray: 5 4; }
.svg-zt { font: 500 10.5px var(--font-mono); letter-spacing: .08em; fill: var(--text-muted); }
.svg-box { fill: var(--bg-card); stroke: var(--border-medium); stroke-width: 1.2; }
.svg-hot { fill: var(--bg-card); stroke: var(--accent-caramel); stroke-width: 2; }
.svg-t { font: 600 12.5px var(--font-main); fill: var(--text-primary); }
.svg-s { font: 400 10.5px var(--font-mono); fill: var(--text-muted); }
.svg-l { font: 500 10.5px var(--font-mono); fill: var(--text-secondary); }
.svg-warn { font: 600 11.5px var(--font-mono); fill: var(--accent-terracotta); }
.svg-b { font: 500 11.5px var(--font-main); fill: var(--text-primary); }
.svg-line { stroke: var(--text-muted); stroke-width: 1.4; fill: none; marker-end: url(#arr); }
.svg-bar-a { fill: var(--accent-cream); stroke: var(--border-accent); stroke-width: 1; }
.svg-bar-b { fill: var(--bg-muted); stroke: var(--border-accent); stroke-width: 1; }
.svg-gap { fill: url(#hatch); stroke: var(--accent-terracotta); stroke-width: 1; }

.toc-title { font: 500 .7rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0 0 0 12px; border-left: 1px solid var(--border-medium); }
.toc li { margin: 0; }
.toc a { position: relative; display: block; padding: 5px 0; font-size: .84rem; line-height: 1.35; color: var(--text-muted); text-decoration: none; }
.toc a:hover { color: var(--accent-brown); }
/* Scroll-spy (notes.js): the section being read is marked on the rail. */
.toc a::before {
  content: ""; position: absolute; left: -13px; top: 4px; bottom: 4px; width: 2px; border-radius: 2px;
  background: var(--grad-accent); transform: scaleY(0);
}
.toc a.on { color: var(--text-primary); font-weight: 500; }
.toc a.on::before { transform: scaleY(1); }
@media (prefers-reduced-motion: no-preference) {
  .toc a { transition: color .2s var(--ease); }
  .toc a::before { transition: transform .3s var(--ease); }
}

.prose .parts { list-style: none; padding: 0; margin: 0 0 1em; border-top: 1px solid var(--border-light); }
.prose .parts li { display: grid; grid-template-columns: 3em minmax(0, 1fr); align-items: baseline; gap: 0 10px; margin: 0; padding: 14px 0; border-bottom: 1px solid var(--border-light); }
.parts .num { grid-row: span 2; font: 500 .78rem var(--font-mono); color: var(--accent-terracotta); }
.parts .ttl { font-weight: 600; color: var(--text-primary); }
.parts a.ttl { text-decoration: none; }
.parts a.ttl:hover { color: var(--accent-brown); text-decoration: underline; }
.parts .tag { margin-left: 8px; }
.parts .desc { grid-column: 2; margin: 4px 0 0; font-size: .93rem; line-height: 1.6; color: var(--text-secondary); }
.parts .soon .num, .parts .soon .ttl, .parts .soon .desc { color: var(--text-muted); }
.prose .parts li:not(.soon):hover { background: linear-gradient(90deg, var(--spot), transparent 60%); }
@media (prefers-reduced-motion: no-preference) { .prose .parts li { transition: background-color .2s var(--ease); } }

.pager { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-top: 48px; }
.pager a {
  display: block; padding: 12px 14px; border: 1px solid var(--border-medium); border-radius: var(--radius-md); text-decoration: none;
  /* spotlight that follows the pointer (--mx/--my set by notes.js), over the card surface */
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 70%) no-repeat, var(--bg-card);
  background-size: 0 0, auto;
  box-shadow: var(--edge-hi), var(--shadow-md);
}
.pager a:hover { border-color: var(--accent-caramel); background-size: 100% 100%, auto; box-shadow: var(--edge-hi), var(--shadow-lg); }
.pg-a { display: inline-block; }
.pager a:hover .pg-a { color: var(--accent-terracotta); }
@media (prefers-reduced-motion: no-preference) {
  .pager a { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease); }
  .pager a:hover { transform: translateY(-2px); }
  .pg-a { transition: transform .25s var(--ease), color .25s var(--ease); }
  .pager .prev:hover .pg-a { transform: translateX(-4px); }
  .pager .next:hover .pg-a { transform: translateX(4px); }
}
.pager .next { grid-column: 2; text-align: right; }
.pg-k { display: block; font: 500 .68rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.pg-t { display: block; margin-top: 4px; font-size: .95rem; font-weight: 600; line-height: 1.35; color: var(--text-primary); }
@media (max-width: 600px) { .pager { grid-template-columns: minmax(0, 1fr); } .pager .next { grid-column: 1; } }

.foot { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--border-light); font: 400 .74rem/1.6 var(--font-mono); color: var(--text-muted); }

/* ---------- home /notes/<lang>/: counters, category filter, card grid ---------- */
.doc.doc-home { max-width: 1040px; grid-template-columns: minmax(0, 1fr); }
.home-ls { text-transform: none; letter-spacing: .02em; color: var(--text-muted); }
.home-ls span { color: var(--accent-terracotta); }
.home-stats { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 30px; font: 400 .76rem var(--font-mono); color: var(--text-muted); }
.home-stats b { font-weight: 600; color: var(--text-primary); }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 22px; }
.filters[hidden] { display: none; }
.filter {
  display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer;
  font: 500 .74rem var(--font-mono); color: var(--text-secondary);
  background: var(--bg-card); border: 1px solid var(--border-medium); border-radius: 999px;
  box-shadow: var(--edge-hi), var(--shadow-sm);
}
.filter:hover { border-color: var(--accent-caramel); color: var(--text-primary); }
.filter[aria-pressed="true"] { color: var(--bg-card); background: var(--accent-brown); border-color: var(--accent-brown); }
.filter-n { font-size: .66rem; padding: 0 6px; border-radius: 999px; background: var(--bg-muted); color: var(--text-muted); }
.filter[aria-pressed="true"] .filter-n { background: transparent; color: inherit; opacity: .8; }

.cards { list-style: none; margin: 0; padding: 0 0 8px; display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); }
.card { --kind: var(--kind-other); position: relative; isolation: isolate; min-width: 0; padding-bottom: 12px; } /* room for the series stack, on every card so rows line up */
.card[hidden] { display: none; }
.card[data-kind="project"] { --kind: var(--kind-project); }
.card[data-kind="incident"] { --kind: var(--kind-incident); }
.card-b {
  position: relative; height: 100%; display: flex; flex-direction: column; overflow: hidden;
  padding: 20px 20px 16px; border: 1px solid var(--border-medium); border-radius: var(--radius-md);
  /* spotlight that follows the pointer (--mx/--my set by notes.js), like the pager */
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), var(--spot), transparent 70%) no-repeat, var(--bg-card);
  background-size: 0 0, auto;
  box-shadow: var(--edge-hi), var(--shadow-md);
}
/* category accent along the top edge */
.card-b::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--kind); }
/* a series is a stack: two sheets peek out below the card (vertical offset only, no horizontal overflow) */
.card-series::before, .card-series::after {
  content: ""; position: absolute; z-index: -1; border: 1px solid var(--border-medium); border-radius: var(--radius-md); background: var(--bg-card); box-shadow: var(--shadow-sm);
}
.card-series::before { inset: 6px 8px 6px; }
.card-series::after { inset: 12px 16px 0; opacity: .7; }
.card:hover .card-b, .card:focus-within .card-b { border-color: var(--accent-caramel); background-size: 100% 100%, auto; box-shadow: var(--edge-hi), var(--shadow-lg); }

.card-k { display: flex; flex-wrap: wrap; gap: 0 8px; margin: 0 0 10px; font: 500 .68rem var(--font-mono); letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); }
.card-kind { color: var(--kind); }
.card-t { margin: 0 0 8px; font-size: 1.12rem; line-height: 1.3; font-weight: 650; text-wrap: balance; }
.card-a { color: var(--text-primary); text-decoration: none; }
/* the whole card follows the title link; "Start" sits above it */
.card-a::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
.card-a:focus-visible { outline: none; }
.card-b:has(.card-a:focus-visible) { outline: 2px solid var(--accent-caramel); outline-offset: 2px; }
.card-d { margin: 0 0 14px; font-size: .9rem; line-height: 1.6; color: var(--text-secondary); }

.segs { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.segs-bar { flex: 1; display: flex; gap: 3px; min-width: 0; }
.pbar-seg { flex: 1 1 0; height: 6px; border-radius: 2px; border: 1px dashed var(--border-accent); }
.pbar-seg.annex { flex-grow: .45; }
.pbar-seg.on { border: 0; background: var(--kind); }
.segs-n { font: 500 .68rem var(--font-mono); color: var(--text-muted); }

.card-tags { margin: 0 0 14px; gap: 6px; }
.card-tags li { font-size: .66rem; padding: 2px 8px; box-shadow: none; background: var(--bg-main); }
.card-m { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: auto 0 0; padding-top: 12px; border-top: 1px solid var(--border-light); font: 400 .72rem var(--font-mono); color: var(--text-muted); }
.card-go { margin-left: auto; font-weight: 500; color: var(--accent-brown); text-decoration: none; }
a.card-go { position: relative; z-index: 2; }
a.card-go:hover { color: var(--accent-terracotta); text-decoration: underline; }
.card-arr { display: inline-block; }
@media (prefers-reduced-motion: no-preference) {
  .card-b { transition: transform .25s var(--ease), box-shadow .25s var(--ease), border-color .25s var(--ease); }
  .card:hover .card-b { transform: translateY(-2px); }
  .card-arr { transition: transform .25s var(--ease); }
  .card:hover .card-arr { transform: translateX(4px); }
  .filter { transition: background-color .2s var(--ease), color .2s var(--ease), border-color .2s var(--ease); }
}
