:root {
  --bg: #0e1719;
  --bg2: #122024;
  --panel: #16272b;
  --line: #2a3d42;
  --line2: #36504f;
  --ink: #ebe5d5;
  --mute: #9eaca8;
  --dim: #6f817d;
  --amber: #e9a23b;
  --amber-ink: #1d1406;
  --rust: #e0603f;
  --lichen: #9cc293;
  --sand: #d8c48a;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --sans: "Archivo", "Segoe UI", system-ui, sans-serif;
  --r: 6px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(233,162,59,.06), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, #0c1416 100%);
  background-attachment: fixed;
  color: var(--ink);
  font: 400 16px/1.6 var(--sans);
  font-variation-settings: "wdth" 100;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 3px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--amber); color: var(--amber-ink); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  max-width: 1080px; margin: 0 auto; padding: 18px 20px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 750; font-size: 19px; font-variation-settings: "wdth" 112; letter-spacing: .01em; }
.brand-mark { width: 30px; height: 30px; color: var(--amber); }
.top nav { display: flex; gap: 18px; font-size: 15px; }
.top nav a { text-decoration: none; color: var(--mute); padding: 6px 0; }
.top nav a:hover { color: var(--ink); }

main { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- hero ---------- */
.hero { padding: 28px 0 56px; }
h1 {
  font-size: clamp(36px, 7.2vw, 76px);
  line-height: .98;
  font-weight: 800;
  font-variation-settings: "wdth" 68;
  letter-spacing: -.01em;
  margin: 0 0 18px;
  max-width: 13ch;
  text-wrap: balance;
}
.lede { color: var(--mute); font-size: clamp(16px, 2.1vw, 19px); max-width: 60ch; margin: 0 0 8px; }

/* ---------- scanner ---------- */
.tray {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 24px 60px -30px rgba(0,0,0,.6);
  overflow: hidden;
}
.tray-bar { display: flex; justify-content: space-between; align-items: baseline; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 14px; }
.tray-bar label { font-weight: 650; }
.count { color: var(--dim); font-family: var(--mono); font-size: 12px; }
textarea {
  display: block; width: 100%; min-height: 150px; max-height: 60vh; resize: vertical;
  background: transparent; color: var(--ink); border: 0; padding: 14px;
  font: 400 14px/1.55 var(--mono);
}
textarea::placeholder { color: var(--dim); }
textarea:focus { outline: none; }
.tray:focus-within { border-color: var(--line2); }
.tray-actions { display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.file-btn, .ghost {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r); background: transparent; color: var(--mute);
  font: 500 14px var(--sans); cursor: pointer; transition: color .15s, border-color .15s;
}
.file-btn:hover, .ghost:hover { color: var(--ink); border-color: var(--line2); }
.file-btn:focus-within { outline: 2px solid var(--amber); outline-offset: 2px; }
.file-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.go {
  margin-left: auto; min-height: 44px; padding: 0 26px; border: 0; border-radius: var(--r);
  background: var(--amber); color: var(--amber-ink); font: 700 16px var(--sans); font-variation-settings: "wdth" 110;
  cursor: pointer; transition: transform .12s ease, filter .15s;
}
.go:hover { filter: brightness(1.06); }
.go:active { transform: translateY(1px) scale(.985); }
.go[disabled] { cursor: progress; filter: saturate(.6) brightness(.85); }

/* ---------- the trapline (signature) ---------- */
.line { position: relative; height: 104px; margin: -14px 4px 8px; }
.wire-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.wire { fill: none; stroke: var(--line2); stroke-width: 2; vector-effect: non-scaling-stroke; }
.wire.pulse { stroke: var(--amber); stroke-width: 2.5; stroke-dasharray: 10 100; stroke-dashoffset: 10; opacity: 0; }
.scanning .wire.pulse { opacity: 1; animation: run 1.1s linear infinite; }
@keyframes run { to { stroke-dashoffset: -100; } }
.traps { position: absolute; inset: 0; display: flex; justify-content: space-around; align-items: center; }
.trap { display: flex; flex-direction: column; align-items: center; gap: 4px; transform: translateY(18px); }
.trap b { font-size: 12px; font-weight: 600; color: var(--dim); letter-spacing: .02em; transition: color .3s; }
.jaws { position: relative; width: 38px; height: 38px; border-radius: 50%; background: var(--bg); border: 1.5px solid var(--line2); transition: border-color .3s, background .3s; }
.jaw { position: absolute; left: 6px; right: 6px; height: 11px; background: var(--line2); transition: transform .28s cubic-bezier(.5,1.8,.5,1), background .3s; }
.jaw.up { top: 5px; border-radius: 12px 12px 0 0; transform-origin: 50% 100%; transform: translateY(-1px) rotateX(0); clip-path: polygon(0 0,100% 0,100% 100%,84% 55%,68% 100%,50% 55%,32% 100%,16% 55%,0 100%); }
.jaw.down { bottom: 5px; border-radius: 0 0 12px 12px; transform-origin: 50% 0; clip-path: polygon(0 0,16% 45%,32% 0,50% 45%,68% 0,84% 45%,100% 0,100% 100%,0 100%); }
.trap.armed .jaws { border-color: var(--amber); }
.trap.armed .jaw { background: var(--amber); }
.trap.armed .jaw.up { transform: translateY(-3px); }
.trap.armed .jaw.down { transform: translateY(3px); }
.trap.armed b { color: var(--ink); }
.trap.caught .jaws { border-color: var(--rust); background: rgba(224,96,63,.12); }
.trap.caught .jaw { background: var(--rust); }
.trap.caught .jaw.up { transform: translateY(4px); }
.trap.caught .jaw.down { transform: translateY(-4px); }
.trap.caught b { color: var(--rust); }
.trap.clear .jaws { border-color: var(--lichen); }
.trap.clear .jaw { background: var(--lichen); }
.trap.clear b { color: var(--lichen); }
.trap.off .jaws { border-style: dashed; }
.trap.off b { color: var(--dim); }

.status { min-height: 24px; color: var(--mute); font-size: 14px; margin-top: 6px; }
.status.err { color: var(--rust); }

/* ---------- result ---------- */
.result { margin-top: 12px; display: grid; gap: 22px; }
.result:not([hidden]) { animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.verdict {
  display: grid; grid-template-columns: auto 1fr; gap: 18px 22px; align-items: center;
  padding: 20px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2);
}
.tag {
  position: relative; width: 112px; height: 132px; display: grid; place-items: center; text-align: center;
  border-radius: 10px 10px 14px 14px; color: var(--amber-ink);
  clip-path: polygon(22% 0, 78% 0, 100% 16%, 100% 100%, 0 100%, 0 16%);
}
.tag::before { content: ""; position: absolute; top: 12px; left: 50%; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--bg2); }
.tag .lvl { font-weight: 800; font-size: 30px; line-height: 1; font-variation-settings: "wdth" 70; margin-top: 18px; text-transform: capitalize; }
.tag .num { font: 600 13px var(--mono); opacity: .8; margin-top: 4px; }
.tag .unit { font-size: 11px; opacity: .75; }
.risk-low .tag { background: var(--lichen); }
.risk-medium .tag { background: var(--sand); }
.risk-high .tag { background: var(--rust); color: #1f0b05; }
.verdict h2 { margin: 0 0 6px; font-size: clamp(20px, 3vw, 26px); line-height: 1.2; font-variation-settings: "wdth" 90; font-weight: 700; }
.verdict ul { margin: 0; padding: 0 0 0 18px; color: var(--mute); }
.verdict li + li { margin-top: 6px; }
.layers { display: flex; flex-wrap: wrap; gap: 8px; grid-column: 1 / -1; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--mute); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.chip.ok i { background: var(--lichen); }
.chip.warn i { background: var(--sand); }
.chip.bad i { background: var(--rust); }

.block h3 { font-size: 18px; margin: 0 0 10px; font-variation-settings: "wdth" 90; }
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.finding { border: 1px solid var(--line); border-left: 4px solid var(--line2); border-radius: var(--r); padding: 12px 14px; background: var(--bg2); }
.finding.w-high { border-left-color: var(--rust); }
.finding.w-mid { border-left-color: var(--sand); }
.finding.w-low { border-left-color: var(--dim); }
.finding header { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.finding strong { font-size: 15px; }
.finding .cat { font-size: 12px; color: var(--dim); }
.finding p { margin: 6px 0 0; color: var(--mute); font-size: 14px; }
.finding code, .excerpt { font: 13px/1.5 var(--mono); word-break: break-word; }
.excerpt { display: block; margin-top: 8px; padding: 8px 10px; background: var(--bg); border-radius: 4px; color: var(--ink); white-space: pre-wrap; }
.excerpt .lab { color: var(--dim); }
.jump { background: none; border: 0; color: var(--amber); font: 500 13px var(--sans); cursor: pointer; padding: 6px 0 0; text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }

.marked {
  margin: 0; max-height: 420px; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); font: 13px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; color: var(--mute);
}
.marked mark { background: rgba(224,96,63,.2); color: var(--ink); border-bottom: 2px solid var(--rust); border-radius: 2px; }
.marked mark.m-mid { background: rgba(216,196,138,.16); border-bottom-color: var(--sand); }
.marked mark.m-low { background: rgba(156,172,168,.12); border-bottom-color: var(--dim); }
.marked mark.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: rgba(233,162,59,.55); } }
.marked .inv { display: inline-block; padding: 0 3px; margin: 0 1px; border-radius: 3px; background: var(--amber); color: var(--amber-ink); font-size: 10px; line-height: 1.5; vertical-align: 1px; }
.note { color: var(--dim); font-size: 13px; margin: 8px 0 0; }
.cls-box { border: 1px dashed var(--line2); border-radius: var(--r); padding: 12px 14px; color: var(--mute); font-size: 14px; }
.cls-box q { color: var(--ink); }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- sections ---------- */
section h2 { font-size: clamp(28px, 4.6vw, 44px); line-height: 1.05; font-weight: 800; font-variation-settings: "wdth" 72; margin: 0 0 10px; }
.section-lede { color: var(--mute); max-width: 58ch; margin: 0 0 26px; }
.catches, .how, .api { padding: 56px 0; border-top: 1px solid var(--line); }
.specimens { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px 32px; }
.specimen svg { width: 80px; height: 56px; margin-bottom: 8px; }
.specimen h3 { margin: 0 0 4px; font-size: 18px; font-variation-settings: "wdth" 92; }
.specimen p { margin: 0; color: var(--mute); font-size: 15px; }
.s-frame { fill: none; stroke: var(--line2); stroke-width: 2; }
.s-ink { fill: none; stroke: var(--mute); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.s-ghost { fill: none; stroke: var(--line2); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 2 6; }
.s-hot { fill: none; stroke: var(--amber); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.s-hot.dash { stroke-dasharray: 3 4; }
circle.s-hot { fill: var(--amber); stroke: none; }

.steps { list-style: none; margin: 0; padding: 0; counter-reset: s; display: grid; grid-template-columns: repeat(4, 1fr); gap: 24px; position: relative; }
.steps li { counter-increment: s; position: relative; padding-top: 44px; }
.steps li::before {
  content: counter(s); position: absolute; top: 0; left: 0; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; border: 1.5px solid var(--amber); color: var(--amber); font: 600 13px var(--mono); background: var(--bg);
  z-index: 1;
}
.steps li::after { content: ""; position: absolute; top: 15px; left: 30px; right: -24px; height: 1.5px; background: var(--line2); }
.steps li:last-child::after { display: none; }
.steps h3 { margin: 0 0 6px; font-size: 18px; font-variation-settings: "wdth" 92; }
.steps p { margin: 0; color: var(--mute); font-size: 15px; }

.code { margin: 0 0 14px; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow-x: auto; font: 13.5px/1.6 var(--mono); color: var(--ink); }
.textlink { color: var(--amber); text-underline-offset: 3px; }
.foot { max-width: 1080px; margin: 0 auto; padding: 32px 20px 48px; border-top: 1px solid var(--line); color: var(--dim); font-size: 14px; }
.foot p { margin: 0 0 6px; max-width: 70ch; }

/* ---------- docs ---------- */
.doc { max-width: 760px; padding-bottom: 64px; }
.doc h1 { font-size: clamp(34px, 6vw, 56px); max-width: none; }
.doc h2 { font-size: 26px; margin: 40px 0 10px; font-variation-settings: "wdth" 80; }
.doc h3 { font-size: 18px; margin: 24px 0 8px; }
.doc p, .doc li { color: var(--mute); }
.doc code { font: 13.5px var(--mono); color: var(--ink); background: var(--panel); padding: 1px 5px; border-radius: 4px; }
.doc pre code { background: none; padding: 0; }
.doc table { width: 100%; border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.doc th, .doc td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.doc th { color: var(--ink); font-weight: 650; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .specimens { grid-template-columns: 1fr 1fr; }
  .steps { grid-template-columns: 1fr 1fr; gap: 28px 24px; }
  .steps li:nth-child(2)::after { display: none; }
}
@media (max-width: 560px) {
  .top { padding: 14px 16px; }
  .top nav { gap: 14px; font-size: 14px; }
  main { padding: 0 16px; }
  .hero { padding-top: 14px; }
  textarea { min-height: 132px; font-size: 13px; }
  .go { flex: 1 0 100%; order: -1; margin: 0; }
  .tray-actions .file-btn { flex: 1; justify-content: center; }
  .specimens, .steps { grid-template-columns: 1fr; }
  .steps li::after { display: none; }
  .verdict { grid-template-columns: 1fr; justify-items: start; padding: 16px; }
  .tag { width: 96px; height: 116px; }
  .line { height: 100px; }
}
@media (max-width: 340px) {
  .top nav a[href="#catches"] { display: none; }
  .jaws { width: 34px; height: 34px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
  .scanning .wire.pulse { opacity: .6; }
}
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.nf { padding-top: 64px; }
.cls-target { margin: 0 0 6px; }
.trap .state { font: 500 11px var(--mono); color: var(--dim); min-height: 14px; }
.trap.caught .state { color: var(--rust); }
.trap.clear .state { color: var(--lichen); }
.weak summary { cursor: pointer; color: var(--mute); font-size: 14px; padding: 8px 0; min-height: 44px; display: flex; align-items: center; }
.weak .findings { margin-top: 8px; }
