:root {
  color-scheme: light;
  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #f0efec;
  --border: #e2e1dc;
  --text: #121212;
  --text-2: #52514e;
  --muted: #7d7c77;
  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-soft: #e7eff9;
  --series-1: #2a78d6;
  --series-muted: #c9c8c0;
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --good-ink: #0a6b0a;
  --warn-ink: #8a5600;
  --bad-ink: #a32a2a;
  --good-soft: #e8f6e8;
  --warn-soft: #fff4dc;
  --bad-soft: #fbe9e9;
  --radius: 10px;
  --k1: #4a9e68; --k2: #e3c27a; --k3: #e0b4b1;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #33332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #5598e7;
    --accent-hover: #6da7ec;
    --accent-soft: #1b2a3d;
    --series-1: #3987e5;
    --series-muted: #4a4a45;
    --good-ink: #5fd35f;
    --warn-ink: #f5c04a;
    --bad-ink: #f08080;
    --good-soft: #15291a;
    --warn-soft: #2e2511;
    --bad-soft: #321a1a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #33332f;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86;
  --accent: #5598e7; --accent-hover: #6da7ec; --accent-soft: #1b2a3d;
  --series-1: #3987e5; --series-muted: #4a4a45;
  --good-ink: #5fd35f; --warn-ink: #f5c04a; --bad-ink: #f08080;
  --good-soft: #15291a; --warn-soft: #2e2511; --bad-soft: #321a1a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Pretendard", "Pretendard Variable", -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.3; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
small, .muted { color: var(--muted); }
code, pre { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 52px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { font-weight: 800; font-size: 17px; letter-spacing: .02em; color: var(--text); white-space: nowrap; margin-right: auto; }
.brand:hover { text-decoration: none; color: var(--accent); }
.topset { padding: 6px 12px; border-radius: 6px; color: var(--text-2); font-weight: 600; }
.topset:hover, .topset.on { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topnav { display: flex; gap: 4px; flex: 1; min-width: 0; overflow-x: auto; }
.topnav a, .topnav select {
  padding: 6px 10px; border-radius: 6px; color: var(--text-2); white-space: nowrap;
}
.topnav a:hover, .topnav a.on { background: var(--surface-2); color: var(--text); text-decoration: none; }
.topnav select { border: 1px solid var(--border); background: var(--surface); font: inherit; }
.who { display: flex; align-items: center; gap: 10px; color: var(--text-2); white-space: nowrap; }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; color: var(--text-2); font: inherit; cursor: pointer; padding: 4px 6px; }
.linkbtn:hover { color: var(--text); text-decoration: underline; }

main { max-width: 1240px; margin: 0 auto; padding: 24px; }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead p { color: var(--text-2); margin: 4px 0 0; }
.crumb { color: var(--muted); font-size: 12.5px; margin-bottom: 4px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs a {
  padding: 9px 14px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.flash { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: var(--text); margin-bottom: 16px; }
.flash.err { background: var(--bad-soft); }
.flash.ok { background: var(--good-soft); }

/* ---------- layout ---------- */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-21 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
.kpis { display: grid; gap: 12px; grid-template-columns: repeat(6, minmax(0, 1fr)); margin-bottom: 16px; }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g3, .g-21 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 720px) {
  main { padding: 16px; }
  .topbar { padding: 0 16px; }
  .kpis, .kpis.k4, .g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .who .uname { display: none; }
}

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); min-width: 0;
}
.card > h2, .card-head { margin-bottom: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.card-head h2 { margin: 0; }
.card + .card, .grid + .card, .card + .grid, .grid + .grid { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.section-note { color: var(--text-2); margin: -4px 0 12px; font-size: 13px; }

/* ---------- KPI tile ---------- */
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { color: var(--text-2); font-size: 12.5px; display: flex; justify-content: space-between; gap: 6px; }
.kpi .k-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .k-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .k-foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.hero .k-value { font-size: 34px; }

.delta { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--good-ink); }
.delta.down { color: var(--bad-ink); }
.delta.flat { color: var(--muted); }

.st { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.st::before { font-size: 10px; }
.st.good { background: var(--good-soft); color: var(--good-ink); }
.st.good::before { content: "\2713"; }
.st.warn { background: var(--warn-soft); color: var(--warn-ink); }
.st.warn::before { content: "!"; font-weight: 800; }
.st.bad { background: var(--bad-soft); color: var(--bad-ink); }
.st.bad::before { content: "\00d7"; font-size: 13px; }
.st.na { background: var(--surface-2); color: var(--muted); }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--text-2); font-size: 12px; white-space: nowrap; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.high { background: var(--bad-soft); color: var(--bad-ink); }
.chip.mid { background: var(--warn-soft); color: var(--warn-ink); }
.chip.low { background: var(--surface-2); color: var(--text-2); }

/* ---------- tables ---------- */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--text-2); background: var(--surface-2); white-space: nowrap; }
tbody tr:hover td { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
td.r, th.r { text-align: right; }
td.c, th.c { text-align: center; }
.tight td, .tight th { padding: 6px 8px; }

/* prompt x engine matrix */
.mx td.cell { text-align: center; white-space: nowrap; width: 96px; }
.mx .cell a { display: inline-block; min-width: 52px; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.mx .hit a { background: var(--accent-soft); color: var(--accent); }
.mx .miss a { background: var(--surface-2); color: var(--muted); font-weight: 500; }
.mx .confused a { background: var(--bad-soft); color: var(--bad-ink); }
.mx .none { color: var(--muted); }
.mx td.q { min-width: 260px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* ---------- bars ---------- */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(84px, 140px) minmax(0, 1fr) 52px; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .b-name { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row .b-name.us { color: var(--text); font-weight: 700; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--series-muted); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-fill.us { background: var(--series-1); }
.bar-row .b-val { text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }

/* ---------- chart ---------- */
.viz { width: 100%; height: auto; display: block; }
.viz-grid { stroke: var(--border); stroke-width: 1; }
.viz-axis { fill: var(--muted); font-size: 11px; }
.viz-line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.viz-dot { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.viz-hit { fill: transparent; }
.viz-pt:hover .viz-dot { r: 6.5; }
.viz-label { fill: var(--text); font-size: 12px; font-weight: 600; }

/* ---------- executive view ---------- */
:root { --f0: #cde2fb; --f1: #6da7ec; --f2: #184f95; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --f0: #2a3a52; --f1: #3987e5; --f2: #9ec5f4; }
}
:root[data-theme="dark"] { --f0: #2a3a52; --f1: #3987e5; --f2: #9ec5f4; }

.tag { font-size: 12px; font-weight: 700; color: var(--accent); letter-spacing: 0.04em; margin-bottom: 4px; }
.gq { font-size: 22px; margin-bottom: 14px; }
.verdict { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 24px; align-items: center; }
.answer-main { font-size: 18px; font-weight: 700; line-height: 1.5; margin-bottom: 6px; }
.answer-why { font-size: 15px; color: var(--text-2); margin-bottom: 12px; }
.ranking { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13.5px; color: var(--text-2); }
.ranking li.us { color: var(--text); font-weight: 700; }
.ranking strong { color: var(--text); margin-left: 2px; }
.kpi-box { border-left: 1px solid var(--border); padding-left: 24px; }
.hero-num { font-size: 56px; font-weight: 800; letter-spacing: -0.03em; line-height: 1.05; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.hero-sub { font-size: 13px; }

.sec { font-size: 16px; margin-bottom: 4px; }
.sec-note { color: var(--text-2); font-size: 13.5px; margin-bottom: 14px; }
.funnel { display: grid; gap: 4px; max-width: 760px; }
.f-row, .f-drop { display: grid; grid-template-columns: 170px minmax(0, 1fr) 56px; align-items: center; gap: 12px; }
.f-label { font-size: 13.5px; color: var(--text-2); }
.f-track { height: 22px; }
.f-fill { height: 100%; border-radius: 0 4px 4px 0; min-width: 3px; }
.f0 { background: var(--f0); }
.f1 { background: var(--f1); }
.f2 { background: var(--f2); }
.f-val { text-align: right; font-size: 14px; }
.f-drop { grid-template-columns: 170px minmax(0, 1fr); }
.f-loss { font-size: 12.5px; color: var(--text-2); padding: 1px 0 1px 10px; border-left: 2px dashed var(--border); }
.f-loss b { color: var(--accent); margin-right: 2px; }
.f-loss strong { color: var(--text); margin-left: 4px; }

.branch.key { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.b-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.b-head h2 { margin: 0; font-size: 16px; }
.b-no { font-size: 18px; font-weight: 800; color: var(--accent); }
.b-val { font-size: 20px; font-weight: 800; margin-left: auto; }
.b-def { color: var(--text-2); font-size: 13px; margin: 4px 0 12px; }
.b-dl { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: 10px 12px; font-size: 13.5px; margin: 0; }
.b-dl dt { color: var(--text-2); font-weight: 600; }
.b-dl dd { margin: 0; }
.ex { margin: 0; padding-left: 16px; }
.ex li { margin-bottom: 2px; }
.so-what { margin-top: 14px; padding: 10px 12px; background: var(--accent-soft); border-radius: 8px; font-size: 13.5px; line-height: 1.6; }
.so-what .lbl { display: block; color: var(--accent); margin-bottom: 2px; }
.appendix tr.grp td { background: var(--surface-2); font-size: 12px; font-weight: 600; color: var(--text-2); }
.method { font-size: 12px; margin-top: 12px; line-height: 1.6; }
@media (max-width: 720px) {
  .grid.g2.stack { grid-template-columns: minmax(0, 1fr); }
  .verdict { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .kpi-box { border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
  .hero-num { font-size: 44px; }
  .f-row { grid-template-columns: 110px minmax(0, 1fr) 48px; gap: 8px; }
  .f-drop { grid-template-columns: 110px minmax(0, 1fr); gap: 8px; }
}

/* ---------- forms ---------- */
form.inline { display: inline; margin: 0; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label, .lbl { font-size: 12.5px; color: var(--text-2); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); }
input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=url], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 160px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.sm { padding: 3px 9px; font-size: 12.5px; font-weight: 500; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
details > summary { cursor: pointer; color: var(--accent); }
details[open] > summary { margin-bottom: 10px; }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 36px 16px; color: var(--text-2); }
.empty h2 { margin-bottom: 8px; color: var(--text); }
.answer { white-space: pre-wrap; background: var(--surface-2); border-radius: 8px; padding: 14px 16px; max-height: 560px; overflow: auto; }
.codebox { position: relative; }
.codebox pre { background: var(--surface-2); border-radius: 8px; padding: 12px 14px; max-height: 360px; overflow: auto; white-space: pre-wrap; margin: 0; }
.codebox .btn { position: absolute; top: 8px; right: 8px; }
.list { margin: 0; padding-left: 18px; }
.list li { margin-bottom: 4px; }
.rec { padding: 10px 0; border-bottom: 1px solid var(--border); }
.rec:last-child { border-bottom: 0; }
.rec-title { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rec-detail { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--series-1); }
.kv { display: grid; grid-template-columns: 120px minmax(0, 1fr); gap: 6px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.pre { white-space: pre-wrap; }
.login-wrap { max-width: 380px; margin: 10vh auto; }
.foot { color: var(--muted); font-size: 12px; text-align: center; padding: 24px 0 8px; }

@media print {
  .topbar, .tabs, .noprint, .btn { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
}

/* ---------- answers build-up ---------- */
.bk { display: inline-block; min-width: 58px; padding: 1px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; text-align: center; }
a.bk:hover { text-decoration: none; filter: brightness(0.95); }
.bk-first { background: var(--k1); color: #fff; }
.bk-behind { background: var(--k2); color: #1b1b1b; }
.bk-absent { background: var(--k3); color: #1b1b1b; }
.sec-note .bk { min-width: 0; margin: 0 2px; }
table.buildup td.q { min-width: 240px; }
table.buildup tfoot td { border-top: 2px solid var(--text-2); border-bottom: 0; background: var(--surface-2); }

/* ---------- value chain: steps 1-3 ---------- */
.tabs .step { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--surface-2); font-size: 11px; font-weight: 700; margin-right: 4px; color: var(--text-2); }
.tabs a.on .step { background: var(--accent); color: #fff; }
.tabs .tab-util { margin-left: auto; color: var(--muted); }
.step-intro { color: var(--text-2); font-size: 14px; margin: -4px 0 16px; max-width: 900px; line-height: 1.6; }
.step-intro b { color: var(--text); }
.lead { font-size: 15px; line-height: 1.65; max-width: 900px; }
.sub { font-size: 13.5px; margin-bottom: 8px; }
td.k { font-weight: 600; min-width: 112px; overflow-wrap: normal; word-break: keep-all; }
td.src { white-space: nowrap; font-size: 12px; }
.chip.prio-high { background: var(--accent); color: #fff; }
.chip.prio-medium { background: var(--accent-soft); color: var(--accent); }
.chip.prio-low { background: var(--surface-2); color: var(--text-2); }
.oos { margin-top: 12px; padding: 8px 12px; border-left: 3px solid var(--border); color: var(--text-2); font-size: 13px; }
.kv.crit { grid-template-columns: 200px minmax(0, 1fr); }
.next { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.next p { margin: 0 auto 0 0; font-size: 12.5px; }
ol.rules { margin: 0; padding-left: 20px; line-height: 1.7; }
ol.rules li { margin-bottom: 4px; }
table.cov td { vertical-align: top; min-width: 170px; }
table.cov td .w { font-size: 11.5px; color: var(--muted); margin-bottom: 4px; font-variant-numeric: tabular-nums; }
table.cov td .chip { margin: 0 2px 4px 0; }
table.cov td.cell-skipped { background: var(--surface-2); }
table.cov td.cell-gap { background: var(--bad-soft); }
table.qset td.q, table.buildup td.q { min-width: 280px; }
tr.grp td { background: var(--surface-2); font-weight: 700; color: var(--text); }
table.buildup tr.sub td { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); font-weight: 600; }
@media (max-width: 720px) { .kv.crit { grid-template-columns: minmax(0, 1fr); } .tabs .tab-util { margin-left: 0; } }
td.num, th.r { white-space: nowrap; }

/* ---------- workspace: summary bar on top, the results matrix under it ---------- */
.mx { padding: 14px 16px; position: relative; }

/* the matrix: corner = product, headers = markets and buyers, cells = results */
.map { display: grid; gap: 6px; overflow-x: auto; padding: 2px; }
.map .corner, .map .mh, .map .rh { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 10px; border: 1px solid transparent; background: var(--surface-2); min-width: 0; }
.map .corner { background: var(--surface); border-color: var(--border); }
.map .sel { border-color: var(--accent) !important; box-shadow: 0 0 0 1px var(--accent); }
.htop { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.hname { all: unset; font-weight: 700; font-size: 13.5px; line-height: 1.3; color: var(--text); cursor: pointer; }
.hname:hover { color: var(--accent); text-decoration: underline dotted; }
.hname:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hname.static { cursor: default; color: var(--text-2); }
.hname.static:hover { text-decoration: none; color: var(--text-2); }
.hname.prod { font-size: 19px; font-weight: 800; }
.hsub { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.htot { display: flex; align-items: center; gap: 8px; margin-top: auto; padding-top: 4px; }
.htot .mid { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 40px; }
.htot .mb { max-width: 120px; height: 5px; }
.ctot { display: grid; gap: 5px; margin-top: 6px; }
.ctot .big { font-size: 32px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ctot .mb { max-width: 180px; }
.ctot .n { font-size: 11.5px; color: var(--text-2); }
.axes { font-size: 11px; color: var(--muted); margin-top: auto; padding-top: 6px; }
.nores { font-size: 12.5px; color: var(--muted); }
.pmini { display: inline-flex; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; background: var(--surface); }
.pmini button { border: 0; background: transparent; width: 21px; height: 19px; padding: 0; font: inherit; font-size: 10.5px; font-weight: 700; color: var(--muted); cursor: pointer; }
.pmini button + button { border-left: 1px solid var(--border); }
.pmini button:hover { color: var(--accent); }
.pmini button.on { background: var(--accent); color: #fff; }
.lang { font-size: 10px; font-weight: 700; color: var(--text-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-right: 2px; }
.map .cell { text-align: left; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 9px 11px; min-height: 84px; font: inherit; color: var(--text); cursor: pointer; display: flex; flex-direction: column; gap: 6px; align-items: stretch; min-width: 0; }
.map .cell:hover { border-color: var(--accent); }
.map .cell.has { background: var(--surface); }
.map .cell.skipped { background: var(--surface-2); }
.map .cell.gap { border-color: var(--bad); box-shadow: inset 0 0 0 1px var(--bad); }
.ctop { display: flex; align-items: center; gap: 8px; }
.cword { font-size: 14px; font-weight: 600; color: var(--text-2); }
.cpct { margin-left: auto; font-size: 14px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }
.ctop .big { font-size: 24px; font-weight: 800; line-height: 1.05; font-variant-numeric: tabular-nums; }
.ctop .n { font-size: 11px; color: var(--text-2); }
.map .cell .mb { max-width: none; height: 5px; }
.cfoot { display: flex; justify-content: space-between; align-items: flex-end; gap: 6px; margin-top: auto; flex-wrap: wrap; }
.qn { font-size: 11.5px; color: var(--text-2); }
.miss { color: var(--bad-ink); }
.toks { display: flex; gap: 3px; flex-wrap: wrap; justify-content: flex-end; }
.tok { font-size: 9.5px; font-weight: 800; letter-spacing: .02em; padding: 0 4px; border-radius: 4px; line-height: 15px; border: 1px solid transparent; }
.tok.full { background: var(--accent); border-color: var(--accent); color: #fff; }
.tok.part { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.tok.none { border: 1px dashed var(--series-muted); color: var(--muted); }
.mb { display: inline-flex; width: 100%; max-width: 160px; height: 8px; border-radius: 3px; overflow: hidden; gap: 1px; background: var(--surface); vertical-align: middle; }
.mb i, .legend i { display: block; height: 100%; }
.b1 { background: var(--k1); }
.b2 { background: var(--k2); }
.b3 { background: var(--k3); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--text-2); align-items: center; }
.legend i { display: inline-block; width: 12px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* drawers */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); border-left: 1px solid var(--border); box-shadow: -8px 0 24px rgba(0, 0, 0, .08); z-index: 30; display: flex; flex-direction: column; }
.drawer .dh { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer .dh small { display: block; color: var(--muted); font-size: 12px; }
.drawer .dh h2 { font-size: 17px; margin-top: 2px; }
.drawer .dh .back { margin: -4px 0 4px -9px; }
.drawer .db { flex: 1 1 auto; padding: 14px 18px 32px; overflow-y: auto; }
.drawer .df { display: flex; gap: 8px; align-items: center; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface); }
.grow { flex: 1 1 auto; }
.drawer .why { background: var(--accent-soft); border-radius: 8px; padding: 10px 12px; font-size: 13.5px; line-height: 1.55; }
.drawer h3 { margin: 18px 0 8px; font-size: 13.5px; }
.drawer .small { font-size: 12.5px; }
.btn.danger { color: var(--bad-ink); }
.f { display: grid; gap: 4px; margin-bottom: 10px; min-width: 0; }
.f > span { font-size: 12px; color: var(--text-2); font-weight: 600; }
.f.wide { grid-column: 1 / -1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.mini-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; padding: 8px 0 4px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.mini-row > .f:has(.chips) { grid-column: 1 / -1; }
.mini-row > .btn { grid-column: 1 / -1; justify-self: end; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: max-content; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.on { background: var(--accent); color: #fff; font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-t { border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12.5px; cursor: pointer; color: var(--text-2); }
.chip-t.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip-t b { display: inline-block; min-width: 16px; height: 16px; line-height: 16px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 10.5px; text-align: center; }
.csum { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.csum .mb { display: flex; max-width: none; margin-top: 6px; }
.csum > div { flex: 1 1 auto; }
.csum p { margin: 4px 0 0; }
.qcard { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 10px; display: grid; gap: 6px; }
.qcard.draft { border-style: dashed; border-color: var(--accent); background: var(--accent-soft); }
.qcard textarea { min-height: 56px; }
.qcard .qt { margin: 0; font-weight: 600; }
.qcard p.small { margin: 0; }
.qhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.qmeta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.qmeta select { width: auto; }
.qact { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.qcard .note { font-size: 12px; margin: 0; }
.eng { display: flex; gap: 12px; flex-wrap: wrap; padding-top: 4px; border-top: 1px dashed var(--border); }
.eng-c { display: inline-flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.eng-c > small:first-child { font-size: 11px; color: var(--muted); }
.erow { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.erow:not(.on) .erow-main { opacity: .65; }
.erow-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.erow-side { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.sc-state { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.sc-state.ok { background: var(--good-soft); color: var(--good-ink); }
.sc-state.need { background: var(--warn-soft); color: var(--warn-ink); }
.sc-state.hand { background: var(--surface-2); color: var(--text-2); }
.sc-cost { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.switch { position: relative; width: 36px; height: 20px; flex: 0 0 auto; display: inline-block; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--series-muted); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(16px); }
.switch-line { display: flex; align-items: center; gap: 10px; font-weight: 600; margin-bottom: 12px; cursor: pointer; }
.keyline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.keyrow { display: flex; gap: 6px; margin-top: 6px; }
.keyrow input { flex: 1; min-width: 0; }
details.own summary { font-size: 12.5px; }
.tiny { font-size: 11.5px; margin: 6px 0 0; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--bad-ink); color: #fff; padding: 9px 16px; border-radius: 8px; z-index: 50; font-size: 13.5px; box-shadow: 0 4px 16px rgba(0, 0, 0, .15); }
.toast.ok { background: var(--good-ink); }

/* run dialog */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
.modal { position: fixed; top: 6vh; left: 50%; transform: translateX(-50%); width: min(640px, 94vw); max-height: 88vh; overflow-y: auto; background: var(--surface); border-radius: 12px; z-index: 41; box-shadow: 0 16px 48px rgba(0, 0, 0, .2); }
.modal .dh { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal .dh h2 { font-size: 18px; }
.modal .db { padding: 16px 20px 20px; }
.plan { font-size: 14px; line-height: 1.9; margin-bottom: 4px; }
.plan select { width: auto; display: inline-block; padding: 3px 6px; }
table.cost { margin-top: 10px; }
table.cost tr.off td { color: var(--muted); }
table.cost tfoot td { border-top: 2px solid var(--text-2); border-bottom: 0; }
details.assume { margin-top: 12px; font-size: 12.5px; }
details.assume ul { margin: 6px 0; padding-left: 18px; color: var(--text-2); }
.modal-act { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.flash.warn-flash { background: var(--warn-soft); margin: 0 0 12px; }
@media (max-width: 900px) {
  .sumband { grid-template-columns: minmax(0, 1fr); }
  .grid2, .mini-row { grid-template-columns: minmax(0, 1fr); }
}

/* summary bar: the aggregate, its 95% range, what stands behind it, and the trend */
.sumband { display: grid; grid-template-columns: minmax(300px, 400px) minmax(0, 1fr); gap: 24px; padding: 16px 20px; margin-bottom: 12px; align-items: stretch; }
.sb-hero { position: relative; display: flex; flex-direction: column; gap: 6px; outline: none; }
.sb-label { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.sb-figure { display: flex; align-items: center; gap: 14px; }
.sb-grade { display: flex; align-items: center; justify-content: center; min-width: 76px; height: 64px; padding: 0 8px; border-radius: 12px; background: var(--tone-soft); color: var(--tone); font-size: 34px; font-weight: 900; letter-spacing: .01em; }
.sb-word { display: flex; flex-direction: column; gap: 2px; font-size: 12px; white-space: nowrap; color: var(--text-2); min-width: 0; }
.sb-word b { font-size: 20px; color: var(--text); }
.ladder { position: relative; display: flex; gap: 2px; padding-top: 11px; }
.lseg { flex: 1; height: 22px; display: flex; align-items: center; justify-content: center; border-radius: 3px; font-size: 10px; font-weight: 700; background: var(--surface-2); color: var(--muted); }
.lseg.on { background: var(--tone-soft); color: var(--tone); }
.lci { position: absolute; top: 5px; height: 6px; border: 1.5px solid var(--muted); border-bottom: 0; border-radius: 2px 2px 0 0; pointer-events: none; }
.lmark { position: absolute; top: 0; width: 0; height: 0; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top: 9px solid var(--text); pointer-events: none; }
.sb-split { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.sb-split .mb { max-width: none; height: 10px; }
.sb-keys { display: flex; gap: 1px; margin-top: -2px; }
.sb-keys span { flex: 1 0 0; min-width: max-content; display: flex; flex-direction: column; font-size: 11px; line-height: 1.3; color: var(--text-2); white-space: nowrap; }
.sb-keys b { font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums; }
.sb-keys .k-absent { text-align: right; align-items: flex-end; }
.sb-big { font-size: 52px; font-weight: 800; line-height: 1; }
.sb-delta { font-size: 13px; font-weight: 700; color: var(--text-2); }
.sb-delta.up { color: var(--good-ink); }
.sb-delta.down { color: var(--bad-ink); }
.sb-ci { font-size: 12.5px; color: var(--text-2); }
.sb-bar { position: relative; padding-top: 9px; }
.sb-bar .mb { max-width: none; height: 14px; border-radius: 4px; }
.sb-bar .ci { position: absolute; top: 0; height: 26px; border: 2px solid var(--text); border-bottom: 0; border-radius: 3px 3px 0 0; box-sizing: border-box; pointer-events: none; }
.sb-n { font-size: 12px; color: var(--muted); }
.sb-hero .legend { font-size: 12px; }
.sb-pop { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 25; width: min(560px, 90vw); padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 12px 32px rgba(0, 0, 0, .14); font-size: 12.5px; line-height: 1.5; }
.sb-pop p { margin: 6px 0; }
.sb-pop table { margin: 8px 0; }
.sb-pop .tok { margin-right: 4px; }
.sb-hero:hover .sb-pop, .sb-hero:focus-within .sb-pop { display: block; }
.warn-t { color: var(--warn-ink); font-weight: 600; }
.ok-t { color: var(--good-ink); }
.err-t { color: var(--bad-ink); font-weight: 600; font-size: 12.5px; margin: 6px 0; }
.sb-trend { position: relative; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.sb-title { font-size: 12.5px; font-weight: 700; color: var(--text-2); }
.sb-trend .plot { width: 100%; min-height: 150px; }
.sb-trend svg { display: block; overflow: visible; }
.sb-trend .grid { stroke: var(--border); stroke-width: 1; }
.sb-trend .tick { font-size: 10.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.sb-trend .band { fill: var(--text); fill-opacity: .08; stroke: none; }
.sb-trend .gband { fill: none; stroke: var(--border); stroke-width: 1; }
.sb-trend .whisker { stroke: var(--text); stroke-opacity: .35; stroke-width: 6; stroke-linecap: round; }
.sb-trend .line { fill: none; stroke: var(--text); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.sb-trend .dot { fill: var(--text); stroke: var(--surface); stroke-width: 2; }
.sb-trend .endlabel { font-size: 12px; font-weight: 700; fill: var(--text); }
.sb-trend .cross { stroke: var(--text-2); stroke-width: 1; }
.sb-trend .hit { fill: transparent; cursor: crosshair; }
.sb-trend .tip { position: absolute; top: 28px; width: 210px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); font-size: 12px; line-height: 1.5; pointer-events: none; z-index: 5; }
.empty-band { grid-template-columns: minmax(0, 1fr); }

/* Run: a square at the top-right of the matrix, and the menu it opens */
.sqslot { display: flex; align-items: flex-start; justify-content: center; }
.runsq { position: relative; width: 76px; height: 76px; flex: 0 0 auto; border-radius: 12px; border: 0; background: var(--accent); color: #fff; font: inherit; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; box-shadow: var(--shadow); }
.runsq:hover { background: var(--accent-hover, var(--accent)); filter: brightness(1.05); }
.runsq.on { box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.runsq .sq-label { font-size: 12px; font-weight: 700; }
.runsq .sq-pct { font-size: 18px; font-weight: 800; }
.runsq.running { cursor: default; opacity: .9; }
.runsq .sq-err { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; border-radius: 10px; background: var(--bad-ink); color: #fff; font-size: 11px; font-weight: 800; line-height: 20px; text-align: center; border: 2px solid var(--surface); }
.runmenu { position: absolute; top: 98px; right: 16px; z-index: 26; width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 140px); display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, .18); }
.rm-head { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.rm-head { justify-content: space-between; }
.switch-line.sm { margin: 0; font-size: 12.5px; gap: 8px; }
.rm-body { overflow-y: auto; padding: 4px 14px 12px; }
.rm-body h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rm-mode { font-size: 12.5px; line-height: 1.5; background: var(--accent-soft); border-radius: 8px; padding: 8px 10px; margin: 10px 0 0; }
.rm-eng { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 10px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--border); }
.rm-eng:not(.on) { opacity: .6; }
.share { margin-left: 6px; white-space: nowrap; font-size: 11.5px; font-weight: 700; color: var(--text-2); font-variant-numeric: tabular-nums; }
.rm-loc { margin: 8px 0 2px; font-size: 12.5px; font-weight: 600; }
.rm-h { display: flex; justify-content: space-between; align-items: baseline; }
.rm-h .cover { font-size: 11.5px; font-weight: 700; text-transform: none; letter-spacing: 0; color: var(--text-2); }
.rm-eng .why-s, .rm-eng .keyfix, .rm-eng .tiny { grid-column: 1 / -1; }
.rm-eng.err { background: color-mix(in srgb, var(--bad-soft) 55%, transparent); margin: 0 -8px; padding: 7px 8px; border-radius: 6px; }
.chk, .radio { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.chk input, .radio input { width: auto; margin: 0; }
.radio { margin: 3px 0; }
.why-s { margin: 2px 0 0; font-size: 11.5px; color: var(--text-2); line-height: 1.45; }
.rec-tag { display: inline-block; margin-top: 6px; font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 4px; padding: 0 6px; }
.errbtn { border: 0; cursor: pointer; font: inherit; font-size: 11.5px; font-weight: 600; }
.keyfix { display: flex; gap: 6px; margin-top: 6px; }
.keyfix input { flex: 1; min-width: 0; }
.rm-foot { border-top: 1px solid var(--border); padding: 10px 14px 12px; display: grid; gap: 6px; }
.rm-est { font-size: 12.5px; color: var(--text-2); display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.rm-cost { font-size: 16px; font-weight: 800; color: var(--text); }
.rm-cost small { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.rm-foot .btn.primary { justify-self: end; }

/* settings: engines and keys, usage drawer */
.llms tr.llm { cursor: pointer; }
.llms tr.llm:hover td { background: var(--surface-2); }
.keyform { display: flex; gap: 6px; flex-wrap: nowrap; margin: 0; }
.keyform input { width: 180px; }
.keyacts { display: flex; gap: 4px; margin-top: 4px; }
.keyacts form { margin: 0; }
.keyres { margin-top: 4px; font-size: 12px; font-weight: 600; max-width: 220px; line-height: 1.35; }
.keyres:empty { display: none; }
.llms .credit { font-size: 12.5px; line-height: 1.45; white-space: nowrap; }
.llms .credit b { font-size: 14px; font-variant-numeric: tabular-nums; }
.llms .credit b.low { color: var(--bad-ink); }
.keycell [hidden] { display: none !important; }
.keyres.ok { color: var(--good-ink); }
.keyres.bad { color: var(--bad-ink); }
.keyres.busy { color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.spin { width: 12px; height: 12px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.drawer-back { position: fixed; inset: 0; background: rgba(0, 0, 0, .2); z-index: 29; }
.utiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.utile { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; }
.ut-k { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.ut-v { font-size: 26px; font-weight: 800; line-height: 1.1; }
.ut-c { font-size: 15px; font-weight: 700; margin-top: 4px; }
.ut-s { font-size: 11.5px; color: var(--text-2); }
.uchart { position: relative; }
.uchart svg { display: block; }
.uchart .grid { stroke: var(--border); stroke-width: 1; }
.uchart .tick { font-size: 10.5px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.uchart .bar { fill: var(--f2); }
.uchart .hit { fill: transparent; }
.uchart .hit:hover { fill: var(--surface-2); fill-opacity: .5; }
.uchart .tip { position: absolute; top: 4px; width: 140px; padding: 6px 9px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .12); font-size: 12px; line-height: 1.5; pointer-events: none; }
@media (max-width: 720px) { .utiles { grid-template-columns: minmax(0, 1fr); } }
.sumband { grid-template-rows: auto 1fr; }
.sb-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
.sb-head h2 { margin: 0; font-size: 16px; }
.sb-help { position: relative; }
.h-help { display: flex; align-items: center; gap: 8px; }
.h-help .sb-pop { font-weight: 400; }
.h-help .sb-pop h4 { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.h-help .sb-pop p { margin: 8px 0 0; }
.qmark { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--text-2); background: var(--surface); color: var(--text-2); font: inherit; font-size: 12px; font-weight: 800; line-height: 1; padding: 0; cursor: help; }
.qmark:hover, .qmark:focus-visible { border-color: var(--accent); color: var(--accent); }
.sb-help:hover .sb-pop, .sb-help:focus-within .sb-pop { display: block; }
.sb-pop h4 { margin: 4px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sb-pop h4 + table { margin-top: 2px; }
.sb-pop ul { margin: 4px 0 0; padding-left: 18px; }
.sb-pop li { margin: 2px 0; }

/* workspace layout: rating over run and admin | matrix */
main.wide { max-width: none; padding: 16px 20px; }
.ws-grid { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: 14px; height: calc(100vh - 32px); }
.ws-grid .htop { flex-wrap: wrap; justify-content: flex-start; align-items: center; gap: 4px 8px; }
.ws-grid .hname { overflow-wrap: normal; word-break: keep-all; }
.ws-grid .mx { padding: 12px; }
.ws-left { position: relative; z-index: 3; display: flex; flex-direction: column; gap: 14px; min-height: 0; }
.ws-left > .card { margin: 0; }
.ws-grid > .mx { margin: 0; display: flex; flex-direction: column; min-height: 0; }
.ws-grid .map { flex: 1 1 auto; min-height: 0; overflow: visible; }
.ws-grid .map .cell { min-height: 0; }
.ws-left .sumband { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; margin: 0; padding: 16px; }
.ws-left .sb-big { font-size: 48px; }
.ws-left .sb-trend { flex: 1 1 auto; min-height: 124px; }
.ws-left .sb-trend .plot { position: relative; flex: 1 1 auto; min-height: 0; }
.ws-left .sb-trend svg { position: absolute; top: 0; left: 0; }
.ws-left.tighter .sb-trend, .ws-left.menu .sb-trend { display: none; }
.ws-left.menu .sumband { flex: none; }
.runcard { flex: none; display: flex; flex-direction: column; gap: 12px; margin: 0; padding: 16px; }
.ws-left.menu .runcard { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.runcard .sb-head h2 { margin: 0; font-size: 16px; }
.run-row { display: flex; gap: 12px; align-items: center; }
.runcard .runsq { width: 88px; height: 88px; border-radius: 14px; gap: 6px; }
.runcard .runsq svg { width: 28px; height: 28px; }
.runcard .runsq .sq-label { font-size: 13px; }
.run-plan { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; font-size: 12.5px; color: var(--text-2); line-height: 1.45; min-width: 0; }
.run-plan .rec-tag { margin: 0; }
.run-plan .err-t { margin: 0; }
.run-loc { font-weight: 600; color: var(--text); }
.run-loc::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--accent); vertical-align: 1px; }
.runcard .runmenu { position: static; width: auto; max-height: none; border: 1px solid var(--border); box-shadow: none; border-radius: 10px; }
.runcard .rm-body { overflow: visible; }
.runcard .rm-eng { grid-template-columns: minmax(0, 1fr) auto; }
.rm-state { grid-column: 1 / -1; }
.adminbox { flex: none; position: relative; margin: 0; padding: 10px 8px; }
.admin-head { all: unset; display: flex; justify-content: space-between; align-items: center; box-sizing: border-box; width: 100%; padding: 0 8px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); cursor: default; }
.admin { display: flex; flex-direction: column; gap: 1px; }
.ws-left.tight .admin-head { padding: 2px 8px; cursor: pointer; }
.ws-left.tight .admin-head::after { content: "▴"; font-size: 12px; }
.ws-left.tight .admin-head:hover { color: var(--text); }
.ws-left.tight .adminbox .admin { display: none; }
.ws-left.tight .adminbox.open .admin { display: flex; position: absolute; left: 0; bottom: calc(100% + 6px); width: 100%; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .14); z-index: 20; }
.admin a, .admin .linkbtn { display: block; width: 100%; text-align: left; padding: 6px 8px; border-radius: 6px; color: var(--text-2); font-size: 13px; }
.admin a:hover, .admin .linkbtn:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.admin form { margin: 0; }
@media (max-width: 1100px) {
  .ws-grid { grid-template-columns: minmax(0, 1fr); height: auto; }
  .ws-left { position: static; height: auto; }
  .ws-grid .map { grid-template-rows: none !important; }
  .ws-left .sb-trend .plot { min-height: 150px; }
  .admin { flex-direction: row; flex-wrap: wrap; align-items: center; }
  .admin a, .admin .linkbtn { width: auto; }
}
.switch-line.sm { white-space: nowrap; }
.ws-grid .map.compact .mh .hsub, .ws-grid .map.compact .rh .hsub { display: none; }
.ws-grid .map.compact .cell { gap: 4px; padding: 7px 10px; }
.ws-grid .map.compacter .cfoot { display: none; }
.ws-grid .map.compacter .mh, .ws-grid .map.compacter .rh, .ws-grid .map.compacter .corner { padding: 6px 10px; gap: 2px; }
.ws-grid .map.compacter .htot { padding-top: 0; }
.ppop.up { top: auto; bottom: calc(100% + 4px); }

/* question brief: question, why asked, tested on, result, why, action */
.qbrief { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); }
.qb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.qb-no { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .04em; }
.qverdict { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.v-first { background: var(--good-soft); color: var(--good-ink); }
.v-behind { background: var(--warn-soft); color: var(--warn-ink); }
.v-absent { background: var(--bad-soft); color: var(--bad-ink); }
.qb { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 13px; line-height: 1.5; }
.qb dt { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding-top: 2px; }
.qb dd { margin: 0; min-width: 0; }
.qb dd p { margin: 0; }
.qb .qt { font-weight: 600; }
.qb-act { font-weight: 600; color: var(--text); border-left: 3px solid var(--accent); padding-left: 8px; }
.qb-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.qres { display: inline-flex; align-items: center; gap: 8px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; color: var(--text); }
.qres:hover { border-color: var(--accent); text-decoration: none; }
.qres span::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 4px; vertical-align: 0; }
.qs-first::before { background: var(--k1); }
.qs-behind::before { background: var(--k2); }
.qs-absent::before { background: var(--k3); }
.qb-pend { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; margin-top: 4px; font-size: 12px; }
.cell-sum { padding: 12px 14px; border-radius: 10px; background: var(--surface-2); margin-bottom: 10px; }
.why-line { font-size: 12px; color: var(--muted); margin: 0 0 12px; }
.qb-head .btn + .btn { margin-left: 4px; }

/* all answers for one question, by run */
.ev-run { margin: 0 0 14px; }
.ev-run h4 { margin: 0 0 6px; font-size: 12px; font-weight: 700; color: var(--text-2); }
.ev-ans { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 6px; background: var(--surface); }
.ev-ans summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px; cursor: pointer; font-size: 13px; list-style: none; }
.ev-ans summary::-webkit-details-marker { display: none; }
.ev-ans summary::before { content: "▸"; color: var(--muted); }
.ev-ans[open] summary::before { content: "▾"; }
.ev-ans .bk { min-width: 0; white-space: nowrap; }
.ev-ans summary b { white-space: nowrap; }
.ev-body { padding: 0 12px 12px; border-top: 1px solid var(--border); }
.ev-body .answer { white-space: pre-wrap; font-size: 13px; line-height: 1.6; margin: 10px 0; max-height: none; }
.ev-src { margin: 2px 0 8px; padding-left: 18px; font-size: 12px; word-break: break-all; }
.ev-na { background: var(--surface-2); color: var(--muted); }
.ev-err { background: var(--bad-soft); color: var(--bad-ink); }
.ws-grid .map .mh { gap: 6px; padding: 9px 12px; }
.ws-grid .map .mh .htot { margin-top: 0; padding-top: 0; }

/* matrix axes and crosshair */
.axis { display: flex; align-items: center; gap: 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.axis::before, .axis::after { content: ""; flex: 1; block-size: 1px; background: var(--border); }
.axis.x { padding: 0 2px 2px; }
.axis.y { writing-mode: vertical-rl; transform: rotate(180deg); justify-content: center; }
.axis-add { all: unset; display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; margin-inline-start: -2px; border-radius: 5px; color: var(--accent); font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer; }
.axis-add:hover, .axis-add:focus-visible { background: var(--accent-soft); }
.axis.y .axis-add { transform: rotate(180deg); }
.map .mh, .map .rh { transition: background-color .12s, box-shadow .12s; }
.map .mh.hl, .map .rh.hl { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.map .cell.xline { background: color-mix(in srgb, var(--accent-soft) 60%, var(--surface)); }

/* AI GEO Rating grades: green at the top, amber in the middle, red at the bottom */
.t-g3, .t-g2, .t-g1 { --tone: var(--good-ink); --tone-soft: var(--good-soft); }
.t-w1, .t-w2 { --tone: var(--warn-ink); --tone-soft: var(--warn-soft); }
.t-b1, .t-b2 { --tone: var(--bad-ink); --tone-soft: var(--bad-soft); }
.gchip { flex: none; min-width: 30px; color: var(--tone); font-size: 13px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; }
.gchip.lg { min-width: 40px; font-size: 22px; line-height: 1; }
.gchip.xl { display: inline-flex; align-items: center; justify-content: center; min-width: 60px; height: 44px; border-radius: 9px; background: var(--tone-soft); font-size: 22px; }

/* weight beside a market or buyer name */
.pwrap { position: relative; display: inline-flex; flex: none; }
.pchip { border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 1px 8px; font: inherit; font-size: 10.5px; font-weight: 700; line-height: 16px; cursor: pointer; }
.pchip.p-high { color: var(--text); }
.pchip.p-low { border-style: dashed; color: var(--muted); font-weight: 600; }
.pchip:hover { border-color: var(--accent); }
.ppop { position: absolute; top: calc(100% + 4px); left: 0; z-index: 20; display: flex; flex-direction: column; min-width: 116px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 6px 18px rgba(0, 0, 0, .14); }
.ppop button { all: unset; display: flex; justify-content: space-between; gap: 12px; padding: 6px 8px; border-radius: 5px; font-size: 12.5px; cursor: pointer; }
.ppop button:hover, .ppop button:focus-visible { background: var(--surface-2); }
.ppop button.on { font-weight: 700; color: var(--accent); }

/* product logo */
.prodbtn { all: unset; display: flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.prodbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.plogo { display: block; max-width: 100%; max-height: 40px; }
.pmono { display: flex; flex: none; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #fff; font-size: 18px; font-weight: 800; }
.logo-edit { display: flex; align-items: center; gap: 16px; padding: 4px 0 12px; }
.logo-edit .plogo { max-width: 200px; max-height: 48px; }
.logo-btns { display: flex; gap: 6px; flex-wrap: wrap; }
