:root {
  --bg: #0a0a0a;
  --bg-elev: #111111;
  --bg-soft: #161616;
  --ink: #f3f1ec;
  --muted: #8c887f;
  --faint: #5c5954;
  --line: rgba(243, 241, 236, 0.1);
  --line-strong: rgba(243, 241, 236, 0.18);
  --amber: #e39b3a;
  --amber-dim: #8a5c1c;
  --amber-soft: rgba(227, 155, 58, 0.14);
  --led-on: #ffb24a;
  --led-off: #2a2116;
  --red: #d45146;
  --yellow: #e0c15a;
  --ok: #7d9a6a;
  --max: 1080px;
  --nav-h: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; }

.wrap {
  width: min(var(--max), calc(100% - 48px));
  margin: 0 auto;
}

.mono {
  font-family: "SF Mono", ui-monospace, "IBM Plex Mono", Menlo, Consolas, monospace;
}

/* Nav */
nav {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--nav-h);
  backdrop-filter: blur(16px) saturate(1.2);
  background: rgba(10, 10, 10, 0.78);
  border-bottom: 1px solid var(--line);
}

nav .wrap {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  text-decoration: none;
  letter-spacing: 0.14em;
  font-size: 13px;
  font-weight: 560;
}

.brand span { color: var(--muted); letter-spacing: 0.04em; font-weight: 450; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 22px;
  list-style: none;
  font-size: 13px;
  color: var(--muted);
}

.nav-links a {
  text-decoration: none;
  transition: color 0.15s ease;
}

.nav-links a:hover { color: var(--ink); }

.nav-links .ext {
  padding: 6px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
}

/* Hero */
.hero {
  padding: 96px 0 88px;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(243,241,236,0.09) 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 20%, transparent 70%);
  pointer-events: none;
}

.kicker {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 22px;
}

.hero h1 {
  font-size: clamp(48px, 8vw, 84px);
  font-weight: 520;
  letter-spacing: -0.045em;
  line-height: 0.95;
  margin-bottom: 22px;
}

.hero .lede {
  max-width: 34em;
  font-size: 20px;
  line-height: 1.45;
  color: #d0cdc6;
  margin-bottom: 36px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 56px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn.primary {
  background: var(--ink);
  color: #111;
  border-color: var(--ink);
  font-weight: 520;
}

.btn.primary:hover { background: #fff; }

.btn.ghost:hover { background: rgba(255,255,255,0.04); }

.notice {
  max-width: 40em;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,0.02);
}

/* Panel */
.panel-block { margin-top: 8px; }

.panel-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.led-panel {
  background: #070707;
  border: 1px solid #1c1c1c;
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: inset 0 0 0 1px rgba(227,155,58,0.06), 0 20px 50px rgba(0,0,0,0.35);
}

.digits {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 8px;
}

.status-leds {
  display: flex;
  gap: 18px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #1a1a1a;
}

.lamp {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
}

.lamp i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1a1a;
  box-shadow: inset 0 0 0 1px #2a2a2a;
}

.lamp.on-fault i { background: var(--red); box-shadow: 0 0 8px var(--red); }
.lamp.on-msg i, .lamp.on-res i { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); }

/* Seven segment */
.digit {
  position: relative;
  aspect-ratio: 0.58 / 1;
  min-height: 42px;
}

.seg {
  position: absolute;
  background: var(--led-off);
  border-radius: 1px;
}

.digit.on .seg.on {
  background: var(--led-on);
  box-shadow: 0 0 8px rgba(255, 178, 74, 0.45);
}

.seg.h { height: 7%; left: 18%; right: 18%; }
.seg.v { width: 12%; }
.seg.a { top: 6%; }
.seg.d { bottom: 6%; }
.seg.g { top: 46.5%; }
.seg.b { top: 14%; right: 8%; height: 32%; }
.seg.c { bottom: 14%; right: 8%; height: 32%; }
.seg.e { bottom: 14%; left: 8%; height: 32%; }
.seg.f { top: 14%; left: 8%; height: 32%; }

/* Sections */
section.block, #panel, #sources {
  scroll-margin-top: 80px;
}

section.block {
  padding: 88px 0;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 14px;
}

h2 {
  font-size: clamp(28px, 4vw, 40px);
  font-weight: 520;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 18px;
}

h3 {
  font-size: 18px;
  font-weight: 560;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}

.prose {
  max-width: 38em;
  color: #c8c5bd;
}

.prose p + p, .prose p + ul, .prose ul + p { margin-top: 14px; }

.prose a { color: var(--ink); text-underline-offset: 3px; }

.prose ul { padding-left: 1.15em; }

.prose li + li { margin-top: 6px; }

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

.cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-top: 36px;
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 20px 18px;
}

.card h3 { margin-bottom: 8px; }

.card p { font-size: 14.5px; color: var(--muted); }

.part {
  font-size: 12px;
  color: var(--faint);
  letter-spacing: 0.04em;
  margin-top: 12px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

blockquote.quote {
  margin: 36px 0 0;
  padding: 22px 24px;
  border-left: 2px solid var(--amber);
  background: var(--amber-soft);
  border-radius: 0 14px 14px 0;
}

blockquote.quote p {
  font-size: 22px;
  letter-spacing: -0.02em;
  line-height: 1.35;
  color: var(--ink);
}

blockquote.quote cite {
  display: block;
  margin-top: 12px;
  font-style: normal;
  font-size: 13px;
  color: var(--muted);
}

blockquote.quote cite a { color: var(--muted); }

/* Memory map */
.map {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

.bank {
  display: grid;
  grid-template-columns: 148px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  background: #101010;
  border: 1px solid transparent;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.bank .addr { font-size: 12px; color: var(--faint); }

.bank .meta { font-size: 12.5px; color: #cfcbc3; }

.bank.active {
  border-color: rgba(227,155,58,0.55);
  background: rgba(227,155,58,0.08);
}

.bank.locked {
  border-color: rgba(224,193,90,0.45);
  background: rgba(224,193,90,0.07);
}

.bank.wiping {
  border-color: rgba(212,81,70,0.45);
  background: rgba(212,81,70,0.07);
}

/* Signing studio */
.studio {
  display: grid;
  grid-template-columns: 0.95fr 1.05fr;
  gap: 28px;
  margin-top: 36px;
}

.studio-card {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
}

.sim-label {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.field input {
  background: #0c0c0c;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
}

.field input:focus {
  outline: none;
  border-color: rgba(227,155,58,0.6);
}

.steps { list-style: none; margin: 8px 0 16px; }

.steps li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  color: var(--faint);
}

.steps li .n {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--faint);
  padding-top: 2px;
}

.steps li.done { color: #cfcbc3; }
.steps li.current { color: var(--ink); }
.steps li.current .n { color: var(--amber); }

.out {
  margin-top: 8px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #b9b5ac;
  word-break: break-all;
  min-height: 4.5em;
}

.out strong { color: var(--ink); font-weight: 550; }

.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }

button.btn {
  cursor: pointer;
  background: transparent;
  color: var(--ink);
  font: inherit;
}

button.btn.primary { background: var(--ink); color: #111; }

button.btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Test ROM */
.rom-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  margin-top: 32px;
}

.keys {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.key {
  appearance: none;
  background: #141414;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  height: 44px;
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.key:hover { background: #1b1b1b; }

.key.active {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--ink);
}

.rom-readout p { color: #c8c5bd; margin-top: 10px; font-size: 15px; }

.rom-readout h3 { margin-top: 4px; }

/* Commands */
.cmds {
  margin-top: 28px;
  background: #0e0e0e;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.cmds pre {
  padding: 18px 20px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: #d7d3cb;
  overflow-x: auto;
}

.cmds .cmt { color: #7a766e; }

/* Status list */
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 28px;
  margin-top: 28px;
}

.fact {
  padding: 16px 0;
  border-top: 1px solid var(--line);
}

.fact dt {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}

.fact dd { font-size: 15px; color: #d4d0c8; }

/* Footer */
footer {
  padding: 48px 0 64px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

footer a { color: #cfcbc3; text-underline-offset: 3px; }

.foot-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 32px;
}

/* Responsive */
@media (max-width: 860px) {
  .wrap { width: min(var(--max), calc(100% - 32px)); }
  .nav-links a:not(.ext) { display: none; }
  .hero { padding: 64px 0 56px; }
  section.block { padding: 64px 0; }
  .grid-2, .studio, .rom-grid, .cards, .facts, .foot-grid {
    grid-template-columns: 1fr;
  }
  .digits { gap: 4px; }
  .digit { min-height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

.out em { color: var(--faint); font-style: italic; font-weight: 400; }
.out .cmt { color: var(--faint); display: inline-block; margin-top: 8px; }
.steps li .n { font-variant-numeric: tabular-nums; }
