/* AI, LLM, inference... WTF?? (short version)
   Styled on the SecLeap design system: dark by default with a light
   alternative, one desaturated green accent, system fonts, mono labels,
   small radii. Mobile first. Reading text uses the system's "body large"
   size (18px), because this guide is read start to finish on phones. */

/* ---------- Tokens ---------- */
:root {
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px;
  --s-6: 32px; --s-7: 48px; --s-8: 64px;

  --radius-xs: 2px; --radius-sm: 4px; --radius-md: 6px; --radius-lg: 10px;

  --fs-h1: 30px;   --lh-h1: 1.1;  --tr-h1: -0.02em;
  --fs-h2: 23px;   --lh-h2: 1.2;  --tr-h2: -0.015em;
  --fs-h3: 19px;   --lh-h3: 1.3;  --tr-h3: -0.01em;
  --fs-read: 17px; --lh-read: 1.6;
  --fs-small: 14px;
  --fs-caption: 12px;

  --maxw: 46rem;      /* reading column */
  --frame: 48rem;     /* header + layout width; widens with the side rail */
  --rail: 220px;
  --gutter: 64px;

  /* One accent: desaturated green */
  --accent:      oklch(0.72 0.09 145);
  --accent-ink:  oklch(0.20 0.03 145);
  --accent-soft: oklch(0.72 0.09 145 / 0.14);
}
@media (min-width: 720px) {
  :root { --fs-h1: 40px; --fs-h2: 28px; --fs-h3: 20px; --fs-read: 18px; }
}
@media (min-width: 1100px) {
  :root { --frame: calc(var(--rail) + var(--gutter) + var(--maxw) + 2 * var(--s-4)); }
}

[data-theme="dark"] {
  --bg:            oklch(0.17 0.005 250);
  --bg-elev:       oklch(0.21 0.006 250);
  --bg-sunken:     oklch(0.14 0.005 250);
  --surface:       oklch(0.23 0.007 250);
  --border:        oklch(0.30 0.008 250);
  --border-strong: oklch(0.40 0.010 250);
  --text:          oklch(0.94 0.004 250);
  --text-muted:    oklch(0.72 0.006 250);
  --text-dim:      oklch(0.64 0.008 250);   /* 4.5:1 or better on every surface it sits on */
  --danger:  oklch(0.68 0.17 25);
  --warning: oklch(0.78 0.14 75);
  --success: oklch(0.72 0.12 155);
  --info:    oklch(0.72 0.09 235);
  --accent-text: var(--accent);
  --grid-dot: oklch(0.30 0.008 250 / 0.45);
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:            oklch(0.985 0.003 85);
  --bg-elev:       oklch(1.00 0 0);
  --bg-sunken:     oklch(0.965 0.004 85);
  --surface:       oklch(1.00 0 0);
  --border:        oklch(0.90 0.006 85);
  --border-strong: oklch(0.78 0.008 85);
  --text:          oklch(0.22 0.008 250);
  --text-muted:    oklch(0.42 0.008 250);
  --text-dim:      oklch(0.52 0.006 250);   /* 4.5:1 or better on every surface it sits on */
  --danger:  oklch(0.52 0.19 25);
  --warning: oklch(0.50 0.13 75);
  --success: oklch(0.46 0.13 155);
  --info:    oklch(0.50 0.11 235);
  /* links and labels need more contrast on white than the accent swatch gives */
  --accent-text: oklch(0.48 0.10 145);
  --grid-dot: oklch(0.80 0.008 85 / 0.7);
  color-scheme: light;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  font-size: var(--fs-read);
  line-height: var(--lh-read);
  color: var(--text);
  background: var(--bg);
  background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
  background-size: 24px 24px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
::selection { background: var(--accent-soft); color: var(--text); }
a { color: var(--accent-text); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }
[hidden] { display: none !important; }
b, strong { font-weight: 600; }
/* Emphasis in the accent, per the design system */
b, strong, i, em { color: var(--accent-text); }
.warning b, .warning i, .warning em, .warning strong { color: inherit; }

.skip { position: absolute; left: -999px; top: 0; background: var(--surface); color: var(--text); padding: var(--s-2) var(--s-4); z-index: 10; }
.skip:focus { left: var(--s-2); top: var(--s-2); }
main:focus { outline: none; }
.offscreen { position: fixed; left: -9999px; top: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Shared: mono caption labels */
.page-meta, .box-label, .toy-label, .card-group, .stack-header, .remember-title, .stop-title,
.g-link, .foot, .brand-sub, details.starter summary {
  font-family: var(--font-mono);
}

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.top-inner {
  max-width: var(--frame); margin: 0 auto; padding: var(--s-4) var(--s-4) var(--s-3);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-4);
}
.brand-wrap { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.org {
  display: inline-flex; align-items: center; gap: var(--s-2); flex-shrink: 0;
  color: var(--text); text-decoration: none; font-weight: 500; font-size: 17px; letter-spacing: -0.02em;
}
.org:hover { color: var(--accent-text); }
.org-mark { width: 22px; height: 22px; color: var(--accent); flex-shrink: 0; }
.brand-sep { width: 1px; height: 26px; background: var(--border-strong); flex-shrink: 0; }
@media (max-width: 560px) {
  .org-name { display: none; }
  .top .brand-wrap { gap: 6px; }
  .top .brand-line { font-size: 15px; }
  .top .top-inner { gap: var(--s-2); }
  .top .top-tools { gap: 4px; }
  .top .lang button { padding: 4px 6px; }
}
@media (max-width: 420px) {
  .top .brand-line { font-size: 14px; letter-spacing: -0.02em; }
  .top .lang { padding: 2px; gap: 1px; }
  .top .lang button { padding: 4px; letter-spacing: 0.02em; }
  .top .theme-btn { width: 28px; }
}
.brand { text-decoration: none; color: var(--text); display: block; min-width: 0; }
.brand-line { font-weight: 500; font-size: 17px; letter-spacing: -0.01em; }
.brand-em { font-style: normal; color: var(--accent-text); }
.brand-sub {
  display: block; font-size: 11px; color: var(--text-dim); line-height: 1.4; margin-top: 2px;
  text-transform: uppercase; letter-spacing: 0.06em;
}
@media (max-width: 560px) { .brand-sub { display: none; } }

.top-tools { display: flex; align-items: center; gap: var(--s-2); flex-shrink: 0; }
.lang {
  display: flex; gap: 2px; padding: 3px;
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.lang button {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  border: 0; background: transparent; color: var(--text-muted);
  padding: 4px 8px; border-radius: 3px; cursor: pointer;
}
.lang button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 30px; padding: 0; cursor: pointer;
  background: var(--bg-sunken); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.theme-btn:hover { color: var(--text); }
.theme-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; fill: none; }

.tabs {
  max-width: var(--frame); margin: 0 auto; padding: 0 var(--s-2) var(--s-3);
  display: grid; grid-template-columns: repeat(6, minmax(58px, 1fr)); gap: 2px;
  overflow-x: auto; scrollbar-width: none;   /* six tabs: the row scrolls sideways on the narrowest phones */
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  text-decoration: none; color: var(--text-muted);
  font-size: 12px; font-weight: 500; line-height: 1.2; text-align: center;
  padding: 6px 2px; border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tab:hover { color: var(--text); }
.tab-n {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  min-width: 24px; padding: 1px 6px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
}
.tab[aria-current="page"] { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); }
.tab[aria-current="page"] .tab-n { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.tab.done .tab-t::after { content: " ✓"; color: var(--success); }
@media (min-width: 620px) {
  .tabs {
    grid-template-columns: repeat(6, auto); justify-content: space-between;
    padding: 4px; margin-bottom: var(--s-4);
    background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
    max-width: calc(var(--frame) - 2 * var(--s-4));
  }
  .tab { flex-direction: row; gap: var(--s-2); font-size: var(--fs-small); padding: 6px 10px; white-space: nowrap; }
}

/* ---------- Page ---------- */
main { padding: var(--s-7) 0 var(--s-6); }
.layout { max-width: var(--frame); margin: 0 auto; padding: 0 var(--s-4); }
.content { max-width: var(--maxw); margin: 0 auto; min-width: 0; }
.rail { display: none; }
@media (min-width: 1100px) {
  .layout {
    display: grid; grid-template-columns: var(--rail) minmax(0, var(--maxw));
    gap: var(--gutter); justify-content: center;
  }
  .content { margin: 0; }
  .rail {
    display: block; position: sticky; top: 132px; align-self: start;
    max-height: calc(100vh - 150px); overflow-y: auto; padding-top: var(--s-2);
  }
}
.rail-label {
  margin: 0 0 var(--s-3); font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-dim);
}
.rail-list { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--border); }
.rail-list li { margin: 0; }
.rail-link {
  display: grid; grid-template-columns: 22px 1fr; gap: var(--s-2); width: 100%;
  margin-left: -1px; padding: 6px 0 6px var(--s-3);
  background: none; border: 0; border-left: 2px solid transparent;
  font-family: var(--font-sans); font-size: 13px; line-height: 1.35; text-align: left;
  color: var(--text-muted); cursor: pointer;
}
.rail-link:hover { color: var(--text); }
.rail-n { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); padding-top: 1px; }
.rail-link.is-current { color: var(--text); border-left-color: var(--accent); }
.rail-link.is-current .rail-n { color: var(--accent-text); }
.page-head { margin: 0 0 var(--s-5); }
.page-meta {
  margin: 0 0 var(--s-3); color: var(--text-dim);
  font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: 0.08em;
}
h1 { font-size: var(--fs-h1); line-height: var(--lh-h1); letter-spacing: var(--tr-h1); font-weight: 500; margin: 0; }
h2 { font-size: var(--fs-h2); line-height: var(--lh-h2); letter-spacing: var(--tr-h2); font-weight: 500; margin: var(--s-7) 0 var(--s-3); }
h3 { font-size: var(--fs-h3); line-height: var(--lh-h3); letter-spacing: var(--tr-h3); font-weight: 500; margin: var(--s-2) 0 var(--s-3); }
p { margin: 0 0 var(--s-4); }
ul, ol { padding-left: 1.3rem; margin: 0 0 var(--s-4); }
li { margin: var(--s-1) 0; }
li::marker { color: var(--text-dim); }
.lead { font-size: calc(var(--fs-read) + 1px); line-height: 1.55; color: var(--text-muted); }

/* Section numbers, like the system's "§ 01 — Color" heads */
.page-body { counter-reset: sec; }
.page-body > h2 {
  counter-increment: sec; scroll-margin-top: 150px;
  padding-top: var(--s-5); border-top: 1px solid var(--border);
}
.page-body > h2::before {
  content: "§ " counter(sec, decimal-leading-zero);
  display: block; margin-bottom: var(--s-2);
  font-family: var(--font-mono); font-size: var(--fs-caption); font-weight: 400;
  letter-spacing: 0.08em; color: var(--text-dim);
}

blockquote.big.key {
  border-left: 4px solid var(--warning);
  background: color-mix(in oklab, var(--warning) 10%, var(--surface));
  font-size: calc(var(--fs-read) + 7px); line-height: 1.3;
}
blockquote.big {
  margin: var(--s-4) 0 var(--s-5); padding: var(--s-4) var(--s-5);
  border-left: 3px solid var(--accent); background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: calc(var(--fs-read) + 3px); font-weight: 500; line-height: 1.4; letter-spacing: -0.01em;
}

/* ---------- Callouts (left border + tint, as in the system) ---------- */
.try, .field, .remember, .stop, .warning, .tryfirst {
  border-left: 3px solid var(--text-muted);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--s-4) var(--s-5) var(--s-1);
  margin: var(--s-5) 0;
}
.box-label, .remember-title, .stop-title {
  display: flex; align-items: center; gap: var(--s-2);
  margin: 0 0 var(--s-3);
  font-size: var(--fs-caption); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
}
.box-label::before, .remember-title::before, .stop-title::before, .warning::before, .tryfirst::before {
  content: ""; width: 16px; height: 16px; flex-shrink: 0; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
}

/* Try it: accent */
.try { border-left-color: var(--accent); background: color-mix(in oklab, var(--accent) 7%, var(--surface)); }
.try .box-label { color: var(--accent-text);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='4' y='6' width='24' height='20' rx='1'/%3E%3Cpath d='M9 13 l4 3 l-4 3M17 19h6'/%3E%3C/svg%3E"); }
.look { font-size: calc(var(--fs-read) - 1px); color: var(--text-muted); }
.look-label { color: var(--accent-text); font-weight: 600; }

/* Field notes: the red side */
.field { border-left-color: var(--danger); background: color-mix(in oklab, var(--danger) 7%, var(--surface)); }
.field .box-label { color: var(--danger);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 20 L20 6'/%3E%3Cpath d='M14 6h6v6'/%3E%3Ccircle cx='9' cy='23' r='3'/%3E%3C/svg%3E"); }
.field-intro { font-size: var(--fs-small); color: var(--text-dim); font-style: italic; }
.field h3 { color: var(--text); }

/* In one breath: info */
.remember { border-left-color: var(--info); background: color-mix(in oklab, var(--info) 8%, var(--surface)); }
.remember-title { color: var(--info);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M8 7.5v3.5M8 5v.01'/%3E%3C/svg%3E"); }

/* Don't paste: danger */
.stop { border-left-color: var(--danger); background: color-mix(in oklab, var(--danger) 8%, var(--surface)); }
.stop-title { color: var(--danger);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='8' cy='8' r='6'/%3E%3Cpath d='M5.5 5.5l5 5M10.5 5.5l-5 5'/%3E%3C/svg%3E"); }

/* The privacy warning: deliberately loud, bold and red */
.warning {
  position: relative;
  border: 1px solid var(--danger); border-left-width: 4px;
  background: color-mix(in oklab, var(--danger) 12%, var(--surface));
  padding: var(--s-4) var(--s-5) var(--s-4) calc(var(--s-5) + 24px);
  color: var(--danger); font-weight: 600; line-height: 1.5;
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2 L14 13 L2 13 Z'/%3E%3Cpath d='M8 7v3M8 11.5v.01'/%3E%3C/svg%3E");
}
.warning::before { position: absolute; left: var(--s-4); top: calc(var(--s-4) + 3px); width: 18px; height: 18px; }
.warning p { margin: 0; }
.warning b { font-weight: 800; }
.warning a { color: var(--danger); }

/* "Impatient?" shortcut */
.tryfirst {
  position: relative;
  border-left-color: var(--info); background: color-mix(in oklab, var(--info) 8%, var(--surface));
  padding: var(--s-3) var(--s-5) var(--s-3) calc(var(--s-5) + 22px);
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8h10M9 4l4 4-4 4'/%3E%3C/svg%3E");
}
.tryfirst::before { position: absolute; left: var(--s-4); top: calc(var(--s-3) + 5px); color: var(--info); }
.tryfirst b { color: var(--info); }
.tryfirst a { color: var(--info); font-weight: 500; }

/* ---------- "Never used one?" ---------- */
details.starter {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 0 var(--s-5); margin: var(--s-5) 0 var(--s-4);
}
details.starter summary {
  cursor: pointer; padding: var(--s-3) 0; color: var(--text);
  font-size: var(--fs-caption); letter-spacing: 0.08em; text-transform: uppercase;
  list-style: none; display: flex; align-items: center; gap: var(--s-2);
}
details.starter summary::-webkit-details-marker { display: none; }
details.starter summary:hover { color: var(--accent-text); }
details.starter summary:hover::before { border-color: var(--accent); }
details.starter summary::before {
  content: "+"; display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: 1px solid var(--border-strong); border-radius: var(--radius-xs);
  color: var(--accent-text); font-size: 13px;
}
details.starter[open] summary::before { content: "−"; }
details.starter[open] summary { border-bottom: 1px solid var(--border); margin-bottom: var(--s-4); }

/* Flags */
.flag {
  display: inline-block; width: 1.4em; height: 0.95em; vertical-align: -0.12em;
  border-radius: var(--radius-xs); overflow: hidden; box-shadow: 0 0 0 1px var(--border-strong);
}
.flag svg { display: block; width: 100%; height: 100%; }
.flag-head { margin-top: var(--s-3); }

/* AI / LLM / Inference / Agent */
dl.trio { margin: 0 0 var(--s-4); display: grid; gap: var(--s-3); }
dl.trio > div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--s-4) var(--s-5); }
dl.trio dt {
  font-family: var(--font-mono); font-size: var(--fs-caption); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent-text); margin-bottom: var(--s-1);
}
dl.trio dd { margin: 0; }

ol.recipe li { margin: var(--s-2) 0; }
ul.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2); }
ul.chips li {
  margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 10px; font-size: var(--fs-small); color: var(--text);
}
ul.chips li::before { content: "“"; color: var(--accent-text); }
ul.chips li::after { content: "”"; color: var(--accent-text); }

/* ---------- Prompts (code-block container, readable sans text) ---------- */
.prompt-wrap { position: relative; margin: var(--s-2) 0 var(--s-4); }
pre.prompt {
  margin: 0; white-space: pre-wrap; word-wrap: break-word;
  font-family: var(--font-sans); font-size: calc(var(--fs-read) - 1px); line-height: 1.5;
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--s-4) var(--s-4) calc(var(--s-4) + 30px);
}
.copy-btn {
  position: absolute; right: var(--s-2); bottom: var(--s-2);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.copy-btn:hover { background: var(--surface); border-color: var(--accent); }
.copy-btn.is-copied { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }

/* ---------- Diagrams ---------- */
figure.diagram {
  margin: var(--s-5) 0; padding: var(--s-5) var(--s-4) var(--s-3);
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md);
}
figure.diagram svg { display: block; width: 100%; max-width: 30rem; height: auto; margin: 0 auto; font-family: var(--font-sans); overflow: visible; }
figure.diagram figcaption {
  margin-top: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--border);
  text-align: center; color: var(--text-muted); font-size: var(--fs-small); line-height: 1.5;
}

.d-text { fill: var(--text); }
.d-strong { fill: var(--text); font-weight: 600; }
.d-title { fill: var(--text); font-weight: 600; }
.d-muted { fill: var(--text-muted); }
.d-tag-ok { fill: var(--success); font-weight: 600; }
.d-tag-warn { fill: var(--warning); font-weight: 600; }
.d-tag-bad { fill: var(--danger); font-weight: 600; }
.d-box { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.25; }
.d-box-cool { fill: color-mix(in oklab, var(--info) 14%, var(--surface)); stroke: color-mix(in oklab, var(--info) 55%, transparent); stroke-width: 1.25; }
.d-box-accent { fill: color-mix(in oklab, var(--accent) 16%, var(--surface)); stroke: var(--accent); stroke-width: 1.25; }
.d-arrow { stroke: var(--text-muted); stroke-width: 1.75; fill: none; }
.d-arrowhead { fill: var(--text-muted); }
.d-leader { stroke: var(--text-dim); stroke-width: 1; }
.d-zone-out { fill: color-mix(in oklab, var(--danger) 13%, var(--bg-elev)); stroke: color-mix(in oklab, var(--danger) 45%, transparent); stroke-width: 1.25; }
.d-zone-mid { fill: color-mix(in oklab, var(--warning) 15%, var(--bg-elev)); stroke: color-mix(in oklab, var(--warning) 50%, transparent); stroke-width: 1.25; }
.d-zone-in { fill: color-mix(in oklab, var(--success) 18%, var(--bg-elev)); stroke: color-mix(in oklab, var(--success) 55%, transparent); stroke-width: 1.25; }
.d-ring { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.25; }
.d-ring1 { fill: var(--bg-sunken); }
.d-bull { fill: var(--accent); }
.d-dot { fill: var(--info); stroke: var(--bg-elev); stroke-width: 1.5; }
.d-sheet { fill: var(--surface); stroke: var(--border-strong); stroke-width: 1.25; }
.d-sheet-line { stroke: var(--border-strong); stroke-width: 2; stroke-linecap: round; }
.d-sheet-new { stroke: var(--accent); stroke-width: 2; }
.d-sheet-bad { fill: color-mix(in oklab, var(--danger) 18%, var(--surface)); stroke: var(--danger); stroke-width: 2; }
.d-fade1 { opacity: .6; }
.d-fade2 { opacity: .4; }
.d-fade3 { opacity: .22; }
.d-pagebar { fill: color-mix(in oklab, var(--info) 28%, var(--surface)); }
.d-hiddenbox { fill: none; stroke: var(--danger); stroke-width: 1.2; stroke-dasharray: 4 3; }
.d-hidden { fill: var(--danger); opacity: .85; font-style: italic; }

/* ---------- Toys (showcase panels) ---------- */
.toy {
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: var(--s-4) var(--s-4) var(--s-2); margin: var(--s-5) 0;
}
.toy-label {
  margin: 0 0 var(--s-3); color: var(--text-dim);
  font-size: var(--fs-caption); letter-spacing: 0.08em; text-transform: uppercase;
}
.toy-tabs {
  display: flex; gap: 2px; padding: 3px; margin-bottom: var(--s-4);
  background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.chip {
  flex: 1; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  border: 0; background: transparent; color: var(--text-muted);
  padding: 7px 8px; border-radius: 3px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border-strong); }
.toy-controls { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-4) 0; }
.btn {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-family: var(--font-sans); font-size: var(--fs-small); font-weight: 500; line-height: 1.2;
  padding: 10px 16px; border-radius: var(--radius-sm); cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--border-strong);
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.btn:hover { background: var(--surface); }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn:disabled { opacity: .45; cursor: default; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-text); }
.toy-note { font-size: calc(var(--fs-read) - 1px); color: var(--text); }
.toy-note:empty, .nw-history:empty { display: none; }
.toy-small { font-size: var(--fs-caption); color: var(--text-dim); font-family: var(--font-mono); line-height: 1.5; }

.nw-sentence { font-size: calc(var(--fs-read) + 3px); font-weight: 500; letter-spacing: -0.01em; margin: 0 0 var(--s-4); }
.nw-blank { display: inline-block; min-width: 3.5em; border-bottom: 2px solid var(--accent); color: var(--text-dim); }
.nw-blank.filled { color: var(--accent-text); }
.nw-bars { list-style: none; padding: 0; margin: 0; }
.nw-bars li {
  display: grid; grid-template-columns: minmax(6.5rem, 38%) 1fr; align-items: center; gap: var(--s-3);
  margin: 2px 0; padding: 4px 6px; border-radius: var(--radius-xs);
}
.nw-word { font-size: var(--fs-small); overflow-wrap: anywhere; }
.nw-track { height: 10px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-xs); overflow: hidden; }
.nw-fill { display: block; height: 100%; background: color-mix(in oklab, var(--accent) 45%, var(--surface)); }
.nw-bars li.chosen { background: var(--accent-soft); }
.nw-bars li.chosen .nw-word { font-weight: 600; color: var(--accent-text); }
.nw-bars li.chosen .nw-fill { background: var(--accent); }
.nw-history { font-size: var(--fs-small); color: var(--text-muted); font-family: var(--font-mono); margin-bottom: var(--s-2); }

.stack-header { font-size: var(--fs-caption); color: var(--text-dim); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: var(--s-2); }
.stack-pile {
  list-style: none; padding: var(--s-2); margin: 0 0 var(--s-3);
  background: var(--bg-sunken); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}
.blk { margin: 6px 0; padding: 8px 12px; border-radius: var(--radius-sm); font-size: var(--fs-small); line-height: 1.45; transition: opacity .3s; }
.blk-who {
  display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 2px;
}
.blk-you { background: var(--accent-soft); margin-left: 15%; }
.blk-ai { background: var(--surface); border: 1px solid var(--border); margin-right: 15%; }
.blk-mem { background: color-mix(in oklab, var(--warning) 12%, var(--surface)); border: 1px solid color-mix(in oklab, var(--warning) 45%, transparent); }
.blk-mem .blk-who { color: var(--warning); }
.blk-empty { color: var(--text-dim); font-style: italic; text-align: center; }
.blk.fresh { box-shadow: inset 0 0 0 1px var(--accent); }
.blk.fresh .blk-who { color: var(--accent-text); }
.blk-ai.used-notes { border-color: color-mix(in oklab, var(--warning) 55%, transparent); box-shadow: inset 3px 0 0 var(--warning); }
.blk-ai.used-notes .blk-who { color: var(--warning); }
.blk.fresh.used-notes { box-shadow: inset 3px 0 0 var(--warning), inset 0 0 0 1px var(--accent); }
.blk.fade1 { opacity: .6; }
.blk.fade2 { opacity: .4; }
.blk.fade3 { opacity: .22; }

/* ---------- Cheat sheet card ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-md);
  border-top: 3px solid var(--accent);
  padding: var(--s-5) var(--s-5) var(--s-3); margin: var(--s-5) 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-2); }
.card-title { font-weight: 500; font-size: var(--fs-h3); letter-spacing: var(--tr-h3); margin: 0; }
.print-btn {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase;
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: var(--radius-sm);
  padding: 8px 12px; cursor: pointer;
}
.print-btn:hover { filter: brightness(1.08); }
.card-group {
  margin: var(--s-4) 0 var(--s-1); padding-top: var(--s-3); border-top: 1px solid var(--border);
  font-size: var(--fs-caption); letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-text);
}
.card ol { margin-bottom: var(--s-2); }
.card li { margin: 6px 0; }
.card-date { margin: var(--s-4) 0 var(--s-2); font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--text-dim); }
.next-steps { color: var(--text-muted); }
.resource-list {
  list-style: none; padding: 0; margin: var(--s-4) 0 var(--s-5);
  display: grid; gap: var(--s-3);
}
.resource-list li {
  margin: 0; padding: var(--s-3) var(--s-4);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.resource-list a { font-weight: 600; }
.resource-list li.res-last { order: 99; }   /* the most technical one goes last */
.resource-list small {
  display: block; margin-top: var(--s-1); color: var(--text-muted);
  font-size: var(--fs-small); line-height: 1.45;
}

/* ---------- Glossary ---------- */
.g-search {
  width: 100%; font-family: var(--font-sans); font-size: 16px; line-height: 1.3;
  padding: 10px 12px; margin: var(--s-2) 0 var(--s-5);
  background: var(--bg-sunken); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm); outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.g-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.g-search::placeholder { color: var(--text-dim); }
dl.glossary { margin: 0; border-top: 1px solid var(--border-strong); }
.g-item { padding: var(--s-4) 0; border-bottom: 1px solid var(--border); }
.g-item dt { font-weight: 500; font-size: var(--fs-h3); letter-spacing: var(--tr-h3); color: var(--text); }
.g-item dd { margin: var(--s-1) 0 0; color: var(--text-muted); }
.g-link {
  display: inline-block; margin-top: var(--s-1);
  font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
}
.g-empty { color: var(--text-dim); font-style: italic; }

/* ---------- Pager and footer ---------- */
.pager {
  margin: var(--s-7) 0 0; padding-top: var(--s-5); border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap;
}
.pager a {
  font-size: var(--fs-small); font-weight: 500; text-decoration: none; color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
}
.pager a:hover { background: var(--surface); }
.pager-next { background: var(--accent); color: var(--accent-ink) !important; border-color: transparent !important; margin-left: auto; }
.pager-next:hover { background: var(--accent) !important; filter: brightness(1.08); }
.foot-links { margin: 6px 0 0; }
.foot-links a { color: var(--text-muted); }
.foot-links a:hover { color: var(--accent-text); }
.foot p { margin: 0; }
.foot {
  max-width: var(--frame); margin: 0 auto; padding: var(--s-5) var(--s-4) var(--s-7);
  color: var(--text-dim); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; text-align: center;
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 12mm; }
  :root, [data-theme] {
    --bg: #fff; --bg-elev: #fff; --bg-sunken: #fff; --surface: #fff;
    --text: #000; --text-muted: #333; --text-dim: #555; --border: #bbb; --border-strong: #888;
    --accent-text: #2f6b3a;
  }
  body { background: #fff; }
  .top, .rail, .pager, .foot, .copy-btn, .toy-controls, .print-btn, .g-search { display: none !important; }
  main { max-width: none; padding: 0; }
  .try, .field, .remember, .stop, .toy, figure.diagram { break-inside: avoid; }
  h2, h3, .page-head { break-after: avoid; }
  body.print-card main { padding: 0; }
  body.print-card .layout { display: block; max-width: none; padding: 0; }
  body.print-card .content { max-width: none; }
  body.print-card #page > * { display: none !important; }
  body.print-card #page > .page-body { display: block !important; }
  body.print-card .page-body > * { display: none !important; }
  body.print-card .page-body > .card { display: block !important; border: 2px solid #000; margin: 0; font-size: 11pt; line-height: 1.45; }
  body.print-card .card li { margin-bottom: 3pt; }
  .card-group { color: #000; }
}

/* ---------- Whole guide in one document (index.html?print=all, used for the PDFs) ---------- */
.pdf-cover { margin: 0 0 var(--s-6); padding-bottom: var(--s-4); border-bottom: 2px solid var(--text); }
.pdf-title { margin: 0; font-size: 34px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.1; }
.pdf-sub { margin: var(--s-2) 0 0; font-family: var(--font-mono); font-size: var(--fs-caption); color: var(--text-dim); }
.pdf-part + .pdf-part { break-before: page; margin-top: var(--s-8); }
.pdf-license {
  margin: var(--s-7) 0 0; padding-top: var(--s-3); border-top: 1px solid var(--border-strong);
  font-size: var(--fs-caption); line-height: 1.5; color: var(--text-muted);
}
.print-all .top, .print-all .foot, .print-all .rail, .print-all .pager { display: none; }

/* ---------- Phones: less nested padding, more room for the text ---------- */
@media (max-width: 719px) {
  .try, .field, .remember, .stop { padding: 14px 14px 2px; }
  .warning { padding: 14px 14px 14px 40px; }
  .warning::before { left: 13px; top: 17px; }
  .tryfirst { padding: 12px 14px 12px 38px; }
  .tryfirst::before { left: 13px; top: 17px; }
  details.starter { padding: 0 14px; }
  dl.trio > div { padding: 12px 14px; }
  blockquote.big { padding: 14px 16px; }
  pre.prompt { padding: 12px 12px 42px; }
  .try .prompt-wrap { margin-left: -4px; margin-right: -4px; }
  figure.diagram { padding: 16px 8px 10px; }
  .toy { padding: 14px 12px 6px; }
  .card { padding: 18px 14px 10px; }
}

/* "Important" box (amber), for the few points that must not be skimmed */
.keybox {
  border-left: 3px solid var(--warning); background: color-mix(in oklab, var(--warning) 9%, var(--surface));
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: var(--s-4) var(--s-5) var(--s-1); margin: var(--s-5) 0;
}
.keybox-title {
  display: flex; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-3); color: var(--warning);
  font-family: var(--font-mono); font-size: var(--fs-caption); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase;
  --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 2 L14 13 L2 13 Z'/%3E%3Cpath d='M8 7v3M8 11.5v.01'/%3E%3C/svg%3E");
}
.keybox-title::before {
  content: ""; width: 16px; height: 16px; flex-shrink: 0; background: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat; mask: var(--ico) center / contain no-repeat;
}

/* Screenshots */
figure.shot { margin: var(--s-5) 0; }
figure.shot img { display: block; width: 100%; height: auto; border: 1px solid var(--border-strong); border-radius: var(--radius-md); }
figure.shot figcaption { margin-top: var(--s-2); text-align: center; color: var(--text-muted); font-size: var(--fs-small); }

@media (max-width: 719px) {
  .keybox { padding: 14px 14px 2px; }
}
