:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #1b1f24;
  --muted: #5f6b7a;
  --line: #dde2e8;
  --accent: #2f6fde;
  --accent-soft: #e3ecfb;
  --bar: #9db8ea;
  --bar-top: #2f6fde;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --err: #c53030;
  --err-soft: #fdecec;
  --code: #f0f2f5;
  --radius: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --panel: #1a1e24;
    --text: #e6e9ed;
    --muted: #93a0b0;
    --line: #2c333c;
    --accent: #6b9cf0;
    --accent-soft: #1f2d45;
    --bar: #3a5584;
    --bar-top: #6b9cf0;
    --ok: #4cc27f;
    --warn: #e0a84a;
    --err: #f07070;
    --err-soft: #3a1d1f;
    --code: #14181d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h2 { font-size: 14px; font-weight: 600; margin: 0; }
code, .code, textarea, input, select { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { font-weight: 700; font-size: 16px; }
.brand-sub { display: block; font-weight: 400; font-size: 11px; color: var(--muted); letter-spacing: .02em; }
.tabs { display: flex; gap: 4px; }
.tabs button { border: 0; background: none; padding: 6px 10px; border-radius: 6px; color: var(--muted); cursor: pointer; font: inherit; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); }
.conn { margin-left: auto; display: flex; align-items: center; gap: 10px; }
/* the machine, its load and who else is here (/status) */
.sysbar { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; padding: 4px 16px; font-size: 12px;
          border-bottom: 1px solid var(--line); }
.sysbar:empty { display: none; }
.sysbar .load { display: inline-flex; align-items: center; gap: 6px; }
.sysbar .meter { width: 70px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.sysbar .meter > i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
/* live throughput, power and temperature (renderLive) */
.livebar { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: center; padding: 4px 16px; font-size: 12px;
           color: var(--muted); border-bottom: 1px solid var(--line); }
.livebar:empty { display: none; }
.livebar .live-main { color: var(--text); }
.livebar .live-main strong { font-size: 15px; color: var(--accent); }
.livebar .spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.livebar .live-spark { display: inline-flex; }
.key input { width: 160px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.loading { background: var(--warn); }
.dot.down { background: var(--err); }

main { padding: 16px; max-width: 1400px; margin: 0 auto; }
.view { display: none; }
.view.active { display: block; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
@media (max-width: 900px) { .cols { grid-template-columns: minmax(0, 1fr); } .key input { width: 110px; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
details.panel > summary { cursor: pointer; list-style: none; }
details.panel > summary h2 { display: inline; }
details.panel[open] > summary { margin-bottom: 8px; }

textarea, input, select {
  width: 100%; background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
}
textarea { resize: vertical; }
textarea:focus, input:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label.check { flex-direction: row; align-items: center; gap: 6px; }
label.check input { width: auto; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button {
  font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--text);
  border-radius: 6px; padding: 6px 12px; cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { padding: 2px 8px; font-size: 12px; }
button.icon { width: 26px; padding: 2px 0; }
.btnrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: end; }
.btnrow label { width: 90px; }
/* The answer column sticks to the top on wide screens, so a result stays in
   view while the question list is scrolled. */
@media (min-width: 901px) {
  #result-panel { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; }
}
.kbd { opacity: .75; font-size: 11px; margin-left: 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; border-radius: 0; padding: 3px 10px; font-size: 12px; }
.seg button.active { background: var(--accent-soft); color: var(--accent); }

.examples { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.examples button { font-size: 12px; }
.examples button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
/* variants of the chosen example: one row per group, the chosen option's note after it */
.variants { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px;
            margin-bottom: 12px; display: flex; flex-direction: column; gap: 6px; }
.variants-desc { font-size: 13px; color: var(--muted); }
.variant { display: grid; grid-template-columns: 120px auto 1fr; gap: 10px; align-items: center; }
.variant-label { font-size: 12px; font-weight: 600; }
.variant-note { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) {
  .variant { grid-template-columns: 1fr; gap: 4px; }
}

/* question editor */
.q { border: 1px solid var(--line); border-radius: 6px; padding: 8px; margin-bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.q.error, textarea.error, select.error { border-color: var(--err); background: var(--err-soft); }
.q-head { display: flex; gap: 6px; align-items: center; }
.q-id { width: 40%; }
.q-type { width: 110px; }
.spacer { flex: 1; }
.rows { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; gap: 4px; align-items: center; }
.row .lbl { width: 28px; text-align: right; color: var(--muted); font-family: ui-monospace, monospace; font-size: 12px; flex: none; }
.row input.k { width: 35%; flex: none; }
.field-err { color: var(--err); font-size: 12px; min-height: 0; }

/* answer cards */
.meta { font-size: 12px; text-align: right; }
.card { border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin-bottom: 10px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.card-head .id { font-weight: 600; font-family: ui-monospace, monospace; }
.card-head .ans { font-weight: 600; color: var(--accent); }
.bars { display: flex; flex-direction: column; gap: 4px; }
.bar { display: grid; grid-template-columns: minmax(60px, 32%) 1fr 56px; gap: 8px; align-items: center; font-size: 12px; }
.bar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar .track { height: 14px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--bar); }
.bar.top .fill { background: var(--bar-top); }
.bar.top .name { font-weight: 600; }
.bar .val { text-align: right; font-family: ui-monospace, monospace; }
.conf { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.axis { position: relative; height: 26px; margin: 24px 4px 2px; border-top: 2px solid var(--line); }
.axis .tick { position: absolute; top: 2px; transform: translateX(-50%); font-size: 11px; color: var(--muted); }
.axis .marker { position: absolute; top: -8px; width: 2px; height: 14px; background: var(--accent); transform: translateX(-1px); }
.axis .marker span { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--accent); white-space: nowrap; }
.noul-track { position: relative; height: 18px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.noul-track .fill { height: 100%; background: var(--bar-top); }
.noul-track .half { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; background: var(--muted); }
.hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.errcard { border-color: var(--err); background: var(--err-soft); }

/* plain answers on top (summaryRow) */
#summary { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.sum { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.sum-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sum-q { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.sum-ans { font-size: 18px; font-weight: 600; margin-top: 2px; }
/* yes and no stay neutral: whether yes is good depends on the question ("is spam") */
.sum-desc { font-size: 13px; margin-top: 2px; }
.sum-detail { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill { font-size: 11px; padding: 2px 8px; border-radius: 10px; white-space: nowrap; border: 1px solid currentColor; }
.pill.sure { color: var(--ok); }
.pill.likely { color: var(--accent); }
.pill.unsure { color: var(--warn); }
.pill.split { color: var(--err); }
/* a score as a strip of its levels, each as strong as it is likely */
.levels { display: flex; gap: 3px; margin-top: 8px; }
.lvl { flex: 1; min-width: 0; position: relative; border: 1px solid var(--line); border-radius: 4px; padding: 6px 4px 4px; text-align: center; }
.lvl.top { border-color: var(--accent); }
.lvl-fill { position: absolute; inset: 0; background: var(--accent); border-radius: 3px; }
.lvl-name { position: relative; font-size: 11px; line-height: 1.2; display: block; overflow: hidden; text-overflow: ellipsis;
            white-space: nowrap; }
.lvl.top .lvl-name { font-weight: 600; }
.lvl.strong .lvl-name { color: #fff; }   /* on a fill of 50 % and more */
/* a verdict that settles the case (examples/index.json "verdicts") */
.sum.verdict { border-color: var(--accent); background: var(--accent-soft); }
/* the server card: one fact per line */
.kv-row { display: grid; grid-template-columns: 110px 1fr; gap: 8px; font-size: 12px; padding: 1px 0; word-break: break-all; }
/* the technical cards, folded away below */
.tech { margin-top: 4px; }
.tech > summary { cursor: pointer; color: var(--muted); font-size: 13px; padding: 4px 0; }
.tech #cards { margin-top: 8px; }
.code { background: var(--code); border-radius: 6px; padding: 8px; overflow: auto; max-height: 420px; white-space: pre; margin: 0; }
#resp-raw-wrap summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-top: 4px; }

/* batch */
.progress { height: 6px; background: var(--bg); border-radius: 3px; margin: 10px 0 6px; overflow: hidden; }
#batch-bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; font-size: 13px; }
.kv .v { font-family: ui-monospace, monospace; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 12px; }
th, td { text-align: left; padding: 4px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
svg text { fill: var(--muted); font-size: 11px; }
svg .grid { stroke: var(--line); }
svg .diag { stroke: var(--muted); stroke-dasharray: 4 3; }
svg .pt { fill: var(--accent); }
svg .ln { stroke: var(--accent); fill: none; stroke-width: 2; }

/* blocks */
.filebtn { flex-direction: row; display: inline-flex; align-items: center; cursor: pointer; border: 1px solid var(--line);
  border-radius: 6px; padding: 2px 8px; color: var(--text); font-size: 12px; }
.filebtn:hover { border-color: var(--accent); }
#blocks-summary { margin-top: 8px; }
tr.blk { cursor: pointer; }
tr.blk:hover td { background: var(--accent-soft); }
tr.blk.miss td.ok { color: var(--err); font-weight: 600; }
tr.blk.hit td.ok { color: var(--ok); }
tr.detail td { background: var(--bg); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: minmax(0, 1fr); } }
.statetext { white-space: pre-wrap; font-family: ui-monospace, monospace; font-size: 12px; max-height: 360px; overflow: auto; }
