/* OP_DROP protocol site: mechanical-apparatus visual language.
   Dark slate base, one luminous cyan accent for the payload path. */

:root {
  color-scheme: light dark;

  --slate-0: #f2f5f7;
  --slate-1: #ffffff;
  --slate-2: #e7ecf0;
  --rule: #c3cfd9;
  --rule-strong: #93a4b3;
  --ink: #131c25;
  --ink-muted: #48596a;
  --accent: #06697a;
  --accent-soft: #d7f0f4;
  --accent-line: #0d8ea3;
  --warn: #8a4b00;
  --warn-soft: #fdefdc;
  --bad: #96222a;
  --bad-soft: #fbe6e7;
  --good: #1c6134;
  --good-soft: #dff0e3;

  --shadow: 0 1px 0 var(--rule);
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;

  --measure: 74ch;
  --gap: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --slate-0: #0d141b;
    --slate-1: #141d26;
    --slate-2: #1b2733;
    --rule: #2a3846;
    --rule-strong: #43576b;
    --ink: #dde6ee;
    --ink-muted: #9aabbb;
    --accent: #56dced;
    --accent-soft: #10333c;
    --accent-line: #3fc3d6;
    --warn: #f0b45f;
    --warn-soft: #33260f;
    --bad: #f18b90;
    --bad-soft: #351a1c;
    --good: #74d296;
    --good-soft: #13301f;
  }
}

:root[data-theme="dark"] {
  --slate-0: #0d141b;
  --slate-1: #141d26;
  --slate-2: #1b2733;
  --rule: #2a3846;
  --rule-strong: #43576b;
  --ink: #dde6ee;
  --ink-muted: #9aabbb;
  --accent: #56dced;
  --accent-soft: #10333c;
  --accent-line: #3fc3d6;
  --warn: #f0b45f;
  --warn-soft: #33260f;
  --bad: #f18b90;
  --bad-soft: #351a1c;
  --good: #74d296;
  --good-soft: #13301f;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--slate-0);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ---------- structural type ---------- */

h1, h2, h3, h4 {
  font-weight: 620;
  line-height: 1.22;
  margin: 2.4rem 0 0.7rem;
  letter-spacing: -0.012em;
}
h1 { font-size: clamp(1.7rem, 1.2rem + 2.2vw, 2.5rem); margin-top: 0; }
h2 { font-size: clamp(1.3rem, 1.05rem + 1.1vw, 1.65rem); }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.97rem; }

h2::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 2px;
  background: var(--accent-line);
  margin-bottom: 0.7rem;
}

p, li { max-width: var(--measure); }
p { margin: 0 0 1rem; }
ul, ol { padding-left: 1.25rem; margin: 0 0 1rem; }
li { margin-bottom: 0.35rem; }

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }

:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
  border-radius: 2px;
}

code, kbd, samp, pre { font-family: var(--mono); }
code {
  font-size: 0.88em;
  background: var(--slate-2);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.06em 0.32em;
  word-break: break-word;
}
pre {
  background: var(--slate-1);
  border: 1px solid var(--rule);
  border-left: 3px solid var(--accent-line);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  font-size: 0.82rem;
  line-height: 1.55;
  margin: 0 0 1.2rem;
}
pre code { background: none; border: 0; padding: 0; font-size: inherit; }

.label {
  font-size: 0.68rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-muted);
}

/* ---------- skip link ---------- */

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--slate-0);
  padding: 0.6rem 1rem;
  z-index: 100;
  font-weight: 700;
}
.skip:focus { left: 0; }

/* ---------- masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--rule);
  background: var(--slate-1);
  position: sticky;
  top: 0;
  z-index: 40;
}
.masthead-in {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.98rem;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.brand svg { flex: none; }
.brand:hover { color: var(--accent); }
.brand-sub {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  border-left: 1px solid var(--rule-strong);
  padding-left: 0.55rem;
}
.masthead-tools { margin-left: auto; display: flex; gap: 0.5rem; align-items: center; }

.tbtn {
  font: inherit;
  font-size: 0.78rem;
  background: var(--slate-2);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.tbtn:hover { border-color: var(--rule-strong); }

/* ---------- shell ---------- */

.shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem 4rem;
  display: grid;
  grid-template-columns: 15rem minmax(0, 1fr);
  gap: 2.4rem;
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
}

.sidebar {
  padding-top: 2rem;
  align-self: start;
  position: sticky;
  top: 4rem;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
}
@media (max-width: 900px) {
  .sidebar { position: static; max-height: none; padding-top: 1.2rem; }
}
.sidebar nav ul { list-style: none; padding: 0; margin: 0 0 1.4rem; }
.sidebar nav li { margin: 0; }
.sidebar nav a {
  display: block;
  padding: 0.3rem 0 0.3rem 0.75rem;
  border-left: 2px solid var(--rule);
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.88rem;
}
.sidebar nav a:hover { color: var(--ink); border-left-color: var(--rule-strong); }
.sidebar nav a[aria-current="page"] {
  color: var(--accent);
  border-left-color: var(--accent-line);
  font-weight: 640;
}
.sidebar .label { display: block; margin: 0 0 0.5rem; }

main { padding-top: 2rem; min-width: 0; }

/* ---------- technical panel ---------- */

.panel {
  position: relative;
  background: var(--slate-1);
  border: 1px solid var(--rule);
  padding: 1.1rem 1.2rem;
  margin: 0 0 1.4rem;
}
.panel > :last-child { margin-bottom: 0; }
.panel::before, .panel::after {
  content: "";
  position: absolute;
  width: 9px;
  height: 9px;
  border: 1px solid var(--accent-line);
  pointer-events: none;
}
.panel::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.panel::after { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

.panel > .label { display: block; margin-bottom: 0.5rem; }

.note {
  border-left: 3px solid var(--accent-line);
  background: var(--accent-soft);
  padding: 0.8rem 1rem;
  margin: 0 0 1.3rem;
}
.note > :last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--warn); background: var(--warn-soft); }
.note.bad { border-left-color: var(--bad); background: var(--bad-soft); }

/* ---------- hero ---------- */

.hero { padding: 0.5rem 0 0.5rem; }
.hero .kicker {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.7rem;
}
.hero .lede {
  font-size: 1.1rem;
  color: var(--ink-muted);
  max-width: 62ch;
}

.specplate {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  border: 1px solid var(--rule);
  background: var(--slate-1);
  margin: 1.6rem 0;
}
.specplate div {
  padding: 0.7rem 0.85rem;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.specplate dt, .specplate .k {
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
  font-weight: 700;
  margin-bottom: 0.2rem;
}
.specplate .v { font-family: var(--mono); font-size: 0.86rem; }

/* ---------- cards ---------- */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1rem;
  margin: 1.4rem 0;
}
.card {
  display: block;
  border: 1px solid var(--rule);
  background: var(--slate-1);
  padding: 0.95rem 1rem;
  text-decoration: none;
  color: var(--ink);
}
.card:hover { border-color: var(--accent-line); }
.card h3 { margin: 0 0 0.3rem; font-size: 0.98rem; color: var(--accent); }
.card p { margin: 0; font-size: 0.87rem; color: var(--ink-muted); }

/* ---------- tables ---------- */

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  margin: 0 0 1.4rem;
  background: var(--slate-1);
}
table { border-collapse: collapse; width: 100%; font-size: 0.87rem; }
caption {
  text-align: left;
  padding: 0.6rem 0.8rem;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-muted);
  border-bottom: 1px solid var(--rule);
}
th, td {
  text-align: left;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid var(--rule);
  vertical-align: top;
}
th { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td code { white-space: nowrap; }
.num { text-align: right; font-family: var(--mono); }

/* ---------- rule list (normative) ---------- */

.rules { list-style: none; padding: 0; counter-reset: none; }
.rules > li {
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr);
  gap: 0.9rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
  max-width: none;
  margin: 0;
}
.rules > li:last-child { border-bottom: 1px solid var(--rule); }
.rules .rid {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  padding-top: 0.12rem;
}
.rules .rbody > :last-child { margin-bottom: 0; }
.rules .rbody p { max-width: none; }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 0.1rem 0.42rem;
  border-radius: 2px;
  border: 1px solid currentColor;
  white-space: nowrap;
}
.badge.ok { color: var(--good); background: var(--good-soft); }
.badge.no { color: var(--bad); background: var(--bad-soft); }
.badge.part { color: var(--warn); background: var(--warn-soft); }

/* ---------- figures / diagrams ---------- */

figure {
  margin: 1.6rem 0;
  border: 1px solid var(--rule);
  background: var(--slate-1);
  padding: 1rem;
}
figure svg { display: block; width: 100%; height: auto; }
figcaption {
  font-size: 0.8rem;
  color: var(--ink-muted);
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--rule);
  max-width: none;
}
.figscroll { overflow-x: auto; }
.figscroll > svg { min-width: 34rem; }
.figwide > svg { min-width: 44rem; }

/* SVG token classes, shared by every diagram */
.d-bg { fill: var(--slate-2); }
.d-box { fill: var(--slate-2); stroke: var(--rule-strong); stroke-width: 1; }
.d-box-a { fill: var(--accent-soft); stroke: var(--accent-line); stroke-width: 1.5; }
.d-box-mute { fill: none; stroke: var(--rule); stroke-width: 1; stroke-dasharray: 3 3; }
.d-lead { stroke: var(--rule-strong); stroke-width: 1; fill: none; }
.d-lead-a { stroke: var(--accent-line); stroke-width: 1.25; fill: none; }
.d-arrow { fill: var(--rule-strong); }
.d-arrow-a { fill: var(--accent-line); }
.d-t { fill: var(--ink); font-family: var(--sans); font-size: 11px; }
.d-tm { fill: var(--ink); font-family: var(--mono); font-size: 11px; }
.d-tmute { fill: var(--ink-muted); font-family: var(--sans); font-size: 10px; }
.d-ta { fill: var(--accent); font-family: var(--mono); font-size: 11px; font-weight: 600; }
.d-cap { fill: var(--ink-muted); font-family: var(--sans); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; font-weight: 700; }
.d-num { fill: var(--slate-1); }
.d-numring { fill: none; stroke: var(--accent-line); stroke-width: 1.25; }
.d-numtext { fill: var(--accent); font-family: var(--mono); font-size: 10px; font-weight: 700; }

/* ---------- search ---------- */

.searchbox { position: relative; }
.searchbox input {
  font: inherit;
  font-size: 0.85rem;
  width: 12rem;
  max-width: 45vw;
  padding: 0.35rem 0.6rem;
  background: var(--slate-0);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.searchbox input::placeholder { color: var(--ink-muted); }
#search-results {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  width: min(30rem, 92vw);
  max-height: 60vh;
  overflow-y: auto;
  background: var(--slate-1);
  border: 1px solid var(--rule-strong);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.28);
  z-index: 60;
  padding: 0.35rem;
}
#search-results[hidden] { display: none; }
#search-results ul { list-style: none; margin: 0; padding: 0; }
#search-results a {
  display: block;
  padding: 0.5rem 0.6rem;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--rule);
}
#search-results li:last-child a { border-bottom: 0; }
#search-results a:hover, #search-results a:focus { background: var(--slate-2); }
#search-results .r-page {
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 700;
}
#search-results .r-head { display: block; font-weight: 620; font-size: 0.9rem; }
#search-results .r-snip { display: block; font-size: 0.8rem; color: var(--ink-muted); }
#search-results .r-empty { padding: 0.8rem; font-size: 0.86rem; color: var(--ink-muted); }
#search-results p { margin: 0; }

/* ---------- tool ---------- */

.tool { border: 1px solid var(--rule); background: var(--slate-1); padding: 1rem; margin: 1.5rem 0; }
.tool textarea, .tool input[type="text"], .tool select {
  font-family: var(--mono);
  font-size: 0.82rem;
  width: 100%;
  padding: 0.55rem 0.7rem;
  background: var(--slate-0);
  color: var(--ink);
  border: 1px solid var(--rule);
  border-radius: 3px;
}
.tool textarea { min-height: 7.5rem; resize: vertical; line-height: 1.5; }
.tool label { display: block; margin-bottom: 0.35rem; }
.tool .field { margin-bottom: 0.9rem; }
.tool .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.8rem; }
.tool .actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.9rem; }
.tool button {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
}
.tool button.secondary { border-color: var(--rule-strong); background: var(--slate-2); color: var(--ink); }
.tool button:hover { border-color: var(--accent); }

.verdict {
  border: 1px solid var(--rule);
  border-left-width: 3px;
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.verdict.ok { border-left-color: var(--good); background: var(--good-soft); color: var(--good); }
.verdict.no { border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.verdict.idle { border-left-color: var(--rule-strong); color: var(--ink-muted); }
.verdict strong { color: inherit; }

.stackview { display: grid; gap: 0.4rem; margin: 0 0 1.2rem; }
.stackstep {
  display: grid;
  grid-template-columns: 2rem minmax(7rem, 12rem) minmax(0, 1fr);
  gap: 0.7rem;
  align-items: start;
  border: 1px solid var(--rule);
  background: var(--slate-0);
  padding: 0.45rem 0.6rem;
  font-size: 0.8rem;
}
.stackstep .n { font-family: var(--mono); color: var(--ink-muted); }
.stackstep .op { font-family: var(--mono); font-weight: 700; color: var(--accent); word-break: break-all; }
.stackstep .st { font-family: var(--mono); color: var(--ink-muted); word-break: break-all; }
.stackstep.drop .op { color: var(--warn); }

.out { font-family: var(--mono); font-size: 0.8rem; word-break: break-all; }

/* ---------- footer ---------- */

.pagefoot {
  border-top: 1px solid var(--rule);
  margin-top: 3.5rem;
  padding-top: 1.2rem;
  font-size: 0.8rem;
  color: var(--ink-muted);
}
.pagefoot dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.7rem 1.2rem;
  margin: 0 0 1rem;
}
.pagefoot dt {
  font-size: 0.63rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 700;
}
.pagefoot dd { margin: 0.1rem 0 0; font-family: var(--mono); font-size: 0.78rem; color: var(--ink); word-break: break-word; }
.pagefoot .foot-links { display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; }

.jsonly { display: none; }
.js .jsonly { display: revert; }
.js .nojs { display: none; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
