:root {
  --paper: #cfc6b0;
  --paper-2: #b8ad93;
  --ink: #16130e;
  --rule: #3a3126;
  --flag: #c44e12;
  --scope: #1a5862;
  --ok: #2a4a28;
  --fail: #7a1c1c;
  --mute: #5c5346;
  --glow: #e8dcc4;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "IBM Plex Sans", "Source Sans 3", system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  display: grid;
  grid-template-columns: 13rem 1fr var(--console-w, clamp(20rem, 32vw, 46rem));
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
}
body.resizing { cursor: col-resize; user-select: none; }
body::before {
  content: "";
  position: fixed; inset: 0 auto 0 0; width: 0.7rem;
  background: repeating-linear-gradient(
    to bottom,
    var(--ink) 0 4px,
    transparent 4px 10px,
    var(--flag) 10px 14px,
    transparent 14px 22px
  );
  pointer-events: none;
  z-index: 4;
}
a { color: var(--scope); }
h1, h2, h3 { font-family: "IBM Plex Serif", "Newsreader", Georgia, serif; font-weight: 500; margin: 0 0 0.4rem; }
h1 { font-size: 1.7rem; letter-spacing: -0.02em; }
h2 { font-size: 1.15rem; border-bottom: 1px solid var(--rule); padding-bottom: 0.2rem; margin-top: 1.4rem; }
.eyebrow { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--flag); }
header {
  grid-column: 1 / -1;
  display: flex; align-items: baseline; gap: 1.2rem; flex-wrap: wrap;
  padding: 0.7rem 1.2rem 0.7rem 1.8rem;
  border-bottom: 2px solid var(--ink);
  background: var(--glow);
}
header .host { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.75rem; color: var(--mute); }
header .target-pick {
  margin-left: auto; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap;
}
header .target-pick label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--mute);
}
header select { width: auto; max-width: 22rem; }
.site-nav {
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
}
.site-nav a { color: var(--ink); text-decoration: none; border-bottom: 1px solid transparent; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--flag); border-bottom-color: var(--flag); }
body.doc {
  display: block;
  max-width: 54rem;
  margin: 0 auto;
  padding: 0 0 4rem;
}
body.doc header { display: flex; }
body.doc main { max-width: none; padding: 1rem 1.5rem 4rem 1.8rem; }
body.doc nav.toc {
  border-right: 0;
  padding: 0.4rem 1.8rem;
  display: flex; flex-wrap: wrap; gap: 0.35rem 1rem;
}
body.doc nav.toc a { display: inline; padding: 0; }
.doc-ctl {
  display: grid;
  grid-template-columns: 8rem 1fr 8rem 1fr;
  gap: 0.15rem 0.6rem;
  font-size: 0.8rem;
  border: 1px solid var(--rule);
  padding: 0.6rem 0.8rem;
  background: #d8cfb8;
  margin: 0.8rem 0;
}
@media print {
  body, body.doc { background: #fff; }
  body::before, aside, .target-pick, header .host { display: none !important; }
  a { color: #000; }
}
.banner {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
  border: 1px solid var(--rule);
  padding: 0.45rem 0.6rem;
  background: var(--glow);
}
.banner.viewing { border-color: var(--flag); color: var(--flag); }
nav {
  padding: 0.8rem 0.6rem 2rem 1.6rem;
  border-right: 1px solid var(--rule);
  overflow: auto;
}
nav a {
  display: block; text-decoration: none; color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.72rem;
  padding: 0.22rem 0;
}
nav a:hover, nav a:focus { color: var(--flag); }
main { padding: 1rem 1.4rem 6rem 1.2rem; overflow: auto; max-width: 52rem; }
aside {
  border-left: 1px solid var(--rule);
  background: #c4bb9f;
  padding: 0.8rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  min-height: 0;
  position: relative;                 /* anchor for the resize splitter */
  overflow: hidden;
}
/* drag-to-resize handle on the console's left edge */
.splitter {
  position: absolute; left: -3px; top: 0; bottom: 0; width: 8px;
  cursor: col-resize; z-index: 5; touch-action: none;
}
.splitter::before {
  content: ""; position: absolute; left: 3px; top: 0; bottom: 0; width: 2px;
  background: var(--rule); opacity: 0.5;
}
.splitter:hover::before, body.resizing .splitter::before { background: var(--flag); opacity: 1; }
aside h2 { margin-top: 0; font-size: 0.95rem; }
.actions { display: flex; flex-wrap: wrap; gap: 0.35rem; }
button, select {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.72rem;
  background: var(--ink); color: var(--paper);
  border: 0; padding: 0.4rem 0.55rem; cursor: pointer;
}
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--rule); }
button:hover { background: var(--flag); }
button:focus-visible, select:focus-visible, a:focus-visible { outline: 2px solid var(--flag); outline-offset: 2px; }
/* console output: a scrollable stack of per-run blocks, newest on top */
.log {
  flex: 1; min-height: 10rem;
  background: var(--ink);
  padding: 0.4rem; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column; gap: 0.4rem;
}
.log:empty::before {
  content: "run an allowlisted action — output appears here, newest first";
  color: var(--mute); font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.66rem; padding: 0.5rem;
}
.run { border: 1px solid #3a3426; background: #16130c; }
.run[open] { border-color: #4a4230; }
.run-hd {
  list-style: none; cursor: pointer;
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem;
  padding: 0.3rem 0.45rem;
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.66rem;
  color: #d8cbb0; background: #221d13;
}
.run-hd::-webkit-details-marker { display: none; }
.run-hd::before { content: "▸ "; color: var(--mute); }
.run[open] .run-hd::before { content: "▾ "; }
.run-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-st { flex: none; font-size: 0.62rem; padding: 0.05rem 0.4rem; border-radius: 2px; background: #3a3426; color: #d8cbb0; }
.run-st.ok { background: #1f3a1f; color: #9fdca0; }
.run-st.bad { background: #4a1f1f; color: #ee9b9b; }
.run-out {
  margin: 0; padding: 0.45rem 0.5rem; max-height: 26rem; overflow: auto;
  background: var(--ink); color: #cbbe9f;
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.68rem;
  white-space: pre; tab-size: 2;
}
.run-note { color: #b8ac8e; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.66rem; padding: 0.15rem 0.3rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { text-align: left; padding: 0.2rem 0.4rem; border-bottom: 1px solid var(--paper-2); vertical-align: top; }
th { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.65rem; letter-spacing: 0.08em; }
code, .mono { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.78em; }
.card { border: 1px solid var(--rule); padding: 0.7rem 0.8rem; margin: 0.6rem 0; background: #d8cfb8; }
.warn { color: var(--fail); }
.ok { color: var(--ok); }
.kvs { display: grid; grid-template-columns: 8rem 1fr; gap: 0.15rem 0.6rem; font-size: 0.85rem; }
footer {
  grid-column: 1 / -1;
  padding: 0.4rem 1.2rem 0.4rem 1.8rem;
  border-top: 1px solid var(--rule);
  font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.65rem;
  color: var(--mute);
}
@media (max-width: 960px) {
  body { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; }
  nav { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; border-right: 0; border-bottom: 1px solid var(--rule); padding-left: 1.2rem; }
  aside { border-left: 0; border-top: 1px solid var(--rule); }
  .splitter { display: none; }          /* stacked layout: no horizontal resize */
  .log { max-height: 60vh; }            /* keep the console usable when it sits under main */
  main { max-width: none; }
  body::before { width: 0.4rem; }
}
pre {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  background: #b8ad93;
  padding: 0.6rem 0.7rem;
  overflow: auto;
  border: 1px solid var(--rule);
  white-space: pre-wrap;
}
.chip {
  display: inline-block;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.65rem;
  border: 1px solid var(--rule);
  padding: 0.12rem 0.35rem;
  margin: 0.1rem 0.15rem 0.1rem 0;
}
.chip.on { background: var(--ink); color: var(--paper); }
.badge { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--flag); }
ol.tut { padding-left: 1.2rem; }
ol.tut li { margin: 0.35rem 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
aside label {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.65rem; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--mute); display: block; margin-top: 0.35rem;
}
aside select, aside input { width: 100%; }
input[type=search] {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.75rem;
  background: var(--glow); color: var(--ink);
  border: 1px solid var(--rule); padding: 0.35rem 0.45rem; width: 100%;
}
.busy { opacity: 0.55; pointer-events: none; }
@media (max-width: 960px) {
  .grid2 { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---- hand-built diagrams (offline, no deps) ---------------------------------------------------- */
figure.diagram { margin: 1.1rem 0; }
figure.diagram figcaption { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.7rem; color: var(--mute); margin-top: 0.35rem; }

/* vertical layered stack with downward flow */
.stack { display: flex; flex-direction: column; max-width: 46rem; }
.stack .layer {
  position: relative; background: var(--glow); border: 1px solid var(--rule);
  border-left: 5px solid var(--acc, var(--flag)); padding: 0.5rem 0.75rem;
}
.stack .layer + .layer { margin-top: 1.15rem; }
.stack .layer + .layer::before {
  content: "▼"; position: absolute; left: 1.2rem; top: -1rem; color: var(--mute); font-size: 0.72rem;
}
.stack .layer b { display: block; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.8rem; color: var(--ink); }
.stack .layer span { font-size: 0.72rem; color: var(--mute); }

/* responsive card grid (four libraries, pqc modes) */
.dgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0.7rem; }
.dgrid .card2 { background: var(--glow); border: 1px solid var(--rule); border-top: 4px solid var(--acc, var(--scope)); padding: 0.55rem 0.7rem; }
.dgrid .card2 h4 { margin: 0 0 0.3rem; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.82rem; }
.dgrid .card2 .sub { font-size: 0.7rem; color: var(--mute); }
.dgrid .card2 .is { font-size: 0.72rem; color: var(--ok); display: block; }
.dgrid .card2 .isnot { font-size: 0.72rem; color: var(--fail); display: block; }
.dgrid .card2 .tag { display: inline-block; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.62rem; background: var(--acc, var(--scope)); color: var(--glow); padding: 0.05rem 0.35rem; border-radius: 2px; margin-bottom: 0.3rem; }

/* horizontal seal flow */
.flow { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0; max-width: 46rem; }
.flow .step { background: var(--glow); border: 1px solid var(--rule); padding: 0.4rem 0.6rem; font-size: 0.72rem; display: flex; align-items: center; }
.flow .step b { font-family: "IBM Plex Mono", ui-monospace, monospace; }
.flow .arr { display: flex; align-items: center; color: var(--flag); padding: 0 0.35rem; font-weight: 700; }
@media (max-width: 700px) { .flow { flex-direction: column; } .flow .arr { transform: rotate(90deg); padding: 0.2rem 0; } }
