*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: var(--text-md)/1.6 var(--font-sans); -webkit-font-smoothing: antialiased;
}
/* Circuit traces and a warm glow behind everything, as on gridhawk.ai. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 0% 100%, var(--glow), transparent 60%),
    radial-gradient(50rem 32rem at 100% 0%, var(--glow), transparent 62%),
    url("../circuit.svg") top right / 900px auto no-repeat;
}
h1, h2, h3, p { margin: 0; }
h1 {
  font: 800 var(--text-xl)/1.02 var(--font-display); letter-spacing: -0.035em; text-wrap: balance;
  background: var(--heading); -webkit-background-clip: text; background-clip: text; color: transparent;
  padding-bottom: 0.08em;
}
h2 { font: 700 var(--text-lg)/1.25 var(--font-display); letter-spacing: -0.015em; color: var(--text-strong); }
h3 { font-size: var(--text-md); font-weight: 600; color: var(--text-strong); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; z-index: 10; background: var(--primary); color: var(--on-primary); padding: 0.5rem 1rem; }
.muted { color: var(--muted); }
.small { font-size: var(--text-sm); }
.mono { font-family: var(--font-mono); font-size: 0.86em; overflow-wrap: anywhere; }
[hidden] { display: none !important; }
details summary { cursor: pointer; }

/* Shell: scrolling tab bar on small screens, side rail from 900px. */
.shell { min-height: 100dvh; display: grid; grid-template: "brand" auto "view" 1fr / minmax(0, 1fr); }
.brand { grid-area: brand; display: flex; align-items: center; gap: 0.75rem; padding: 1rem var(--pad); border-bottom: 1px solid var(--line); }
.brand div { display: flex; flex-direction: column; gap: 0.1rem; line-height: 1.1; }
.brand strong { font: 800 1.2rem var(--font-display); color: var(--text-strong); letter-spacing: -0.02em; }
.brand strong em { font-style: normal; color: var(--primary); }
.brand span { font: 500 0.625rem var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: var(--track); }
#view { grid-area: view; padding: var(--pad); padding-bottom: calc(var(--pad) + 78px + env(safe-area-inset-bottom)); max-width: 1240px; width: 100%; margin-inline: auto; outline: none; }
#nav {
  position: fixed; inset: auto 0 0 0; z-index: 5; display: flex; overflow-x: auto; scrollbar-width: none;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line); padding: 0 0 env(safe-area-inset-bottom);
}
#nav::-webkit-scrollbar { display: none; }
#nav a {
  flex: 1 0 auto; min-width: 76px; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem;
  color: var(--muted); text-decoration: none; font: 500 0.625rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em;
  padding: 0.4rem 0.7rem; border-top: 2px solid transparent; position: relative;
}
#nav a svg { width: 20px; height: 20px; }
#nav a span { white-space: nowrap; }
#nav a:hover { color: var(--text-strong); }
#nav a[aria-current="page"] { color: var(--primary); border-top-color: var(--primary); background: linear-gradient(var(--primary-soft), transparent); }
@media (min-width: 900px) {
  .shell { grid-template: "brand view" auto "nav view" 1fr / 236px minmax(0, 1fr); }
  .brand { border-bottom: 0; border-right: 1px solid var(--line); padding: 1.6rem 1.4rem 1.2rem; }
  #nav { position: sticky; top: 0; grid-area: nav; flex-direction: column; gap: 1px; align-self: start; height: 100%; inset: auto; overflow: visible; border-top: 0; border-right: 1px solid var(--line); padding: 0.4rem 0; backdrop-filter: none; background: none; }
  #nav a { flex: none; flex-direction: row; justify-content: flex-start; gap: 0.8rem; min-height: var(--tap); font-size: 0.6875rem; letter-spacing: var(--track); padding: 0 1.4rem; border-top: 0; border-left: 2px solid transparent; }
  #nav a[aria-current="page"] { border-left-color: var(--primary); background: linear-gradient(90deg, var(--primary-soft), transparent); }
  #nav a[aria-current="page"]::after { content: ""; position: absolute; right: -4px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px; background: var(--primary); box-shadow: 0 0 10px var(--primary); }
  #view { padding-bottom: var(--pad); }
}

.demo-note { grid-area: note; margin: 0; padding: 0.5rem var(--pad); font: 500 0.625rem/1.5 var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--primary); background: var(--primary-soft); border-bottom: 1px solid var(--primary-line); }
.shell:has(.demo-note) { grid-template: "brand" auto "note" auto "view" 1fr / minmax(0, 1fr); }
@media (min-width: 900px) { .shell:has(.demo-note) { grid-template: "brand note" auto "brand view" auto "nav view" 1fr / 236px minmax(0, 1fr); } }

/* Layout primitives */
.stack { display: grid; gap: var(--gap); align-content: start; min-width: 0; }
.stack-lg { display: grid; gap: calc(var(--gap) * 1.7); align-content: start; }
.row { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min, 220px)), 1fr)); }
.split { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); align-items: start; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(1rem, 0.7rem + 1vw, 1.5rem); min-width: 0; backdrop-filter: blur(6px);
}
/* The square node from the circuit traces, pinned to each panel's corner. */
.card::before { content: ""; position: absolute; top: -4px; left: -4px; width: 7px; height: 7px; background: var(--bg); border: 1px solid var(--primary-line); }
.card.live::before { background: var(--primary); box-shadow: 0 0 10px var(--primary); }
.eyebrow { font: 500 var(--text-xs)/1.4 var(--font-mono); text-transform: uppercase; letter-spacing: var(--track); color: var(--muted); }
header .eyebrow, .eyebrow.hot { color: var(--primary); }
.lede { color: var(--text); max-width: 60ch; font-size: var(--text-lg); line-height: 1.5; }

/* Stat tiles and gauges */
.stat b { display: block; font: 800 var(--text-xl)/1 var(--font-display); color: var(--text-strong); font-variant-numeric: tabular-nums; letter-spacing: -0.03em; margin-top: 0.5rem; }
.stat small { color: var(--muted); font-size: var(--text-sm); }
.bar { display: flex; height: 6px; overflow: hidden; background: var(--surface-2); margin-top: 0.9rem; gap: 2px; }
.bar i { display: block; min-width: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; margin-top: 0.7rem; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.legend span::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 0.45rem; background: var(--c); }
.ring { display: flex; align-items: center; gap: 1rem; }
.ring svg { width: 92px; height: 92px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 9; }
.ring .track { stroke: var(--surface-2); }
.ring .value { stroke: var(--c, var(--primary)); stroke-linecap: butt; transition: stroke-dashoffset 0.8s cubic-bezier(0.2, 0.8, 0.2, 1); }
.ring b { font: 800 1.9rem/1 var(--font-display); color: var(--text-strong); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.ring b small { font: 500 var(--text-sm) var(--font-sans); color: var(--muted); letter-spacing: 0; }
.ring p { font-size: var(--text-sm); color: var(--muted); margin-top: 0.25rem; }
.module { display: grid; gap: 0.5rem; text-decoration: none; color: inherit; transition: border-color 0.15s, transform 0.15s; }
.module:hover { border-color: var(--primary-line); transform: translateY(-2px); }
.module:hover::before { background: var(--primary); box-shadow: 0 0 10px var(--primary); }
.module svg { width: 22px; height: 22px; color: var(--primary); }
.module p { font-size: var(--text-sm); color: var(--muted); }
.module .state { font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--text); }

/* Badges: colour always paired with a word */
.badge { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.2rem 0.55rem; font: 500 var(--text-xs)/1.3 var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; background: var(--info-soft); color: var(--info); white-space: nowrap; border-radius: 2px; }
.badge::before { content: ""; width: 6px; height: 6px; background: currentColor; }
.badge.plain { text-transform: none; letter-spacing: 0; }
.tone-bad { background: var(--bad-soft); color: var(--bad); }
.tone-warn { background: var(--warn-soft); color: var(--warn); }
.tone-good { background: var(--good-soft); color: var(--good); }
.fill-bad { background: var(--bad); } .fill-warn { background: var(--warn); } .fill-good { background: var(--good); } .fill-info { background: var(--info); }

/* Controls */
.btn { min-height: var(--tap); padding: 0 1.3rem; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: transparent; cursor: pointer; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: var(--track); display: inline-flex; align-items: center; gap: 0.6rem; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); font-weight: 600; box-shadow: 0 0 0 0 var(--primary); transition: box-shadow 0.2s, filter 0.2s; }
.btn.primary::after { content: "→"; font-size: 1.1em; transition: transform 0.2s; }
.btn.primary:hover { filter: brightness(1.08); box-shadow: 0 0 24px -4px var(--primary); }
.btn.primary:hover::after { transform: translateX(3px); }
.btn:disabled { opacity: 0.55; cursor: progress; }
.chip { min-height: 36px; padding: 0 0.85rem; border-radius: 2px; border: 1px solid var(--line); background: var(--surface-2); cursor: pointer; font-size: var(--text-sm); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: border-color 0.15s, color 0.15s; }
.chip:hover { border-color: var(--primary); color: var(--text-strong); }
textarea, select, input[type="number"], input[type="text"] { width: 100%; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 0.7rem 0.8rem; }
textarea:focus, select:focus, input:focus { border-color: var(--primary-line); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
textarea { min-height: 9rem; resize: vertical; font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.55; }
select, input[type="number"], input[type="text"] { min-height: var(--tap); }
select option { background: var(--surface-solid); color: var(--text-strong); }
label { display: grid; gap: 0.4rem; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
label > :not(small) { font: var(--text-md) var(--font-sans); text-transform: none; letter-spacing: 0; color: var(--text-strong); }
label textarea { font-family: var(--font-mono); font-size: 0.8125rem; }
label small { font: var(--text-sm) var(--font-sans); text-transform: none; letter-spacing: 0; }
.seg { display: inline-flex; border: 1px solid var(--line); }
.seg button { min-height: 38px; padding: 0 1rem; border: 0; background: transparent; cursor: pointer; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--primary-soft); color: var(--primary); }
.drop { border: 1px dashed var(--line-strong); padding: clamp(1.2rem, 4vw, 2.4rem) 1rem; text-align: center; display: grid; gap: 0.7rem; justify-items: center; transition: border-color 0.15s, background 0.15s; }
.drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop strong { color: var(--text-strong); }

/* Results and findings */
.verdict { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem 1rem; }
.verdict .word { font: 800 var(--text-xl)/1 var(--font-display); letter-spacing: -0.03em; text-transform: capitalize; }
.c-bad { color: var(--bad); } .c-warn { color: var(--warn); } .c-good { color: var(--good); } .c-info { color: var(--info); }
.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr)); gap: 0.8rem 1.2rem; font-size: var(--text-sm); }
.meta dt { font: 500 var(--text-xs) var(--font-mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 0.15rem; }
.meta dd { margin: 0; overflow-wrap: anywhere; color: var(--text-strong); }
dl { margin: 0; }
.finding { border: 1px solid var(--line); border-left: 2px solid var(--edge, var(--info)); padding: 0.85rem 1rem; display: grid; gap: 0.45rem; background: var(--surface-2); min-width: 0; }
.finding p { font-size: var(--text-sm); color: var(--text); }
.finding code { display: block; font-family: var(--font-mono); font-size: 0.75rem; background: var(--bg); border: 1px solid var(--line); padding: 0.5rem 0.65rem; overflow-wrap: anywhere; white-space: pre-wrap; color: var(--text-strong); }
.tags { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font: var(--text-xs) var(--font-mono); color: var(--muted); }
pre.redacted { margin: 0; font-family: var(--font-mono); font-size: 0.8125rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); padding: 0.75rem 0.85rem; color: var(--text-strong); max-height: 22rem; overflow: auto; }

/* The firewall path: application → Vigil → model, lit by the last decision. */
.flow { display: grid; grid-template-columns: minmax(3.2rem, 1fr) auto minmax(3.2rem, 1fr) auto minmax(3.2rem, 1fr); align-items: center; gap: 0.4rem; }
.flow .node { border: 1px solid var(--line-strong); padding: 0.7rem 0.4rem; overflow: hidden; text-overflow: ellipsis; text-align: center; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-strong); background: var(--surface-solid); min-width: 0; }
.flow .node.core { border-color: var(--primary); color: var(--primary); box-shadow: 0 0 22px -6px var(--primary); }
.flow .node.off { opacity: 0.4; border-style: dashed; }
.flow .wire { display: grid; gap: 0.35rem; min-width: clamp(74px, 18vw, 150px); }
.flow .wire i { display: block; height: 2px; background: var(--c, var(--line-strong)); position: relative; }
.flow .wire i.stop { background: linear-gradient(90deg, var(--c) 55%, transparent 55%); }
.flow .wire i.stop::after { content: ""; position: absolute; left: 55%; top: -4px; width: 2px; height: 10px; background: var(--c); }
.flow .wire i.back.stop { background: linear-gradient(270deg, var(--c) 55%, transparent 55%); }
.flow .wire i.back.stop::after { left: 45%; }
.flow .wire span { font: 500 0.625rem var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--c, var(--muted)); text-align: center; white-space: nowrap; }

/* Tables that become stacked rows on narrow screens */
.table { display: grid; }
.table .tr { display: grid; grid-template-columns: var(--cols); gap: 0.3rem 1rem; padding: 0.65rem 0.2rem; border-top: 1px solid var(--line); align-items: center; font-size: var(--text-sm); min-width: 0; }
.table .tr.head { border-top: 0; font: 500 var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding-bottom: 0.4rem; }
.table .tr > * { min-width: 0; overflow-wrap: anywhere; }
.table button.tr { background: none; border-inline: 0; border-bottom: 0; text-align: left; width: 100%; cursor: pointer; color: inherit; }
.table button.tr:hover { background: var(--surface-2); }
@container (max-width: 560px) { .table .tr { grid-template-columns: 1fr; } .table .tr.head { display: none; } }
.cq { container-type: inline-size; }

/* History list */
.list { display: grid; }
.item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 0.2rem 0.8rem; align-items: center; padding: 0.75rem 0.3rem; border-top: 1px solid var(--line); background: none; border-inline: 0; border-bottom: 0; text-align: left; width: 100%; cursor: pointer; min-height: var(--tap); color: inherit; }
.item:first-child { border-top: 0; }
.item:hover { background: var(--surface-2); }
.item .title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-strong); font-size: var(--text-sm); }
.item .sub { grid-column: 2 / -1; font: var(--text-xs) var(--font-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item time { font: var(--text-xs) var(--font-mono); color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); font-size: var(--text-sm); padding: 0.6rem 0; }
.notice { border: 1px solid var(--bad); background: var(--bad-soft); color: var(--text-strong); padding: 0.75rem 1rem; font-size: var(--text-sm); }
.saved { color: var(--good); font-size: var(--text-sm); }
.working { display: flex; align-items: center; gap: 0.7rem; color: var(--muted); font: var(--text-xs) var(--font-mono); text-transform: uppercase; letter-spacing: 0.1em; }
.working::before { content: ""; width: 8px; height: 8px; background: var(--primary); animation: pulse 1s steps(2) infinite; }
@keyframes pulse { 50% { opacity: 0.2; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }
@media print { #nav, .drop, .btn, .chip, body::before { display: none !important; } body { background: #fff; color: #000; } h1 { color: #000; background: none; } }
