:root {
  --bg: #faf9f7;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #595f69;
  --border: #e2dfda;
  --accent: #2c6b5a;
  --accent-text: #ffffff;
  --accent-soft: rgba(44, 107, 90, 0.14);
  --high: #d0473b;
  --medium: #b7790a;
  --low: #7d838c;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --surface: #1d2024;
    --text: #e9e7e3;
    --muted: #a7acb4;
    --border: #353a41;
    --accent: #72c2a8;
    --accent-text: #10231d;
    --accent-soft: rgba(114, 194, 168, 0.18);
    --high: #f28b80;
    --medium: #e3b04b;
    --low: #969ca5;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top, .layout, .bottom { max-width: 1120px; margin: 0 auto; padding: 0 24px; }
.top { padding-top: 40px; padding-bottom: 24px; }
.brand-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0; font-weight: 700; font-size: 1.15rem; }
.mark { color: var(--accent); flex: none; }
.gh { display: inline-flex; align-items: center; text-decoration: none; color: var(--text); }
.top h1 { margin: 0 0 8px; font-size: 2.1rem; line-height: 1.2; letter-spacing: -0.015em; }
.tagline { margin: 0; color: var(--muted); max-width: 720px; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 720px) minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
.label { font-weight: 600; }
.actions { display: flex; gap: 8px; }

.btn {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.94rem;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.btn-accent:hover { border-color: var(--accent); opacity: 0.92; }
.link {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 0.9rem;
  text-decoration: underline;
  cursor: pointer;
}
a.link { display: inline-flex; align-items: center; }
.link + .link { margin-left: 16px; }

/* The editor: a transparent textarea on top of a layer that draws the underlines.
   Both must share the exact same font, padding and wrapping so the text lines up. */
.editor { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea:focus-visible { outline: none; }
.backdrop, textarea {
  margin: 0;
  padding: 20px;
  border: 0;
  font: inherit;
  line-height: 1.6;
  letter-spacing: normal;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  tab-size: 4;
}
.backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  color: transparent;
}
textarea {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 18rem;
  resize: none;
  overflow: hidden;
  background: transparent;
  color: var(--text);
  outline: none;
}
textarea::placeholder { color: var(--muted); }

mark {
  background: none;
  color: transparent;
  text-decoration-line: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  text-decoration-skip-ink: none;
  border-radius: 3px;
  transition: background-color 0.4s;
}
.sev-high { text-decoration-style: solid; text-decoration-color: var(--high); }
.sev-medium { text-decoration-style: wavy; text-decoration-color: var(--medium); text-decoration-thickness: 1.5px; }
.sev-low { text-decoration-style: dotted; text-decoration-color: var(--low); }
mark.flash, mark.is-open { background: var(--accent-soft); }

.popover {
  position: absolute;
  z-index: 5;
  width: min(340px, calc(100vw - 32px));
  padding: 4px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
.popover .card + .card { border-top: 1px solid var(--border); }

.card { padding: 12px 0; }
.card p { margin: 0 0 6px; }
.card-name { display: flex; align-items: baseline; gap: 8px; font-weight: 600; }
.card-match { color: var(--muted); font-size: 0.9rem; }
.card-why, .card-also { color: var(--muted); font-size: 0.94rem; }
.card-fix { font-size: 0.94rem; }
.sev {
  flex: none;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-bottom: 2px;
  text-decoration-line: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

.panel { position: sticky; top: 16px; }
.empty { padding: 20px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty p { margin: 0 0 12px; color: var(--muted); }
.summary { margin: 0; font-size: 1.1rem; font-weight: 600; }
.note { margin: 4px 0 12px; color: var(--muted); font-size: 0.9rem; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 0 0 12px; padding: 0; list-style: none; color: var(--muted); font-size: 0.85rem; }
.sample { color: var(--text); font-weight: 600; text-decoration-line: underline; text-underline-offset: 4px; text-decoration-thickness: 2px; }
.sample.sev-medium { text-decoration-thickness: 1.5px; }
.turned-off { margin: 0 0 12px; color: var(--muted); font-size: 0.9rem; }
.list { margin: 0; padding: 0; list-style: none; max-height: calc(100vh - 220px); overflow-y: auto; }
.list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0 16px; margin-bottom: 10px; }
.jump {
  display: block;
  width: 100%;
  min-height: 44px;
  margin: 0 0 6px;
  padding: 12px 0 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.jump:hover .card-name span:first-child { text-decoration: underline; }
.status { color: var(--muted); }

.bottom { padding-top: 40px; padding-bottom: 40px; color: var(--muted); font-size: 0.9rem; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .panel { position: static; }
  .list { max-height: none; overflow: visible; }
}
@media (max-width: 480px) {
  body { font-size: 16px; }
  .top, .layout, .bottom { padding-left: 16px; padding-right: 16px; }
  .top { padding-top: 24px; }
  .backdrop, textarea { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  mark { transition: none; }
}
