:root {
  --paper: #e3dccb;
  --paper-deep: #d4ccb8;
  --ink: #1b1914;
  --muted: #5c564c;
  --line: rgba(27, 25, 20, 0.28);
  --edit: #a3261c;
  --display: "Clash Display", "Satoshi", system-ui, sans-serif;
  --sans: "Satoshi", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --letter: 18px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: var(--sans);
  font-weight: 400;
  line-height: 1.4;
  min-height: 100vh;
  padding: 28px 32px 48px;
  background-image:
    linear-gradient(180deg, rgba(255, 252, 245, 0.45), transparent 220px),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(27, 25, 20, 0.015) 28px);
}

button, p, h1 { margin: 0; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  max-width: 1180px;
  margin: 0 auto 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--ink);
}

.mark {
  font-family: var(--display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.22em;
}

h1 {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: -0.03em;
  line-height: 0.95;
  margin-top: 6px;
}

.id {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  text-align: right;
  color: var(--muted);
}

.locus, .reader, .product, .ops, .keys, .colophon {
  max-width: 1180px;
  margin-left: auto;
  margin-right: auto;
}

.locus-row {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: center;
  margin-top: 18px;
  overflow-x: auto;
}

.lcr {
  width: 92px;
  min-height: 72px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 8px 7px;
  transform-origin: 100% 50%;
  transform: rotate(-7deg) translateY(-6px);
  transition: transform 220ms ease;
}

.lcr.is-closed {
  transform: none;
  background: var(--ink);
  color: var(--paper);
}

.lcr-k {
  font-family: var(--display);
  font-weight: 600;
  letter-spacing: 0.14em;
  font-size: 14px;
}

.lcr-s {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

#map { width: 100%; min-width: 760px; height: auto; display: block; }

.map-label {
  font-family: var(--sans);
  font-size: 11px;
  fill: var(--muted);
}

.map-strong {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 600;
  fill: var(--ink);
}

.map-num {
  font-family: var(--mono);
  font-size: 10px;
  fill: var(--muted);
}

.joins {
  margin-top: 4px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  color: var(--ink);
  overflow-x: auto;
}

.joins .line { white-space: nowrap; }

.joins span { color: var(--muted); }

.reader { margin-top: 22px; }

.slot {
  position: relative;
  height: 74px;
  overflow: hidden;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  background: rgba(255, 252, 245, 0.35);
}

.reader.is-idle .slot { opacity: 0.45; }

.tape {
  position: absolute;
  left: 0;
  top: 24px;
  height: 28px;
  white-space: nowrap;
}

.base {
  position: absolute;
  top: 0;
  width: var(--letter);
  text-align: center;
  font-family: var(--mono);
  font-size: 18px;
  line-height: 28px;
  color: var(--ink);
  opacity: 0.34;
}

.base.on { opacity: 1; }

.base.A { font-weight: 700; }

.base.C {
  color: transparent;
  -webkit-text-stroke: 1px var(--ink);
}

.base.G { box-shadow: inset 0 -2px 0 currentColor; }

.base.T {
  color: transparent;
  background-image: linear-gradient(
    180deg,
    var(--ink) 0 38%,
    transparent 38% 62%,
    var(--ink) 62% 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
}

.base.edit { opacity: 1; color: var(--edit); }
.base.C.edit { -webkit-text-stroke-color: var(--edit); }
.base.T.edit {
  background-image: linear-gradient(
    180deg,
    var(--edit) 0 38%,
    transparent 38% 62%,
    var(--edit) 62% 100%
  );
}

.head {
  position: absolute;
  left: 50%;
  top: 20px;
  width: 54px;
  height: 36px;
  margin-left: -27px;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  pointer-events: none;
}

.cuts, .codon, .keys, .checks, .sources, .product-k {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
}

.cuts { margin-top: 8px; }

.codon {
  margin-top: 16px;
  letter-spacing: 0.18em;
  color: var(--ink);
}

.residue {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(32px, 5vw, 52px);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-top: 2px;
}

.status {
  max-width: 62ch;
  margin-top: 10px;
  font-size: 16px;
  min-height: 3.2em;
}

.parser {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  max-width: 70ch;
}

.parser p { font-size: 14px; margin-bottom: 8px; }

.phase {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 13px;
  margin-top: 4px;
}

.phase b { font-weight: 500; color: var(--muted); }

.phase i {
  font-style: normal;
  background: var(--ink);
  color: var(--paper);
  padding: 0 1px;
}

.product {
  margin-top: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 28px;
  align-items: start;
}

.product-k {
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.cable-wrap {
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.cable { display: block; height: 86px; }

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

.ops {
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px 28px;
  padding-top: 12px;
  border-top: 1px solid var(--ink);
}

fieldset {
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

legend {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0;
}

.ops button {
  font-family: var(--sans);
  font-size: 15px;
  background: transparent;
  color: var(--ink);
  border: 0;
  border-bottom: 1px solid transparent;
  min-height: 44px;
  padding: 8px 2px;
  margin-right: 12px;
  cursor: pointer;
}

.ops button[aria-pressed="true"],
.ops button[aria-checked="true"] {
  border-bottom-color: var(--ink);
}

.ops button:disabled {
  opacity: 0.35;
  cursor: default;
}

.keys { margin-top: 4px; }

kbd {
  font-family: var(--mono);
  font-size: 10px;
  border: 1px solid var(--line);
  padding: 1px 4px;
}

.colophon {
  margin-top: 22px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.checks { color: var(--ink); }

.fail {
  color: var(--edit);
  font-family: var(--mono);
  font-size: 13px;
  margin-bottom: 8px;
}

.sources { margin-top: 6px; max-width: 90ch; line-height: 1.5; }

@media (max-width: 800px) {
  body { padding: 18px 16px 36px; }
  .top { align-items: flex-start; }
  .id { text-align: left; }
  .product { grid-template-columns: 1fr; }
  .locus-row { grid-template-columns: 72px 1fr; }
  .lcr { width: 72px; min-height: 64px; }
  .status { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .lcr { transition: none; }
}
