/* wall · forged terminal
 *
 * Ground #0B0D10, panels #0E1115 / #12151A, hairlines #1A1E24 / #2A3038.
 * Amber is the brand and primary accent; ember is only for blocked or
 * destructive things; cyan is only for allowed things and taps.
 * IBM Plex Sans for prose, IBM Plex Mono for data, labels and buttons.
 */

/* --- Fonts (self-hosted, SIL OFL 1.1; see fonts/OFL-*.txt) --- */
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 500; font-display: swap; src: url("fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-mono-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-style: normal; font-weight: 700; font-display: swap; src: url("fonts/ibm-plex-mono-latin-700-normal.woff2") format("woff2"); }

:root {
  color-scheme: dark;

  --ground: #0B0D10;
  --panel: #0E1115;
  --panel-2: #12151A;
  --panel-3: #14171C;
  --well: #07090C;
  --line: #1A1E24;
  --line-soft: #15181D;
  --line-2: #2A3038;
  --line-3: #3D4550;
  --steel: #191D23;
  --steel-hi: #1F242B;
  --steel-lo: #15191E;

  --text: #E8EAED;
  --text-2: #C9D0D8;
  --text-3: #B8C0CA;
  --muted: #9AA3AE;
  --faint: #7C8591;
  --placeholder: #5D6570;
  --led-off: #3A3F47;

  --amber: #FFB224;
  --amber-hi: #FFC24D;
  --amber-lo: #F0A416;
  --amber-ink: #16110A;
  --ember: #FF5A36;
  --ember-text: #FF8A6E;
  --cyan: #5CE1E6;

  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 10px;
  --gutter: 48px;
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }
body {
  background: var(--ground);
  color: var(--text);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a { color: var(--text-2); text-decoration: none; cursor: pointer; }
a:hover { color: var(--amber); }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

h1, h2, h3, h4, p { margin: 0; }
h1 { font: 600 32px/1.1 var(--sans); letter-spacing: -.01em; }
h2 { font: 600 18px/1.2 var(--sans); }
h3 { font: 600 15px/1.2 var(--mono); }
.h-sm { font-size: 16px; }
.h1-mono { font: 600 26px/1.2 var(--mono); overflow-wrap: anywhere; }
.h1-mono .expr { font: inherit; }

code {
  font: 500 .92em/1.3 var(--mono);
  color: var(--text);
  background: var(--panel-3);
  padding: 1px 6px;
  border-radius: 4px;
  overflow-wrap: anywhere;
}

pre {
  margin: 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--well);
  border: 1px solid var(--line);
  font: 400 13px/1.55 var(--mono);
  color: var(--text-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 480px;
  overflow: auto;
}

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap; border: 0;
}

/* --- Type helpers --- */
.eyebrow {
  margin: 0;
  font: 600 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow--status { display: flex; align-items: center; gap: 8px; }
.meta { font: 400 12px/1.5 var(--mono); color: var(--muted); }
.meta code { font-size: 12px; }
.lede { max-width: 640px; font: 400 15px/1.5 var(--sans); color: var(--muted); }
.sub { font: 400 13px/1 var(--mono); color: var(--muted); }
.prose { font-family: var(--sans) !important; }
.amber-text { color: var(--amber); }
.ember-text { color: var(--ember-text); }
.cool-text { color: var(--cyan); }
.legend { margin: 0; }

/* --- Logo --- */
.brand { display: flex; align-items: center; gap: 12px; padding: 0 12px; }
.brand .mark { width: 32px; height: 32px; flex: none; }
.wordmark { font: 700 26px/1 var(--mono); letter-spacing: -.03em; color: var(--text); }
.brand--lg { gap: 18px; padding: 0; }
.brand--lg .mark { width: 64px; height: 64px; }
.brand--lg .wordmark { font-size: 56px; }

/* --- LEDs --- */
.led {
  display: inline-block;
  flex: none;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 6px rgba(255,178,36,.55);
}
.led--amber { background: var(--amber); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 6px rgba(255,178,36,.55); }
.led--off { background: var(--led-off); box-shadow: 0 0 0 1px rgba(0,0,0,.6); }
.led--ember { background: var(--ember); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 6px rgba(255,90,54,.55); }
.led--cool { background: var(--cyan); box-shadow: 0 0 0 1px rgba(0,0,0,.6), 0 0 6px rgba(92,225,230,.55); }

/* Status: an LED dot plus a word */
.status { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.status--cool { color: var(--cyan); }
.status--ember { color: var(--ember-text); }
.status--amber { color: var(--amber); }
.status--muted { color: var(--muted); }

/* --- Forged keys (buttons) --- */
.key {
  font: 600 13px/1 var(--mono);
  letter-spacing: .08em;
  text-transform: uppercase;
  height: 44px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  white-space: nowrap;
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--steel);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.45);
  transition: background .12s, border-color .12s, transform .06s;
}
.key:hover { color: var(--text); background: var(--steel-hi); border-color: var(--line-3); }
.key:active { transform: translateY(1px); background: var(--steel-lo); box-shadow: inset 0 1px 2px rgba(0,0,0,.5); }
.key:disabled, .key.htmx-request { cursor: not-allowed; opacity: .55; }
.key:disabled .led { background: var(--led-off); box-shadow: 0 0 0 1px rgba(0,0,0,.6); }

.key--sm { height: 32px; padding: 0 12px; font-size: 11px; gap: 8px; }
.key--lg { height: 56px; padding: 0 22px; font-size: 14px; }
.key--block { width: 100%; }

.key--primary {
  background: var(--amber);
  border-color: var(--amber);
  color: var(--amber-ink);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), 0 0 0 1px rgba(0,0,0,.25), 0 0 20px rgba(255,178,36,.16);
}
.key--primary:hover { background: var(--amber-hi); border-color: var(--amber-hi); color: var(--amber-ink); }
.key--primary:active { background: var(--amber-lo); box-shadow: inset 0 1px 2px rgba(0,0,0,.3); }
.key--primary:disabled { background: #2A2F37; border-color: #2A2F37; color: var(--faint); box-shadow: none; opacity: 1; }
.key--primary .led { background: var(--amber-ink); box-shadow: 0 0 0 2px rgba(22,17,10,.18); }

.key--ghost { background: none; box-shadow: none; border-color: transparent; color: var(--muted); }
.key--ghost:hover { background: var(--panel-3); border-color: var(--line-2); color: var(--text); }

.key--danger { color: var(--ember-text); }
.key--danger:hover { color: var(--ember-text); }

/* --- Switches --- */
.switch {
  position: relative;
  flex: none;
  width: 44px; height: 26px;
  padding: 0;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--panel-3);
  cursor: pointer;
  vertical-align: middle;
}
.switch span {
  position: absolute;
  top: 4px; left: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--led-off);
  transition: left .12s, background .12s;
}
.switch:hover { border-color: var(--line-3); }
.switch[aria-checked="true"] { border-color: #7A5510; background: rgba(255,178,36,.14); }
.switch[aria-checked="true"] span { left: 22px; background: var(--amber); box-shadow: 0 0 8px rgba(255,178,36,.6); }
.switch--cool[aria-checked="true"] { border-color: #1F6467; background: rgba(92,225,230,.12); }
.switch--cool[aria-checked="true"] span { background: var(--cyan); box-shadow: 0 0 8px rgba(92,225,230,.6); }
.switch.htmx-request { opacity: .6; }

/* A checkbox drawn as a switch, for create forms (posts "on" like before). */
.switch-input {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: none;
  margin: 0;
  width: 44px; height: 26px;
  border-radius: 13px;
  border: 1px solid var(--line-2);
  background: var(--panel-3);
  cursor: pointer;
}
.switch-input::after {
  content: "";
  position: absolute;
  top: 4px; left: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--led-off);
  transition: left .12s;
}
.switch-input:checked { border-color: #7A5510; background: rgba(255,178,36,.14); }
.switch-input:checked::after { left: 22px; background: var(--amber); box-shadow: 0 0 8px rgba(255,178,36,.6); }

.switch-label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font: 500 13px/1 var(--mono);
  color: var(--text-2);
  cursor: pointer;
}
.switch-label--meta { font: 400 12px/1 var(--mono); color: var(--muted); gap: 8px; min-height: 32px; }

/* --- Fields --- */
.field, .select {
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-2);
  background: var(--ground);
  color: var(--text);
  font: 500 14px/1 var(--mono);
  min-width: 0;
  transition: border-color .12s, box-shadow .12s;
}
.select { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("chevron.svg"); /* a file, not an inline URI: the CSP only allows self */
  background-repeat: no-repeat; background-position: right 12px center; }
.select option { background: var(--panel); color: var(--text); }
.field::placeholder { color: var(--placeholder); }
.field:focus, .select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 3px rgba(255,178,36,.18); }
.field--grow { flex: 1 1 240px; }
.select--grow { flex: 1 1 280px; }
.field--num { width: 104px; }
.field--amber, .select--amber { color: var(--amber); font: 600 15px/1 var(--mono); }
.field--secret { width: 100%; height: 48px; padding: 0 14px; color: var(--amber); caret-color: var(--amber); font: 500 15px/1 var(--mono); letter-spacing: .06em; }

.field-label { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.field-label .field { width: 100%; }
.field-label--grow { flex: 1 1 260px; }
.field-label--grow2 { flex: 2 1 320px; }
.field-label--narrow { max-width: 420px; }

/* --- Notices --- */
.notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-2);
  background: var(--panel);
  font: 400 14px/1.5 var(--sans);
  color: var(--text-2);
}
.notice .led { margin-top: 7px; }
.notice p { margin: 0; }
.notice--amber { border-color: rgba(255,178,36,.35); background: rgba(255,178,36,.06); color: var(--text); }
.notice--amber code { color: var(--amber); background: none; padding: 0; }
.notice--error { border-color: rgba(255,90,54,.35); background: rgba(255,90,54,.06); color: var(--ember-text); font: 500 13px/1.4 var(--mono); align-items: center; }
.notice--error .led { margin-top: 0; }
.notice--cool { border-color: rgba(92,225,230,.3); background: rgba(92,225,230,.06); color: var(--cyan); font: 500 14px/1.4 var(--mono); align-items: center; }
.notice--cool .led { margin-top: 0; }
.notice--cool a { color: var(--amber); }

/* --- App layout --- */
.app-layout {
  display: flex;
  min-height: 100vh;
  /* paint the sidebar column full height, even when the page scrolls past it */
  background: linear-gradient(90deg, var(--panel) 0 231px, var(--line) 231px 232px, transparent 232px);
}

.sidebar {
  flex: 0 0 232px;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 28px 16px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
}
.nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  padding: 0 12px;
  border-radius: 5px;
  font: 500 13px/1 var(--mono);
  letter-spacing: .04em;
  color: var(--text-2);
}
.nav a .led { visibility: hidden; }
.nav a:hover { color: var(--amber); background: rgba(20,23,28,.6); }
.nav a.active { background: var(--panel-3); color: var(--amber); box-shadow: inset 2px 0 0 var(--amber); }
.nav a.active .led { visibility: visible; }
.nav-footer { margin-top: auto; padding: 0 12px; }

.content {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  padding: 40px var(--gutter) 56px;
}

.page { position: relative; display: flex; flex-direction: column; gap: 24px; max-width: 1400px; }
.page > * { position: relative; }
.page-art { position: absolute !important; top: -40px; right: calc(-1 * var(--gutter)); pointer-events: none; opacity: .5; max-width: 60%; overflow: hidden; z-index: 0; }
.page-art svg { display: block; max-width: 100%; height: auto; }
.page-art--wide { opacity: .45; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.page-title { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.head-actions { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.head-switches { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.back-link { font: 400 12px/1.5 var(--mono); color: var(--muted); }
.warning-banner { margin-bottom: 24px; }

.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }

/* --- Panels --- */
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); min-width: 0; }
.pad { padding: 18px 20px; }
.panel-head { padding: 16px 16px 6px; }
.panel-head--split { display: flex; justify-content: space-between; align-items: baseline; gap: 8px 16px; flex-wrap: wrap; padding: 20px 20px 14px; }
.panel-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px 24px; flex-wrap: wrap; }
.panel-foot { padding: 14px 16px; border-top: 1px solid var(--line); margin: 0; }
.pad > .panel-foot { padding: 14px 0 0; }
.form-panel { padding: 22px; display: flex; flex-direction: column; gap: 18px; }
.form-panel:focus-within { border-color: var(--line-3); }

/* --- Forms --- */
.form-row { display: flex; gap: 12px 16px; flex-wrap: wrap; align-items: center; }
.form-row--end { align-items: flex-end; }
.form-row--split { justify-content: space-between; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.form-foot { padding-top: 14px; border-top: 1px solid var(--line); }
.inline-form { display: inline; margin: 0; }

.condition-builder { display: flex; flex-direction: column; gap: 10px; }
.condition-builder:empty { display: none; }
.condition-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cond-label {
  min-width: 32px;
  font: 400 12px/1.5 var(--mono);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}
#autoblock-conditions .cond-label, .autoblock-form .sentence .cond-label { min-width: 104px; text-transform: none; letter-spacing: 0; }

.sentence { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; font: 400 15px/1.6 var(--sans); color: var(--text-2); }
.sentence--lg { font-size: 17px; }

/* Autoblock: the counted fields follow the segmented control, no script needed. */
.autoblock-form .counted-fields { display: none; }
.autoblock-form:has(input[name="rule_type"][value="counted"]:checked) .counted-fields { display: flex; }

/* Segmented control (buttons with aria-pressed, or radio labels) */
.seg {
  display: inline-flex;
  margin: 0;
  padding: 3px;
  border-radius: 9px;
  background: var(--ground);
  border: 1px solid var(--line-2);
  min-width: 0;
}
.seg button, .seg label span {
  display: inline-flex;
  align-items: center;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: none;
  font: 600 12px/1 var(--mono);
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.seg button:hover, .seg label:hover span { color: var(--text); }
.seg button[aria-pressed="true"], .seg input:checked + span {
  background: var(--steel);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 0 0 1px var(--line-2);
}
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg input:focus-visible + span { outline: 2px solid var(--amber); outline-offset: 2px; }

/* --- Tables --- */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.rules-table { width: 100%; border-collapse: collapse; }
.t-wide { min-width: 900px; }
.t-mid { min-width: 760px; }
.t-narrow { min-width: 520px; }
.rules-table th, .rules-table td {
  text-align: left;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  font: 400 13px/1.4 var(--mono);
  color: var(--text-2);
  vertical-align: middle;
}
.rules-table th {
  font: 600 11px/1 var(--mono);
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 0;
  white-space: nowrap;
}
.rules-table td.value { color: var(--text); overflow-wrap: anywhere; }
.rules-table td.path { max-width: 520px; }
.rules-table td.actions { text-align: right; white-space: nowrap; }
.rules-table td.actions > * + * { margin-left: 6px; }
.rules-table td.empty, .empty { color: var(--faint); font: 400 13px/1.5 var(--mono); text-align: center; padding: 28px 16px; }
.rules-table tbody tr:hover td { background: rgba(20,23,28,.5); }
.rules-table tr.sel td { background: var(--panel-3); }
.rules-table tr.sel td:first-child { box-shadow: inset 2px 0 0 var(--cyan); }
.rules-table.nested { margin-top: 10px; min-width: 640px; }
.rules-table.nested th, .rules-table.nested td { padding: 8px 10px; font-size: 12px; }
details summary { cursor: pointer; color: var(--text-2); font: 500 13px/1.4 var(--mono); }
details summary:hover { color: var(--amber); }
details details { margin-top: 10px; }
details pre { margin-top: 8px; }

/* Readable rule expressions: ip = 203.0.113.9 and path ∋ /wp- */
.expr { font: 500 13px/1.6 var(--mono); color: var(--text); }
.expr b { font-weight: 500; color: var(--muted); }
.expr i { font-style: normal; color: var(--amber); padding: 0 6px; }
.expr .cond { white-space: normal; overflow-wrap: anywhere; }
.expr .and { padding: 0 2px; }
.rule { font: 400 15px/1.5 var(--sans); color: var(--text-2); }
.rule b { font: 600 14px/1 var(--mono); color: var(--text); }

.src-note { display: flex; flex-direction: column; gap: 2px; }
.src--agent { color: var(--amber); }
.src-note .note { font-family: var(--sans); color: var(--muted); }

/* --- Dashboard --- */
.chart-panel { padding: 20px 20px 16px; display: flex; flex-direction: column; gap: 16px; }
.stat-row { margin: 0; display: flex; gap: 32px; }
.stat-row dd { margin: 6px 0 0; font: 600 24px/1 var(--mono); color: var(--text); }
.stat-row .unit { font-size: 13px; color: var(--muted); }
.sparkline-large { width: 100%; height: 200px; }
.sparkline-large svg.chart { display: block; width: 100%; height: 200px; }
.axis { display: flex; justify-content: space-between; gap: 8px; }

.top-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.top-list { padding: 16px 18px; }
.top-list h3.eyebrow { margin-bottom: 8px; }
.top-list .empty { text-align: left; padding: 8px 0; }
.top { margin: 0; padding: 0; list-style: none; }
.top li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.top li:first-child { border-top: 0; }
.top .val { font: 500 13px/1.3 var(--mono); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .num { font: 500 13px/1.3 var(--mono); color: var(--text-2); text-align: right; }
.top .bar { grid-column: 1 / -1; height: 3px; border-radius: 2px; background: var(--line); position: relative; }
.top .bar span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 2px; background: var(--amber); opacity: .75; }
.top-list .eyebrow-sub { letter-spacing: 0; text-transform: none; font-weight: 400; color: var(--faint); }
.rules-firing a.val { display: flex; align-items: center; gap: 8px; min-width: 0; }
.rules-firing a.val:hover .desc { color: var(--amber); }
.rules-firing .num { align-self: center; }
.rules-firing .kind { flex: none; font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-2); border-radius: 3px; padding: 3px 4px; }
.rules-firing .kind--agent { color: var(--amber); }
.rules-firing .desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rules-firing .desc--gone { color: var(--faint); font-style: italic; }

/* --- Tap detail --- */
.hits { display: flex; align-items: flex-end; gap: 3px; height: 64px; border-bottom: 1px solid #262B33; }
.hit { flex: 1; min-width: 2px; border-radius: 2px 2px 0 0; background: var(--cyan); }
.hit--zero { height: 2px; background: var(--line-2); }

.capture-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: stretch; }
.capture-pane { flex: 1 1 420px; min-width: 0; }
.reqline { font: 600 15px/1.4 var(--mono); overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px 16px; margin: 0; font: 400 13px/1.5 var(--mono); }
.kv dt { color: var(--muted); overflow-wrap: anywhere; }
.kv dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
.kv dd.redacted { color: var(--faint); font-style: italic; }
.capture-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* --- Autoblocks --- */
.rule-card { padding: 18px 20px; display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.rule-card-body { flex: 1 1 420px; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rule-card-controls { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.sentence-text { font: 400 15px/1.6 var(--sans); color: var(--text-2); }

/* --- Agent --- */
.agent-status { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 400 14px/1.5 var(--mono); color: var(--muted); }
.agent-status code { background: none; padding: 0; color: var(--text-2); }
.budget { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.budget p { display: flex; justify-content: space-between; gap: 12px; font: 500 12px/1 var(--mono); color: var(--muted); }
.budget .v { color: var(--text); }

.agent-grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.agent-main { flex: 999 1 640px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.agent-aside { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: 24px; }
.agent-rows { min-width: 760px; }
.agent-rows > .empty { border-top: 1px solid var(--line); }
.agent-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(220px, 2fr) minmax(200px, 1.4fr) minmax(96px, auto);
  gap: 20px;
  align-items: center;
  padding: 18px 20px;
  border-top: 1px solid var(--line);
}
.agent-row .who { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.agent-row .ip { font: 600 15px/1.2 var(--mono); color: var(--text); display: flex; align-items: center; gap: 10px; min-width: 0; }
.agent-row .ip .v { overflow-wrap: anywhere; }
.agent-row .kind { font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-2); border-radius: 3px; padding: 3px 4px; }
.agent-row .did { font: 400 14px/1.5 var(--sans); color: var(--text-2); overflow-wrap: anywhere; }
.agent-row .prob { display: flex; flex-direction: column; gap: 8px; }
.agent-row .prob > p:first-child { display: flex; justify-content: space-between; gap: 12px; font: 500 13px/1.3 var(--sans); color: var(--text-2); }
.agent-row .pv { font-family: var(--mono); color: var(--text-2); }
.agent-row .why { font: 500 12px/1.4 var(--mono); color: var(--amber); }
.agent-row .outcome { font-size: 11px; }
.row-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

.track { position: relative; height: 6px; border-radius: 3px; background: var(--line); }
.track--bar { height: 10px; border-radius: 2px; }
.fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.fill--amber { background: var(--amber); }
.fill--ember { background: var(--ember); }
.fill--muted { background: var(--faint); }
.fill--base { background: #3A424C; }
.tick { position: absolute; top: -4px; width: 2px; height: 14px; margin-left: -1px; background: var(--text); }
.tick-key { display: inline-block; width: 2px; height: 10px; background: var(--text); vertical-align: -1px; margin-left: 4px; }

.funnel-row { display: flex; flex-direction: column; gap: 6px; }
.funnel-row p { display: flex; justify-content: space-between; gap: 12px; font: 400 13px/1.3 var(--sans); color: var(--text-2); }
.funnel-row .v { font: 600 13px/1.3 var(--mono); color: var(--text); text-align: right; }

.windows { display: flex; align-items: flex-end; gap: 4px; height: 96px; padding-bottom: 6px; border-bottom: 1px solid #262B33; }
.win { flex: 1; min-width: 3px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; gap: 3px; }
.win-bar { display: block; border-radius: 2px 2px 0 0; background: var(--line-2); }
.win-bar--on { background: var(--amber); }
.win-block { display: block; height: 4px; border-radius: 1px; background: var(--ember); }
.legend-keys { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-keys > span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.swatch--amber { background: var(--amber); }
.swatch--off { background: var(--line-2); }
.swatch--ember { height: 4px; border-radius: 1px; background: var(--ember); }

/* --- Settings --- */
.settings-section { display: flex; flex-wrap: wrap; gap: 24px; padding: 28px 0; border-top: 1px solid var(--line); }
.settings-section > header { flex: 1 1 240px; max-width: 320px; display: flex; flex-direction: column; gap: 8px; }
.settings-section > header .d { font: 400 14px/1.5 var(--sans); color: var(--muted); }
.settings-section > :not(header) { flex: 999 1 480px; min-width: 0; }
.facet-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.facet-card { padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.facet-name { font: 600 14px/1 var(--mono); }
.facet-card .status { font: 400 12px/1 var(--mono); }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.readout > div { background: var(--panel); padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.readout b { font: 600 20px/1.1 var(--mono); color: var(--text); overflow-wrap: anywhere; }
.readout b.small { font-size: 13px; font-weight: 500; line-height: 1.4; }

/* --- Sign-in and register --- */
.auth { display: flex; flex-wrap: wrap; min-height: 100vh; }
.auth-art { flex: 1 1 520px; min-height: 360px; position: relative; overflow: hidden; background: var(--panel); border-right: 1px solid var(--line); }
.auth-art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.auth-caption { position: absolute; left: 48px; bottom: 44px; font: 500 12px/1.6 var(--mono); letter-spacing: .1em; color: var(--muted); text-transform: uppercase; }
.auth-main { flex: 1 1 440px; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.auth-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 28px; }
.auth-box h1 { font-size: 24px; line-height: 1.2; }
.auth-card { padding: 24px; border-radius: 12px; border: 1px solid #22272E; background: var(--panel-2); display: flex; flex-direction: column; gap: 18px; }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.auth-form .key { margin-top: 10px; }
.auth-hint { font: 400 15px/1.5 var(--sans); color: var(--text-3); }
.login-divider { display: flex; align-items: center; gap: 12px; font: 500 11px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--placeholder); }
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: #262B33; }

/* --- Alert toasts --- */
.alert-toast {
  position: fixed;
  right: 16px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: 8px;
  border: 1px solid rgba(255,90,54,.45);
  background: var(--panel-2);
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  font: 500 13px/1.4 var(--mono);
  color: var(--text);
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateX(16px);
  transition: opacity .25s, transform .25s, top .25s;
}
.alert-toast.show { opacity: 1; transform: none; }

/* --- HTMX --- */
.htmx-request.key, .htmx-request .key[type="submit"] { opacity: .7; }

/* --- Phone and narrow screens --- */
@media (max-width: 900px) {
  :root { --gutter: 16px; }
  .app-layout { flex-direction: column; background: none; }
  .sidebar {
    position: static;
    height: auto;
    flex: none;
    padding: 12px 16px;
    gap: 12px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar .brand { padding: 0; }
  .nav-footer { margin: 0 0 0 auto; padding: 0; }
  .nav {
    order: 3;
    flex: 1 0 100%;
    flex-direction: row;
    overflow-x: auto;
    gap: 4px;
    margin: 0 -16px;
    padding: 0 16px 2px;
  }
  .nav a { height: 40px; white-space: nowrap; padding: 0 12px; }
  .nav a .led { display: none; }
  .nav a.active { box-shadow: inset 0 -2px 0 var(--amber); }
  .content { padding: 24px var(--gutter) 40px; }
  .page-art { display: none; }
  h1 { font-size: 26px; }
  .auth-art { min-height: 200px; flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); }
  .auth-caption { left: 16px; bottom: 16px; }
  .brand--lg .mark { width: 48px; height: 48px; }
  .brand--lg .wordmark { font-size: 44px; }
  .form-panel { padding: 16px; }
  .pad { padding: 16px; }
  .stat-row { gap: 20px; }
  .field--num { width: 88px; }
  .cond-label { min-width: 0; flex: 1 0 100%; }
  #autoblock-conditions .cond-label, .autoblock-form .sentence .cond-label { min-width: 0; }
  .condition-row .select { flex: 1 1 120px; }
  .settings-section > header { max-width: none; }
  .rule-card-controls { width: 100%; justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}

/* --- Blocks list: filter and pages --- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; padding: 4px 16px 16px; }
.filter-bar .select { min-width: 220px; max-width: 100%; }
.pager { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 12px 16px; border-top: 1px solid var(--line); }
.pager-keys { display: flex; gap: 8px; }

.nav-version { margin: 8px 0 0; font: 400 11px/1.4 var(--mono); color: var(--faint); overflow-wrap: anywhere; }
.kv .redacted { color: var(--faint); font-style: italic; }
@media (max-width: 900px) { .nav-version { display: none; } }

/* --- Recommended rules panel (Throttles, Autoblocks) --- */
.rec-panel > details > summary.rec-summary { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 4px 16px; padding: 18px 20px; list-style: none; }
.rec-panel > details > summary.rec-summary::-webkit-details-marker { display: none; }
.rec-summary h2 { margin: 0; }
.rec-summary h2::before { content: "▸ "; color: var(--muted); }
.rec-panel > details[open] > summary h2::before { content: "▾ "; }
.rec-form { padding: 0 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.rec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rec-row { display: flex; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); }
.rec-row--added .rec-desc { color: var(--muted); }
.rec-check { padding-top: 3px; }
.rec-check input { width: 18px; height: 18px; accent-color: var(--amber); }
.rec-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.rec-title { margin: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--text); }
.rec-title label { cursor: pointer; }
.rec-desc { margin: 0; font: 400 14px/1.5 var(--sans); color: var(--text-2); max-width: 72ch; }
.rec-numbers { font-size: 14px; gap: 8px 16px; }
.rec-num { display: inline-flex; align-items: center; gap: 8px; }
.kind-pill { font: 600 10px/1 var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line-2); border-radius: 3px; padding: 3px 4px; }
.probe-status { white-space: normal; min-width: 200px; }
.probe-table td.value { min-width: 220px; overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .rec-panel > details > summary.rec-summary { padding: 16px; }
  .rec-form { padding: 0 16px 16px; }
  .rec-num { flex-wrap: wrap; }
}
