/* Agentic design systems — "Night layers"
   Layout: sticky course bar on top; on wide screens a sticky "in this section"
   list beside a single reading column. Rules, skills and tools each own one colour,
   used only when the page refers to that layer. Deliberately dark-only. */

:root {
  --ink: #12162a;
  --surface: #191e35;
  --surface-2: #20264a;
  --line: #2a3050;
  --fg: #e9ebf5;
  --fg-soft: #c9cde0;
  --muted: #a3a9c2;
  --rules: #edc06a;
  --skills: #a9b4ff;
  --tools: #7dd8cf;
  --pass: #86dba0;
  --fail: #ff9b8a;
  --display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 72px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 24px); -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background: var(--ink);
  color: var(--fg);
  font: 400 17px/1.65 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--rules); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: #f7d98f; }
:focus-visible { outline: 2px solid var(--rules); outline-offset: 3px; border-radius: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -0.015em; line-height: 1.1; text-wrap: balance; margin: 0; }
p, li { text-wrap: pretty; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.35em; }
strong { font-weight: 600; color: #fff; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -48px; background: var(--rules); color: var(--ink); padding: 10px 14px; border-radius: var(--radius-sm); z-index: 50; }
.skip:focus { top: 12px; }
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px)); }

/* ---------------------------------------------------------------- header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(18, 22, 42, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.bar {
  max-width: 1280px; margin: 0 auto;
  padding-inline: max(20px, env(safe-area-inset-left, 0px)) max(20px, env(safe-area-inset-right, 0px));
  display: flex; align-items: stretch; gap: 32px; min-height: var(--header-h);
}
.brand { display: flex; align-items: center; gap: 12px; color: var(--fg); text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 17px; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { color: #fff; }
.mark { display: grid; gap: 3px; width: 22px; }
.mark span { height: 4px; border-radius: 1px; }
.mark .m1 { background: var(--rules); }
.mark .m2 { background: var(--skills); margin-left: 4px; }
.mark .m3 { background: var(--tools); margin-left: 8px; }
.sections { flex: 1; min-width: 0; }
.sections ol { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 32px; height: 100%; }
.sections a {
  white-space: nowrap;
  height: 100%; display: flex; flex-direction: column; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.3;
  border-bottom: 2px solid transparent; padding-top: 2px;
}
.sections a:hover { color: var(--fg); }
.sections a[aria-current="page"] { color: var(--fg); font-weight: 600; border-bottom-color: var(--rules); }
.sections .snum { font-size: 12px; font-weight: 500; }
.sections a[aria-current="page"] .snum { color: var(--rules); }
.sources-link { display: flex; align-items: center; color: var(--muted); text-decoration: none; font-size: 14px; border-bottom: 2px solid transparent; }
.sources-link:hover, .sources-link[aria-current="page"] { color: var(--fg); }
.sources-link[aria-current="page"] { border-bottom-color: var(--fg); }

@media (max-width: 1120px) {
  :root { --header-h: 108px; }
  .bar { flex-wrap: wrap; gap: 0 20px; }
  .brand { height: 52px; }
  .sources-link { margin-left: auto; height: 52px; }
  .sections { order: 3; flex-basis: 100%; overflow-x: auto; margin-inline: -20px; padding-inline: 20px; scrollbar-width: none; }
  .sections::-webkit-scrollbar { display: none; }
  .sections ol { display: flex; gap: 20px; }
  .sections li { flex: 0 0 auto; }
  .sections a { height: 56px; }
  .sections .snum { display: none; }
}

/* ---------------------------------------------------------------- layout */
.layout {
  max-width: 1280px; margin: 0 auto;
  padding: 56px max(20px, env(safe-area-inset-right, 0px)) 96px max(20px, env(safe-area-inset-left, 0px));
  display: grid; grid-template-columns: 250px minmax(0, 760px); gap: 72px; justify-content: center;
}
.toc { position: relative; }
.toc-box { position: sticky; top: calc(var(--header-h) + 32px); }
.toc-box summary { list-style: none; display: flex; flex-direction: column; gap: 2px; margin-bottom: 14px; cursor: default; }
.toc-box summary::-webkit-details-marker { display: none; }
.toc-label { font-size: 12px; color: var(--muted); }
.toc-title { font-family: var(--display); font-weight: 700; font-size: 17px; line-height: 1.25; }
.toc ol { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc li a {
  display: block; padding: 7px 0 7px 16px; margin-left: -1px; border-left: 2px solid transparent;
  color: var(--muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.toc li a:hover { color: var(--fg); }
.toc li a.is-active { color: var(--fg); border-left-color: var(--fg); font-weight: 500; }

@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; padding-top: 0; }
  .toc { position: sticky; top: var(--header-h); z-index: 10; margin-inline: -20px; }
  .toc-box { position: static; background: var(--surface); border-bottom: 1px solid var(--line); }
  .toc-box summary { flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 12px 20px; min-height: 48px; cursor: pointer; }
  .toc-box summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: -4px; flex: 0 0 auto; }
  .toc-box[open] summary::after { transform: rotate(-135deg); margin-top: 4px; }
  .toc-title { font-size: 15px; flex: 1; }
  .toc-label { order: 2; }
  .toc ol { border-left: 0; padding: 0 20px 12px; max-height: 60vh; overflow-y: auto; }
  .toc li a { padding-left: 12px; }
  .content { padding-top: 40px; }
}

/* ---------------------------------------------------------------- content */
.content { min-width: 0; display: flex; flex-direction: column; gap: 56px; }
.content--wide { max-width: 1000px; margin: 0 auto; padding: 56px max(20px, env(safe-area-inset-right, 0px)) 96px max(20px, env(safe-area-inset-left, 0px)); }
.page-head { display: flex; flex-direction: column; gap: 16px; }
.eyebrow { margin: 0; font-size: 14px; color: var(--muted); }
.page-head h1 { font-size: clamp(38px, 6vw, 58px); line-height: 1.02; letter-spacing: -0.025em; }
.page-head p:not(.eyebrow) { margin: 0; font-size: 19px; color: var(--fg-soft); }

.part { display: flex; flex-direction: column; gap: 18px; }
.part > * { margin: 0; }
.part h2 { font-size: clamp(26px, 3.4vw, 32px); }
.part h3 { font-size: 21px; margin-top: 10px; letter-spacing: -0.01em; }
.part p, .part li { color: var(--fg-soft); }
.part ul, .part ol { padding-left: 22px; display: flex; flex-direction: column; gap: 10px; }
.part li::marker { color: var(--muted); }

.part--lead { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; gap: 14px; }
.part--lead h2 { font-family: var(--body); font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.part--lead p { font-size: 19px; line-height: 1.6; color: var(--fg); }
.part--quiet h2 { font-size: 22px; }
.part--quiet p, .part--quiet li { font-size: 16px; }

blockquote { margin: 0; padding: 20px 24px; background: var(--surface); border-radius: var(--radius); font-size: 18px; color: var(--fg); }
blockquote p { margin: 0; }

.cite {
  font-family: var(--mono); font-size: 0.72em; font-weight: 500; text-decoration: none;
  color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0.05em 0.35em;
  vertical-align: 0.12em; white-space: nowrap;
}
.cite:hover { color: var(--ink); background: var(--rules); border-color: var(--rules); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 15px; }
th, td { text-align: left; vertical-align: top; padding: 14px 16px; border-bottom: 1px solid var(--line); }
thead th { background: var(--surface); font-weight: 600; color: var(--fg); font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
td { color: var(--fg-soft); min-width: 160px; }

.checklist { list-style: none; padding-left: 0 !important; }
.checklist li { display: flex; gap: 12px; align-items: flex-start; }
.check { flex: 0 0 18px; height: 18px; margin-top: 5px; border: 2px solid var(--muted); border-radius: 4px; }

.pager { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; padding-top: 32px; border-top: 1px solid var(--line); }
.pager a { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--fg); }
.pager a:hover { border-color: var(--muted); }
.pager span { font-size: 13px; color: var(--muted); }
.pager b { font-weight: 600; font-size: 17px; }
.pager .next { text-align: right; }

/* ---------------------------------------------------------------- home */
.hero { border-bottom: 1px solid var(--line); padding-block: 88px 72px; }
.hero .wrap { display: flex; flex-direction: column; gap: 24px; }
.hero h1 { font-size: clamp(48px, 9vw, 104px); line-height: 0.95; letter-spacing: -0.035em; max-width: 12ch; }
.hero-intro { display: flex; flex-direction: column; gap: 16px; max-width: 62ch; }
.hero-intro p { margin: 0; font-size: 19px; color: var(--fg-soft); }
.hero-intro p:first-child { font-size: 22px; color: var(--fg); }
.hero p { margin: 0; }
.button { display: inline-flex; align-items: center; min-height: 48px; padding: 0 22px; border-radius: var(--radius-sm); background: var(--rules); color: var(--ink); font-weight: 600; text-decoration: none; }
.button:hover { background: #f7d98f; color: var(--ink); }
.home-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(460px, 100%), 1fr)); gap: 56px 72px; padding-block: 72px 96px; }
.home-body .part:first-child { grid-column: 1 / -1; }
.home-body #reading-order ol { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: 16px; counter-reset: sec; }
.home-body #reading-order li {
  counter-increment: sec; position: relative; display: flex; flex-direction: column; gap: 6px;
  padding: 56px 22px 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: 15px;
}
.home-body #reading-order li::before { content: "Section " counter(sec); position: absolute; top: 20px; left: 22px; font-size: 12px; color: var(--muted); }
.home-body #reading-order li a { font-family: var(--display); font-weight: 700; font-size: 20px; line-height: 1.2; color: var(--fg); text-decoration: none; }
.home-body #reading-order li a::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.home-body #reading-order li:hover { border-color: var(--muted); }

/* ---------------------------------------------------------------- sources */
.sources { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.source { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 16px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.source:target { background: var(--surface); border-radius: var(--radius); padding-inline: 16px; }
.sid { font-family: var(--mono); font-size: 14px; color: var(--muted); padding-top: 2px; }
.sbody { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.stitle { font-weight: 600; font-size: 18px; color: var(--fg); overflow-wrap: anywhere; }
.smeta { font-size: 15px; color: var(--muted); }
.source dl { margin: 6px 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); gap: 8px 24px; font-size: 14px; }
.source dt { color: var(--muted); font-size: 12px; }
.source dd { margin: 0; color: var(--fg-soft); }

/* ---------------------------------------------------------------- footer */
.site-footer { border-top: 1px solid var(--line); padding-block: 40px; font-size: 14px; color: var(--muted); }
.site-footer p { margin: 0 0 8px; max-width: 70ch; }

/* ---------------------------------------------------------------- figures */
.fig { margin: 8px 0; display: flex; flex-direction: column; gap: 12px; }
.fig figcaption { font-size: 14px; color: var(--muted); line-height: 1.5; }

/* anatomy */
.anatomy { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 10px; }
.anatomy-stack { display: flex; flex-direction: column; gap: 6px; }
.layer { display: flex; flex-direction: column; gap: 2px; padding: 14px 18px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--line); }
.layer b { font-weight: 600; color: var(--fg); }
.layer span { font-size: 14px; color: var(--muted); }
.layer code { font-size: 12px; }
.layer.l4 { margin-inline: 0; }
.layer.l3 { margin-inline: 12px; }
.layer.l2 { margin-inline: 24px; }
.layer.l1 { margin-inline: 36px; background: var(--surface-2); }
.anatomy-gov { display: flex; flex-direction: column; gap: 6px; justify-content: center; padding: 16px; border: 1px dashed var(--muted); border-radius: var(--radius-sm); }
.anatomy-gov span { font-size: 14px; color: var(--muted); }
@media (max-width: 560px) {
  .anatomy { grid-template-columns: minmax(0, 1fr); }
  .layer.l3, .layer.l2, .layer.l1 { margin-inline: 0; }
}

/* qualities */
.qualities { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.mock-stage { background: #e9ecf3; padding: 32px 24px; display: flex; align-items: center; justify-content: center; }
.mock-card { width: 100%; max-width: 340px; background: #fff; color: #161b2e; border-radius: 8px; padding: 18px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 8px 24px rgba(22,27,46,0.12); font-size: 14px; }
.mock-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge-ok { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: #d9f2e1; color: #17603a; }
.mock-line { height: 8px; border-radius: 4px; background: #edf0f4; }
.mock-line.short { width: 72%; }
.mock-note { font-size: 13px; color: #5a6275; }
.verdicts { list-style: none; margin: 0; padding: 8px 24px; display: flex; flex-direction: column; background: var(--surface); }
.verdicts li { display: grid; grid-template-columns: 76px minmax(0, 1fr); gap: 14px; padding: 16px 0; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--fg-soft); }
.verdicts li:last-child { border-bottom: 0; }
.verdicts b { display: block; color: var(--fg); font-weight: 600; }
.verdict { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border-radius: 4px; font-size: 13px; font-weight: 600; width: fit-content; }
.verdict.pass { color: var(--pass); background: rgba(134, 219, 160, 0.12); }
.verdict.fail { color: var(--fail); background: rgba(255, 155, 138, 0.12); }

/* flows */
.flow { list-style: none; margin: 0; padding: 0 !important; display: flex !important; flex-direction: row !important; align-items: stretch; gap: 8px !important; }
.flow-step { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg) !important; font-size: 15px; }
.flow-step--key { border-color: var(--rules); }
.flow-step b { font-weight: 600; }
.flow-big { font-family: var(--display); font-size: 22px; line-height: 1.15; }
.flow-label { font-size: 12px; color: var(--muted); }
.flow-step--key .flow-label { color: var(--rules); }
.flow-sep { display: flex; align-items: center; justify-content: center; color: var(--muted); flex: 0 0 auto; }
.rule { display: block; background: none; border: 0; padding: 0; font-size: 13px; line-height: 1.7; color: var(--fg); }
.rule b { color: var(--rules); font-weight: 500; }
.mini-dialog { display: flex; flex-direction: column; gap: 6px; background: #fff; color: #161b2e; border-radius: 6px; padding: 12px; font-size: 13px; }
.mini-dialog b { font-size: 14px; }
.mini-actions { display: flex; justify-content: flex-end; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.mini-btn { font-size: 12px; padding: 5px 9px; border-radius: 4px; border: 1px solid #c3c8d4; }
.mini-btn.danger { background: #b4232a; border-color: #b4232a; color: #fff; font-weight: 600; }
.flow--five { flex-direction: column !important; }
.flow--five .flow-step { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 4px 14px; padding: 14px 18px; }
.flow--five .flow-label { font-family: var(--mono); flex: 0 0 auto; }
.flow--five .flow-step .muted { flex-basis: 100%; padding-left: 22px; font-size: 14px; }
.flow--five .flow-sep { transform: rotate(90deg); height: 20px; }
@media (max-width: 680px) {
  .flow:not(.flow--five) { flex-direction: column !important; }
  .flow:not(.flow--five) .flow-sep { transform: rotate(90deg); height: 20px; }
}

/* context timeline */
.timeline-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.timeline { min-width: 640px; table-layout: fixed; font-size: 14px; }
.timeline th, .timeline td { padding: 14px 10px; border-bottom: 1px solid var(--line); }
.timeline thead th { background: transparent; font-weight: 400; color: var(--muted); border-left: 1px solid var(--line); }
.timeline thead th:first-child { border-left: 0; width: 120px; font-size: 12px; padding-left: 18px; }
.timeline thead b { display: block; color: var(--fg); font-weight: 600; }
.timeline thead span { font-size: 13px; }
.timeline tbody th { padding-left: 18px; font-weight: 400; }
.timeline tbody th b { display: block; font-weight: 600; }
.timeline tbody th span { font-size: 13px; color: var(--muted); }
.timeline tbody tr:last-child th, .timeline tbody tr:last-child td { border-bottom: 0; }
.timeline td { min-width: 0; vertical-align: middle; }
.t-rules { color: var(--rules); } .t-skills { color: var(--skills); } .t-tools { color: var(--tools); }
.tl-bar { display: block; overflow-wrap: anywhere; padding: 9px 12px; border-radius: 4px; font-family: var(--mono); font-size: 12.5px; line-height: 1.4; color: var(--ink); }
.tl-bar-rules { background: var(--rules); }
.tl-bar-skills { background: var(--skills); }
.tl-bar-tools { background: var(--tools); }
.tl-bar-skills-ghost { border: 1px dashed var(--skills); color: var(--skills); font-family: var(--body); font-size: 13px; }
