:root {
  --bg: #f7f8fb;
  --bg-alt: #eef1f6;
  --surface: #ffffff;
  --surface-2: #f3f5f9;
  --border: #dfe3ec;
  --text: #0f172a;
  --muted: #55607a;
  --accent: #0284c7;
  --accent-2: #7c3aed;
  --accent-ink: #ffffff;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --critical: #dc2626;
  --high: #ea580c;
  --medium: #ca8a04;
  --low: #2563eb;
  --info: #64748b;
  --ok: #16a34a;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius: 14px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0f17;
    --bg-alt: #0f1521;
    --surface: #121a28;
    --surface-2: #172133;
    --border: #243049;
    --text: #e6ebf5;
    --muted: #93a0b8;
    --accent: #38bdf8;
    --accent-2: #a78bfa;
    --accent-ink: #04111d;
    --code-bg: #0a0f19;
    --code-text: #dbe4f3;
    --critical: #f87171;
    --high: #fb923c;
    --medium: #facc15;
    --low: #60a5fa;
    --info: #94a3b8;
    --ok: #4ade80;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0f17;
  --bg-alt: #0f1521;
  --surface: #121a28;
  --surface-2: #172133;
  --border: #243049;
  --text: #e6ebf5;
  --muted: #93a0b8;
  --accent: #38bdf8;
  --accent-2: #a78bfa;
  --accent-ink: #04111d;
  --code-bg: #0a0f19;
  --code-text: #dbe4f3;
  --critical: #f87171;
  --high: #fb923c;
  --medium: #facc15;
  --low: #60a5fa;
  --info: #94a3b8;
  --ok: #4ade80;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; animation: none !important; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, kbd { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 6px; padding: 0.05em 0.35em; overflow-wrap: anywhere; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: 16px; top: 12px; z-index: 100; background: var(--surface); padding: 8px 12px; border-radius: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* NAV */
.nav { position: sticky; top: 0; z-index: 50; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(160%) blur(10px); border-bottom: 1px solid var(--border); }
.nav-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.1rem; color: var(--text); }
.brand svg { color: var(--accent); }
.brand-bg { fill: var(--surface-2); }
.brand:hover { text-decoration: none; }
.nav nav { display: flex; gap: 20px; margin-left: 8px; }
.nav nav a { color: var(--muted); font-weight: 500; font-size: 0.95rem; }
.nav nav a:hover { color: var(--text); text-decoration: none; }
.nav-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
@media (max-width: 860px) { .nav nav { display: none; } }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 10px; font: 600 0.95rem var(--sans); border: 1px solid transparent; cursor: pointer; transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease; white-space: nowrap; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 86%, var(--text)); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border); background: transparent; color: var(--text); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.chip { border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 6px 12px; border-radius: 999px; font: 500 0.85rem var(--sans); cursor: pointer; }
.chip:hover, .chip[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

/* HERO */
.hero { padding: 72px 0 56px; background: radial-gradient(1200px 420px at 85% -10%, color-mix(in srgb, var(--accent-2) 18%, transparent), transparent 60%), radial-gradient(900px 380px at -10% 10%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 60%); }
.hero-grid { display: grid; grid-template-columns: 1.05fr 1fr; gap: 48px; align-items: center; }
@media (max-width: 960px) { .hero-grid { grid-template-columns: 1fr; } }
.eyebrow { text-transform: uppercase; letter-spacing: 0.12em; font-size: 0.78rem; font-weight: 700; color: var(--accent); margin-bottom: 14px; }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); font-weight: 800; }
h1 code { font-size: 0.82em; background: none; border: 0; padding: 0; color: var(--accent); }
h1 em { font-style: normal; background: linear-gradient(90deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { font-size: 1.15rem; color: var(--muted); max-width: 56ch; }
.cta { display: flex; gap: 12px; flex-wrap: wrap; margin: 24px 0; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0; }
.pills li { font-size: 0.82rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; background: var(--surface); }

.pr-card { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.pr-head { display: flex; align-items: center; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.dot { width: 10px; height: 10px; border-radius: 50%; }
.dot.r { background: #ef4444; } .dot.y { background: #eab308; } .dot.g { background: #22c55e; }
.pr-title { margin-left: 8px; font-size: 0.8rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-body { padding: 18px; font-size: 0.92rem; }
.pr-h { font-weight: 700; font-size: 1.05rem; margin-bottom: 2px; }
.pr-meta { color: var(--muted); font-size: 0.85rem; }
.pr-row { padding: 10px 0; border-top: 1px dashed var(--border); overflow-wrap: anywhere; }
.pr-row small { display: block; color: var(--muted); margin-top: 4px; }

/* SEVERITY */
.sev { display: inline-block; font: 700 0.68rem var(--sans); letter-spacing: 0.06em; padding: 2px 7px; border-radius: 6px; margin-right: 8px; vertical-align: 1px; color: #fff; }
.sev-critical { background: var(--critical); } .sev-high { background: var(--high); } .sev-medium { background: var(--medium); color: #1f1600; } .sev-low { background: var(--low); } .sev-info { background: var(--info); } .sev-none { background: var(--ok); }

/* SECTIONS */
.section { padding: 72px 0; }
.section.alt { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; }
.section-head { margin-bottom: 24px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid3 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); min-width: 0; }
.card h3 { font-size: 1.08rem; }
.card p { color: var(--muted); margin: 0; }
.problem { padding-top: 24px; }

/* ANALYZER */
.analyzer { display: grid; grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .analyzer { grid-template-columns: 1fr; } }
.input-panel, .result-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 22px 14px; border: 2px dashed var(--border); border-radius: 12px; cursor: pointer; color: var(--muted); transition: border-color 0.15s, background 0.15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 7%, transparent); color: var(--text); }
.drop code { font-size: 0.72rem; overflow-wrap: anywhere; }
.label { display: block; font-weight: 600; font-size: 0.85rem; margin: 14px 0 6px; }
textarea, select, input[type="search"] { width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; font: 0.82rem/1.5 var(--mono); }
textarea { min-height: 150px; resize: vertical; }
textarea.short { min-height: 110px; }
select, input[type="search"] { font-family: var(--sans); font-size: 0.9rem; }
.config { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.config summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.config-body { padding-bottom: 6px; }
.run-row { display: flex; gap: 10px; margin-top: 14px; }
.error { color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, transparent); border: 1px solid color-mix(in srgb, var(--critical) 40%, transparent); padding: 10px 12px; border-radius: 10px; margin: 12px 0 0; white-space: pre-wrap; font-size: 0.88rem; }

.empty { display: grid; place-items: center; text-align: center; gap: 8px; color: var(--muted); min-height: 360px; }
.r-head { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.ring { position: relative; width: 96px; height: 96px; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .track { stroke: var(--surface-2); }
.ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; line-height: 1; }
.ring-label b { font-size: 1.6rem; }
.ring-label span { font-size: 0.68rem; color: var(--muted); display: block; margin-top: 2px; }
.r-title { min-width: 0; flex: 1; }
.r-title h3 { margin: 0 0 6px; font-size: 1.2rem; overflow-wrap: anywhere; }
.gate { font-weight: 700; font-size: 0.9rem; }
.gate.pass { color: var(--ok); } .gate.fail { color: var(--critical); }
.counts { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; margin: 16px 0; }
@media (max-width: 560px) { .counts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.count { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 6px; text-align: center; }
.count b { display: block; font-size: 1.15rem; }
.count span { font-size: 0.7rem; color: var(--muted); }
.count.hot b { color: var(--critical); }
.r-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.r-actions .btn { padding: 7px 12px; font-size: 0.85rem; }
.warn { background: color-mix(in srgb, var(--medium) 14%, transparent); border: 1px solid color-mix(in srgb, var(--medium) 40%, transparent); border-radius: 10px; padding: 8px 12px; font-size: 0.88rem; margin: 8px 0; }
.findings { display: grid; gap: 8px; margin-top: 10px; }
.finding { border: 1px solid var(--border); border-left: 4px solid var(--info); border-radius: 10px; background: var(--surface); }
.finding.critical { border-left-color: var(--critical); } .finding.high { border-left-color: var(--high); } .finding.medium { border-left-color: var(--medium); } .finding.low { border-left-color: var(--low); }
.finding summary { cursor: pointer; padding: 10px 12px; list-style: none; display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start; }
.finding summary::-webkit-details-marker { display: none; }
.finding .rid { font: 600 0.75rem var(--mono); color: var(--muted); }
.finding .msg { grid-column: 1 / -1; overflow-wrap: anywhere; font-size: 0.93rem; }
.finding .body { padding: 0 12px 12px; font-size: 0.88rem; color: var(--muted); }
.finding .body ul { margin: 0 0 8px; padding-left: 18px; }
.finding .body li { overflow-wrap: anywhere; }
.finding .fix { color: var(--text); }
.finding pre, .code pre { background: var(--code-bg); color: var(--code-text); padding: 12px 14px; border-radius: 10px; overflow-x: auto; margin: 6px 0; font-size: 0.8rem; line-height: 1.55; }
.group-title { margin: 18px 0 6px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.changes { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; }
.changes summary { cursor: pointer; font-weight: 600; }
.changes table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: 8px; table-layout: fixed; }
.changes td { padding: 6px 4px; border-top: 1px solid var(--border); vertical-align: top; overflow-wrap: anywhere; }
.changes td:first-child { width: 92px; font-weight: 600; }
.kind-delete, .kind-replace { color: var(--critical); } .kind-create { color: var(--ok); } .kind-update { color: var(--medium); }
.clean { text-align: center; padding: 26px 8px; color: var(--ok); font-weight: 600; }

/* STEPS */
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; counter-reset: s; }
@media (max-width: 960px) { .steps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .steps { grid-template-columns: 1fr; } }
.steps li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.steps p { color: var(--muted); margin: 0; font-size: 0.93rem; }
.step-n { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-weight: 800; margin-bottom: 10px; }

/* RULES */
.rule-filters { display: flex; gap: 10px; margin-bottom: 16px; }
.rule-filters input { flex: 1; }
.rule-filters select { width: auto; min-width: 170px; }
@media (max-width: 560px) { .rule-filters { flex-direction: column; } .rule-filters select { width: 100%; } }
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; }
@media (max-width: 400px) { .rule-grid { grid-template-columns: 1fr; } }
.rule { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px; min-width: 0; }
.rule header { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; flex-wrap: wrap; }
.rule .rid { font: 600 0.78rem var(--mono); color: var(--muted); margin-left: auto; }
.rule h3 { font-size: 0.98rem; margin: 0 0 6px; }
.rule p { margin: 0; color: var(--muted); font-size: 0.86rem; }
.rule .cat { font-size: 0.72rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; }

/* TABS / CODE */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; color: var(--muted); padding: 10px 14px; font: 600 0.92rem var(--sans); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.code { position: relative; }
.code pre { padding: 16px 18px; }
.copy { position: absolute; top: 8px; right: 8px; background: color-mix(in srgb, var(--code-text) 12%, transparent); color: var(--code-text); border: 1px solid color-mix(in srgb, var(--code-text) 25%, transparent); border-radius: 8px; padding: 4px 10px; font: 600 0.75rem var(--sans); cursor: pointer; }

/* FAQ */
.faq { display: grid; gap: 10px; max-width: 900px; }
.faq details { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq p { color: var(--muted); margin: 10px 0 0; }

.footer { padding: 28px 0; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.9rem; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer p { margin: 0; }

/* v1.1 additions */
.grid3.features { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid3.features { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .grid3.features { grid-template-columns: 1fr; } }
.cost { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 0 0 12px; font-size: 0.9rem; }
.cost b { font-size: 1rem; }
.cost .up { color: var(--high); font-weight: 700; }
.cost .down { color: var(--ok); font-weight: 700; }
.cost ul { flex-basis: 100%; margin: 4px 0 0; padding-left: 18px; color: var(--muted); font-size: 0.82rem; }
.cost li { overflow-wrap: anywhere; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 14px 0 4px; }
.filter-bar input { flex: 1 1 180px; width: auto; padding: 6px 10px; font-size: 0.85rem; }
.filter-bar .chip { padding: 4px 10px; font-size: 0.78rem; }
.filter-bar .chip[aria-pressed="false"] { opacity: 0.45; }
.filter-empty { color: var(--muted); font-size: 0.88rem; padding: 10px 2px; }
.cost-missing { border-style: dashed; }
.cost-missing code { font-size: 0.76rem; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }
.error.info { color: var(--text); background: color-mix(in srgb, var(--accent) 10%, transparent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.rule-doc { margin-top: 16px; scroll-margin-top: 80px; }
.rule-doc h2 { font-size: 1.25rem; }
a.rule { color: inherit; display: block; }
a.rule:hover { border-color: var(--accent); text-decoration: none; }
.lead code { font-size: 0.85em; }
