:root {
  /* --panel, --ink, --warn, --accent share their names with sd-tools.css
     tokens of the same name — deleted here (not aliased) so the shared
     token's value cascades through untouched; a var(--panel): var(--panel)
     self-reference would be a cycle and compute to nothing. */
  --bg: var(--bone);
  --panel-2: var(--bone-deep);
  --muted: var(--ink-mute);
  --line: var(--bone-line);
  --line-strong: var(--ink-mute);
  --accent-ink: var(--bone);
  --accent-soft: var(--bone-deep);
  --warn-soft: var(--bone-deep);
  --danger: var(--bad);
  --danger-soft: var(--bone-deep);
  --radius: 6px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.wrap { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 20px; }

code, .mono, .fig { font-family: "IBM Plex Mono", monospace; }

/* ---- Masthead ------------------------------------------------------------ */
.masthead {
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
  border-bottom: 3px solid var(--accent);
  padding: 36px 0 30px;
}
.mark {
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  letter-spacing: .18em;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
}
.mark span { color: var(--muted); letter-spacing: .1em; }
.masthead h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4.5vw, 2.1rem);
  line-height: 1.2;
  letter-spacing: -.01em;
  margin: 14px 0 10px;
}
.lede { color: var(--muted); max-width: 62ch; margin: 0; font-size: 15px; }

/* ---- Form panel ------------------------------------------------------------ */
main.wrap { padding: 28px 20px 60px; }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 18px;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--muted);
}
.field input[type="text"], .field input[type="number"], .field select {
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px 11px;
  width: 100%;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.field .hint { font-size: 12px; color: var(--muted); margin: 0; line-height: 1.5; }
.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 9px;
}
.field.checkbox label {
  display: flex; align-items: center; gap: 8px;
  text-transform: none; font-size: 14px; font-weight: 500; letter-spacing: 0; color: var(--ink);
}
.field.checkbox input { width: 17px; height: 17px; accent-color: var(--accent); }

.adjustments {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.adjustments summary {
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.adjustments summary::-webkit-details-marker { display: none; }
.adjustments summary::before { content: "+ "; color: var(--accent); }
.adjustments[open] summary::before { content: "− "; }
.adjustments .grid { margin-top: 14px; }

button.primary {
  margin-top: 20px;
  width: 100%;
  font-family: "IBM Plex Sans", sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius);
  padding: 13px 18px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-ink);
  transition: transform .06s ease, background .12s ease;
}
button.primary:hover { background: var(--accent-deep); }
button.primary:active { transform: translateY(1px); }
button.primary:disabled { opacity: .6; cursor: default; }

/* ---- Result ------------------------------------------------------------ */
.result { margin-top: 22px; }
.result.error {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
}

.headline {
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 16px;
}
.headline .rationale { font-size: 13.5px; color: var(--muted); margin: 0 0 16px; line-height: 1.6; }
.range { display: flex; flex-wrap: wrap; gap: 22px; margin-bottom: 4px; }
.range .stat { min-width: 140px; }
.range .stat .k {
  font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
  margin-bottom: 4px;
}
.range .stat .v {
  font-family: "IBM Plex Mono", monospace; font-weight: 600; font-size: clamp(1.5rem, 6vw, 2.2rem);
  color: var(--ink);
}
.range .stat.ask .v { color: var(--accent); }
.range .stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.notes { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.notes li {
  font-size: 12.5px; color: var(--warn); background: var(--warn-soft);
  border: 1px solid var(--warn); border-radius: var(--radius); padding: 8px 11px; line-height: 1.5;
}

.breakdown {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.breakdown h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 12px; }
.breakdown table { width: 100%; border-collapse: collapse; font-size: 14px; }
.breakdown td { padding: 7px 0; border-bottom: 1px dashed var(--line); }
.breakdown tr:last-child td { border-bottom: none; }
.breakdown td.label { color: var(--muted); }
.breakdown td.value { text-align: right; font-family: "IBM Plex Mono", monospace; font-weight: 500; white-space: nowrap; }
.breakdown tr.total td { border-top: 1px solid var(--line-strong); padding-top: 10px; font-weight: 600; }
.breakdown tr.total td.value { color: var(--accent); }

.mha-note { font-size: 12.5px; color: var(--muted); margin: 10px 0 0; }

.editions {
  font-size: 11.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 14px;
  border-top: 1px solid var(--line); margin-top: 14px; padding-top: 10px;
}

/* ---- Coverage ------------------------------------------------------------ */
.coverage {
  margin-top: 16px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 15px 14px;
}
.coverage summary { cursor: pointer; padding: 10px 0; font-size: 13.5px; font-weight: 600; color: var(--ink); list-style: none; }
.coverage summary::-webkit-details-marker { display: none; }
.coverage summary::before { content: "+ "; color: var(--accent); }
.coverage[open] summary::before { content: "− "; }
.coverage .hint { font-size: 12.5px; color: var(--muted); line-height: 1.55; margin: 0 0 10px; }
.coverage-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
  font-size: 12.5px; color: var(--ink);
}
.coverage-list .mono { color: var(--muted); }
@media (max-width: 560px) { .coverage-list { grid-template-columns: 1fr; } }

/* ---- OPSEC + footer ------------------------------------------------------ */
.opsec-note {
  margin-top: 22px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 15px;
}
.opsec-note p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.55; }
.opsec-note strong { color: var(--ink); }

.foot { border-top: 1px solid var(--line); padding: 26px 0 40px; margin-top: 10px; }
.foot .disclaimer, .foot .localstorage-note { color: var(--muted); font-size: 12.5px; max-width: 70ch; margin: 0 0 10px; line-height: 1.55; }

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }
  main.wrap { padding: 22px 14px 50px; }
  .range { gap: 16px; }
}
