:root {
  --bg: #fafaf8; --panel: #ffffff; --ink: #1c2430; --muted: #5c6773;
  --line: #e3e2dd; --accent: #0e6e6b; --accent-ink: #ffffff;
  --code-bg: #f1f3f2; --quote-bg: #f6f5f0;
  --tier-a: #0e6e6b; --tier-a-bg: #e3f1f0; --tier-b: #8a5a00; --tier-b-bg: #fdf3e0;
  --bad: #a33a2a; --bad-bg: #fbeae7; --ok: #2c6e3f; --ok-bg: #e7f3ea;
  --chip-s1: #24457a; --chip-s2: #4a3a7a; --chip-int: #5c6773;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181d; --panel: #1b2129; --ink: #e6e9ed; --muted: #98a2ad;
    --line: #2b333d; --accent: #4cc2bd; --accent-ink: #10221f;
    --code-bg: #232b34; --quote-bg: #20262e;
    --tier-a: #58c7c1; --tier-a-bg: #16333290; --tier-b: #e0a94f; --tier-b-bg: #3a2d1290;
    --bad: #e08373; --bad-bg: #40201b90; --ok: #7cc490; --ok-bg: #1c331f90;
    --chip-s1: #8fb0e8; --chip-s2: #b3a1e8; --chip-int: #98a2ad;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre {
  font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  font-size: .875em;
}
code { background: var(--code-bg); padding: .1em .35em; border-radius: 4px; }
pre {
  background: var(--code-bg); padding: 1rem; border-radius: 8px;
  overflow-x: auto; line-height: 1.45;
}
pre code { background: none; padding: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .7rem 1.4rem; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.brand { display: flex; gap: .6rem; align-items: center; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .mark {
  background: var(--accent); color: var(--accent-ink); width: 2rem; height: 2rem;
  display: grid; place-items: center; border-radius: 8px; font-size: 1.2rem;
}
.brand small { display: block; color: var(--muted); font-size: .72rem; }
.topbar nav { display: flex; gap: 1.1rem; flex-wrap: wrap; }
.topbar nav a { color: var(--ink); font-size: .92rem; }

.provenance-strip {
  padding: .5rem 1.4rem; font-size: .82rem; color: var(--muted);
  border-bottom: 1px solid var(--line); background: var(--panel);
}

.layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  gap: 2rem; max-width: 1280px; margin: 0 auto; padding: 1.6rem 1.4rem 3rem;
}
.layout.no-rail { grid-template-columns: minmax(0, 1fr); max-width: 980px; }
@media (max-width: 980px) { .layout { grid-template-columns: minmax(0, 1fr); } }

h1 { font-size: 1.7rem; line-height: 1.25; margin: .4rem 0 1rem; }
h2 { font-size: 1.25rem; margin-top: 2rem; }
h3 { font-size: 1.05rem; }
.lede { color: var(--muted); font-size: 1.05rem; max-width: 62ch; }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 1.1rem 1.3rem; margin: 1rem 0;
}
.grid2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: .45rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
.tablewrap { overflow-x: auto; }

.method {
  display: inline-block; min-width: 3.2rem; text-align: center;
  font-family: ui-monospace, monospace; font-size: .74rem; font-weight: 700;
  padding: .15rem .45rem; border-radius: 5px;
}
.method-get { background: var(--ok-bg); color: var(--ok); }
.method-post { background: #e8ecf7; color: var(--chip-s1); }
@media (prefers-color-scheme: dark) { .method-post { background: #22304a; } }

.tier {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: .12rem .5rem; border-radius: 99px; letter-spacing: .02em;
}
.tier-a { background: var(--tier-a-bg); color: var(--tier-a); }
.tier-b { background: var(--tier-b-bg); color: var(--tier-b); }

.chip {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: .1rem .5rem; border-radius: 5px; border: 1px solid var(--line);
}
.chip-s1 { color: var(--chip-s1); }
.chip-s2 { color: var(--chip-s2); }
.chip-int, .chip-s3, .chip-s4, .chip-s5 { color: var(--chip-int); border-style: dashed; }

.badge-dep {
  background: var(--bad-bg); color: var(--bad); font-size: .7rem; font-weight: 700;
  padding: .12rem .5rem; border-radius: 99px;
}
.badge-step {
  background: var(--code-bg); color: var(--muted); font-size: .7rem; font-weight: 700;
  padding: .12rem .5rem; border-radius: 99px;
}
.badge-ok { background: var(--ok-bg); color: var(--ok); font-size: .7rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; }
.badge-bad { background: var(--bad-bg); color: var(--bad); font-size: .7rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; }
.badge-info { background: var(--code-bg); color: var(--muted); font-size: .7rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; }

.evidence-rail {
  position: sticky; top: 4.4rem; align-self: start;
  max-height: calc(100vh - 5.4rem); overflow-y: auto;
  border-left: 1px solid var(--line); padding-left: 1.4rem;
}
.evidence-rail h2 { margin: 0; font-size: 1rem; }
.rail-sub { color: var(--muted); font-size: .8rem; margin: .2rem 0 1rem; }
.ev-item { margin-bottom: 1.1rem; }
.ev-item blockquote {
  margin: 0 0 .4rem; padding: .6rem .8rem; background: var(--quote-bg);
  border-left: 3px solid var(--accent); border-radius: 0 6px 6px 0;
  font-size: .84rem; white-space: pre-wrap;
}
.ev-internal {
  margin: 0 0 .4rem; padding: .6rem .8rem; background: var(--code-bg);
  border-left: 3px dashed var(--muted); border-radius: 0 6px 6px 0;
  font-size: .84rem; color: var(--muted); font-style: italic;
}
.ev-meta { display: flex; gap: .4rem; align-items: baseline; flex-wrap: wrap; }
.ev-loc { color: var(--muted); font-size: .75rem; }
.rail-note { color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line); padding-top: .8rem; }

.endpoint-row { display: flex; gap: .7rem; align-items: baseline; padding: .45rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.endpoint-row:last-child { border-bottom: 0; }
.endpoint-row .path { font-family: ui-monospace, monospace; font-size: .85rem; }

.resp-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.resp-tab {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 6px; padding: .3rem .7rem; font-size: .8rem; cursor: pointer;
}
.resp-tab.on { border-color: var(--accent); color: var(--accent); font-weight: 700; }

.sim-controls { display: flex; gap: .6rem; flex-wrap: wrap; margin: 1rem 0; }
button.step-btn {
  border: 1px solid var(--accent); background: var(--panel); color: var(--accent);
  border-radius: 8px; padding: .5rem .9rem; font-size: .88rem; cursor: pointer;
  font-weight: 600;
}
button.step-btn:hover { background: var(--accent); color: var(--accent-ink); }
button.step-btn.done { border-color: var(--ok); color: var(--ok); }
button.reset-btn {
  border: 1px solid var(--line); background: none; color: var(--muted);
  border-radius: 8px; padding: .5rem .9rem; cursor: pointer;
}
.sim-log { max-height: 460px; overflow-y: auto; }
.sim-entry { margin-bottom: 1rem; }
.sim-entry .req { font-family: ui-monospace, monospace; font-size: .84rem; font-weight: 700; }
.sim-entry .teach {
  font-size: .86rem; color: var(--muted); border-left: 3px solid var(--tier-b);
  padding: .3rem .7rem; margin-top: .4rem;
}
.sim-status { font-size: .85rem; color: var(--muted); margin-top: .4rem; }

.searchbox {
  width: 100%; max-width: 420px; padding: .55rem .8rem; font-size: .95rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
  color: var(--ink);
}
details.src summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.footer {
  border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem;
  padding: 1.2rem 1.4rem 2rem; max-width: 1280px; margin: 0 auto;
}
.stat { text-align: center; }
.stat .n { font-size: 1.9rem; font-weight: 800; color: var(--accent); }
.stat .l { color: var(--muted); font-size: .8rem; }
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .6rem; }
@media (max-width: 640px) { .statgrid { grid-template-columns: repeat(2, 1fr); } }
.try-panel textarea, .try-panel input[type=text] {
  width: 100%; font-family: ui-monospace, monospace; font-size: .82rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--code-bg);
  color: var(--ink); padding: .6rem;
}
.mode-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mode-seg button { border: 0; background: var(--panel); color: var(--muted); padding: .4rem .9rem; cursor: pointer; font-size: .84rem; }
.mode-seg button.on { background: var(--accent); color: var(--accent-ink); font-weight: 700; }
.notice { border-left: 3px solid var(--tier-b); background: var(--tier-b-bg); padding: .7rem 1rem; border-radius: 0 8px 8px 0; font-size: .9rem; }
.notice-bad { border-left-color: var(--bad); background: var(--bad-bg); }
