:root {
  --bg: #0c1014;
  --card: #141a1c;
  --text: #e8efe9;
  --muted: #9aada3;
  --accent: #d4a054;
  --accent2: #3dba9c;
  --good: #3ddc97;
  --bad: #e07a6a;
  --line: #2a3532;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
}
h1 { margin: 0; font-size: 1.45rem; letter-spacing: 0.08em; font-weight: 700; }
.sub { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.86rem; max-width: 52rem; }
.pill {
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  background: #1a2321;
  border: 1px solid var(--line);
  font-size: 0.82rem;
  white-space: nowrap;
}
.pill.ok { border-color: #2f6b4f; color: var(--good); }
.pill.bad { border-color: #7a3030; color: var(--bad); }

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
}
@media (min-width: 1120px) {
  .grid { grid-template-columns: 440px 1fr; }
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1rem 1.1rem 1.2rem;
}
h2 { margin: 0 0 0.7rem; font-size: 1.02rem; }
h3 { margin: 1.1rem 0 0.45rem; font-size: 0.92rem; color: #c5d4cc; }
.lede {
  margin: 0 0 0.9rem;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}
.row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
  margin-bottom: 0.65rem;
}
.checks { grid-template-columns: 1fr; }
label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-size: 0.76rem;
  color: var(--muted);
}
.checks label {
  flex-direction: row;
  align-items: center;
  gap: 0.45rem;
}
input, select, button, pre { font: inherit; }
input, select {
  background: #0e1413;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.42rem 0.52rem;
}
button {
  width: 100%;
  margin-top: 0.35rem;
  background: var(--accent);
  color: #1a1408;
  border: none;
  border-radius: 9px;
  padding: 0.68rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
button:disabled { opacity: 0.55; cursor: not-allowed; }
button.secondary {
  background: #1a2321;
  color: var(--text);
  border: 1px solid var(--line);
  width: auto;
  font-weight: 600;
}
.progress { margin-top: 0.85rem; }
.progress.hidden, .hidden { display: none; }
.bar {
  height: 8px;
  background: #0e1413;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--accent2);
  transition: width 0.25s ease;
}
#progress-text { margin-top: 0.4rem; font-size: 0.84rem; color: var(--muted); }
.meta { font-size: 0.84rem; color: var(--muted); margin-bottom: 0.7rem; }
.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}
.compare .stat {
  background: #0e1413;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
}
.compare .k { font-size: 0.7rem; color: var(--muted); }
.compare .v { font-size: 1.05rem; font-weight: 700; margin-top: 0.15rem; }
.table-wrap { overflow: auto; max-height: 380px; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.8rem; }
th, td { padding: 0.42rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; background: #1a2321; }
td.mono, #code { font-family: var(--mono); }
#code {
  background: #0e1413;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  max-height: 380px;
  overflow: auto;
  font-size: 0.74rem;
  white-space: pre-wrap;
}
footer {
  padding: 0 1.5rem 1.5rem;
  color: #7f9489;
  font-size: 0.78rem;
}
.ok-text { color: var(--good); }
.bad-text { color: var(--bad); }
#folds tbody tr:hover { background: #1a2824; }
#folds tbody tr.selected { background: #243833; }

.detail { margin-top: 1rem; }
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}
.detail-head h3 { margin: 0; }
.equity-legend {
  font-size: 0.76rem;
  color: var(--muted);
  font-family: var(--mono);
}
#equity-canvas {
  width: 100%;
  height: 320px;
  margin-top: 0.55rem;
  background: #0e1413;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: block;
}
.pool {
  margin-top: 1rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}
.pool .cat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  background: #0e1413;
}
.pool .cat h4 {
  margin: 0 0 0.3rem;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}
.pool .cat span {
  display: inline-block;
  font-size: 0.68rem;
  margin: 0.1rem 0.15rem 0.1rem 0;
  padding: 0.12rem 0.35rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
}
.chromosome {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.chromosome .cat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.55rem;
  background: #0e1413;
}
.chromosome h4 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent2);
}
.pill-on {
  display: inline-block;
  margin: 0.12rem 0.18rem 0.12rem 0;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  background: #1d3b34;
  color: var(--accent2);
  font-size: 0.72rem;
  font-family: var(--mono);
}
.pill-off {
  display: inline-block;
  margin: 0.12rem 0.18rem 0.12rem 0;
  padding: 0.16rem 0.42rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: #6b7c74;
  font-size: 0.72rem;
}
.lib-out {
  background: #0e1413;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.7rem;
  max-height: 260px;
  overflow: auto;
  font-size: 0.72rem;
  white-space: pre-wrap;
  font-family: var(--mono);
  color: #c9d6f0;
}
@media (max-width: 720px) {
  .row { grid-template-columns: 1fr; }
  .pool, .chromosome { grid-template-columns: 1fr; }
}
