/* PatentAI app styles. Every colour, size and radius comes from tokens.css.
   Order: base, shell, typography, controls, components, pages, charts, responsive. */

/* ----- base ------------------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: var(--fs-base) / var(--lh) var(--font);
}
img, svg { max-width: 100%; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--r-sm); }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }
.skip {
  position: absolute; left: var(--s-2); top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md); text-decoration: none;
}
.skip:focus { top: var(--s-2); color: var(--accent-ink); }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}
.ico {
  width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.only-light { display: var(--show-light); }
.only-dark { display: var(--show-dark); }

/* ----- shell ----------------------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  grid-template-rows: auto 1fr;
  grid-template-areas: "side top" "side main";
  min-height: 100vh;
}
.sidebar {
  grid-area: side;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: var(--s-4);
  background: var(--nav-bg); color: var(--nav-ink);
  padding: var(--s-4) var(--s-3);
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: var(--s-2);
  color: var(--nav-ink-strong); text-decoration: none; font-weight: 650;
  font-size: var(--fs-md); line-height: var(--lh-tight); padding: var(--s-1) var(--s-2);
}
.brand:hover { color: var(--nav-ink-strong); }
.brand .mark {
  display: grid; place-items: center; width: 32px; height: 32px; flex: none;
  border-radius: var(--r-md); background: var(--accent); color: #ffffff;
}
.brand .mark .ico { width: 20px; height: 20px; }
.brand small { display: block; font-weight: 400; font-size: var(--fs-xs); color: var(--nav-ink); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 9px var(--s-3); border-radius: var(--r-md);
  color: var(--nav-ink); text-decoration: none; font-weight: 500;
}
.nav a:hover { background: var(--nav-active); color: var(--nav-ink-strong); }
.nav a[aria-current="page"] { background: var(--nav-active); color: var(--nav-ink-strong); box-shadow: inset 3px 0 0 var(--chart-1); }
.nav a:focus-visible { outline-color: var(--nav-ink-strong); }
.nav .ico { width: 18px; height: 18px; }
.sidebar-foot {
  margin-top: auto; font-size: var(--fs-xs); line-height: 1.45;
  border-top: 1px solid var(--nav-line); padding: var(--s-3) var(--s-2) 0;
  display: flex; gap: var(--s-2);
}
.sidebar-foot .ico { width: 16px; height: 16px; margin-top: 1px; }

.topbar {
  grid-area: top;
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3);
  padding: var(--s-2) var(--s-5);
  min-height: 56px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: none; color: var(--ink); padding: 0; }
.topbar .brand small { color: var(--muted); }
.topbar-title { flex: 1; min-width: 0; font-size: var(--fs-sm); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-title a { color: var(--muted); }
.topbar-tools { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.content {
  grid-area: main;
  width: 100%; max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--s-5) var(--s-5) var(--s-7);
  display: flex; flex-direction: column; gap: var(--s-4);
  min-width: 0;
}

/* ----- typography ------------------------------------------------------------------------ */
h1, h2, h3 { line-height: var(--lh-tight); text-wrap: balance; margin: 0; }
h1 { font-size: var(--fs-xl); font-weight: 680; letter-spacing: -0.01em; }
h2 { font-size: var(--fs-lg); font-weight: 650; }
h3 { font-size: var(--fs-md); font-weight: 620; }
p { margin: 0; }
.lead { font-size: var(--fs-md); color: var(--ink-2); max-width: 68ch; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }
.xs { font-size: var(--fs-xs); }
.mono { font-family: var(--font-mono); font-size: 0.92em; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.eyebrow {
  font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--muted);
}
.stack { display: flex; flex-direction: column; gap: var(--s-3); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s-2); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--s-3) var(--s-4); }
.page-head .titles { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: var(--s-1); }
.page-head .actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ----- controls -------------------------------------------------------------------------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 38px; padding: 8px 16px;
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap;
  color: var(--accent-ink); background: var(--accent);
  border: 1px solid var(--accent); border-radius: var(--r-md);
  cursor: pointer; transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}
button:hover, .button:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }
button.secondary, .button.secondary {
  color: var(--ink); background: var(--surface); border-color: var(--line-strong);
}
button.secondary:hover, .button.secondary:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line-strong); }
button.ghost, .button.ghost { color: var(--accent); background: transparent; border-color: transparent; }
button.ghost:hover, .button.ghost:hover { background: var(--accent-soft); color: var(--accent); }
button.danger, .button.danger { color: #ffffff; background: var(--chart-bad); border-color: var(--chart-bad); }
button.danger:hover, .button.danger:hover { background: var(--bad); border-color: var(--bad); color: #ffffff; }
button.big, .button.big { min-height: 46px; padding: 11px 22px; font-size: var(--fs-md); }
button:disabled { opacity: 0.55; cursor: not-allowed; }
.icon-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px;
  border-radius: var(--r-md); color: var(--ink-2); border: 1px solid var(--line);
  background: var(--surface); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
form.inline { display: inline; margin: 0; }
label { font-weight: 600; }
.field { display: flex; flex-direction: column; gap: 6px; }
input[type="text"], input[type="search"], select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md);
  padding: 9px 11px; min-height: 40px;
}
input[type="text"]:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--focus); outline-offset: 0; }
textarea { min-height: 140px; resize: vertical; line-height: 1.45; }
.field-hint { color: var(--muted); font-size: var(--fs-sm); max-width: 72ch; }
.check { display: flex; gap: var(--s-2); align-items: flex-start; font-weight: 500; }
.check input { margin-top: 4px; }

/* switch: a real checkbox, visually a track + knob */
.switch-row { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-weight: 600; }
.switch-row input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  width: 42px; height: 24px; border-radius: var(--r-pill);
  background: var(--line-strong); position: relative; cursor: pointer;
  transition: background-color 0.15s;
}
.switch-row input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #ffffff; box-shadow: var(--sh-1); transition: transform 0.15s;
}
.switch-row input:checked { background: var(--accent); }
.switch-row input:checked::after { transform: translateX(18px); }
.switch-row input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ----- components ------------------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-5); box-shadow: var(--sh-1);
  display: flex; flex-direction: column; gap: var(--s-3);
  min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s-2) var(--s-3); }
.card-head h2 { flex: 1; }
.card.flat { box-shadow: none; background: var(--surface-2); }

/* status chips and badges */
.chip, .badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; min-height: 24px;
  border-radius: var(--r-pill); font-size: var(--fs-sm); font-weight: 600; line-height: 1.3;
  background: var(--surface-3); color: var(--ink-2); white-space: nowrap;
  border: 1px solid transparent; text-decoration: none;
}
.chip::before, .badge.dot::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none;
}
.chip.plain::before { display: none; }
.status-done, .status-skipped { background: var(--ok-bg); color: var(--ok); }
.status-running, .status-queued, .status-created, .status-new { background: var(--info-bg); color: var(--info); }
.status-awaiting_confirmation, .status-partial, .status-paused,
.status-paused_llm_limit, .status-paused_ops_hourly { background: var(--warn-bg); color: var(--warn); }
.status-failed, .status-error { background: var(--bad-bg); color: var(--bad); }
.status-no_results, .status-pending { background: var(--surface-3); color: var(--muted); }
.status-running::before, .status-queued::before { animation: pulse 1.4s ease-in-out infinite; }
td.status-done, td.status-error, td.status-running, span.small.status-done { background: none; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.killed { background: var(--killed-bg); color: var(--killed); }
.badge.demo { background: var(--warn-bg); color: var(--warn); }
.badge.live { background: var(--ok-bg); color: var(--ok); }
.badge.demo::before, .badge.live::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.badge.live::before { animation: pulse 2s ease-in-out infinite; }
.badge.outline { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }

/* EPO usage chip in the top bar */
.usage {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 4px 10px; border-radius: var(--r-pill); min-height: 30px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums;
}
.usage:hover { border-color: var(--line-strong); color: var(--ink); }
.mini-meter { width: 54px; height: 6px; border-radius: var(--r-pill); background: var(--chart-track); overflow: hidden; }
.mini-meter i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--chart-ok); }
.usage.warn .mini-meter i { background: var(--chart-warn); }
.usage.bad .mini-meter i, .usage.killed .mini-meter i { background: var(--chart-bad); }
.usage.killed { border-color: var(--chart-bad); color: var(--bad); }

/* language toggle: segmented control */
.lang-toggle {
  display: inline-flex; align-items: center; padding: 2px; gap: 2px;
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
  font-size: var(--fs-sm); font-weight: 650;
}
.lang-toggle a, .lang-toggle strong {
  display: inline-grid; place-items: center; min-width: 34px; height: 28px; padding: 0 6px;
  border-radius: 6px; text-decoration: none;
}
.lang-toggle a { color: var(--muted); }
.lang-toggle a:hover { color: var(--ink); background: var(--surface-3); }
.lang-toggle strong { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.lang-toggle .sep { display: none; }

/* banners and notices */
.notice, .error, .flash, .status-box {
  display: flex; flex-direction: column; gap: var(--s-2);
  border-radius: var(--r-lg); padding: var(--s-4) var(--s-4) var(--s-4) calc(var(--s-4) + 4px);
  border: 1px solid var(--line); background: var(--surface);
  position: relative; overflow: hidden;
}
.notice::before, .error::before, .flash::before, .status-box::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--line-strong);
}
.notice { background: var(--warn-bg); border-color: transparent; color: var(--ink); }
.notice::before { background: var(--chart-warn); }
.error { background: var(--bad-bg); border-color: transparent; color: var(--ink); }
.error::before { background: var(--chart-bad); }
.flash { background: var(--ok-bg); border-color: transparent; }
.flash::before { background: var(--chart-ok); }
.status-box.ok { background: var(--ok-bg); border-color: transparent; }
.status-box.ok::before { background: var(--chart-ok); }
.status-box.bad { background: var(--bad-bg); border-color: transparent; }
.status-box.bad::before { background: var(--chart-bad); }
.status-box.info { background: var(--info-bg); border-color: transparent; }
.status-box.info::before { background: var(--chart-1); }
.status-box.action { background: var(--warn-bg); border-color: transparent; }
.status-box.action::before { background: var(--chart-warn); }
.banner-head { display: flex; align-items: center; gap: var(--s-2); font-weight: 650; font-size: var(--fs-md); }
.notice strong, .status-box strong { font-weight: 650; }
.notice p, .status-box p { max-width: 72ch; }
.notice.small { font-size: var(--fs-sm); }

/* toast (flash message from ?msg=) */
.flash[data-toast] {
  position: fixed; z-index: 60; right: var(--s-5); bottom: var(--s-5);
  max-width: min(420px, calc(100vw - 2 * var(--s-4)));
  flex-direction: row; align-items: flex-start; gap: var(--s-3);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2);
  animation: toast-in 0.25s ease-out;
}
.flash[data-toast] .ico { color: var(--ok); margin-top: 2px; }
.flash[data-toast] .toast-text { flex: 1; }
.flash[data-toast] .toast-close {
  min-height: 28px; width: 28px; padding: 0; background: transparent; border-color: transparent; color: var(--muted);
}
.flash[data-toast] .toast-close:hover { background: var(--surface-3); color: var(--ink); }
.flash[data-toast].leaving { opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; }

/* modal (confirmation dialog) */
dialog.modal {
  width: min(460px, calc(100vw - 2 * var(--s-4)));
  border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0;
  background: var(--surface); color: var(--ink); box-shadow: var(--sh-3);
}
dialog.modal::backdrop { background: rgba(8, 18, 28, 0.55); }
dialog.modal form { display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-5); margin: 0; }
.modal-icon {
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
  background: var(--warn-bg); color: var(--warn);
}
dialog.modal.danger .modal-icon { background: var(--bad-bg); color: var(--bad); }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--s-2); margin-top: var(--s-2); }

/* collapsible hint and technical details */
details.hint {
  background: var(--accent-soft); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4);
  color: var(--ink);
}
details.hint summary { cursor: pointer; font-weight: 600; color: var(--accent); display: flex; align-items: center; gap: var(--s-2); }
details.hint summary::-webkit-details-marker { display: none; }
details.hint summary::before { content: "i"; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.6px solid currentColor; font: 700 12px/1 var(--font); }
details.hint p { margin-top: var(--s-2); max-width: 78ch; }
details.tech { border: 1px dashed var(--line-strong); border-radius: var(--r-lg); padding: var(--s-3) var(--s-4); background: var(--surface-2); }
details.tech > summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
details.tech[open] > summary { margin-bottom: var(--s-3); }
details.tech h3 { margin: var(--s-4) 0 var(--s-2); font-size: var(--fs-base); }
details > summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
pre.log {
  margin: var(--s-2) 0; padding: var(--s-3); max-height: 360px; overflow: auto;
  background: var(--surface-3); color: var(--ink); border-radius: var(--r-md);
  font: var(--fs-xs) / 1.5 var(--font-mono); white-space: pre-wrap; word-break: break-word;
}

/* tables */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th {
  font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--muted); background: var(--surface-2); white-space: nowrap;
}
tbody tr:hover td { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row-link { font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.cell-title { max-width: 360px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* empty state */
.empty {
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s-2);
  padding: var(--s-6) var(--s-4); color: var(--muted);
}
.empty .empty-icon {
  width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2);
}
.empty .empty-icon .ico { width: 24px; height: 24px; }
.empty strong { color: var(--ink); font-size: var(--fs-md); }
.empty p { max-width: 52ch; }

/* skeletons and live indicator */
.skeleton {
  display: block; height: 8px; border-radius: var(--r-pill); width: 60%;
  background: linear-gradient(90deg, var(--surface-3) 0%, var(--line) 50%, var(--surface-3) 100%);
  background-size: 200% 100%; animation: shimmer 1.4s linear infinite;
}
.live-dot {
  display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600;
  color: var(--info); text-transform: uppercase; letter-spacing: 0.06em;
}
.live-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--chart-1); animation: pulse 1.4s ease-in-out infinite; }
.htmx-request .live-dot::before { background: var(--chart-ok); }

/* progress bar */
.progress {
  height: 10px; border-radius: var(--r-pill); background: var(--chart-track); overflow: hidden;
}
.progress > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--chart-1); transition: width 0.6s ease; }
.progress.ok > i { background: var(--chart-ok); }
.progress.bad > i { background: var(--chart-bad); }
.progress-meta { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-variant-numeric: tabular-nums; }

/* meters (relevance, confidence) */
.meter {
  flex: 1; min-width: 60px; height: 8px; border-radius: var(--r-pill);
  background: var(--chart-track); overflow: hidden;
}
.meter > i { display: block; height: 100%; border-radius: var(--r-pill); background: var(--chart-1); }
.meter-row { display: flex; align-items: center; gap: var(--s-3); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.meter-row .meter-label { color: var(--muted); min-width: 0; }
.meter-row .meter-value { font-weight: 650; min-width: 3.2em; text-align: right; }

/* ----- dashboard ------------------------------------------------------------------------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: var(--s-5);
  padding: var(--s-6) var(--s-6) var(--s-5);
  border-radius: var(--r-lg); border: 1px solid var(--line);
  background:
    radial-gradient(120% 140% at 100% 0%, var(--accent-soft) 0%, transparent 60%),
    var(--surface);
  box-shadow: var(--sh-1);
}
.hero h1 { font-size: var(--fs-2xl); }
.hero .lead { margin-top: var(--s-2); }
.steps-guide {
  list-style: none; margin: var(--s-5) 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4);
  counter-reset: guide;
}
.steps-guide li { display: flex; gap: var(--s-3); counter-increment: guide; }
.steps-guide li::before {
  content: counter(guide); flex: none; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: var(--fs-sm);
  background: var(--accent); color: var(--accent-ink);
}
.steps-guide li > div { display: flex; flex-direction: column; gap: 2px; }
.hero .hero-cta { align-self: center; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s-4); }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s-4); display: flex; flex-direction: column; gap: var(--s-2); min-width: 0;
}
.kpi .label { font-size: var(--fs-sm); color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: var(--s-2); }
.kpi .value { font-size: var(--fs-xl); font-weight: 680; font-variant-numeric: tabular-nums; line-height: 1.1; overflow-wrap: anywhere; }
.kpi .sub { font-size: var(--fs-sm); color: var(--muted); }
.kpi .meter { flex: none; height: 6px; position: relative; overflow: visible; }
.kpi .meter > i.ok { background: var(--chart-ok); }
.kpi .meter > i.warn { background: var(--chart-warn); }
.kpi .meter > i.bad, .kpi .meter > i.killed { background: var(--chart-bad); }
.kpi .meter .mark { position: absolute; top: -3px; width: 2px; height: 12px; background: var(--ink-2); border-radius: 1px; }
.split { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s-4); align-items: start; }

/* ----- weekly gauge (shared by dashboard and traffic) ------------------------------------ */
.gauge-wrap { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: var(--s-5); align-items: center; }
.gauge-svg { width: 100%; height: auto; display: block; }
.gauge-svg .track { stroke: var(--chart-track); }
.gauge-svg .fill.ok { stroke: var(--chart-ok); }
.gauge-svg .fill.warn { stroke: var(--chart-warn); }
.gauge-svg .fill.bad, .gauge-svg .fill.killed { stroke: var(--chart-bad); }
.gauge-svg .tick { stroke: var(--ink-2); stroke-width: 2; }
.gauge-svg .tick-label { fill: var(--muted); font: 600 9px var(--font); }
.gauge-svg .big { fill: var(--ink); font: 700 22px var(--font); font-variant-numeric: tabular-nums; }
.gauge-svg .cap { fill: var(--muted); font: 500 9.5px var(--font); }
.gauge-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: var(--fs-xs); color: var(--muted); }
.gauge-legend span { display: inline-flex; align-items: center; gap: 6px; }
.gauge-legend i { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: var(--s-3); }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s-3); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .label { font-size: var(--fs-xs); color: var(--muted); font-weight: 600; }
.stat .value { font-size: var(--fs-md); font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat.primary { background: var(--accent-soft); border-color: transparent; }
.stat.primary .value { font-size: var(--fs-lg); }

/* ----- new search wizard ----------------------------------------------------------------- */
.wiz-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: var(--s-2); counter-reset: wiz; }
.wiz-steps li {
  flex: 1; display: flex; align-items: center; gap: var(--s-2); min-width: 0;
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 600; font-size: var(--fs-sm);
}
.wiz-steps li .num {
  flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2); font-size: var(--fs-xs); font-weight: 700;
}
.wiz-steps li span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wiz-steps li[aria-current="step"] { border-color: var(--accent); color: var(--ink); box-shadow: 0 0 0 1px var(--accent) inset; }
.wiz-steps li[aria-current="step"] .num, .wiz-steps li.done .num { background: var(--accent); color: var(--accent-ink); }
.wiz-steps li.done { color: var(--ink-2); }
fieldset.wiz-panel { margin: 0; min-width: 0; }
fieldset.wiz-panel legend { padding: 0; font-size: var(--fs-lg); font-weight: 650; float: left; width: 100%; margin-bottom: var(--s-2); }
fieldset.wiz-panel legend + * { clear: both; }
.wizard.js .wiz-panel:not(.active) { display: none; }
.wiz-nav { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: flex-end; border-top: 1px solid var(--line); padding-top: var(--s-4); margin-top: var(--s-2); }
.wiz-nav .spacer { flex: 1; }
.wizard { display: flex; flex-direction: column; gap: var(--s-4); }
.opt-group { display: flex; flex-direction: column; gap: var(--s-2); padding-bottom: var(--s-4); border-bottom: 1px solid var(--line); }
.opt-group:last-of-type { border-bottom: 0; padding-bottom: 0; }

.dropzone {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-2); text-align: center; cursor: pointer; font-weight: 400;
  padding: var(--s-6) var(--s-4); border-radius: var(--r-lg);
  border: 2px dashed var(--line-strong); background: var(--surface-2); color: var(--ink-2);
  transition: border-color 0.15s, background-color 0.15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.dropzone .drop-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--sh-1); }
.dropzone .drop-icon .ico { width: 24px; height: 24px; }
.dropzone strong { color: var(--ink); font-size: var(--fs-md); }
.dropzone input[type="file"] {
  position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden;
}
.dropzone.nojs input[type="file"] { position: static; width: auto; height: auto; opacity: 1; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-2); }
.file-list li {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface);
}
.file-list .fname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.file-list .fmeta { font-size: var(--fs-xs); color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.file-list li.bad { border-color: var(--chart-bad); background: var(--bad-bg); }
.file-list .remove { min-height: 30px; width: 30px; padding: 0; background: transparent; color: var(--muted); border-color: transparent; }
.file-list .remove:hover { background: var(--surface-3); color: var(--bad); }
.detect { font-size: var(--fs-sm); color: var(--ok); font-weight: 600; min-height: 1.4em; }
.detect.muted { color: var(--muted); font-weight: 400; }
.chips-input {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px;
  border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--surface); min-height: 44px;
}
.chips-input:focus-within { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 0; }
.chips-input ul { display: contents; list-style: none; margin: 0; padding: 0; }
.chips-input li {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px;
  border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: var(--fs-sm); font-weight: 600;
}
.chips-input li button { min-height: 22px; width: 22px; padding: 0; border-radius: 50%; background: transparent; border-color: transparent; color: inherit; }
.chips-input li button:hover { background: var(--surface); color: var(--bad); }
.chips-input input[type="text"] { flex: 1; min-width: 160px; border: 0; min-height: 30px; padding: 4px 6px; background: transparent; }
.chips-input input[type="text"]:focus-visible { outline: none; }
.review { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: var(--s-2) var(--s-5); margin: 0; }
.review dt { color: var(--muted); font-weight: 600; font-size: var(--fs-sm); }
.review dd { margin: 0; overflow-wrap: anywhere; }

/* ----- run page -------------------------------------------------------------------------- */
.run-meta { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }
.run-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s-4); align-items: start; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: var(--s-3); position: relative; padding-bottom: var(--s-4); }
.tl-item::before {
  content: ""; position: absolute; left: 15px; top: 32px; bottom: 0; width: 2px; background: var(--line);
}
.tl-item:last-child { padding-bottom: 0; }
.tl-item:last-child::before { display: none; }
.tl-item.step-done::before, .tl-item.step-skipped::before { background: var(--chart-ok); }
.tl-marker {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; z-index: 1;
  background: var(--surface); border: 2px solid var(--line-strong); color: var(--muted);
}
.tl-marker .ico { width: 16px; height: 16px; stroke-width: 2.4; }
.step-done .tl-marker, .step-skipped .tl-marker { background: var(--chart-ok); border-color: var(--chart-ok); color: #ffffff; }
.step-running .tl-marker { border-color: var(--chart-1); color: var(--chart-1); }
.step-running .tl-marker .ico { animation: spin 1.1s linear infinite; }
.step-failed .tl-marker, .step-error .tl-marker { background: var(--chart-bad); border-color: var(--chart-bad); color: #ffffff; }
.step-awaiting_confirmation .tl-marker, .step-paused .tl-marker { border-color: var(--chart-warn); color: var(--warn); background: var(--warn-bg); }
.tl-body { display: flex; flex-direction: column; gap: 3px; padding-top: 5px; min-width: 0; }
.tl-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); }
.tl-head strong { font-weight: 620; }
.step-pending .tl-head strong { color: var(--ink-2); font-weight: 500; }
.tl-meta { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-item .skeleton { margin-top: 4px; max-width: 280px; }
.step-running .tl-body { background: var(--info-bg); margin: -2px 0 0 -8px; padding: 7px 10px 9px; border-radius: var(--r-md); }
.downloads { display: flex; flex-direction: column; gap: var(--s-3); }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s-3); }
.dl-card {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  color: var(--ink); text-decoration: none; min-width: 0;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.dl-card:hover { border-color: var(--accent); box-shadow: var(--sh-2); color: var(--ink); }
.dl-card .dl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.dl-card .dl-text strong { font-weight: 620; font-size: var(--fs-sm); }
.dl-card .dl-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dl-card > .ico { color: var(--accent); }
.file-icon {
  position: relative; flex: none; width: 40px; height: 46px; display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--surface-3); color: var(--ink-2);
}
.file-icon .ico { width: 22px; height: 22px; }
.file-icon .ext {
  position: absolute; bottom: -4px; left: 50%; transform: translateX(-50%);
  font: 700 9px/1 var(--font); letter-spacing: 0.04em; padding: 2px 4px; border-radius: 3px;
  background: var(--ink-2); color: var(--surface);
}
.file-icon[data-ext="docx"] { background: var(--info-bg); color: var(--info); }
.file-icon[data-ext="docx"] .ext { background: var(--chart-1); color: #ffffff; }
.file-icon[data-ext="zip"] { background: var(--warn-bg); color: var(--warn); }
.file-icon[data-ext="zip"] .ext { background: var(--chart-warn); color: #1a1100; }
.file-icon[data-ext="pdf"] { background: var(--bad-bg); color: var(--bad); }
.file-icon[data-ext="pdf"] .ext { background: var(--chart-bad); color: #ffffff; }
.file-icon[data-ext="md"], .file-icon[data-ext="txt"] { background: var(--ok-bg); color: var(--ok); }
.file-icon[data-ext="md"] .ext, .file-icon[data-ext="txt"] .ext { background: var(--chart-ok); color: #ffffff; }
.controls-card .row form { margin: 0; }
.side-stack { display: flex; flex-direction: column; gap: var(--s-4); }

/* ----- CPC review ------------------------------------------------------------------------ */
.cpc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--s-4); }
.cpc-card {
  display: flex; flex-direction: column; gap: var(--s-3); padding: var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface); box-shadow: var(--sh-1);
  transition: opacity 0.15s, background-color 0.15s, border-color 0.15s;
}
.cpc-card header { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.cpc-symbol { font-family: var(--font-mono); font-size: var(--fs-lg); font-weight: 700; letter-spacing: 0.01em; }
.cpc-card .keep-off { display: none; }
.cpc-card:has(input[name="keep"]:not(:checked)) { background: var(--surface-2); border-style: dashed; }
.cpc-card:has(input[name="keep"]:not(:checked)) .cpc-body { opacity: 0.5; }
.cpc-card:has(input[name="keep"]:not(:checked)) .keep-on { display: none; }
.cpc-card:has(input[name="keep"]:not(:checked)) .keep-off { display: inline; }
.cpc-body { display: flex; flex-direction: column; gap: var(--s-3); }
.crumbs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }
.crumbs li { display: flex; gap: var(--s-2); align-items: baseline; padding-left: calc(var(--depth, 0) * 10px); color: var(--ink-2); }
.crumbs li::before { content: ""; flex: none; width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); transform: translateY(-1px); }
.crumbs li:last-child { color: var(--ink); font-weight: 600; }
.crumbs li:last-child::before { background: var(--accent); }
.crumbs .sym { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--muted); flex: none; }
.rationale { color: var(--ink-2); font-size: var(--fs-sm); }
.action-bar {
  position: sticky; bottom: var(--s-3); z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--sh-2);
}
details.edit > summary { list-style: none; align-self: flex-start; }
details.edit > summary::-webkit-details-marker { display: none; }
details.edit[open] > summary { margin-bottom: var(--s-3); }
details.edit .field { margin-bottom: var(--s-3); }

/* ----- results --------------------------------------------------------------------------- */
.class-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.class-chips .chip { font-family: var(--font-mono); font-weight: 600; background: var(--surface-3); color: var(--ink); }
.class-chips .chip::before { display: none; }
.hits { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.hit {
  display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: var(--s-4);
  padding: var(--s-4); border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  box-shadow: var(--sh-1);
}
.hit-rank {
  width: 52px; height: 52px; border-radius: var(--r-md); display: grid; place-items: center;
  background: var(--surface-3); color: var(--ink-2); font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: var(--fs-sm); text-align: center; line-height: 1.1;
}
.hit-main { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.hit-top { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); }
.hit-pn { font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-md); }
.hit-title { font-size: var(--fs-md); font-weight: 560; }
.hit-meta { font-size: var(--fs-sm); color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px var(--s-3); }
.hit-actions { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-3); align-items: center; }
.hit.closest { border: 2px solid var(--accent); box-shadow: var(--sh-2); padding: calc(var(--s-4) - 1px); }
.hit.closest .hit-rank { background: var(--accent); color: var(--accent-ink); }
.closest-flag {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--accent); color: var(--accent-ink); font-size: var(--fs-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
}
.hit .meter-row { max-width: 420px; }
details.hit-more > summary { cursor: pointer; font-weight: 600; color: var(--accent); font-size: var(--fs-sm); }
details.hit-more[open] > summary { margin-bottom: var(--s-2); }
.hit-more .cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); }
.hit-more ul { margin: var(--s-1) 0 0; padding-left: 1.1em; font-size: var(--fs-sm); color: var(--ink-2); display: flex; flex-direction: column; gap: 3px; }
.hit-more h4 { margin: 0; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.hit-more p { font-size: var(--fs-sm); color: var(--ink-2); margin-bottom: var(--s-3); max-width: 80ch; }
/* X / Y / A category letter with an explanatory tooltip */
.cat {
  position: relative; display: inline-grid; place-items: center; width: 26px; height: 26px;
  border-radius: var(--r-sm); font: 700 var(--fs-sm) / 1 var(--font-mono); cursor: help;
  background: var(--surface-3); color: var(--ink-2);
}
.cat.cat-X { background: var(--bad-bg); color: var(--bad); }
.cat.cat-Y { background: var(--warn-bg); color: var(--warn); }
.cat .tip {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  width: max-content; max-width: 260px; padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  background: var(--ink); color: var(--surface); box-shadow: var(--sh-2);
  font: 500 var(--fs-xs) / 1.45 var(--font); text-align: left; white-space: normal;
  display: none; z-index: 20; pointer-events: none;
}
.cat:hover .tip, .cat:focus .tip, .cat:focus-visible .tip { display: block; }
.legend-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-5); font-size: var(--fs-sm); }
.legend-list li { display: flex; align-items: center; gap: var(--s-2); }
/* star rating */
.rating-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--line); }
.rating-form input[type="text"] { flex: 1 1 200px; width: auto; min-height: 36px; padding: 6px 10px; }
.rating-form button { min-height: 36px; }
.stars { display: inline-flex; flex-direction: row-reverse; }
.stars input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.stars label { font-size: 22px; line-height: 1; padding: 2px; color: var(--line-strong); cursor: pointer; font-weight: 400; }
.stars label:hover, .stars label:hover ~ label, .stars input:checked ~ label { color: var(--chart-warn); }
.stars input:focus-visible + label { outline: 2px solid var(--focus); outline-offset: 1px; border-radius: var(--r-sm); }

/* ----- traffic, tokens and charts -------------------------------------------------------- */
.ledger-switch { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.ledger-switch a, .ledger-switch strong { padding: 5px 12px; border-radius: 6px; font-size: var(--fs-sm); text-decoration: none; font-weight: 600; }
.ledger-switch a { color: var(--muted); }
.ledger-switch strong { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
/* HTML column chart: one zero baseline, round ticks, <= 24 px columns, 4 px rounded tops */
.colchart {
  display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: 220px auto;
  column-gap: var(--s-3); row-gap: 6px; font-size: var(--fs-xs); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cc-y { position: relative; min-width: 58px; }
.cc-y span { position: absolute; right: 0; transform: translateY(50%); white-space: nowrap; }
.cc-plot { position: relative; display: flex; align-items: flex-end; border-bottom: 1px solid var(--chart-axis); }
.cc-grid { position: absolute; left: 0; right: 0; height: 1px; background: var(--chart-grid); }
.cc-grid.base { display: none; }
.cc-slot { position: relative; flex: 1; height: 100%; display: flex; align-items: flex-end; justify-content: center; border-radius: var(--r-sm); }
.cc-slot:hover, .cc-slot:focus-visible { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.cc-col { display: block; width: min(24px, 62%); background: var(--chart-1); border-radius: 4px 4px 0 0; position: relative; }
.cc-slot:hover .cc-col, .cc-slot:focus-visible .cc-col { background: var(--accent-hover); }
.cc-tip {
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  width: max-content; max-width: 220px; padding: 6px 10px; border-radius: var(--r-md);
  background: var(--ink); color: var(--surface); font-size: var(--fs-xs); box-shadow: var(--sh-2);
  display: none; pointer-events: none; z-index: 5;
}
.cc-slot { overflow: visible; }
.cc-slot:hover .cc-tip, .cc-slot:focus-visible .cc-tip { display: block; bottom: 102%; }
.cc-slot:first-child .cc-tip, .cc-slot:nth-child(2) .cc-tip { left: 0; transform: none; }
.cc-slot:last-child .cc-tip, .cc-slot:nth-last-child(2) .cc-tip { left: auto; right: 0; transform: none; }
.cc-x { grid-column: 2; display: flex; }
.cc-x span { flex: 1; text-align: center; }
.hbars { display: flex; flex-direction: column; gap: var(--s-3); }
.hbar { display: grid; grid-template-columns: minmax(90px, 200px) minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; font-size: var(--fs-sm); }
.hbar .hlabel { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .htrack { display: flex; gap: 2px; height: 14px; }
.hbar .htrack i { display: block; height: 100%; min-width: 0; }
.hbar .htrack i:first-child { border-radius: 2px 0 0 2px; }
.hbar .htrack i:last-child { border-radius: 0 4px 4px 0; }
.hbar .htrack .s1 { background: var(--chart-1); }
.hbar .htrack .s2 { background: var(--chart-2); }
.hbar .hvalue { font-variant-numeric: tabular-nums; font-weight: 650; white-space: nowrap; }
.chart-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); font-size: var(--fs-sm); color: var(--ink-2); }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend .s1 { background: var(--chart-1); }
.chart-legend .s2 { background: var(--chart-2); }
.inline-bar { display: flex; align-items: center; gap: var(--s-2); min-width: 120px; }
.inline-bar .meter { height: 6px; }
.danger-zone { border: 1px solid var(--chart-bad); border-radius: var(--r-lg); background: var(--surface); padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-4); }
.danger-zone h2 { color: var(--bad); display: flex; align-items: center; gap: var(--s-2); }
.danger-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--line); }
.danger-row:first-of-type { border-top: 0; padding-top: 0; }
.danger-row .what { flex: 1 1 280px; display: flex; flex-direction: column; gap: 2px; }
.danger-row form { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: 0; align-items: center; }
.danger-row input[type="text"] { width: 220px; }
.md { white-space: pre-wrap; font: var(--fs-xs) / 1.5 var(--font-mono); background: var(--surface-2); padding: var(--s-3); border-radius: var(--r-md); overflow-x: auto; }
.bench-compare { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: flex-end; }
.bench-compare label { display: flex; flex-direction: column; gap: 4px; flex: 1 1 220px; }

/* error page */
.error-page { align-items: center; text-align: center; padding: var(--s-7) var(--s-5); }
.error-page .code { font: 700 var(--fs-2xl) var(--font-mono); color: var(--muted); }

/* ----- motion ---------------------------------------------------------------------------- */
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes toast-in { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
}

/* ----- responsive ------------------------------------------------------------------------ */
@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-grid, .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto auto 1fr; grid-template-areas: "top" "side" "main"; }
  .sidebar { position: static; height: auto; padding: 0 var(--s-2); gap: 0; overflow: visible; }
  .sidebar > .brand, .sidebar-foot { display: none; }
  .nav { flex-direction: row; overflow-x: auto; gap: 2px; padding: 6px 0; scrollbar-width: none; }
  .nav a { flex: none; padding: 7px 10px; gap: 6px; font-size: var(--fs-sm); }
  .nav a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--chart-1); }
  .topbar { padding: var(--s-2) var(--s-4); }
  .topbar .brand { display: flex; }
  .topbar-title { display: none; }
  .topbar-tools { margin-left: auto; }
  .content { padding: var(--s-4) var(--s-4) var(--s-7); }
  .hero { grid-template-columns: minmax(0, 1fr); padding: var(--s-5); }
  .hero h1 { font-size: var(--fs-xl); }
  .steps-guide { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
  .gauge-wrap { grid-template-columns: minmax(0, 1fr); }
  .gauge-wrap .gauge-svg { max-width: 320px; margin: 0 auto; }
  .hit-more .cols { grid-template-columns: minmax(0, 1fr); }
  .cc-x .x-odd { visibility: hidden; }
  .colchart { grid-template-rows: 180px auto; }
}
@media (max-width: 560px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--s-4); }
  h1 { font-size: var(--fs-lg); }
  .usage .usage-label { display: none; }
  .mini-meter { width: 36px; }
  .topbar { gap: var(--s-2); }
  .topbar-tools { gap: 6px; }
  .wiz-steps li span:last-child { display: none; }
  .wiz-steps li[aria-current="step"] span:last-child { display: inline; }
  .wiz-steps li { flex: none; }
  .wiz-steps li[aria-current="step"] { flex: 1; }
  .hit { grid-template-columns: minmax(0, 1fr); gap: var(--s-3); }
  .hit-rank { width: auto; height: auto; padding: 4px 10px; justify-self: start; }
  .hbar { grid-template-columns: minmax(0, 1fr) auto; }
  .hbar .htrack { grid-column: 1 / -1; grid-row: 2; }
  .review { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .review dd { margin-bottom: var(--s-2); }
  .hide-sm { display: none; }
  .flash[data-toast] { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); }
  .danger-row input[type="text"] { width: 100%; }
  .cpc-grid { grid-template-columns: minmax(0, 1fr); }
  .dl-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Windows high contrast: keep marks visible */
@media (forced-colors: active) {
  .progress > i, .meter > i, .mini-meter i, .hbar .htrack i, .cc-col { forced-color-adjust: none; background: Highlight; }
}
.ico.spin { animation: spin 1.1s linear infinite; }

/* ----- settings page (AI provider) ----- */
.device-code { font: 700 2rem/1.2 var(--font-mono); letter-spacing: .15em; margin: .25rem 0 .75rem; }
.provider-card .actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin: .75rem 0; }
.provider-card form { margin: .5rem 0; }
.provider-form fieldset { border: 0; padding: 0; margin: 0 0 .75rem; display: grid; gap: .35rem; }
.models-form label { display: block; margin: .35rem 0; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline; }

/* ----- sign-in ----- */
.user-chip { display: inline-flex; align-items: center; gap: .3rem; color: var(--ink-2); }
.sidebar-user { margin: 0 0 .5rem; color: var(--ink-2); overflow-wrap: anywhere; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(26rem, 100%); }
.login-card label { display: block; margin: .6rem 0; }
.login-card input { width: 100%; }
.login-card .brand { display: flex; align-items: center; gap: .5rem; margin-bottom: .75rem; }
