/* parse_sdp playground — restrained, system-font, light/dark via tokens. */

:root {
  color-scheme: light dark;
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f0f0ee;
  --border: #d9d9d4;
  --text: #1c1c1a;
  --text-muted: #6b6b66;
  --accent: #1f5fbf;
  --accent-text: #ffffff;
  --focus: #1f5fbf;
  --error: #b42318;
  --error-bg: #fdecea;
  --warn: #9a6700;
  --warn-bg: #fff6d6;
  --pass: #1a7f37;
  --pass-bg: #e6f4ea;
  --add-bg: #e6f4ea;
  --del-bg: #fdecea;
  --hl: #fff3b0;
  /* keycap tier cards: backlight colours and cap translucency */
  --key-pass: #1f9d4a;
  --key-fail: #e0443a;
  --key-off: #9a9a95;
  --key-cap-top: rgba(255, 255, 255, 0.74);
  --key-cap-bottom: rgba(255, 255, 255, 0.46);
  --key-edge: rgba(0, 0, 0, 0.18);
  --key-edge-alpha: 0.8;     /* light at the cap edge; centre is 1.0 */
  --key-edge-base: #000;     /* what the edge fades towards: darker on a light page */
  --key-hover-brightness: 1.06;
  --key-outer: 0.15;
  --key-ink: #141414;
  --key-state-pass: #0d4f22;
  --key-state-fail: #7f160f;
  --key-text-shadow: none;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 6px;
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141414;
    --surface: #1d1d1d;
    --surface-2: #262626;
    --border: #3a3a3a;
    --text: #e8e8e4;
    --text-muted: #a0a09a;
    --accent: #7aa7ff;
    --accent-text: #0b1a36;
    --focus: #7aa7ff;
    --error: #ff7b72;
    --error-bg: #3a1d1b;
    --warn: #e3b341;
    --warn-bg: #3a2f12;
    --pass: #56d364;
    --pass-bg: #16301c;
    --add-bg: #16301c;
    --del-bg: #3a1d1b;
    --hl: #4a3f12;
    --key-pass: #3ddc6b;
    --key-fail: #ff6a5e;
    --key-off: #6e6e6a;
    --key-cap-top: rgba(255, 255, 255, 0.18);
    --key-cap-bottom: rgba(255, 255, 255, 0.04);
    --key-edge: rgba(255, 255, 255, 0.22);
    --key-edge-alpha: 0.8;
    --key-edge-base: transparent;  /* the dark page itself provides the falloff */
    --key-hover-brightness: 1.08;
    --key-outer: 0.15;
    --key-ink: #141414;
    --key-state-pass: #062b12;
    --key-state-fail: #3a0a07;
    --key-text-shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { font-family: var(--sans); font-size: 15px; line-height: 1.45; }
body { margin: 0; background: var(--bg); color: var(--text); }

h1, h2, h3 { margin: 0; font-weight: 600; line-height: 1.2; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; color: var(--text-muted); font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
kbd { font-family: var(--mono); font-size: 0.8em; border: 1px solid var(--border); border-radius: 3px; padding: 0 4px; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 6px 10px; z-index: 10; }
.skip-link:focus { left: 8px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Sticky top bar: brand, section nav, output actions */
:root { --bar-h: 56px; }
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px;
  padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
  max-width: 100%; min-width: 0;
}
.site-header > * { min-width: 0; }
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 0 1 auto; }
.tagline { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.site-nav { display: flex; gap: 4px; flex-wrap: wrap; min-width: 0; }
.site-nav a { text-decoration: none; color: var(--text); font-weight: 500; padding: 4px 8px; border-radius: var(--radius); border-bottom: 2px solid transparent; }
.site-nav a:hover { background: var(--surface-2); }
.site-nav a[aria-current="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.nav-toggle { display: none; width: 38px; height: 34px; padding: 0; align-items: center; justify-content: center; }
.nav-toggle-bars, .nav-toggle-bars::before, .nav-toggle-bars::after {
  display: block; width: 18px; height: 2px; background: currentColor; border-radius: 1px; content: ""; position: relative;
}
.nav-toggle-bars::before { position: absolute; top: -6px; }
.nav-toggle-bars::after { position: absolute; top: 6px; }
.nav-toggle[aria-expanded="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.bar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; flex: 0 1 auto; min-width: 0; max-width: 100%; }
.bar-actions select { flex: 0 1 auto; min-width: 0; max-width: 12em; }
.bar-actions button { flex: 0 0 auto; }
.bar-status { min-width: 0; flex: 1 1 4em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.engine-status { color: var(--text-muted); font-size: 0.8rem; flex-basis: 100%; }
.engine-status.is-mock { color: var(--warn); }
.site-footer { padding: 20px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 0.88rem; display: grid; gap: 4px; }

@media (max-width: 900px) {
  .tagline, .engine-status { display: none; }
  .site-header { gap: 8px 10px; padding: 8px 12px; }
  .nav-toggle { display: inline-flex; }
  .site-nav { display: none; }
  .site-nav.is-open {
    display: flex; flex-direction: column; gap: 0;
    position: absolute; left: 0; right: 0; top: 100%;
    background: var(--surface); border-bottom: 1px solid var(--border); padding: 6px 12px 10px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
  }
  .site-nav.is-open a { padding: 10px 8px; border-bottom: 1px solid var(--border); border-radius: 0; }
  .site-nav.is-open a[aria-current="true"] { border-bottom-color: var(--border); background: color-mix(in srgb, var(--accent) 10%, transparent); }
  .bar-actions { margin-left: auto; }
}
@media (max-width: 480px) {
  .bar-actions { flex-basis: 100%; margin-left: 0; }
  .bar-actions select { flex: 1 1 6em; }
}

/* Intro block */
.intro { display: grid; gap: 8px; padding: 0 2px; }
.intro p { font-size: 0.95rem; max-width: 75ch; }
.intro-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 0.9rem; }
.intro-links img { height: 20px; width: auto; display: block; }
.intro-links a.badge-link { display: inline-flex; height: 20px; }

/* Layout */
main { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px; max-width: 1400px; margin: 0 auto; min-width: 0; }
main > section { min-width: 0; max-width: 100%; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); min-width: 0; scroll-margin-top: calc(var(--bar-h) + 12px); }
.output-head .toolbar h2 { margin-right: 6px; }
.panel-head { display: grid; gap: 4px; }
.hint { color: var(--text-muted); font-size: 0.88rem; }
.meta { color: var(--text-muted); font-size: 0.85rem; }

/* Controls */
button, .button {
  font: inherit; font-size: 0.9rem; padding: 6px 12px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer;
}
button:hover, .button:hover { border-color: var(--text-muted); }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
button.small, .small { padding: 2px 8px; font-size: 0.8rem; }
button.ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
button.ghost:hover { color: var(--text); border-color: var(--border); }
button.danger:hover { color: var(--error); border-color: var(--error); }
.file-button { display: inline-block; }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-button:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }

input[type="text"], input[type="search"], input[type="number"], select, textarea {
  font: inherit; font-size: 0.9rem; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 8px;
}
textarea { width: 100%; resize: vertical; min-height: 160px; line-height: 1.4; }
label { font-size: 0.9rem; }
label.check { display: inline-flex; align-items: center; gap: 6px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; max-width: 100%; }
.toolbar > * { min-width: 0; max-width: 100%; }
.toolbar > label { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; min-width: 0; }
.toolbar select, select { min-width: 0; max-width: 100%; }
.toolbar-group { padding-left: 8px; border-left: 1px solid var(--border); }
#example-select { flex: 1 1 10em; }
.toolbar-label { color: var(--text-muted); font-size: 0.85rem; }

.banner { padding: 8px 12px; border-radius: var(--radius); font-size: 0.9rem; }
.banner.error { background: var(--error-bg); color: var(--error); border: 1px solid color-mix(in srgb, var(--error) 35%, transparent); }
.banner.warn { background: var(--warn-bg); color: var(--warn); }

/* Input */
.drop-zone { position: relative; min-width: 0; }
.drop-zone textarea { max-width: 100%; min-width: 0; }
.drop-overlay {
  display: none; position: absolute; inset: 0; align-items: center; justify-content: center;
  border: 2px dashed var(--accent); border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 10%, transparent);
  font-weight: 600; color: var(--accent); pointer-events: none;
}
.drop-zone.is-dragging .drop-overlay { display: flex; }

/* Tier cards: clear-plastic keycaps lit from behind. State classes
   (pass / fail / none) only set the light colour; everything else is CSS.
   The card is a size container: wide cards lay the content out in one
   row, narrow ones stack it. */
.tier-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr)); gap: var(--gap); min-width: 0; padding: 2px 0; }
.tier-card {
  --key-color: var(--key-off);
  position: relative; isolation: isolate; overflow: hidden;
  container-type: inline-size;
  border-radius: 11px; padding: 8px 14px; min-width: 0;
  border: 1px solid var(--key-edge);
  background: transparent;   /* layers: ::after light (z -1) → ::before cap (z 0) → .tier-body text (z 1) */
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -3px 4px rgba(0, 0, 0, 0.16),
    inset 0 0 0 3px rgba(255, 255, 255, 0.07),
    0 2px 3px rgba(0, 0, 0, 0.18),
    0 0 6px -1px color-mix(in srgb, var(--key-color) calc(var(--key-outer) * 100%), transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  transform: translateY(0);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  text-shadow: var(--key-text-shadow);
}
/* Backlight: the cap is evenly lit in the tier colour, brightest at the
   centre and only gently faded towards the edges (never transparent). */
.tier-card::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 70% 120% at 50% 50%,
    var(--key-color) 0%,
    color-mix(in srgb, var(--key-color) 90%, var(--key-edge-base)) 60%,
    color-mix(in srgb, var(--key-color) calc(var(--key-edge-alpha) * 100%), var(--key-edge-base)) 100%);
  transition: filter 0.12s ease;
}
/* The translucent cap, painted over the light, with a faint diagonal
   specular streak in the same layer so the text always sits on the cap. */
.tier-card::before {
  content: ""; position: absolute; inset: 0; z-index: 0; pointer-events: none;
  background:
    linear-gradient(115deg, transparent 38%, rgba(255, 255, 255, 0.12) 50%, transparent 62%),
    linear-gradient(180deg, var(--key-cap-top), var(--key-cap-bottom));
}
.tier-body { position: relative; z-index: 1; display: grid; gap: 2px; min-height: 36px; align-content: center; }
@container (min-width: 360px) {
  .tier-body { display: flex; align-items: center; gap: 14px; }
  .tier-body .tier-counts { margin-left: auto; text-align: right; }
}
.tier-card.pass { --key-color: var(--key-pass); }
.tier-card.fail { --key-color: var(--key-fail); }
.tier-card.none { --key-outer: 0; filter: saturate(0.5); color: var(--text-muted); }
.tier-card.none::after { display: none; }
.tier-card:hover, .tier-card:focus-within {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.35),
    inset 0 -2px 3px rgba(0, 0, 0, 0.16),
    inset 0 0 0 3px rgba(255, 255, 255, 0.07),
    0 1px 2px rgba(0, 0, 0, 0.18),
    0 0 6px -1px color-mix(in srgb, var(--key-color) calc(var(--key-outer) * 100%), transparent);
}
.tier-card:hover::after, .tier-card:focus-within::after { filter: brightness(var(--key-hover-brightness)); }
@media (prefers-reduced-motion: reduce) {
  .tier-card, .tier-card::after { transition: none; }
}
.tier-card .tier-name { font-weight: 700; white-space: nowrap; }
.tier-card.pass, .tier-card.fail { color: var(--key-ink); }
.tier-card .tier-arrow { color: var(--text-muted); font-weight: 400; }
.tier-card.pass .tier-arrow, .tier-card.fail .tier-arrow { color: var(--key-ink); opacity: 0.6; }
.tier-card .tier-state { font-weight: 700; white-space: nowrap; }
.tier-card .tier-state::before { font-weight: 700; }
.tier-card.pass .tier-state { color: var(--key-state-pass); }
.tier-card.pass .tier-state::before { content: "✓ "; }
.tier-card.fail .tier-state { color: var(--key-state-fail); }
.tier-card.fail .tier-state::before { content: "✗ "; }
.tier-card .tier-counts { color: var(--text-muted); font-size: 0.85rem; white-space: nowrap; }
.tier-card.pass .tier-counts, .tier-card.fail .tier-counts { color: var(--key-ink); opacity: 0.9; }

/* Badges */
.badge { display: inline-block; font-size: 0.72rem; font-weight: 600; padding: 1px 6px; border-radius: 10px; text-transform: uppercase; letter-spacing: 0.02em; line-height: 1.5; }
.badge.error { background: var(--error-bg); color: var(--error); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.tier { background: var(--surface-2); color: var(--text-muted); text-transform: none; }
.badge.kind { background: var(--surface-2); color: var(--text-muted); text-transform: none; font-weight: 500; }

/* Findings + source */
.report-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--gap); align-items: start; }
@media (max-width: 900px) { .report-grid { grid-template-columns: minmax(0, 1fr); } }
.findings { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; max-height: 70vh; overflow: auto; min-width: 0; }
.finding { width: 100%; max-width: 100%; min-width: 0; text-align: left; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: start; padding: 8px 10px; background: var(--surface); }
.finding:hover { background: var(--surface-2); }
.finding.is-selected { outline: 2px solid var(--accent); }
.finding .f-main { display: grid; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.finding .f-id { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); word-break: break-all; }
.finding .f-msg { font-size: 0.9rem; }
.finding .f-sub { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.8rem; color: var(--text-muted); }
.finding .f-loc { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; }
.findings .empty { color: var(--text-muted); font-size: 0.9rem; padding: 8px; }
.badge.count { background: var(--surface-2); color: var(--text); text-transform: none; }
.finding-toggle::after { content: "▸"; color: var(--text-muted); font-size: 0.8em; grid-column: 3; justify-self: end; }
.finding-toggle[aria-expanded="true"]::after { content: "▾"; }
.group-lines { display: flex; flex-wrap: wrap; gap: 4px; padding: 6px 10px 8px 10px; border: 1px solid var(--border); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); background: var(--surface-2); }
.finding-group .finding-toggle[aria-expanded="true"] { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.line-chip { padding: 1px 7px; font-family: var(--mono); font-size: 0.78rem; border-radius: 10px; background: var(--surface); }
.line-chip.is-selected { outline: 2px solid var(--accent); }

.source-view { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; position: sticky; top: 12px; min-width: 0; }
.source-lines { list-style: none; margin: 0; padding: 0; font-family: var(--mono); font-size: 0.82rem; border: 1px solid var(--border); border-radius: var(--radius); overflow: auto; overflow-x: auto; max-height: 70vh; background: var(--surface-2); counter-reset: line; min-width: 0; max-width: 100%; }
pre { overflow-x: auto; max-width: 100%; }
.source-lines li { display: grid; grid-template-columns: 3.2em 1.1em 1fr; gap: 0 6px; padding: 1px 8px 1px 0; white-space: pre; }
.source-lines li .ln { text-align: right; color: var(--text-muted); user-select: none; }
.source-lines li .mark { color: var(--text-muted); text-align: center; user-select: none; }
.source-lines li.has-error .mark { color: var(--error); }
.source-lines li.has-warn .mark { color: var(--warn); }
.source-lines li.hl { background: var(--hl); }
.source-lines li.add { background: var(--add-bg); }
.source-lines li.del { background: var(--del-bg); text-decoration: line-through; opacity: 0.8; }
.source-lines .empty { padding: 8px 12px; color: var(--text-muted); font-family: var(--sans); white-space: normal; display: block; }

/* Editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--gap); }
.editor > div, .card, .card-body, .list, .cards, .params { min-width: 0; }
.card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card > summary { cursor: pointer; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; list-style: none; }
.card > summary::-webkit-details-marker { display: none; }
.card > summary::before { content: "▸"; color: var(--text-muted); font-size: 0.8em; }
.card[open] > summary::before { content: "▾"; }
.card > summary .card-title { font-weight: 600; }
.card > summary .card-preview { font-family: var(--mono); font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60ch; }
.card > summary .card-tools { margin-left: auto; display: inline-flex; gap: 4px; }
.card-body { padding: 4px 12px 12px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; border-top: 1px solid var(--border); }
.card.level-1 { background: var(--surface-2); }
.card.level-1 > .card-body > .card { background: var(--surface); }
.card.has-error { border-color: var(--error); }
.card.is-target, .row.is-target, .param-row.is-target { outline: 2px solid var(--accent); outline-offset: 2px; transition: outline-color 0.3s; }

.rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 8px; min-width: 0; }
.row { display: grid; gap: 3px; position: relative; }
.row label, .list-label, .params-label { font-size: 0.8rem; color: var(--text-muted); font-family: var(--mono); }
.row .row-input { display: flex; gap: 4px; align-items: center; }
.row .row-input input[type="text"] { flex: 1; min-width: 0; font-family: var(--mono); }
.row.kind-number input[type="text"] { text-align: right; }
.row .kind { font-size: 0.7rem; color: var(--text-muted); }
.row.has-error input { border-color: var(--error); }
.field-error { color: var(--error); font-size: 0.8rem; }
.row.has-finding, .list.has-finding, .params.has-finding, .param-row.has-finding { border-left: 3px solid var(--warn); padding-left: 8px; border-radius: 3px; }
.row.has-finding.sev-error, .list.has-finding.sev-error, .params.has-finding.sev-error, .param-row.has-finding.sev-error { border-left-color: var(--error); }
.card.has-finding { border-color: var(--warn); }
.card.has-finding.sev-error { border-color: var(--error); }
.card .finding-marks { text-transform: none; font-weight: 600; margin-left: 4px; }
.expand-findings { font-size: 0.75rem; }
.field-findings { display: grid; gap: 4px; grid-column: 1 / -1; }
.row .field-findings { margin-top: 4px; }
.card-body > .field-findings { margin-top: 8px; }
.fdisc { border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: var(--radius); background: var(--surface); min-width: 0; }
.fdisc.sev-error { border-left-color: var(--error); }
.fdisc.is-missing { border-style: dashed; border-left-style: solid; }
.fdisc-summary { width: 100%; text-align: left; display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; padding: 5px 8px; background: transparent; border: 0; font-size: 0.82rem; line-height: 1.35; }
.fdisc-summary:hover { background: var(--surface-2); }
.fdisc-summary::after { content: "▸"; color: var(--text-muted); margin-left: auto; font-size: 0.75em; }
.fdisc-summary[aria-expanded="true"]::after { content: "▾"; }
.fdisc-glyph { font-weight: 700; }
.fdisc-glyph.sev-error { color: var(--error); }
.fdisc-glyph.sev-warn { color: var(--warn); }
.fdisc-id { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); word-break: break-all; }
.fdisc-short { min-width: 0; overflow-wrap: anywhere; }
.badge.missing { background: var(--error-bg); color: var(--error); text-transform: none; border: 1px dashed var(--error); }
.fdisc-body { padding: 4px 10px 8px 24px; display: grid; gap: 4px; font-size: 0.84rem; border-top: 1px solid var(--border); }
.fdisc-meta { display: flex; flex-wrap: wrap; gap: 10px; color: var(--text-muted); font-size: 0.8rem; }
.fdisc-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.fdisc-sev { font-size: 0.8rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 4px; }
.fdisc-actions { flex: 1 1 4em; min-height: 1.6em; }

.list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; }
.tokens { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.token { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 1px 4px 1px 8px; font-family: var(--mono); font-size: 0.82rem; }
.token button { padding: 0 5px; border: 0; background: transparent; color: var(--text-muted); font-size: 0.9rem; line-height: 1.2; }
.token button:hover { color: var(--error); }
.tokens input[type="text"] { width: 9em; font-family: var(--mono); }

.params { display: grid; gap: 4px; }
.param-row { display: grid; grid-template-columns: minmax(8em, 1fr) minmax(8em, 2fr) auto auto; gap: 6px; align-items: center; }
.param-row input[type="text"] { font-family: var(--mono); min-width: 0; }
.param-row label.check { white-space: nowrap; font-size: 0.8rem; }
@media (max-width: 560px) { .param-row { grid-template-columns: 1fr 1fr; } }

.cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.add-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.add-bar select, .add-bar input[type="text"] { font-size: 0.85rem; }
.editor .empty { color: var(--text-muted); font-size: 0.9rem; }

/* Editor findings summary block */
.editor-summary { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); display: grid; min-width: 0; }
.editor-summary-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.editor-summary-counts { font-size: 0.92rem; color: var(--text); }
.editor-summary-counts .n-err { color: var(--error); }
.editor-summary-counts .n-warn { color: var(--warn); }
.editor-summary-head button { margin-left: auto; }
.editor-summary-list { list-style: none; margin: 0; padding: 0 8px 8px; display: grid; gap: 2px; max-height: 40vh; overflow: auto; }
.editor-summary-list li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 4px 6px; border-radius: 4px; background: var(--surface); font-size: 0.84rem; }
.editor-summary-list .es-id { font-family: var(--mono); font-size: 0.78rem; color: var(--text-muted); word-break: break-all; }
.editor-summary-list .es-msg { overflow-wrap: anywhere; }
.editor-summary-list .es-loc { font-family: var(--mono); font-size: 0.78rem; background: transparent; border: 0; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; text-align: right; word-break: break-all; }
@media (max-width: 600px) { .editor-summary-list li { grid-template-columns: auto minmax(0, 1fr); } .editor-summary-list .es-loc { grid-column: 2; text-align: left; } }

/* Policy popout + per-row controls */
.policy-toggle { display: inline-flex; align-items: center; gap: 6px; }
.policy-toggle[aria-expanded="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.policy-toggle .count { background: var(--accent); color: var(--accent-text); }
.policy-toggle[aria-expanded="true"] .count { background: var(--accent-text); color: var(--accent); }
.policy-panel { border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px; display: grid; gap: 10px; background: var(--surface); max-height: 60vh; overflow: auto; min-width: 0; }
.policy-panel h3 { color: var(--text); margin-right: 6px; }
.silenced { color: var(--warn); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; cursor: pointer; }
.finding-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; align-items: start; min-width: 0; }
.finding-row .group-lines { grid-column: 1 / -1; }
.row-severity { font-size: 0.78rem; padding: 2px 4px; max-width: 9em; align-self: start; margin-top: 4px; }
@media (max-width: 600px) { .finding-row { grid-template-columns: minmax(0, 1fr); } .row-severity { justify-self: end; margin-top: 0; } }

/* Policy */
.policy-groups { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.policy-group .card-body { overflow-x: auto; }
.policy-group > summary { cursor: pointer; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.policy-group .group-count { color: var(--text-muted); font-size: 0.85rem; }
.policy-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.policy-table th, .policy-table td { text-align: left; padding: 5px 8px; border-top: 1px solid var(--border); vertical-align: top; }
.policy-table th { color: var(--text-muted); font-weight: 500; }
.policy-table .pid { font-family: var(--mono); font-size: 0.8rem; overflow-wrap: anywhere; }
.policy-table .pspec { color: var(--text-muted); white-space: nowrap; }
.policy-table tr.is-override td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.policy-table select { padding: 2px 6px; font-size: 0.82rem; }
.policy-table tr[hidden] { display: none; }
@media (max-width: 700px) { .policy-table .pspec { white-space: normal; } .policy-table .pkind { display: none; } }
/* Narrow phones: the spec column goes too, so the id and its severity
   select stay visible without horizontal scrolling. */
@media (max-width: 480px) { .policy-table .pspec { display: none; } .policy-table td:last-child { width: 1%; white-space: nowrap; } }

@media (max-width: 600px) {
  main { padding: 12px; gap: 12px; }
  .panel { padding: 12px; }
  .finding { grid-template-columns: auto 1fr; }
  .finding .f-loc { grid-column: 1 / -1; }
  .source-view { position: static; }
}
