:root {
  --black: #090d0c;
  --black-2: #111816;
  --paper: #f3f7f5;
  --green: #b7f34a;
  --red: #ff5a4e;
  --cyan: #42d3ff;
  --yellow: #ffd15c;
  --muted: #8b9993;
  --line: #2d3935;
  --header: 54px;
}
* { box-sizing: border-box; }
html { background: var(--black); scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--black);
  color: var(--paper);
  font-family: Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}
button, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
[hidden], .chart-empty[hidden] { display: none !important; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--black);
}
.brand { display: inline-flex; align-items: center; gap: 9px; min-width: 0; color: var(--paper); text-decoration: none; font-size: 13px; font-weight: 900; white-space: nowrap; }
.brand-mark { width: 32px; height: 32px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--green); color: var(--green); }
.brand-mark svg { width: 16px; height: 16px; }
.runtime { display: inline-flex; align-items: center; gap: 7px; min-width: 0; color: #c8d3ce; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; white-space: nowrap; }
.runtime span { width: 8px; height: 8px; border-radius: 50%; background: var(--yellow); box-shadow: 0 0 0 3px rgba(255,209,92,.12); }
.runtime.ready span { background: var(--green); box-shadow: 0 0 0 3px rgba(183,243,74,.12); }
.page-shell { width: 100%; max-width: 100%; overflow-x: hidden; }
.diagnosis { min-height: calc(100vh - var(--header)); padding: 22px 24px 18px; background: var(--black); }
.diagnosis-brand { color: #9dafaa; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.quick-controls { width: min(100%, 710px); display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 8px; align-items: end; margin-top: 10px; }
.quick-controls .preset-buttons { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.quick-controls .threshold-label { margin-top: 0; }
.quick-controls .threshold-label > span { color: #a8b6b0; }
.quick-controls .threshold-label > div { border-color: #65746e; background: var(--black-2); }
.quick-controls .threshold-label input { color: var(--paper); }
.quick-controls .threshold-label b { border-color: #65746e; color: #b7c4bf; }
.mast { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(310px, .65fr); gap: 28px; align-items: end; margin-top: 5px; }
.kicker { margin: 0 0 8px; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; font-weight: 800; text-transform: uppercase; }
h1 { width: 100%; max-width: 780px; margin: 0; font-family: "Geist", Arial, sans-serif; font-size: clamp(2.5rem, 5.6vw, 5.2rem); line-height: .88; letter-spacing: 0; }
.boundary { max-width: 740px; margin: 10px 0 0; color: #a7b4af; font-size: 11px; line-height: 1.4; }
.verdict-block { min-width: 0; padding-bottom: 2px; text-align: right; }
#parser-proof { margin: 0 0 7px; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; font-weight: 800; }
h2 { margin: 0; color: var(--red); font-family: "Geist", Arial, sans-serif; font-size: clamp(1.75rem, 3.5vw, 3.7rem); line-height: .92; letter-spacing: 0; overflow-wrap: anywhere; }
.diagnosis.stable h2 { color: var(--green); }
#revised-verdict { margin: 8px 0 0; color: var(--cyan); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; font-weight: 700; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); margin-top: 15px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.metrics > div { min-width: 0; padding: 9px 11px 10px; border-right: 1px solid var(--line); }
.metrics > div:first-child { padding-left: 0; }
.metrics > div:last-child { border-right: 0; }
.metrics span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 8px; font-weight: 800; }
.metrics strong { display: block; color: var(--paper); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(.9rem, 1.7vw, 1.35rem); line-height: 1.05; overflow-wrap: anywhere; }
.chart-frame { position: relative; width: 100%; height: 252px; min-height: 220px; margin-top: 9px; overflow: hidden; border-bottom: 1px solid var(--line); }
.chart-legend { position: absolute; z-index: 3; top: 2px; right: 0; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 13px; color: #b5c1bc; font-size: 9px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend-line { display: inline-block; width: 18px; height: 2px; }
.legend-line.baseline { background: var(--red); }
.legend-line.revised { background: var(--cyan); }
.legend-band { display: inline-block; width: 12px; height: 8px; background: rgba(255,90,78,.18); border: 1px solid rgba(255,90,78,.7); }
#retention-svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-empty { position: absolute; inset: 30px 0 0; display: grid; place-items: center; align-content: center; gap: 8px; color: #72817b; text-align: center; font-size: 11px; }
.chart-empty svg { width: 26px; height: 26px; }
.axis text { fill: #80918a; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.axis path, .axis line { stroke: #34423d; }
.grid line { stroke: #24302c; stroke-dasharray: 2 4; }
.grid path { display: none; }
.baseline-path { fill: none; stroke: var(--red); stroke-width: 3; }
.revised-path { fill: none; stroke: var(--cyan); stroke-width: 3; }
.gain-area { fill: rgba(183,243,74,.10); }
.hotspot-band { fill: rgba(255,90,78,.12); stroke: rgba(255,90,78,.52); stroke-width: 1; }
.baseline-point { fill: var(--black); stroke: var(--red); stroke-width: 2; }
.revised-point { fill: var(--black); stroke: var(--cyan); stroke-width: 2; }
.section-boundary { stroke: #60716a; stroke-width: 1; stroke-dasharray: 3 5; }
.section-label { fill: #91a29b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.half-line { stroke: rgba(255,209,92,.42); stroke-dasharray: 5 5; }
.evidence-tape { display: grid; grid-template-columns: 1.1fr .8fr .8fr 1fr; border-bottom: 1px solid var(--line); }
.evidence-tape > div { min-width: 0; padding: 8px 10px 9px; border-right: 1px solid var(--line); }
.evidence-tape > div:first-child { padding-left: 0; }
.evidence-tape > div:last-child { border-right: 0; }
.evidence-tape span { display: block; color: var(--muted); font-size: 8px; }
.evidence-tape strong { display: block; margin-top: 4px; color: var(--yellow); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 10px; overflow-wrap: anywhere; }
.section-tape { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); }
.section-cell { min-width: 0; padding: 7px 9px 8px; border-right: 1px solid var(--line); }
.section-cell:first-child { padding-left: 0; }
.section-cell:last-child { border-right: 0; }
.section-cell span, .section-cell strong { display: block; }
.section-cell span { color: #9caaa4; font-size: 8px; }
.section-cell strong { margin-top: 3px; color: var(--paper); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; }
.interpretation { display: grid; grid-template-columns: 18px minmax(0,1fr); gap: 9px; align-items: start; padding: 8px 0; border-top: 1px solid var(--line); }
.interpretation svg { width: 17px; height: 17px; color: var(--green); }
.interpretation p { margin: 0; color: #b8c5c0; font-size: 9px; line-height: 1.4; }
.export-status { min-height: 13px; margin: 3px 0 0; color: var(--green); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 8px; }
.edit-dock { display: grid; grid-template-columns: minmax(0,1fr) 184px; gap: 16px; align-items: stretch; padding: 16px 24px 18px; border-top: 1px solid #b9c4c0; background: var(--paper); color: var(--black); }
.dock-title { margin: 0 0 7px; color: #52605b; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.preset-buttons { display: grid; grid-template-columns: 1fr; gap: 6px; }
.preset-buttons button, .dock-actions button { min-width: 0; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 10px; border: 1px solid #8d9995; background: #fff; color: var(--black); font-size: 10px; font-weight: 900; white-space: nowrap; }
.preset-buttons button svg, .dock-actions button svg { width: 15px; height: 15px; flex: 0 0 auto; }
.threshold-label { display: block; margin-top: 9px; }
.threshold-label > span { display: block; margin-bottom: 5px; color: #52605b; font-size: 9px; font-weight: 800; }
.threshold-label > div { display: grid; grid-template-columns: minmax(0,1fr) 62px; border: 1px solid #8d9995; background: #fff; }
.threshold-label input { width: 100%; min-width: 0; height: 38px; padding: 0 9px; border: 0; background: transparent; color: var(--black); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.threshold-label b { display: grid; place-items: center; border-left: 1px solid #c1cbc7; color: #66736e; font-size: 9px; }
.dock-editor { min-width: 0; }
.editor-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 6px; color: #52605b; font-size: 9px; font-weight: 800; text-transform: uppercase; }
.editor-head span { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: none; }
#curve-input { width: 100%; height: 134px; min-height: 110px; resize: vertical; padding: 10px; border: 1px solid #8d9995; background: #fff; color: #1d2724; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 9px; line-height: 1.35; white-space: pre; overflow: auto; }
.input-error { margin: 6px 0 0; padding: 7px 9px; border-left: 4px solid var(--red); background: #fff; color: #a32419; font-size: 9px; font-weight: 700; }
.dock-actions { display: grid; grid-template-columns: 1fr; align-content: start; gap: 6px; }
.dock-actions .analyze-button { background: var(--green); border-color: #6ea41a; }
.dock-actions .view-button { background: var(--cyan); border-color: #1681a4; }
.dock-actions .export-button { background: var(--yellow); border-color: #b68b16; }
.dock-actions button:disabled { cursor: not-allowed; opacity: .42; }

@media (max-width: 860px) {
  .mast { grid-template-columns: minmax(0,1fr) minmax(260px,.75fr); }
  .edit-dock { grid-template-columns: minmax(0,1fr); }
  .dock-actions { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

@media (max-width: 640px) {
  :root { --header: 52px; }
  html { scroll-behavior: auto; }
  body.proof-focus .topbar { position: static; }
  .topbar { padding: 0 12px; }
  .brand { font-size: 11px; }
  .brand-mark { width: 28px; height: 28px; }
  .runtime { max-width: 125px; overflow: hidden; text-overflow: ellipsis; font-size: 8px; }
  .diagnosis { min-height: 0; padding: 14px 12px 16px; }
  .quick-controls { grid-template-columns: 1fr; }
  .quick-controls .preset-buttons { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .mast { grid-template-columns: 1fr; gap: 10px; }
  h1 { font-size: clamp(2.6rem, 13vw, 3.4rem); line-height: .9; }
  .boundary { font-size: 10px; }
  .verdict-block { text-align: left; }
  h2 { font-size: clamp(2rem, 10vw, 2.7rem); }
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .metrics > div { min-height: 60px; border-bottom: 1px solid var(--line); }
  .metrics > div:nth-child(2), .metrics > div:nth-child(4) { border-right: 0; }
  .metrics > div:nth-child(5) { grid-column: 1 / -1; border-bottom: 0; border-right: 0; padding-left: 0; }
  .metrics > div:nth-child(3) { padding-left: 0; }
  .chart-frame { height: 236px; }
  .chart-legend { position: static; justify-content: flex-start; min-height: 28px; }
  #retention-svg { height: calc(100% - 28px); }
  .evidence-tape { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .evidence-tape > div { min-height: 56px; border-bottom: 1px solid var(--line); }
  .evidence-tape > div:nth-child(2) { border-right: 0; }
  .evidence-tape > div:nth-child(3), .evidence-tape > div:nth-child(4) { border-bottom: 0; }
  .evidence-tape > div:nth-child(3) { padding-left: 0; }
  .section-tape { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .section-cell { min-height: 45px; border-bottom: 1px solid var(--line); }
  .section-cell:nth-child(2) { border-right: 0; }
  .section-cell:nth-child(3), .section-cell:nth-child(4) { border-bottom: 0; }
  .section-cell:nth-child(3) { padding-left: 0; }
  .edit-dock { grid-template-columns: 1fr; gap: 12px; padding: 14px 12px 18px; }
  .preset-buttons { grid-template-columns: 1fr; }
  #curve-input { height: 220px; }
  .dock-actions { grid-column: auto; grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
