:root,
:root[data-theme="dark"] {
  --bg: #0f1420;
  --panel: #171e2e;
  --panel-2: #1d2639;
  --line: #26304a;
  --text: #e6e9f2;
  --muted: #8b95b0;
  --input: #0c111b;
  --accent: #4aa3ff;
  --allow: #2fbf71;
  --adjacent: #4aa3ff;
  --redirect: #f0b43c;
  --throttle: #f07d3c;
  --block: #e5484d;
  --bubble-user: #24406b;
  --shadow: 0 1px 2px rgb(0 0 0 / 30%);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --panel-2: #f0f3fa;
  --line: #dde3ef;
  --text: #172033;
  --muted: #5c6782;
  --input: #ffffff;
  --accent: #1f6fd1;
  --allow: #1f9d5a;
  --adjacent: #1f6fd1;
  --redirect: #c98a06;
  --throttle: #d4621a;
  --block: #d1343a;
  --bubble-user: #dce9fb;
  --shadow: 0 1px 3px rgb(20 30 60 / 8%);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a {
  color: var(--accent);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 10px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  font-size: 18px;
}

.brand-mark {
  color: var(--accent);
}

.tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.tabs a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
}

.tabs a:hover {
  color: var(--text);
  background: var(--panel-2);
}

.tabs a.active {
  color: var(--text);
  background: var(--panel-2);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.topbar-tools {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

select,
input,
textarea,
button {
  font: inherit;
  color: var(--text);
}

select,
input[type="text"],
input[type="number"],
textarea {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 90px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

button.danger:hover {
  border-color: var(--block);
  color: var(--block);
}

button.small {
  padding: 3px 8px;
  font-size: 12px;
}

.mission-bar {
  margin: 0;
  padding: 8px 24px;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

/* ---------- layout ---------- */

main {
  padding: 20px 24px 40px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, 1fr);
  max-width: 1440px;
  margin: 0 auto;
  outline: none;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.card h2 {
  margin: 0 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.card h3 {
  margin: 14px 0 6px;
  font-size: 14px;
}

.span3 { grid-column: span 3; }
.span4 { grid-column: span 4; }
.span5 { grid-column: span 5; }
.span6 { grid-column: span 6; }
.span7 { grid-column: span 7; }
.span8 { grid-column: span 8; }
.span12 { grid-column: span 12; }

@media (max-width: 960px) {
  .span3, .span4, .span5, .span6, .span7, .span8 { grid-column: span 12; }
  .kpi { grid-column: span 6; }
  .topbar-tools { margin-left: 0; }
}

@media (max-width: 520px) {
  main { padding: 12px; }
  .kpi { grid-column: span 12; }
}

.muted {
  color: var(--muted);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.stack {
  display: grid;
  gap: 10px;
}

.pill {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #0f1420;
  white-space: nowrap;
}

.pill.ALLOW { background: var(--allow); }
.pill.ADJACENT { background: var(--adjacent); }
.pill.REDIRECT { background: var(--redirect); }
.pill.THROTTLE { background: var(--throttle); }
.pill.BLOCK { background: var(--block); color: #fff; }

/* ---------- try it ---------- */

.chat-log {
  height: 440px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  background: var(--panel-2);
  border-radius: 10px;
  border: 1px solid var(--line);
}

.chat-empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  max-width: 340px;
}

.bubble {
  max-width: 82%;
  padding: 8px 12px;
  border-radius: 12px;
  word-break: break-word;
}

.bubble.user {
  align-self: flex-end;
  background: var(--bubble-user);
  border-bottom-right-radius: 4px;
}

.bubble.bot {
  align-self: flex-start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom-left-radius: 4px;
}

.bubble .who {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.bubble .meta {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.bubble.selectable {
  cursor: pointer;
}

.bubble.selected {
  outline: 2px solid var(--accent);
}

.composer {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.composer input {
  flex: 1;
  min-width: 0;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip {
  border-radius: 14px;
  padding: 3px 10px;
  font-size: 12px;
}

.score-row {
  display: grid;
  grid-template-columns: 96px 1fr 48px;
  gap: 8px;
  align-items: center;
  margin: 6px 0;
}

.bar {
  height: 10px;
  border-radius: 5px;
  background: var(--line);
  overflow: hidden;
}

.bar > span {
  display: block;
  height: 100%;
}

.explain-empty {
  color: var(--muted);
}

dl.facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 12px;
  margin: 10px 0 0;
}

dl.facts dt {
  color: var(--muted);
}

dl.facts dd {
  margin: 0;
  word-break: break-word;
}

/* ---------- dashboard ---------- */

.kpi {
  grid-column: span 3;
}

.kpi .value {
  font-size: 28px;
  font-weight: 650;
}

.kpi .sub {
  color: var(--muted);
  font-size: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 40px;
  gap: 8px;
  align-items: center;
  margin: 7px 0;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

td.msg {
  word-break: break-word;
}

.table-wrap {
  overflow-x: auto;
}

.cluster {
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}

.cluster:last-child {
  border-bottom: none;
}

.cluster .theme {
  font-weight: 600;
}

/* ---------- policy ---------- */

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}

.template {
  text-align: left;
  padding: 12px;
  border-radius: 10px;
  display: grid;
  gap: 4px;
}

.template.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.template .name {
  font-weight: 600;
}

.template .desc {
  color: var(--muted);
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 4px;
}

.field > span {
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field textarea {
  width: 100%;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 960px) {
  .examples-grid { grid-template-columns: 1fr; }
}

.examples-grid textarea {
  min-height: 220px;
  font-size: 13px;
}

.learned-list {
  display: grid;
  gap: 4px;
}

.learned-item {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px solid var(--line);
}

/* ---------- accuracy & integrate ---------- */

.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.metric {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

.metric .value {
  font-size: 22px;
  font-weight: 650;
}

.ok { color: var(--allow); }
.bad { color: var(--block); }

pre {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.45;
}

code {
  font-family: "Cascadia Code", Consolas, monospace;
}

.prose p,
.prose li {
  max-width: 820px;
}

/* ---------- toast & footer ---------- */

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 10px;
  font-weight: 500;
  z-index: 20;
}

.footer {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  padding: 0 24px 28px;
}

@media (prefers-reduced-motion: no-preference) {
  .bubble.fresh {
    animation: rise 0.18s ease-out;
  }

  @keyframes rise {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
  }
}

/* hone 2026-11-07: WCAG AA + phone fit, no visual redesign */
.brand-title { margin: 0; font-size: inherit; font-weight: inherit; line-height: inherit; }
/* Light theme: dark ink on the mid-blue and red pills is 3.7:1; white ink is 4.9:1. Other pills keep dark ink (>= 4.8:1). */
[data-theme="light"] .pill.ADJACENT,
[data-theme="light"] .pill.BLOCK { color: #ffffff; }
@media (max-width: 640px) {
  .brand { min-height: 44px; }
  .chip { min-height: 44px; }
  .footer a { display: inline-block; padding: 14px 0; }
}

/* ---------- Hexbane scan page (load gate) ---------- */
:root, :root[data-theme="dark"] { --sev-critical: #ff6b6b; --sev-high: #f59e4a; --sev-medium: #e8c252; --sev-low: #8b95b0; --pass: #3ccf86; }
:root[data-theme="light"] { --sev-critical: #c4262e; --sev-high: #b85a10; --sev-medium: #8a6400; --sev-low: #5c6782; --pass: #17834b; }
.brand-mark svg { display: block; color: var(--accent); }
.scan-hero { padding-bottom: 18px; }
.scan-title { font-size: clamp(1.35rem, 2.4vw, 1.9rem); line-height: 1.2; margin: 2px 0 8px; letter-spacing: -0.01em; max-width: 30ch; }
.lede { color: var(--muted); max-width: 72ch; margin: 0 0 16px; line-height: 1.55; }
.gates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.gate { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); text-decoration: none; background: var(--input); }
a.gate:hover { border-color: var(--accent); }
.gate.current { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.gate-num { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 0.85rem; border: 1.5px solid var(--accent); color: var(--accent); }
.gate-body { display: grid; gap: 2px; font-size: 0.92rem; line-height: 1.35; }
.gate-body small { font-size: 0.8rem; }
.scan-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: stretch; }
.paste-col { display: grid; gap: 6px; align-content: start; }
.field-label { font-size: 0.82rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
#scan-name, #scan-text { width: 100%; box-sizing: border-box; background: var(--input); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font: 0.9rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
#scan-text { min-height: 210px; resize: vertical; }
#scan-name:focus-visible, #scan-text:focus-visible, .dropzone:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.drop-col { display: grid; grid-template-rows: 1fr auto; gap: 8px; }
.dropzone { display: grid; place-content: center; justify-items: center; gap: 10px; text-align: center; min-height: 210px; border: 1.5px dashed var(--line); border-radius: 12px; padding: 20px; background: var(--input); cursor: pointer; }
.dropzone.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--input)); }
.drop-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.button-like { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: 8px; font-weight: 600; font-size: 0.9rem; cursor: pointer; background: var(--accent); color: #fff; }
.button-like.secondary { background: transparent; color: var(--text); border: 1px solid var(--line); }
.small { font-size: 0.82rem; }
.samples { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.verdict { display: grid; grid-template-columns: auto 1fr auto; gap: 16px; align-items: center; padding: 16px 18px; border-radius: 12px; border: 1px solid var(--line); margin-bottom: 14px; }
.verdict-word { font: 800 1.35rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.06em; padding: 8px 12px; border-radius: 8px; border: 2px solid currentColor; }
.verdict-text { display: grid; gap: 2px; }
.verdict-text strong { font-size: 1.05rem; }
.verdict-text span { color: var(--muted); font-size: 0.9rem; }
.verdict-meta { display: grid; gap: 2px; text-align: right; font-size: 0.85rem; }
.verdict.FAIL { background: color-mix(in srgb, var(--sev-critical) 9%, var(--panel)); border-color: color-mix(in srgb, var(--sev-critical) 45%, var(--line)); }
.verdict.FAIL .verdict-word { color: var(--sev-critical); }
.verdict.REVIEW { background: color-mix(in srgb, var(--sev-medium) 10%, var(--panel)); border-color: color-mix(in srgb, var(--sev-medium) 45%, var(--line)); }
.verdict.REVIEW .verdict-word { color: var(--sev-medium); }
.verdict.PASS { background: color-mix(in srgb, var(--pass) 9%, var(--panel)); border-color: color-mix(in srgb, var(--pass) 45%, var(--line)); }
.verdict.PASS .verdict-word { color: var(--pass); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip.on { border-color: var(--accent); color: var(--accent); }
.findings { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.finding { border: 1px solid var(--line); border-left-width: 4px; border-radius: 10px; padding: 12px 14px; background: var(--panel); }
.finding.sev-critical { border-left-color: var(--sev-critical); }
.finding.sev-high { border-left-color: var(--sev-high); }
.finding.sev-medium { border-left-color: var(--sev-medium); }
.finding.sev-low { border-left-color: var(--sev-low); }
.finding-head { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: baseline; }
.finding-title { font-size: 0.98rem; }
.finding .where { margin-left: auto; color: var(--muted); font-size: 0.82rem; word-break: break-all; }
.rule-id { font-size: 0.8rem; color: var(--muted); }
.sev { display: inline-block; min-width: 64px; text-align: center; font: 700 0.72rem/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; text-transform: uppercase; letter-spacing: 0.06em; padding: 5px 7px; border-radius: 999px; border: 1.5px solid currentColor; }
.sev.critical { color: var(--sev-critical); } .sev.high { color: var(--sev-high); } .sev.medium { color: var(--sev-medium); } .sev.low { color: var(--sev-low); }
.evidence { margin: 10px 0 8px; padding: 8px 10px; white-space: pre-wrap; word-break: break-word; font-size: 0.84rem; max-height: 9em; overflow: auto; }
.hidden-text { display: grid; gap: 4px; margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; border: 1px dashed var(--sev-critical); background: color-mix(in srgb, var(--sev-critical) 6%, transparent); }
.hidden-label { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--sev-critical); }
.hidden-text code { white-space: pre-wrap; word-break: break-word; }
.why, .fix { margin: 4px 0; font-size: 0.9rem; line-height: 1.5; }
.why .k, .fix .k { font-weight: 700; color: var(--text); }
.why { color: var(--muted); }
.refs { margin: 6px 0 0; display: flex; gap: 12px; font-size: 0.8rem; }
.refs a { color: var(--accent); }
.files-summary { margin: 12px 0 0; font-size: 0.9rem; }
.files-summary ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.sev-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; background: var(--sev-low); }
.sev-dot.FAIL { background: var(--sev-critical); } .sev-dot.REVIEW { background: var(--sev-medium); }
.scan-report .row { margin-top: 14px; }
.rules-list summary { cursor: pointer; padding: 2px 0; }
.rules-list table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 0.88rem; }
.rules-list th, .rules-list td { text-align: left; vertical-align: top; padding: 8px 10px; border-top: 1px solid var(--line); }
.rules-list td:first-child, .rules-list td:nth-child(2) { white-space: nowrap; }
@media (max-width: 860px) {
  .gates { grid-template-columns: 1fr; }
  .scan-grid { grid-template-columns: 1fr; }
  .dropzone { min-height: 140px; }
  .verdict { grid-template-columns: 1fr; text-align: left; }
  .verdict-meta { text-align: left; }
  .finding .where { margin-left: 0; width: 100%; }
}

/* The results host is only a wrapper: let its card join the page grid at full width. */
.scan-results { display: contents; }

/* Phones: the wrapped header was ~200px tall and sticky, covering a quarter of the screen.
   Keep it in the page flow and let the tabs scroll sideways on one line. */
@media (max-width: 640px) {
  .topbar { position: static; gap: 10px; padding: 8px 16px; }
  .topbar .tabs { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .topbar .tabs a { flex: 0 0 auto; }
}

/* copy-paste fixes */
.copy-block { position: relative; margin: .4rem 0 .2rem; }
.copy-block pre { margin: 0; padding: .6rem 5.5rem .6rem .7rem; background: var(--code-bg, rgba(127,127,127,.12)); border-radius: 8px; overflow-x: auto; white-space: pre; font-size: .82rem; }
.copy-block .copy-btn { position: absolute; top: .4rem; right: .4rem; }
.finding details.suppress { margin-top: .3rem; font-size: .85rem; }
.finding details.suppress summary { cursor: pointer; color: var(--muted, #6b7280); }
@media (max-width: 640px) {
  .copy-block pre { padding-right: .7rem; padding-bottom: 2.6rem; }
  .copy-block .copy-btn { top: auto; bottom: .4rem; }
}

/* Phones: show every section at once (3 x 2 grid) instead of a sideways-scrolling strip that looks cut off. */
@media (max-width: 640px) {
  .topbar .tabs {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    overflow-x: visible;
    width: 100%;
  }
  .topbar .tabs a {
    text-align: center;
    padding: 8px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
