/* AgentGate — technical report & reference implementation.
   Archival paper, carbon ink, exposed 1px hairlines. No gradients, no shadows,
   no blur, no rounded pills. Fonts are self-hosted (SIL OFL 1.1, see fonts/). */

@font-face { font-family: "Newsreader"; src: url("fonts/newsreader-var.woff2") format("woff2"); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("fonts/plex-sans-var.woff2") format("woff2"); font-weight: 400 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

:root {
  --paper: #FAF8F5;
  --paper-2: #F2EFE9;
  --ink: #141413;
  --muted: #575653;
  --rule: #D8D4CC;
  --rule-strong: #141413;
  --deny: #991B1B;
  --deny-fill: #FEF2F2;
  --pass: #166534;
  --pass-fill: #F0FDF4;
  --hold: #7C4A03;
  --hold-fill: #FBF5E8;
  --serif: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --measure: 68ch;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  font-variant-numeric: tabular-nums lining-nums;
}
a { color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--deny); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
code, pre, kbd, .mono { font-family: var(--mono); font-size: .875em; font-variant-numeric: tabular-nums slashed-zero; }
code { overflow-wrap: anywhere; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; line-height: 1.2; margin: 0; letter-spacing: -0.005em; }
p { margin: 0 0 1em; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.vis-hidden { position: absolute; left: -9999px; }
.vis-hidden:focus { left: 16px; top: 8px; background: var(--paper); padding: 6px 10px; border: 1px solid var(--ink); z-index: 10; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } }

/* ---------- classification bar + running head ---------- */
.classbar { border-bottom: 1px solid var(--rule-strong); font: 500 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.classbar .wrap { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; padding-top: 9px; padding-bottom: 9px; }
.classbar .right { color: var(--muted); }
.runhead { border-bottom: 1px solid var(--rule); background: var(--paper); position: sticky; top: 0; z-index: 5; }
.runhead .wrap { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 20px; padding-top: 10px; padding-bottom: 10px; }
.runhead .name { font: 600 14px/1.2 var(--sans); text-decoration: none; }
.runhead nav { display: flex; flex-wrap: wrap; gap: 2px 16px; font: 400 13px/1.4 var(--mono); }
.runhead nav a { text-decoration: none; color: var(--muted); }
.runhead nav a:hover { color: var(--ink); text-decoration: underline; }
@media (max-width: 720px) { .runhead { position: static; } }

/* ---------- masthead ---------- */
.masthead { padding: 48px 0 0; }
.kicker { font: 500 12px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; }
.masthead h1 { font-size: clamp(30px, 4.6vw, 50px); max-width: 22ch; }
.thesis { font: 400 clamp(17px, 1.9vw, 20px)/1.55 var(--serif); max-width: var(--measure); margin: 20px 0 28px; }
.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--rule-strong); border-left: 1px solid var(--rule); }
.meta > div { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 10px 12px; min-width: 0; }
.meta dt { font: 500 11px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.meta dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
@media (max-width: 860px) { .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 420px) { .meta { grid-template-columns: 1fr; } }

.abstract { margin: 36px 0 0; display: grid; grid-template-columns: 140px minmax(0, 1fr); border-top: 1px solid var(--rule); padding-top: 16px; gap: 0 24px; }
.abstract h2 { font: 500 12px/1.6 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.abstract p { font: 400 17px/1.6 var(--serif); max-width: var(--measure); }
@media (max-width: 720px) { .abstract { grid-template-columns: 1fr; } }

/* ---------- sections ---------- */
section { padding: 56px 0 0; }
.sec-head { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 0 24px; border-top: 1px solid var(--rule-strong); padding-top: 14px; margin-bottom: 22px; }
.sec-num { font: 500 13px/1.9 var(--mono); color: var(--muted); }
.sec-head h2 { font-size: clamp(24px, 3vw, 32px); }
.sec-head .dek { grid-column: 2; margin: 8px 0 0; color: var(--muted); max-width: var(--measure); }
@media (max-width: 720px) { .sec-head { grid-template-columns: 1fr; } .sec-head .dek { grid-column: 1; } }
.body { margin-left: 164px; }
@media (max-width: 720px) { .body { margin-left: 0; } }
.prose { max-width: var(--measure); }
.note { font-size: 13px; color: var(--muted); max-width: var(--measure); }

/* ---------- tables (Tufte-ish: few rules, all hairline) ---------- */
.tbl { border-top: 1px solid var(--rule-strong); border-bottom: 1px solid var(--rule-strong); font-size: 14px; }
.tbl th, .tbl td { text-align: left; vertical-align: top; padding: 8px 12px 8px 0; border-bottom: 1px solid var(--rule); }
.tbl thead th { font: 500 11px/1.4 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--rule-strong); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); white-space: nowrap; padding-right: 0; padding-left: 12px; }
.tbl td.num:not(:last-child), .tbl th.num:not(:last-child) { padding-right: 24px; }
.tbl tr.sep td { border-top: 1px solid var(--rule-strong); }
.tbl .k { font-family: var(--mono); font-size: 13px; }
.tbl-scroll { overflow-x: auto; }

/* status ink */
.v-pass, .v-deny, .v-hold, .v-info { font: 500 12px/1.3 var(--mono); padding: 1px 5px; border: 1px solid; white-space: nowrap; display: inline-block; }
.v-pass { color: var(--pass); background: var(--pass-fill); border-color: var(--pass); }
.v-deny { color: var(--deny); background: var(--deny-fill); border-color: var(--deny); }
#f-verdict .v-pass, #f-verdict .v-deny, #f-verdict .v-hold, #f-verdict .v-info { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.v-hold { color: var(--hold); background: var(--hold-fill); border-color: var(--hold); }
.v-info { color: var(--muted); background: var(--paper-2); border-color: var(--rule); }
.ink-pass { color: var(--pass); }
.ink-deny { color: var(--deny); }

/* ---------- latency scale (HTML so labels keep their size on phones) ---------- */
.scale { margin: 22px 0 6px; border: 1px solid var(--rule); padding: 14px 16px 10px; }
.scale figcaption { font-size: 13px; color: var(--muted); margin-top: 10px; max-width: var(--measure); }
.lat { position: relative; height: 112px; margin: 0 6px; }
.lat-budget { position: absolute; left: 0; top: 54px; height: 14px; background: var(--paper-2); border: 1px solid var(--rule); border-right: 0; }
.lat-axis { position: absolute; left: 0; right: 0; top: 68px; border-top: 1px solid var(--ink); }
.lat-tick { position: absolute; top: 0; height: 69px; border-left: 1px solid var(--ink); }
.lat-tick.ref { border-left: 1px dashed var(--ink); }
.lat-tick.max { border-left-color: var(--deny); }
.lat-tick span { position: absolute; left: 4px; font: 400 11.5px/1.2 var(--mono); white-space: nowrap; }
.lat-tick span.r1 { top: 0; } .lat-tick span.r2 { top: 16px; } .lat-tick span.r3 { top: 32px; }
.lat-tick span.left { left: auto; right: 4px; }
.lat-tick.max span { color: var(--deny); }
.lat-x { position: absolute; top: 74px; font: 400 11px/1 var(--mono); color: var(--muted); transform: translateX(-50%); }
.lat-x:first-child { transform: none; }
.lat-x.end { transform: translateX(-100%); }
.lat-legend { display: none; list-style: none; margin: 8px 0 0; padding: 0; font: 400 12px/1.6 var(--mono); }
.lat-legend li { display: inline-block; margin-right: 14px; }
.lat-legend .ink-deny { color: var(--deny); }
@media (max-width: 600px) {
  .lat { height: 70px; }
  .lat-tick { top: 34px; height: 35px; }
  .lat-tick span { display: none; }
  .lat-budget { top: 54px; }
  .lat-unit { top: 90px; }
  .lat-legend { display: block; margin-top: 22px; }
}
.lat-unit { position: absolute; top: 92px; right: 0; font: 400 11px/1 var(--mono); color: var(--muted); }

/* ---------- schematic ---------- */
.schematic { display: grid; grid-template-columns: minmax(0, 1fr) 28px minmax(0, 1.05fr) 28px minmax(0, 2.2fr) 28px minmax(0, 1.2fr); align-items: stretch; }
.node { border: 1px solid var(--ink); background: var(--paper); padding: 12px; min-width: 0; }
.node h3 { font: 600 13px/1.3 var(--sans); margin-bottom: 6px; }
.node p { font-size: 13px; color: var(--muted); margin: 0; }
.node .mono { font-size: 12px; }
.arrow { display: flex; align-items: center; justify-content: center; font: 400 16px/1 var(--mono); color: var(--ink); }
.arrow::before { content: "→"; }
.guards { border: 1px solid var(--ink); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); min-width: 0; }
.guards > div { padding: 10px 12px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); min-width: 0; }
.guards > div:nth-child(2n) { border-right: 0; }
.guards > div:nth-last-child(-n+2) { border-bottom: 0; }
.guards .tag { font: 500 11px/1 var(--mono); color: var(--muted); letter-spacing: .05em; }
.guards h3 { font: 600 13px/1.3 var(--sans); margin: 4px 0; }
.guards p { font-size: 12px; margin: 0; color: var(--muted); }
.guards-title { grid-column: 1 / -1; background: var(--paper-2); font: 500 12px/1.3 var(--mono); }
.guards-title.guards-title { border-right: 0; border-bottom: 1px solid var(--rule); }
@media (max-width: 960px) {
  .schematic { grid-template-columns: minmax(0, 1fr); }
  .arrow { height: 28px; }
  .arrow::before { content: "↓"; }
}
@media (max-width: 480px) { .guards { grid-template-columns: 1fr; } .guards > div { border-right: 0; } .guards > div:nth-last-child(-n+2) { border-bottom: 1px solid var(--rule); } .guards > div:last-child { border-bottom: 0; } }

/* ---------- trace inspector ---------- */
.tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--rule-strong); border-left: 1px solid var(--rule); }
@media (max-width: 600px) { .tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tab-btn {
  font: 400 12px/1.3 var(--mono); color: var(--muted); background: var(--paper-2);
  border: 0; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  padding: 9px 12px; cursor: pointer; text-align: left; min-width: 0; border-radius: 0;
}
.tab-btn b { font-weight: 500; color: var(--ink); margin-right: 6px; }
.tab-btn:hover { color: var(--ink); }
.tab-btn[aria-selected="true"] { background: var(--paper); color: var(--ink); border-bottom-color: var(--paper); border-top: 2px solid var(--ink); padding-top: 7px; }
.panel { border: 1px solid var(--rule); border-top: 0; padding: 18px; background: var(--paper); }
@media (max-width: 600px) { .panel { padding: 14px 12px; } }
.panel h3 { font-size: 20px; margin-bottom: 4px; }
.panel .atlas { font: 400 12px/1.4 var(--mono); color: var(--muted); }
.fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--rule); border-left: 1px solid var(--rule); margin: 14px 0; }
.fields > div { border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: 8px 10px; min-width: 0; }
.fields dt { font: 500 10.5px/1.3 var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 3px; }
.fields dd { margin: 0; font: 400 13px/1.45 var(--mono); overflow-wrap: anywhere; }
@media (max-width: 860px) { .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .fields { grid-template-columns: 1fr; } }
.steps { font-size: 13px; }
.steps td.args { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; word-break: break-word; }
.steps td:first-child { font-family: var(--mono); color: var(--muted); width: 2.5em; }
@media (max-width: 600px) {
  .steps thead { display: none; }
  .steps tr { display: grid; grid-template-columns: 2em minmax(0, 1fr) auto; border-bottom: 1px solid var(--rule); padding: 6px 0; }
  .steps td { border: 0; padding: 2px 6px 2px 0; }
  .steps td.args { grid-column: 2 / 4; }
  .steps td.num { padding-left: 0; }
}
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 10px; }
.btn {
  font: 500 13px/1.2 var(--mono); color: var(--ink); background: var(--paper);
  border: 1px solid var(--ink); border-radius: 0; padding: 8px 12px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn:hover { background: var(--ink); color: var(--paper); }
.btn.solid { background: var(--ink); color: var(--paper); }
.btn.solid:hover { background: var(--paper); color: var(--ink); }
.console {
  font: 400 12.5px/1.6 var(--mono); background: var(--paper-2); border: 1px solid var(--rule);
  padding: 12px 14px; min-height: 120px; max-height: 420px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere;
}
.console:empty::before { content: "— press Replay trace to step through the recorded calls —"; color: var(--muted); }
.console .line { display: block; }
.console .step { color: var(--ink); font-weight: 500; }
.console .ok { color: var(--pass); }
.console .warn { color: var(--hold); }
.console .bad { color: var(--deny); }
.console .dim, .console .muted { color: var(--muted); }

/* toxic-flow graph (tab 03) */
.graph { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-top: 12px; }
@media (max-width: 860px) { .graph { grid-template-columns: 1fr; } }
.graph svg { width: 100%; height: auto; border: 1px solid var(--rule); background: var(--paper); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { font: 400 12px/1.2 var(--mono); border: 1px solid var(--rule); background: var(--paper-2); color: var(--muted); padding: 6px 9px; cursor: pointer; border-radius: 0; }
.chip[data-on="true"] { border-color: var(--pass); color: var(--pass); background: var(--pass-fill); }
.flow-table td { font-family: var(--mono); font-size: 12px; overflow-wrap: anywhere; }

/* ---------- reproduce ---------- */
pre.block { background: var(--paper-2); border: 1px solid var(--rule); padding: 14px 16px; margin: 0; overflow-x: auto; font-size: 13px; line-height: 1.6; white-space: pre; }
@media (max-width: 600px) { pre.block { white-space: pre-wrap; overflow-wrap: anywhere; } }

/* ---------- scope ---------- */
.scope { border: 1px solid var(--ink); }
.scope > div { display: grid; grid-template-columns: 220px minmax(0, 1fr); border-bottom: 1px solid var(--rule); }
.scope > div:last-child { border-bottom: 0; }
.scope dt { font: 500 12px/1.5 var(--mono); padding: 12px; border-right: 1px solid var(--rule); background: var(--paper-2); }
.scope dd { margin: 0; padding: 12px; font-size: 14px; }
@media (max-width: 600px) { .scope > div { grid-template-columns: 1fr; } .scope dt { border-right: 0; border-bottom: 1px solid var(--rule); } }

/* ---------- schedule of deliverables ---------- */
.sched td, .sched th { font-size: 14px; }
.sched .tier { font: 500 12px/1.4 var(--mono); white-space: nowrap; }
.sched .title { font: 600 15px/1.3 var(--sans); }
.sched .sub { display: block; font: 400 12px/1.4 var(--mono); color: var(--muted); margin-top: 3px; }
.sched ul { margin: 0; padding-left: 1.1em; }
.sched li { margin: 0 0 3px; }
.sched .fee { display: block; font: 500 15px/1.3 var(--mono); white-space: nowrap; margin-bottom: 4px; }
.sched td.num a { font: 400 13px/1.3 var(--mono); }
.sched .fee small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }
@media (max-width: 860px) {
  .sched thead { display: none; }
  .sched tr { display: block; border-bottom: 1px solid var(--rule-strong); padding: 12px 0; }
  .sched td { display: block; border: 0; padding: 4px 0; }
  .sched td.num { text-align: left; padding-left: 0; }
}
.refs { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--rule); }
.refs li { display: grid; grid-template-columns: 3.2em minmax(0, 1fr); padding: 9px 0; border-bottom: 1px solid var(--rule); font-size: 14px; }
.refs .rn { font-family: var(--mono); color: var(--muted); }
.refs .h { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.tmpl { font: 400 12.5px/1.6 var(--mono); background: var(--paper-2); border: 1px solid var(--rule); padding: 12px 14px; white-space: pre; overflow-x: auto; margin: 10px 0; }

/* ---------- footer ---------- */
footer { margin-top: 72px; border-top: 1px solid var(--rule-strong); padding: 18px 0 36px; font-size: 13px; color: var(--muted); }
footer p { margin: 0 0 6px; }

.toast { position: fixed; bottom: 16px; left: 16px; background: var(--ink); color: var(--paper); font: 400 13px/1.3 var(--mono); padding: 8px 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
