:root {
  --paper: #F4F8FC;
  --paper-raised: #FFFFFF;
  --line: #C9DCEE;
  --line-strong: #9FC0DE;
  --ink: #0B2E59;
  --ink-muted: #4A6B8A;
  --stamp-red: #E3452B;
  --stamp-green: #1F9D6B;
  --stamp-amber: #C98A1B;

  --font-display: 'Space Grotesk', ui-sans-serif, system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Grid-paper background texture — the drawing surface itself, not decoration */
.gridpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 32px 32px;
  opacity: 0.45;
}

a { color: var(--ink); }

code, pre {
  font-family: var(--font-mono);
}

/* ---------- Masthead ---------- */

.masthead {
  border-bottom: 1px solid var(--line-strong);
  background: rgba(244, 248, 252, 0.9);
  backdrop-filter: blur(4px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.masthead-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mark {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 600;
}

.masthead nav {
  display: flex;
  gap: 24px;
}

.masthead nav a {
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--ink-muted);
  border-bottom: 1px solid transparent;
}

.masthead nav a:hover {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* ---------- Hero ---------- */

.hero {
  max-width: 1080px;
  margin: 0 auto;
  padding: 72px 24px 48px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 56px;
  align-items: center;
}

.hero-text h1 {
  font-size: 42px;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 22px;
  font-weight: 600;
}

.lede {
  color: var(--ink-muted);
  font-size: 17px;
  max-width: 46ch;
  margin: 0 0 32px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.btn {
  display: inline-flex;
  align-items: center;
  padding: 11px 20px;
  font-family: var(--font-mono);
  font-size: 14px;
  text-decoration: none;
  border-radius: 3px;
  border: 1px solid var(--ink);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper);
}

.btn-primary:hover {
  background: #0e3970;
}

.btn-ghost {
  color: var(--ink);
  background: transparent;
}

.btn-ghost:hover {
  background: var(--paper-raised);
}

/* Hero schematic panel, framed like a drawing sheet */
.hero-panel {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--line-strong);
  padding: 28px 20px 16px;
}

.corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid var(--ink);
}
.corner-tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.corner-tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.corner-bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.corner-br { bottom: -1px; right: -1px; border-left: none; border-top: none; }

.schematic {
  width: 100%;
  height: auto;
  display: block;
}

.hero-panel-caption {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-muted);
  text-align: center;
  margin: 8px 0 4px;
}

/* Stamp entrance — one orchestrated moment on load, not per-scroll */
.stamp {
  opacity: 0;
  transform-origin: center;
  animation: stampin 0.32s cubic-bezier(.2,1.4,.4,1) forwards;
  animation-delay: var(--d, 0s);
}

@keyframes stampin {
  0%   { opacity: 0; transform: scale(2.4) rotate(0deg); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: scale(1) rotate(var(--r, 0deg)); }
}

@media (prefers-reduced-motion: reduce) {
  .stamp { animation: none; opacity: 1; }
  html { scroll-behavior: auto; }
}

/* ---------- Panels ---------- */

.panel {
  max-width: 880px;
  margin: 0 auto;
  padding: 40px 24px;
  border-top: 1px solid var(--line-strong);
}

.panel h2 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 12px;
  letter-spacing: -0.01em;
}

.section-intro {
  color: var(--ink-muted);
  max-width: 60ch;
  margin: 0 0 28px;
}

/* ---------- Controls table ---------- */

.table-wrap {
  border: 1px solid var(--line-strong);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 14px;
  background: var(--paper-raised);
  border-bottom: 1px solid var(--line-strong);
  color: var(--ink-muted);
  font-weight: 500;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }

/* ---------- Quickstart steps (genuine sequence — numbering earned) ---------- */

.steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.steps li {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 18px;
}

.step-num {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  border: 1px solid var(--ink);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.step-title {
  font-weight: 600;
  margin: 4px 0 6px;
}

.steps p {
  margin: 0 0 8px;
  color: var(--ink-muted);
}

.steps code {
  background: var(--paper-raised);
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  font-size: 0.92em;
}

pre {
  background: var(--ink);
  color: var(--paper);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
  border-radius: 3px;
  margin: 6px 0 0;
}

pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
}

/* ---------- Split panel (access) ---------- */

.panel-split {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 48px;
  align-items: start;
}

.panel-split p {
  color: var(--ink-muted);
  margin: 0 0 16px;
}

.link-inline {
  font-family: var(--font-mono);
  font-size: 14px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mini-table {
  border: 1px solid var(--line-strong);
  background: var(--paper-raised);
}

.mini-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 13px;
}

.mini-row:last-child { border-bottom: none; }

.mini-label { color: var(--ink-muted); }
.mini-value { text-align: right; }

/* ---------- Title block footer ---------- */

.titleblock {
  border-top: 2px solid var(--ink);
  margin-top: 40px;
}

.titleblock-inner {
  max-width: 880px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr 3fr;
}

.tb-cell {
  padding: 14px 16px;
  border-left: 1px solid var(--line-strong);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tb-cell:first-child { border-left: none; }

.tb-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-muted);
}

.tb-value {
  font-family: var(--font-mono);
  font-size: 13px;
}

.tb-value a {
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--line-strong);
}

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    padding-top: 48px;
  }
  .hero-text h1 { font-size: 34px; }
  .panel-split { grid-template-columns: 1fr; }
  .titleblock-inner { grid-template-columns: 1fr 1fr; }
  .tb-cell { border-left: none; border-top: 1px solid var(--line-strong); }
  .tb-cell:first-child { border-top: none; }
}

@media (max-width: 480px) {
  .masthead nav { gap: 14px; }
  .hero-text h1 { font-size: 28px; }
}

/* ---------- Focus visibility ---------- */

a:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
