:root {
  --bg: #0c0d0f;
  --panel: #131417;
  --panel-2: #181a1e;
  --line: #24262b;
  --line-2: #30333a;
  --text: #e7e8ea;
  --muted: #8b9099;
  --faint: #5c616a;
  --in: #6fcf97;
  --out: #eb7070;
  --undec: #6b7079;
  --accent: #e7e8ea;
  --cond: #7ea6d8;
  --radius: 8px;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }

a { color: var(--text); text-decoration-color: var(--line-2); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--muted); }

.mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }

/* ---------- header ---------- */

header {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 24px;
  height: var(--header-h);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.brand { display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.brand h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.brand span { color: var(--faint); font-size: 13px; }

nav { display: flex; gap: 4px; height: 100%; }
nav button {
  background: none;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 0 12px;
  color: var(--muted);
  cursor: pointer;
  height: 100%;
  margin-bottom: -1px;
  white-space: nowrap;
}
nav button:hover { color: var(--text); }
nav button.active { color: var(--text); border-bottom-color: var(--text); }


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

main { min-height: calc(100vh - var(--header-h) - 57px); }
.view { display: none; }
.view.active { display: block; }

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 340px;
  height: calc(100vh - var(--header-h));
  min-height: 560px;
}

.side {
  padding: 20px;
  overflow-y: auto;
  border-right: 1px solid var(--line);
}
.side.right { border-right: 0; border-left: 1px solid var(--line); }

.stage { position: relative; min-width: 0; }
.graph { position: absolute; inset: 0; }

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  color: var(--faint);
  font-size: 12px;
  pointer-events: none;
  white-space: nowrap;
}

.stage-top {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  pointer-events: none;
  z-index: 2;
}
.stage-top > * { pointer-events: auto; }

.legend { display: flex; gap: 14px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.legend i {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1.5px solid;
  margin-right: 6px;
  vertical-align: -1px;
}
.legend .in i { border-color: var(--in); background: rgb(111 207 151 / 0.18); }
.legend .out i { border-color: var(--out); background: rgb(235 112 112 / 0.18); }
.legend .undec i { border-color: var(--undec); }
.legend .hid i { border-color: var(--muted); border-style: dashed; }
.legend .shape-x i { border-radius: 50%; border-color: var(--muted); }
.legend .shape-y i { border-radius: 2px; border-color: var(--muted); }
.legend .shape-z i { border-radius: 1px; transform: rotate(45deg) scale(0.85); border-color: var(--muted); }

/* ---------- controls ---------- */

.group { margin-bottom: 24px; }
.group:last-child { margin-bottom: 0; }

.label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  margin-bottom: 8px;
}

.label-row { display: flex; justify-content: space-between; align-items: baseline; }
.label-row .label { margin-bottom: 8px; }

select, .btn {
  height: 32px;
  border-radius: 6px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  padding: 0 10px;
  cursor: pointer;
}
select { width: 100%; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 14px, calc(100% - 10px) 14px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}
select:focus-visible, .btn:focus-visible, .seg button:focus-visible, nav button:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: 1px;
}

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.primary { background: var(--text); color: var(--bg); border-color: var(--text); font-weight: 500; }
.btn.primary:hover { background: #fff; }
.btn.small { height: 26px; padding: 0 8px; font-size: 12px; }
.btn.block { width: 100%; }
.btn.ghost { background: none; }

.row { display: flex; gap: 8px; align-items: center; }
.row > .grow { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 8px; }

.seg {
  display: flex;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 2px;
  background: var(--panel);
}
.seg button {
  flex: 1;
  border: 0;
  background: none;
  height: 26px;
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12.5px;
  padding: 0 6px;
  white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--line-2); color: var(--text); }
.seg.vertical { flex-direction: column; }
.seg.vertical button { flex: none; text-align: left; padding: 0 10px; height: 30px; }

input[type="range"] { width: 100%; accent-color: var(--text); }

.hint { color: var(--faint); font-size: 12.5px; margin: 8px 0 0; }

/* ---------- info panels ---------- */

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-family: var(--mono); font-size: 13px; }

.set {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-word;
}

.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * { padding: 9px 12px; border-top: 1px solid var(--line); }
.list > *:first-child { border-top: 0; }
.list button.item { text-align: left; background: none; border-left: 0; border-right: 0; border-bottom: 0; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.list button.item:first-child { border-top: 0; }
.list button.item:hover { background: var(--panel); }
.list .item.active { background: var(--panel-2); box-shadow: inset 2px 0 0 var(--text); }

.status-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tag {
  font-size: 11.5px;
  padding: 1px 8px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  color: var(--muted);
  white-space: nowrap;
}
.tag.in { color: var(--in); border-color: rgb(111 207 151 / 0.35); }
.tag.out { color: var(--out); border-color: rgb(235 112 112 / 0.35); }
.tag.mid { color: #d8c27a; border-color: rgb(216 194 122 / 0.35); }

.check { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; }
.check + .check { border-top: 1px solid var(--line); }
.yes { color: var(--in); }
.no { color: var(--out); }

.note {
  border-left: 2px solid var(--line-2);
  padding: 2px 0 2px 12px;
  color: var(--muted);
  font-size: 13px;
}
.note b { color: var(--text); font-weight: 500; }

.steps .item { display: flex; gap: 12px; align-items: baseline; justify-content: flex-start !important; color: var(--text); }
.steps .k { color: var(--faint); font-family: var(--mono); font-size: 12px; min-width: 42px; }
.steps .item.current { background: var(--panel-2); }
.steps .item.pending { opacity: 0.35; }

/* ---------- strategic ---------- */

.agent { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.agent + .agent { margin-top: 10px; }
.agent-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.agent-name { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.agent-name .shape { width: 11px; height: 11px; border: 1.5px solid var(--muted); }
.shape.x { border-radius: 50%; }
.shape.y { border-radius: 2px; }
.shape.z { transform: rotate(45deg) scale(0.85); border-radius: 1px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-family: var(--mono);
  font-size: 12.5px;
  height: 26px;
  padding: 0 10px;
  border-radius: 99px;
  border: 1px solid var(--line-2);
  background: var(--panel);
  cursor: pointer;
}
.chip:hover { border-color: var(--faint); }
.chip.hidden { border-style: dashed; color: var(--faint); background: none; text-decoration: line-through; text-decoration-color: var(--faint); }
.chip.in { border-color: rgb(111 207 151 / 0.5); }
.chip.out { border-color: rgb(235 112 112 / 0.5); }
.agent .empty { color: var(--faint); font-size: 12.5px; }

.util { width: 100%; border-collapse: collapse; font-size: 13px; }
.util th { text-align: right; font-weight: 400; color: var(--faint); font-size: 11.5px; padding: 0 0 6px; }
.util th:first-child { text-align: left; }
.util td { padding: 7px 0; border-top: 1px solid var(--line); text-align: right; font-family: var(--mono); }
.util td:first-child { text-align: left; font-family: var(--sans); }
.delta.up { color: var(--in); }
.delta.down { color: var(--out); }

.verdict { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; gap: 10px; }
.verdict + .verdict { border-top: 1px solid var(--line); }
.verdict .t { font-weight: 500; }
.verdict .s { color: var(--muted); font-size: 12.5px; }

.outcome-big { font-family: var(--mono); font-size: 18px; letter-spacing: -0.01em; }

/* ---------- results ---------- */

.page { max-width: 1040px; margin: 0 auto; padding: 48px 24px 64px; }
.page h2 { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
.page h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.page .lede { color: var(--muted); margin: 0 0 32px; max-width: 680px; }
.page section { margin-bottom: 56px; }
.page section > p { color: var(--muted); max-width: 680px; margin: 0 0 20px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 56px; }
.stat { padding: 20px; border-left: 1px solid var(--line); }
.stat:first-child { border-left: 0; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .d { color: var(--muted); font-size: 12.5px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.chart-wrap { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .axis text { fill: var(--faint); font-size: 11px; font-family: var(--mono); }
.chart .grid line { stroke: var(--line); }
.chart .tip {
  position: absolute;
  pointer-events: none;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
}
.chart-legend { display: flex; gap: 20px; font-size: 12.5px; color: var(--muted); margin-top: 12px; flex-wrap: wrap; }
.chart-legend span::before { content: ""; display: inline-block; width: 16px; height: 0; border-top: 2px solid; vertical-align: middle; margin-right: 8px; }
.chart-legend .sp::before { border-color: var(--text); }
.chart-legend .cd::before { border-color: var(--cond); border-top-style: dashed; }
.chart-legend .gap::before { height: 8px; border: 0; background: rgb(126 166 216 / 0.12); }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { text-align: right; font-weight: 400; color: var(--faint); font-size: 11.5px; padding: 0 12px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { text-align: right; padding: 8px 12px; border-bottom: 1px solid var(--line); font-family: var(--mono); font-variant-numeric: tabular-nums; }
table.data th:first-child, table.data td:first-child { text-align: left; padding-left: 0; }
table.data th:last-child, table.data td:last-child { padding-right: 0; }
table.data td.zero { color: var(--in); }
.table-scroll { overflow-x: auto; }

.bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.bar > div { height: 100%; background: var(--text); width: 0; transition: width 0.15s; }

.compare { display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px 24px; font-size: 13px; align-items: baseline; }
.compare .h { color: var(--faint); font-size: 11.5px; }
.compare .v { font-family: var(--mono); text-align: right; }

/* ---------- how it works ---------- */

.prose { max-width: 680px; }
.prose h3 { margin-top: 40px; }
.prose p, .prose li { color: #c4c7cc; }
.prose ul { padding-left: 20px; }
.prose li + li { margin-top: 6px; }
.prose b { color: var(--text); font-weight: 500; }
.prose .num { color: var(--faint); font-family: var(--mono); font-size: 12px; margin-right: 10px; }
.defs { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
.defs td { padding: 9px 0; border-top: 1px solid var(--line); vertical-align: top; color: #c4c7cc; }
.defs td:first-child { width: 120px; color: var(--text); font-weight: 500; }
.try { margin-top: 4px; }

/* ---------- footer & loading ---------- */

footer {
  border-top: 1px solid var(--line);
  padding: 18px 24px;
  display: flex;
  justify-content: space-between;
  color: var(--faint);
  font-size: 12.5px;
  gap: 16px;
  flex-wrap: wrap;
}
footer .links { display: flex; gap: 16px; }
footer a { color: var(--muted); }

.loading {
  position: fixed;
  inset: var(--header-h) 0 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  transition: opacity 0.3s;
}
.loading.done { opacity: 0; pointer-events: none; }
.loading-inner { width: 280px; text-align: center; }
.loading-inner p { color: var(--muted); margin: 14px 0 0; font-size: 13px; }
.loading .bar > div { width: 30%; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(340%); } }

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 260px minmax(0, 1fr); height: auto; }
  .workspace .stage { height: 520px; border-bottom: 1px solid var(--line); }
  .side.right { grid-column: 1 / -1; border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 1000px) {
  .brand span { display: none; }
  .grid-3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n + 3) { border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  :root { --header-h: 92px; }
  header {
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 0;
    padding: 0 16px;
  }
  .brand { height: 48px; align-items: center; }
  nav { width: 100%; height: 44px; gap: 0; }
  nav button { flex: 1; padding: 0 4px; font-size: 13px; }
  .workspace { grid-template-columns: 1fr; }
  .side { border-right: 0; border-bottom: 1px solid var(--line); padding: 16px; }
  .workspace .stage { height: 520px; }
  .grid-2 { grid-template-columns: 1fr; }
  .page { padding: 32px 16px 48px; }
  .stage-hint { white-space: normal; text-align: center; width: 90%; bottom: 12px; }
  .graph { bottom: 56px; }
  .stage-top { top: 12px; left: 12px; right: 12px; }
  footer { padding: 18px 16px; }
}

@media (max-width: 420px) {
  .stats { grid-template-columns: 1fr; }
  .stat { border-left: 0; }
  .stat + .stat { border-top: 1px solid var(--line); }
  .stat .n { font-size: 22px; }
}
