:root {
  --bg: #fbf8f3;
  --surface: #ffffff;
  --surface-2: #f3eee5;
  --text: #1b1a2e;
  --muted: #5d5a70;
  --border: #e4ddd0;
  --accent: #a85f00;
  --accent-ink: #ffffff;
  --header-bg: #1e1b4b;
  --header-text: #ead8b8;
  --pass: #1f7a4d;
  --pass-bg: #e3f4ea;
  --warn: #8a5a00;
  --warn-bg: #fdf0d5;
  --fail: #b42318;
  --fail-bg: #fde7e4;
  --info: #2b4fb3;
  --info-bg: #e5ecfb;
  --skip: #6b6b7b;
  --skip-bg: #ecebf0;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1022;
    --surface: #141a33;
    --surface-2: #1b2242;
    --text: #f1ece2;
    --muted: #a9a6bd;
    --border: #2a3156;
    --accent: #ffb347;
    --accent-ink: #1e1b4b;
    --header-bg: #0b1022;
    --header-text: #ead8b8;
    --pass: #5fd39a;
    --pass-bg: #123326;
    --warn: #ffc56b;
    --warn-bg: #3a2c10;
    --fail: #ff8a7f;
    --fail-bg: #3d1716;
    --info: #9db6ff;
    --info-bg: #18244a;
    --skip: #a3a3b5;
    --skip-bg: #23283f;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1022;
  --surface: #141a33;
  --surface-2: #1b2242;
  --text: #f1ece2;
  --muted: #a9a6bd;
  --border: #2a3156;
  --accent: #ffb347;
  --accent-ink: #1e1b4b;
  --header-bg: #0b1022;
  --header-text: #ead8b8;
  --pass: #5fd39a;
  --pass-bg: #123326;
  --warn: #ffc56b;
  --warn-bg: #3a2c10;
  --fail: #ff8a7f;
  --fail-bg: #3d1716;
  --info: #9db6ff;
  --info-bg: #18244a;
  --skip: #a3a3b5;
  --skip-bg: #23283f;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}

a { color: var(--accent); }
code, pre { font-family: var(--mono); font-size: 0.88em; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px; }

.top { background: var(--header-bg); color: var(--header-text); border-bottom: 1px solid #ffffff14; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 1.1rem; }
.brand img { border-radius: 9px; }

.pill {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid #ffffff2e; background: #ffffff10; color: var(--header-text);
  padding: 6px 12px; border-radius: 999px; font: inherit; font-size: 0.88rem; cursor: pointer;
  max-width: 60vw;
}
.pill:hover { background: #ffffff1c; }
.pill-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #8b8aa0; flex: none; }
.pill[data-state="connected"] .dot { background: #4ade80; box-shadow: 0 0 0 3px #4ade8033; }
.pill[data-state="offline"] .dot,
.pill[data-state="error"] .dot { background: #f87171; box-shadow: 0 0 0 3px #f8717133; }
.pill[data-state="checking"] .dot { background: #ffb347; animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: 0.35; } }

.hero { padding: 36px 0 8px; }
.hero h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.2; margin: 0 0 10px; }
.lead { color: var(--muted); max-width: 70ch; margin: 0 0 20px; }

.summary {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px;
}
.counts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.counts .verdict { font-weight: 600; margin-right: 6px; }
.actions { display: flex; gap: 8px; }

.legend { color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }

.btn {
  font: inherit; font-size: 0.92rem; padding: 7px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn:disabled { opacity: 0.6; cursor: progress; }

.badge {
  display: inline-block; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.02em;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: var(--skip-bg); color: var(--skip);
}
.badge.pass { background: var(--pass-bg); color: var(--pass); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.fail { background: var(--fail-bg); color: var(--fail); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.running { background: var(--surface-2); color: var(--muted); }

.group { margin: 36px 0; }
.group h2 { font-size: 1.25rem; margin: 0 0 4px; }
.group-lead { color: var(--muted); margin: 0 0 14px; }
.cards { display: grid; gap: 10px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.card[data-status="fail"] { border-left: 4px solid var(--fail); }
.card[data-status="warn"] { border-left: 4px solid var(--warn); }

.card-head {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "badge title chev" "badge summary chev";
  gap: 2px 12px; align-items: center; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; padding: 14px 16px; cursor: pointer;
}
.card-head .badge { grid-area: badge; align-self: start; margin-top: 3px; min-width: 76px; text-align: center; }
.card-title { grid-area: title; font-weight: 600; }
.card-summary { grid-area: summary; color: var(--muted); font-size: 0.93rem; overflow-wrap: anywhere; }
.chev { grid-area: chev; width: 10px; height: 10px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; margin-right: 4px; }
.card-head[aria-expanded="true"] .chev { transform: rotate(-135deg); }

.card-body { padding: 0 16px 16px; border-top: 1px solid var(--border); }
.card.open .card-body { border-top: 0; padding-top: 16px; }
.card-body h3 { margin: 0 0 8px; font-size: 1.05rem; }

.kv { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.9rem; table-layout: fixed; }
.kv th { text-align: left; font-weight: 600; color: var(--muted); width: 34%; padding: 6px 12px 6px 0; vertical-align: top; }
.kv td { padding: 6px 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 0.85rem; }
.kv tr + tr th, .kv tr + tr td { border-top: 1px solid var(--border); }

.why { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 0.92rem; margin: 14px 0 0; }
.why::before { content: "Why it matters: "; font-weight: 600; }

.raw { margin-top: 10px; font-size: 0.85rem; }
.raw summary { cursor: pointer; color: var(--muted); }
.raw pre, .cmd {
  background: var(--surface-2); border-radius: 8px; padding: 10px 12px; overflow-x: auto; max-height: 360px;
  white-space: pre; margin: 8px 0 0;
}

.plain { padding-left: 18px; margin: 0; }
.plain li + li { margin-top: 8px; }

.foot { border-top: 1px solid var(--border); color: var(--muted); font-size: 0.88rem; padding: 18px 0 28px; margin-top: 40px; }

.dialog {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 32px));
  background: var(--surface); color: var(--text);
}
.dialog::backdrop { background: #0b102299; }
.dialog-body { padding: 20px; display: grid; gap: 8px; }
.dialog-body h2 { margin: 0; font-size: 1.2rem; }
.dialog-body input {
  font: inherit; font-family: var(--mono); font-size: 0.9rem; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); width: 100%;
}
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.features { list-style: none; padding: 0; margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 0.82rem; }

@media (max-width: 560px) {
  .card-head { grid-template-columns: 1fr auto; grid-template-areas: "badge chev" "title chev" "summary chev"; }
  .card-head .badge { justify-self: start; min-width: 0; }
  .kv th { width: 40%; }
  .pill { max-width: 52vw; }
}
