:root {
  color-scheme: light;
  --bg: #efece3;
  --raise: #f7f5ef;
  --ink: #1a1e1b;
  --muted: #5c665f;
  --line: #d9d2c4;
  --accent: #d6ef4a;
  --accent-ink: #172000;
  --break: #b42318;
  --risk: #8a5b00;
  --safe: #0b6b3a;
  --editor: #fcfbf7;
  --sans: "Segoe UI", system-ui, sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1210;
  --raise: #171c19;
  --ink: #e7eee9;
  --muted: #93a099;
  --line: #3a4741;
  --accent: #dff25a;
  --accent-ink: #172000;
  --break: #ff7a6a;
  --risk: #ffc14d;
  --safe: #5ee0a8;
  --editor: #121816;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 100% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 60%),
    var(--bg);
}

button, input, textarea { font: inherit; color: inherit; }

.wrap {
  width: min(1120px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2.75rem;
}

.skip {
  position: absolute;
  left: 0.75rem;
  top: -3rem;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  z-index: 2;
}

.skip:focus { top: 0.75rem; }

.top, .shelf-head, .report-head, .actions, .save {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.top, .shelf-head, .report-head { justify-content: space-between; }

.top { align-items: flex-end; margin-bottom: 1rem; }

.brand { display: flex; gap: 0.8rem; align-items: center; min-width: 0; }

.mark { width: 2.5rem; height: 2.5rem; flex: none; }

h1, h2 { margin: 0; font-weight: 600; }

h1 {
  font-family: var(--serif);
  font-size: 1.9rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

h2 { font-size: 1rem; letter-spacing: 0.01em; }

.lede, .hint, .legend, .note, .meta, .empty { color: var(--muted); }

.lede { margin: 0.28rem 0 0; font-size: 0.95rem; }

.actions { flex-wrap: wrap; justify-content: flex-end; }

.btn, .chip, .seg {
  min-height: 2.5rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.btn {
  padding: 0 0.9rem;
  font-size: 0.88rem;
  font-weight: 600;
}

.btn:hover, .chip:hover { border-color: var(--ink); }

.btn:focus-visible, .chip:focus-visible, .icon-btn:focus-visible, .open:focus-visible, input:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: transparent;
}

.btn.primary:hover { filter: brightness(1.05); }
.btn.primary:focus-visible { outline-color: var(--ink); }

.file { display: inline-flex; align-items: center; }

.desk {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1rem;
  align-items: stretch;
}

.report, .shelf {
  background: var(--raise);
  border: 1px solid var(--line);
  border-radius: 16px;
}

.report { padding: 0.95rem 1rem 0.8rem; }

.editors { display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }

.mode {
  display: inline-flex;
  align-self: flex-start;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--raise) 80%, var(--bg));
}

.seg {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 0.85rem;
  border: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--muted);
}

.seg input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.seg:has(input:checked) {
  background: var(--accent);
  color: var(--accent-ink);
}

.seg:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

.hint, .legend, .note, .empty { margin: 0; font-size: 0.86rem; }

.editor { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; flex: 1; }

.editor-label {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.err { font-style: normal; color: var(--break); letter-spacing: 0; text-transform: none; font-weight: 600; }

textarea, input[type="text"], #name {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--editor);
  border-radius: 12px;
}

textarea {
  flex: 1 1 auto;
  min-height: 9.6rem;
  resize: vertical;
  padding: 0.75rem 0.8rem;
  font: 13px/1.45 var(--mono);
  tab-size: 2;
}

textarea.bad { border-color: var(--break); }

#name { min-height: 2.5rem; padding: 0 0.75rem; }

.filters { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.chip {
  padding: 0 0.65rem;
  min-height: 2rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip[aria-pressed="true"] { color: var(--ink); border-color: var(--ink); }
.chip[data-sev="break"][aria-pressed="true"] { color: var(--break); border-color: var(--break); }
.chip[data-sev="risk"][aria-pressed="true"] { color: var(--risk); border-color: var(--risk); }
.chip[data-sev="safe"][aria-pressed="true"] { color: var(--safe); border-color: var(--safe); }

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.8rem;
  margin: 0.75rem 0 0.35rem;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.summary span.break { color: var(--break); }
.summary span.risk { color: var(--risk); }
.summary span.safe { color: var(--safe); }

.changes {
  list-style: none;
  margin: 0.35rem 0 0.7rem;
  padding: 0;
  max-height: min(28rem, calc(100vh - 14rem));
  overflow: auto;
}

.row {
  display: grid;
  grid-template-columns: 4.8rem minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 0.55rem;
  align-items: baseline;
  padding: 0.62rem 0.35rem 0.62rem 0.6rem;
  border-top: 1px solid var(--line);
  border-left: 3px solid transparent;
}

.sev-break { border-left-color: var(--break); }
.sev-risk { border-left-color: var(--risk); }
.sev-safe { border-left-color: var(--safe); }

.row:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }

.pill {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sev-break .pill { color: var(--break); }
.sev-risk .pill { color: var(--risk); }
.sev-safe .pill { color: var(--safe); }

code {
  font-family: var(--mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.sum { overflow-wrap: anywhere; }

.report-foot {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 0.75rem;
  padding-top: 0.2rem;
}

.report-foot .legend { flex: 1; }
.report-foot .btn { min-height: 2.15rem; padding: 0 0.75rem; font-size: 0.8rem; flex: none; }

.note:empty { display: none; }

.note {
  display: inline-block;
  margin: 0.15rem 0 0.55rem;
  padding: 0.22rem 0.62rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 30%, transparent);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 600;
}

.shelf { margin-top: 1rem; padding: 0.95rem 1rem 0.5rem; }

.shelf-head { margin-bottom: 0.75rem; }

.save { margin-bottom: 0.4rem; }

.grow { flex: 1; min-width: 0; }

.watches { list-style: none; margin: 0.4rem 0 0; padding: 0; }

.watch {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-top: 1px solid var(--line);
}

.watch.on { background: color-mix(in srgb, var(--accent) 12%, transparent); margin: 0 -0.4rem; padding: 0 0.4rem; border-radius: 8px; }

.open {
  flex: 1;
  min-width: 0;
  text-align: left;
  background: none;
  border: 0;
  padding: 0.65rem 0.1rem;
  min-height: 2.75rem;
  cursor: pointer;
}

.open strong, .meta { display: block; }

.meta { font-size: 0.78rem; margin-top: 0.1rem; }

.icon-btn {
  min-height: 2.25rem;
  padding: 0 0.55rem;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 650;
}

.icon-btn:hover { color: var(--break); border-color: var(--line); }

.icon-btn { font-weight: 600; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 800px) {
  .desk { grid-template-columns: 1fr; }
  .top { flex-direction: column; align-items: stretch; }
  .actions { justify-content: flex-start; }
  .changes { max-height: none; }
  textarea { min-height: 8.5rem; }
}

@media (max-width: 520px) {
  .wrap { width: min(1120px, calc(100% - 1.25rem)); }
  h1 { font-size: 1.6rem; }
  .row { grid-template-columns: 4.6rem minmax(0, 1fr); }
  .sum { grid-column: 2; }
  .save, .report-foot { flex-direction: column; align-items: stretch; }
  .report-head { flex-direction: column; align-items: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
