:root {
  --paper: #f3f0e8;
  --ink: #171916;
  --muted: #696b64;
  --rule: #c9c5b9;
  --teal: #0d625c;
  --teal-soft: #d9e8e3;
  --risk: #c8472c;
  --risk-soft: #f3dbd2;
  --yellow: #f1d83b;
  --white: #fffef9;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid var(--yellow); outline-offset: 2px; }

.skip-link { position: fixed; left: 12px; top: -60px; z-index: 30; background: var(--ink); color: white; padding: 12px; }
.skip-link:focus { top: 12px; }
main { width: min(1480px, 100%); margin: 0 auto; padding: 28px clamp(18px, 3vw, 52px) 24px; overflow-x: hidden; }

.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 32px; padding: 8px 0 26px; border-bottom: 1px solid var(--ink); }
.kicker, .step { margin: 0 0 7px; text-transform: uppercase; font-size: 11px; font-weight: 800; letter-spacing: 0; color: var(--teal); }
h1 { margin: 0; max-width: 900px; font-family: Georgia, serif; font-size: clamp(36px, 5vw, 72px); font-weight: 500; line-height: .96; letter-spacing: 0; }
.lede { margin: 12px 0 0; max-width: 660px; color: var(--muted); font-size: 16px; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.privacy { display: inline-flex; align-items: center; gap: 7px; margin-right: 8px; font-size: 12px; font-weight: 700; }
.privacy span { width: 8px; height: 8px; border-radius: 50%; background: var(--teal); }
.button, .icon-text, .copy-btn { min-height: 42px; border: 1px solid var(--ink); border-radius: 3px; padding: 10px 14px; font-weight: 800; background: transparent; color: var(--ink); }
.button.dark { background: var(--ink); color: white; }
.button.light:hover, .icon-text:hover, .copy-btn:hover { background: var(--white); }
.button.accent { background: var(--yellow); }

.status { min-height: 24px; padding-top: 8px; color: var(--teal); font-size: 13px; font-weight: 700; }
.workspace { display: grid; grid-template-columns: minmax(300px, 410px) minmax(0, 1fr); border: 1px solid var(--ink); background: var(--white); }
.controls { padding: 24px; border-right: 1px solid var(--ink); }
.results { padding: 24px clamp(20px, 3vw, 42px) 30px; min-width: 0; }
.section-head, .result-top, .rewrite-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
h2 { margin: 0; font-family: Georgia, serif; font-size: 26px; font-weight: 500; letter-spacing: 0; }
h3 { margin: 0 0 10px; font-size: 12px; text-transform: uppercase; letter-spacing: 0; }
.count { color: var(--muted); font-size: 12px; }
label, legend { display: block; margin: 22px 0 8px; font-size: 12px; font-weight: 800; }
textarea, select { width: 100%; border: 1px solid var(--rule); border-radius: 3px; background: #faf8f1; color: var(--ink); padding: 12px; }
textarea { resize: vertical; min-height: 142px; line-height: 1.5; }
fieldset { padding: 0; border: 0; margin: 0; }
.segments { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; }
.segments label { margin: 0; }
.segments input { position: absolute; opacity: 0; pointer-events: none; }
.segments span { display: flex; align-items: center; min-height: 42px; border: 1px solid var(--rule); padding: 8px 9px; background: #faf8f1; }
.segments input:checked + span { border-color: var(--ink); background: var(--yellow); }
.segments input:focus-visible + span { outline: 3px solid var(--yellow); outline-offset: 2px; }
.range-block { margin-top: 22px; }
.range-title { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.range-title label { margin: 0; }
.range-title output { font-size: 12px; font-weight: 800; color: var(--teal); }
input[type="range"] { width: 100%; accent-color: var(--teal); margin: 13px 0 4px; }
.range-ends { display: flex; justify-content: space-between; gap: 12px; font-size: 10px; color: var(--muted); }
details { margin-top: 24px; border-top: 1px solid var(--rule); padding-top: 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
summary { color: var(--ink); font-weight: 800; cursor: pointer; }

.score-wrap { display: grid; grid-template-columns: auto auto auto; align-items: baseline; gap: 3px; color: var(--muted); font-size: 12px; }
.score-wrap span:first-child { grid-column: 1 / -1; text-align: right; text-transform: uppercase; font-weight: 800; }
.score-wrap strong { color: var(--ink); font-family: Georgia, serif; font-size: 52px; font-weight: 500; line-height: .8; }
.boundary-card { margin-top: 24px; border-top: 6px solid var(--teal); background: var(--teal-soft); padding: 22px; }
.boundary-meta { display: flex; justify-content: space-between; gap: 26px; align-items: flex-start; }
.boundary-label { display: inline-block; background: var(--ink); color: white; padding: 7px 9px; font-size: 12px; font-weight: 800; white-space: nowrap; }
.boundary-meta p { margin: 0; max-width: 540px; font-family: Georgia, serif; font-size: clamp(19px, 2vw, 28px); line-height: 1.15; }
.spectrum { margin-top: 36px; }
.spectrum-labels { display: grid; grid-template-columns: 1fr 1fr 1fr; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.spectrum-labels span:nth-child(2) { text-align: center; }
.spectrum-labels span:last-child { text-align: right; }
.track { position: relative; height: 12px; margin: 10px 0 12px; background: linear-gradient(90deg, #d7caca 0 33%, var(--yellow) 33% 66%, var(--teal) 66% 100%); border: 1px solid var(--ink); }
.marker { position: absolute; top: -9px; width: 3px; height: 30px; background: var(--ink); transition: left 180ms ease; }
.marker i { position: absolute; left: -5px; top: -7px; width: 13px; height: 13px; background: var(--white); border: 3px solid var(--ink); border-radius: 50%; }
.evidence-note { font-size: 12px; font-weight: 800; }
.diagnostic-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin-top: 1px; background: var(--ink); border: 1px solid var(--ink); }
.diagnostic-grid > div { background: var(--white); padding: 20px; min-height: 150px; }
.diagnostic-grid ul { padding-left: 17px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.next-action { grid-column: 1 / -1; min-height: auto !important; background: var(--yellow) !important; display: grid; grid-template-columns: 150px 1fr; gap: 18px; align-items: start; }
.next-action p { margin: 0; font-family: Georgia, serif; font-size: 19px; line-height: 1.25; }
.rewrite-head { align-items: flex-end; margin: 32px 0 12px; }
.before-after { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 800; }
.rewrites { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rewrites article { min-height: 190px; padding: 18px; border: 1px solid var(--rule); background: #faf8f1; }
.rewrites article.recommended { border: 2px solid var(--teal); background: var(--teal-soft); }
.rewrite-label { display: flex; justify-content: space-between; gap: 12px; align-items: center; font-size: 11px; font-weight: 800; text-transform: uppercase; }
.copy-btn { min-height: 32px; padding: 5px 9px; font-size: 11px; }
.rewrites p { margin: 30px 0 0; font-family: Georgia, serif; font-size: 18px; line-height: 1.42; }
.brief-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.empty-state { margin-top: 24px; border: 1px dashed var(--risk); background: var(--risk-soft); padding: 32px; text-align: center; }
.empty-state p { color: var(--muted); }

.saved { margin-top: 30px; padding: 22px 0; border-top: 1px solid var(--ink); }
.saved-head { align-items: flex-end; }
.saved-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.saved-item { border: 1px solid var(--rule); background: var(--white); padding: 14px; min-width: 0; }
.saved-item strong, .saved-item span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-item span { margin-top: 5px; color: var(--muted); font-size: 11px; }
.saved-item-actions { display: flex; gap: 6px; margin-top: 12px; }
.saved-item button { min-height: 34px; border: 1px solid var(--ink); background: transparent; font-size: 11px; font-weight: 800; }
.saved-item button:first-child { flex: 1; background: var(--ink); color: white; }
.saved-empty { color: var(--muted); font-size: 13px; }
footer { display: flex; justify-content: space-between; gap: 30px; border-top: 1px solid var(--rule); padding-top: 16px; color: var(--muted); font-size: 11px; }

@media (max-width: 900px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .header-actions { justify-content: flex-start; }
  .workspace { grid-template-columns: 1fr; }
  .controls { border-right: 0; border-bottom: 1px solid var(--ink); }
  .saved-list { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 580px) {
  main { padding: 18px 12px; }
  h1 { font-size: 39px; }
  .header-actions { width: 100%; }
  .privacy { width: 100%; }
  .controls, .results { padding: 18px; }
  .boundary-meta { flex-direction: column; }
  .diagnostic-grid, .rewrites { grid-template-columns: 1fr; }
  .next-action { grid-column: auto; grid-template-columns: 1fr; }
  .saved-list { grid-template-columns: 1fr; }
  .brief-actions { flex-direction: column; }
  .brief-actions button { width: 100%; }
  footer { flex-direction: column; gap: 4px; }
}

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