:root {
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", monospace;
  --color-bg: #1c1c1c;
  --color-bg-deep: #181818;
  --color-surface: #1f1f1f;
  --color-border: rgba(255, 255, 255, 0.06);
  --color-border-subtle: rgba(255, 255, 255, 0.04);
  --color-border-hover: rgba(255, 255, 255, 0.10);
  --color-fg: #e5e5e5;
  --color-fg-2: #a1a1a1;
  --color-fg-3: rgba(229, 229, 229, 0.45);
  --color-fg-4: rgba(229, 229, 229, 0.25);
  --color-ok: #44ff9a;
  --color-bad: #ff4747;
  --color-activity: #ff9b4e;
  --color-warn: #f5e663;
  --color-accent: #5ac8fa;
  --color-gold: #f3c449;
  --color-bar: #c6bda8;
  --color-bar-current: #bf9939;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  background: var(--color-bg);
  color: var(--color-fg);
  font-family: var(--font-sans);
  font-size: 13px;
  letter-spacing: -0.15px;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum";
  min-height: 100%;
  overflow-x: hidden;
  /* Stop iOS/Android from inflating text in landscape. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

::-webkit-scrollbar { display: none; }
* { scrollbar-width: none; }

a {
  color: inherit;
  text-decoration: none;
}

a:hover {
  color: var(--color-gold);
}

button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

::selection {
  color: var(--color-fg);
  background: rgba(90, 200, 250, 0.25);
}

/* ---------- nav (affine.io) ---------- */
.top-nav {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}

.nav-inner {
  position: relative;
  width: 100%;
  margin: 0;
  height: 48px;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1;
}

.brand:hover { color: inherit; }

.brand img {
  width: 18px;
  height: 18px;
}

.brand-name {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: -0.01em;
}

.nav-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-chip {
  height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border: 1px solid rgba(243, 196, 73, 0.45);
  background: var(--color-surface);
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
}

.nav-chip:hover {
  border-color: var(--color-gold);
  color: var(--color-gold);
}

.nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 1;
}

.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--color-fg-3);
  border: 1px solid transparent;
}

.nav-icon:hover {
  color: var(--color-gold);
  border-color: rgba(243, 196, 73, 0.35);
}

/* Anchor jumps land below the sticky header (nav + market). */
.hero,
.section {
  scroll-margin-top: 104px;
}

/* ---------- market ticker (TMC) ---------- */
.market-bar {
  border-top: 1px solid rgba(243, 196, 73, 0.22);
  border-bottom: 1px solid var(--color-border);
  background: #161616;
}

.market-bar-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 28px;
  min-height: 36px;
  padding: 8px 20px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.02em;
  width: 100%;
  box-sizing: border-box;
}

.market-item {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
  color: var(--color-fg);
  flex: 0 0 auto;
  justify-content: center;
}

.market-item .k {
  color: var(--color-fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.market-item b {
  font-weight: 500;
  color: var(--color-fg);
}

.market-item b.gold {
  color: var(--color-gold);
}

.market-item .u {
  color: var(--color-fg-4);
  font-size: 10px;
}

.market-item.dim {
  color: var(--color-fg-4);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.market-sep {
  display: none;
}

@media (max-width: 720px) {
  .market-bar-inner {
    gap: 6px 16px;
    padding: 6px 16px;
  }
}

/* ---------- page ---------- */
.page {
  max-width: 1680px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 48px;
}

/* ---------- hero chart (full viewport width) ---------- */
.hero {
  width: 100%;
  border-bottom: 1px solid var(--color-border);
  padding: 20px 0 24px;
  background: var(--color-bg);
}

/* Same shell as .page so the hero grid lines up with the tables below. */
.hero-inner {
  max-width: 1680px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 2×2 hero grid: Reason | Margin (σ) / Margin (abs) | reg price. */
.hero-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

@media (max-width: 900px) {
  .hero-split {
    grid-template-columns: 1fr;
  }
}

.hero-pane {
  min-width: 0;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.015);
  padding: 12px 10px 8px;
}

.hero-pane-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  padding: 0 4px;
}

.hero-pane-title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-gold);
}

.hero-caption {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-fg-3);
}

.hero-scroll {
  overflow: hidden;
  width: 100%;
}

.hero-scroll svg {
  display: block;
  width: 100%;
  height: auto;
}


.hero-king-row {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  justify-content: flex-start;
}

.stat-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.02);
  font-family: var(--font-mono);
  font-size: 11px;
}

.stat-chip .k {
  color: var(--color-fg-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 10px;
}

.stat-chip b {
  color: var(--color-fg);
  font-weight: 500;
}

.stat-chip b.gold { color: var(--color-gold); }

/* ---------- sections ---------- */
.section-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--color-border);
}

#chart-tip {
  position: fixed;
  z-index: 120;
  pointer-events: none;
  max-width: 420px;
  padding: 6px 9px;
  background: #1c1c1c;
  border: 1px solid var(--color-border-hover);
  color: var(--color-fg);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.5;
}

#chart-tip[hidden] {
  display: none;
}

/* Touch devices have no hover: the synthetic mouse event from a tap would
 * leave the tip stuck on screen (over the duel page the tap just opened).
 * Tapping a mark opens the duel page anyway — the richer view of the value. */
@media (hover: none) {
  #chart-tip {
    display: none;
  }
}

/* Subtle hover highlight on chart marks (Z bars, S dots, gate-grid dots).
   CSS properties override the inline opacity attribute on hover. */
.duel-hit rect,
.duel-hit circle {
  transition: filter 120ms ease, opacity 120ms ease;
}

.duel-hit:hover rect,
.duel-hit:hover circle {
  opacity: 1;
  filter: brightness(1.3);
}

.expand-btn {
  margin-left: auto;
  width: 22px;
  height: 22px;
  flex: none;
  border: 1px solid var(--color-border);
  background: transparent;
  color: var(--color-fg-3);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}

.expand-btn:hover {
  color: var(--color-gold);
  border-color: var(--color-border-hover);
}

.chart-modal[hidden] {
  display: none !important;
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.chart-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.66);
}

.chart-modal-sheet {
  position: relative;
  width: min(1240px, 100%);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border);
  overflow: hidden;
}

.chart-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border);
}

.chart-modal-body {
  overflow: auto;
  padding: 16px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-modal-chart {
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.015);
}

.chart-modal-chart svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-modal-detail {
  max-width: 78ch;
  font-family: var(--font-sans, inherit);
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-fg-2);
}

.chart-modal-detail p {
  margin: 0 0 10px;
}

.chart-modal-detail code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-gold);
}

/* 2×N grid of hero-sized panes, same split and breakpoint as .hero-split. */
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: 100%;
}

@media (max-width: 900px) {
  .metric-grid {
    grid-template-columns: 1fr;
  }
}

/* Dedicated #metrics page: wider shell, panes flow into as many equal
 * columns as fit (2 on a laptop, 3 on a wide monitor, 1 on mobile). */
.duel-page.metrics-page {
  max-width: 1560px;
}

.metric-grid--page {
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 18px;
}

@media (max-width: 900px) {
  .metric-grid--page {
    grid-template-columns: 1fr;
  }
}

.metric-grid--page .metric-pane {
  display: flex;
  flex-direction: column;
}

.metric-grid--page .metric-pane svg {
  display: block;
  width: 100%;
  margin-top: auto;
}

.metric-pane {
  min-width: 0;
  border: 1px solid var(--color-border);
  background: rgba(255, 255, 255, 0.015);
  padding: 12px 10px 8px;
}

.metric-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 0 4px 6px;
}

.metric-head-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.metric-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-gold);
}

.metric-caption {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  color: var(--color-fg-3);
}

.metric-pane svg {
  display: block;
  width: 100%;
  height: auto;
}

.section-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--color-fg);
}

.section-right {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-fg-3);
}

.section-right.note {
  text-transform: none;
  letter-spacing: 0;
}

.empty {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-fg-3);
  padding: 18px 0;
}

/* ---------- cards / kv ---------- */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1px;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.kv {
  background: var(--color-surface);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kv .k {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg-3);
}

.kv .v {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--color-fg);
  word-break: break-word;
}

.kv .v.gold { color: var(--color-gold); }
.kv .v.ok { color: var(--color-ok); }
.kv .v.bad { color: var(--color-bad); }
.kv .v.dim { color: var(--color-fg-2); }

/* ---------- tables ---------- */
.filter-bar {
  margin-bottom: 12px;
}

.filter-bar input {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  color: var(--color-fg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 8px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.filter-bar input::placeholder { color: var(--color-fg-4); }
.filter-bar input:focus {
  outline: none;
  border-color: var(--color-border-hover);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Reign / queue / intake tables have no .table-scroll wrapper in the markup;
 * without this they clip (not scroll) once the table outgrows a phone. */
#reign-wrap,
#queue-wrap,
#intake-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

table.data-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-bg);
}

table.data-table th {
  font-size: 10px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-fg-3);
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

table.data-table th.r,
table.data-table td.r {
  text-align: right;
}

/* Duel history: every column centered (overrides the .r right-align). */
#history-wrap table.data-table th,
#history-wrap table.data-table td {
  text-align: center;
}

table.data-table tbody tr {
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background 0.15s;
}

table.data-table tbody tr:hover {
  background: rgba(90, 200, 250, 0.06);
}

table.data-table tbody tr.current td {
  background: rgba(243, 196, 73, 0.05);
}

table.data-table tbody tr.current td:first-child {
  box-shadow: inset 3px 0 0 var(--color-gold);
}

table.data-table td {
  padding: 8px 12px;
  vertical-align: middle;
  color: var(--color-fg-2);
}

table.data-table td a {
  color: var(--color-fg);
}

table.data-table td a:hover {
  color: var(--color-accent);
}

table.data-table td.when {
  color: var(--color-fg-3);
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 18px;
  padding: 0 7px;
  border: 1px solid;
  border-radius: 2px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.badge.crowned {
  background: rgba(243, 196, 73, 0.08);
  border-color: rgba(243, 196, 73, 0.35);
  color: rgba(243, 196, 73, 0.95);
}

.badge.accepted {
  border-color: rgba(68, 255, 154, 0.35);
  color: var(--color-ok);
}

.badge.rejected {
  border-color: rgba(255, 71, 71, 0.35);
  color: rgba(255, 71, 71, 0.9);
}

.badge.failed,
.badge.error {
  border-color: rgba(245, 230, 99, 0.35);
  color: var(--color-warn);
}

.badge.queued {
  border-color: var(--color-border);
  color: var(--color-fg-2);
}

.badge.evaluating {
  border-style: dashed;
  border-color: rgba(90, 200, 250, 0.45);
  color: rgba(90, 200, 250, 0.85);
}

/* Audit verdicts: deliberately muted — the audit is context, not an outcome
   the eye should snag on. Read the full verdict by clicking through. */
.badge.audit-clean {
  border-color: rgba(68, 255, 154, 0.14);
  color: rgba(68, 255, 154, 0.45);
}

.badge.audit-exploit {
  border-color: rgba(255, 71, 71, 0.16);
  color: rgba(255, 71, 71, 0.5);
}

.badge.audit-error {
  border-color: rgba(245, 230, 99, 0.16);
  color: rgba(245, 230, 99, 0.5);
}

.bar {
  display: inline-block;
  width: 48px;
  height: 3px;
  margin-left: 8px;
  border-radius: 2px;
  background: var(--color-border);
  vertical-align: middle;
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  background: var(--color-gold);
}

.weight-cell {
  color: var(--color-gold);
  white-space: nowrap;
}

/* Signed mini-bar (± vs previous king): fill grows from the center line. */
.pm-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.pm-bar {
  position: relative;
  display: inline-block;
  width: 56px;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  vertical-align: middle;
  overflow: hidden;
}

.pm-bar::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -2px;
  bottom: -2px;
  width: 1px;
  background: rgba(255, 255, 255, 0.25);
}

.pm-bar i {
  position: absolute;
  top: 0;
  bottom: 0;
  border-radius: 2px;
}

.ok { color: var(--color-ok); }
.bad { color: var(--color-bad); }
.gold { color: var(--color-gold); }
.dim { color: var(--color-fg-3); }

/* Muted up/down tint for score deltas — softer than .ok/.bad status colors.
 * table.data-table td prefixes outrank the default td color rule. */
.delta-up,
table.data-table td.delta-up { color: #7fb98a; }
.delta-down,
table.data-table td.delta-down { color: #c98080; }

/* King model names (Affine-<roman>) render gold wherever they appear;
 * the td a variant outranks the table link color. */
.king-gold,
table.data-table td a.king-gold,
table.data-table td span.king-gold { color: var(--color-gold); }

.contract {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--color-fg-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 420px;
  overflow: auto;
}

@media (max-width: 720px) {
  .page { gap: 36px; }
}

/* ---------- live status ---------- */
.live-status {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-fg-4);
}

.row-link {
  cursor: pointer;
}

.row-link:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------- duel page (#duel/<cid>) ---------- */
body.duel-open .hero,
body.duel-open main.page {
  display: none;
}

.duel-page[hidden] {
  display: none !important;
}

.duel-page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 32px 96px;
}

.duel-page-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 18px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.duel-page-head .section-title {
  font-size: 15px;
}

.duel-page-head .section-right {
  margin-left: auto;
}

.back-btn {
  width: 36px;
  height: 36px;
  flex: none;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: var(--color-surface);
  color: var(--color-fg-2);
  font-size: 16px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.back-btn:hover {
  color: var(--color-fg);
  border-color: var(--color-border-hover);
}

#duel-page-body {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.duel-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.duel-verdict-line {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--color-fg);
  max-width: 72ch;
}

.duel-overview .v.mono {
  font-size: 11px;
  word-break: break-all;
}

/* One chart per row — these are the duel's evidence, give them the width. */
.duel-chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* Big verdict numbers: the few quantities that decide the duel. */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 12px;
  margin-top: 14px;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  min-width: 0;
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-fg-3);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 26px;
  line-height: 1.1;
  color: var(--color-fg);
}

.stat-value.delta-up { color: #7fb98a; }
.stat-value.delta-down { color: #c98080; }

.stat-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.4;
  color: var(--color-fg-3);
}

.duel-chart-pane {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.duel-chart-pane svg {
  width: 100%;
  height: auto;
  display: block;
}

.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: auto;
}

table.data-table td.num,
table.data-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

table.data-table td.mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

.turns-table td,
.sides-table td {
  white-space: nowrap;
}

.fail-log.duel-log {
  border-color: var(--color-border);
  background: var(--color-surface);
  color: var(--color-fg-2);
  max-height: 360px;
}

.duel-hit[data-cid] {
  cursor: pointer;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0;
  vertical-align: middle;
  border: 1px solid var(--color-border);
  border-radius: 3px;
  background: transparent;
  color: var(--color-fg-3);
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--color-fg);
  border-color: var(--color-border-hover);
}

.copy-btn.copied {
  color: var(--color-ok);
  border-color: rgba(68, 255, 154, 0.4);
}

.turn-row {
  cursor: pointer;
}

.raw-link {
  font-size: 11px;
  white-space: nowrap;
}

.rollout-row > td {
  padding: 0 !important;
  background: var(--color-bg-deep, #0d0d0d);
}

.rollout-detail {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 16px 18px 20px;
  border-left: 2px solid var(--color-gold);
}

.rollout-side {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.rollout-side-head {
  font-family: var(--font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg);
}

.rollout-side-head.gold { color: var(--color-gold); }
.rollout-side-head.dim { color: var(--color-fg-3); }

.rollout-pair {
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rollout-pair-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 11px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 1px 7px;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-fg-2);
  white-space: nowrap;
}

.chip.ok { color: var(--color-ok); border-color: rgba(68, 255, 154, 0.3); }
.chip.bad { color: var(--color-bad); border-color: rgba(255, 71, 71, 0.35); }

.rollout-text .k {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg-3);
  margin-bottom: 4px;
}

.rollout-text pre {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--color-border-subtle, var(--color-border));
  border-radius: 3px;
  background: var(--color-bg);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.55;
  color: var(--color-fg-2);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 260px;
  overflow: auto;
}

.audit-note ol {
  margin: 0;
  padding-left: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-fg-2);
  max-width: 82ch;
}

.audit-note strong {
  color: var(--color-fg);
  font-weight: 600;
}

.audit-note code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--color-gold);
}

/* legacy close button style still used by the chart modal */
.duel-panel-close {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  color: var(--color-fg-2);
  font-size: 14px;
}

.duel-panel-close:hover {
  color: var(--color-fg);
  border-color: var(--color-border-hover);
}

.fail-log-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fail-log {
  margin: 0;
  padding: 14px 16px;
  border: 1px solid rgba(255, 71, 71, 0.35);
  background: rgba(255, 71, 71, 0.06);
  color: #f0c6c6;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 50vh;
}

.note {
  color: var(--color-fg-3);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.04em;
}

/* ---------- dataset page (#dataset) ---------- */

.audit-note p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--color-fg-2);
  max-width: 82ch;
}

.mix-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 20px 28px;
  margin-bottom: 20px;
}

.mix-block {
  min-width: 0;
}

.mix-block-wide {
  margin-top: 4px;
}

.mix-title {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg-3);
  margin-bottom: 8px;
}

.mix-row {
  display: grid;
  grid-template-columns: minmax(90px, 180px) 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 2px 4px;
  border: 0;
  background: none;
  border-radius: 3px;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.mix-row:hover {
  background: var(--color-surface);
}

.mix-row[data-fkind=""] {
  cursor: default;
}

.mix-row[data-fkind=""]:hover {
  background: none;
}

.mix-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--color-fg-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mix-bar {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--color-border);
  overflow: hidden;
}

.mix-bar > i {
  display: block;
  height: 100%;
  background: var(--color-gold);
}

.mix-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-fg-3);
  white-space: nowrap;
}

.ds-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin-bottom: 14px;
}

.ds-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.ds-filter .k {
  font-family: var(--font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-fg-3);
}

.ds-filter select,
.ds-filter input {
  background: var(--color-surface);
  color: var(--color-fg);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  min-width: 130px;
}

.ds-filter select:focus,
.ds-filter input:focus {
  outline: none;
  border-color: var(--color-border-hover);
}

.ds-filter-q input {
  min-width: 200px;
}

.ds-clear,
.ds-more {
  border: 1px solid var(--color-border);
  background: none;
  color: var(--color-fg-2);
  border-radius: 3px;
  padding: 7px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.ds-clear:hover,
.ds-more:hover {
  color: var(--color-fg);
  border-color: var(--color-border-hover);
}

.ds-more-wrap {
  display: flex;
  justify-content: center;
  padding-top: 14px;
}

.ds-table td {
  vertical-align: top;
}

.ds-turn-row {
  cursor: pointer;
}

.ds-ref pre {
  border-color: rgba(212, 175, 55, 0.4);
}

/* ---------- phone layout (mobile audit 2026-08-12) ----------
 * Checklist: no horizontal page scroll, nav that doesn't collide, tap
 * targets ≥ ~40px, 16px inputs (stops iOS focus zoom), readable label
 * floors, tables that swipe instead of clip. */
@media (max-width: 720px) {
  /* Nav: brand + icons stay on row one; the chips become a full-width,
   * horizontally swipeable row below (they collided with the absolute
   * centering on narrow screens). */
  .nav-inner {
    height: auto;
    flex-wrap: wrap;
    padding: 8px 12px;
    row-gap: 6px;
  }

  .brand {
    padding: 6px 8px 6px 0;
  }

  .nav-center {
    position: static;
    transform: none;
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .nav-chip {
    flex: none;
    height: 36px;
    padding: 0 14px;
  }

  .nav-icon {
    width: 40px;
    height: 40px;
  }

  /* The stacked nav would eat ~18% of a phone screen if it stayed sticky
   * (guideline: keep sticky chrome under 15%) — let it scroll away. */
  .top-nav {
    position: static;
  }

  .hero,
  .section {
    scroll-margin-top: 12px;
  }

  /* Tap targets. */
  .expand-btn {
    width: 36px;
    height: 36px;
  }

  .copy-btn {
    width: 30px;
    height: 30px;
  }

  .back-btn {
    width: 44px;
    height: 44px;
  }

  .mix-row {
    min-height: 40px;
    padding: 6px 4px;
  }

  .raw-link {
    display: inline-block;
    padding: 9px 6px;
  }

  /* Readability floor: lift the 10px mono labels one notch on phones. */
  table.data-table th,
  .metric-caption,
  .hero-caption,
  .section-right,
  .market-item .k,
  .market-item .u,
  .market-item.dim,
  .kv .k,
  .badge,
  .ds-filter .k,
  .mix-title,
  .mix-count,
  .stat-label,
  .stat-sub {
    font-size: 11px;
  }

  table.data-table td {
    padding: 10px 12px;
  }

  /* Inside a swipe wrapper, let tables take their natural width instead of
   * compressing to the viewport — otherwise columns hit min-content and
   * cells wrap word-by-word into 90px-tall rows (intake was the worst). */
  .table-scroll table,
  .table-wrap table,
  #reign-wrap table,
  #queue-wrap table,
  #intake-wrap table {
    width: max-content;
    min-width: 100%;
  }

  /* Expanded rollout / dataset-turn rows span the whole (wider) table.
   * Pin the reader to the swipe viewport so its text is never off-screen. */
  .rollout-detail {
    position: sticky;
    left: 0;
    max-width: calc(100vw - 40px);
  }

  /* 16px inputs stop iOS Safari from zooming the page on focus. */
  .filter-bar input,
  .ds-filter-bar input,
  .ds-filter-bar select {
    font-size: 16px;
    min-height: 42px;
  }

  .filter-bar input {
    max-width: none;
  }

  /* Expanded-chart modal uses the whole phone screen. */
  .chart-modal {
    padding: 8px;
  }

  .chart-modal-sheet {
    max-height: 96vh;
  }

  .duel-page {
    padding: 20px 14px 72px;
  }
}

/* ---------- post-crown exploit audits ---------- */
.audit-detail {
  max-width: 920px;
}
.audit-detail-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.audit-conf {
  font-weight: 600;
  color: var(--color-fg-2);
}
.audit-summary {
  font-size: 15px;
  line-height: 1.5;
  margin: 6px 0 12px;
}
.audit-evidence {
  margin: 0 0 16px;
  padding-left: 18px;
  color: var(--color-fg-2);
  line-height: 1.6;
}
.audit-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding: 10px 0 14px;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 16px;
}
.audit-links a {
  color: rgba(90, 200, 250, 0.9);
}
.audit-h {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-fg-2);
  margin: 18px 0 8px;
}
.audit-hash-table td.mono,
.audit-hash-table td:nth-child(2) {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}
.audit-analysis {
  font-size: 14px;
  line-height: 1.55;
  color: var(--color-fg-1);
}
.audit-analysis .audit-p { margin: 8px 0; }
.audit-analysis .audit-li { margin: 3px 0 3px 10px; color: var(--color-fg-2); }
.audit-analysis .audit-gap { height: 6px; }
.audit-analysis .audit-h { margin: 16px 0 6px; }
.audit-analysis pre.audit-code {
  background: var(--color-bg-2, rgba(255, 255, 255, 0.03));
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  font-size: 12.5px;
  white-space: pre;
}
.audit-analysis table.audit-md-table {
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 13px;
}
.audit-analysis table.audit-md-table td {
  border: 1px solid var(--color-border);
  padding: 4px 8px;
}

/* Audit verdict rows interleaved into the history table: one line, always —
   max-width 1px + nowrap forces ellipsis in an auto-layout table. Full text
   lives on the audit page (click the row). */
table.data-table td.audit-summary {
  font-style: italic;
  font-size: 11px;
  max-width: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
