/* Palette: the dataviz reference palette, dark steps, validated against this
   page's own chart surface (#15161a) — categorical slots 1 (mutuals) and 2
   (you) clear every all-pairs gate: CVD dE 26.8, normal-vision dE 31.8. Do not
   re-tint the series colours without re-running the validator. */
:root {
  --plane:      #0e0f12;
  --surface:    #15161a;
  --surface-2:  #1b1d22;
  --ink:        #ffffff;
  --ink-2:      #c3c2b7;
  --muted:      #898781;
  --grid:       #2c2c2a;
  --axis:       #383835;
  --border:     rgba(255, 255, 255, 0.10);
  --mutual:     #3987e5;
  --you:        #d95926;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* .start is display:grid, which would otherwise beat the [hidden] default. */
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--plane);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.015em; }
a { color: var(--mutual); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 40px 20px 64px; }

.masthead { margin-bottom: 28px; }
.masthead h1 { font-size: clamp(2.2rem, 6vw, 3.2rem); letter-spacing: -0.03em; }
.tagline { color: var(--ink-2); margin: 8px 0 0; max-width: 56ch; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
}

/* ------------------------------------------------------------------ start */
.start { display: grid; gap: 32px; grid-template-columns: minmax(280px, 1fr) minmax(280px, 1.15fr); }
@media (max-width: 720px) { .start { grid-template-columns: 1fr; } }

.field-label { display: block; font-size: 0.82rem; color: var(--ink-2); margin-bottom: 6px; font-weight: 550; }
.field-label.sm { margin: 0; }

.ta-field { position: relative; }
.input-wrap { display: flex; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.input-wrap:focus-within { border-color: var(--mutual); }
.at { padding: 0 2px 0 12px; color: var(--muted); }
#handle-input {
  flex: 1; background: none; border: 0; outline: none; color: var(--ink);
  font: inherit; padding: 12px 12px 12px 2px; min-width: 0;
}

.typeahead {
  position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow: auto;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}
.ta-item { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.ta-item.active, .ta-item:hover { background: rgba(255, 255, 255, 0.07); }
.ta-av { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex: none; background: var(--grid); }
.ta-blank { display: grid; place-items: center; font-size: 0.75rem; color: var(--muted); }
.ta-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.ta-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ta-handle { font-size: 0.78rem; color: var(--muted); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
select {
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 0.9rem;
}

.btn {
  font: inherit; font-weight: 600; border-radius: 10px; border: 1px solid transparent;
  padding: 12px 18px; cursor: pointer;
}
.btn.primary { background: var(--mutual); color: #fff; width: 100%; margin-top: 18px; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.ghost { background: none; border-color: var(--border); color: var(--ink-2); }
.btn.ghost:hover { color: var(--ink); border-color: var(--muted); }
.btn.sm { padding: 7px 14px; font-size: 0.87rem; }
.linkish { background: none; border: 0; color: var(--mutual); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

.error { color: #e66767; min-height: 1.4em; margin: 10px 0 0; font-size: 0.9rem; }

.explainer h2 { font-size: 1.05rem; margin-bottom: 8px; }
.explainer p { color: var(--ink-2); font-size: 0.94rem; margin: 0 0 12px; }
.explainer strong { color: var(--ink); }
.explainer .fine { font-size: 0.84rem; color: var(--muted); }
code { font-family: var(--mono); font-size: 0.86em; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }

/* --------------------------------------------------------------- progress */
.progress { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.status { margin: 0; font-weight: 550; }
.status-detail { margin: 0; color: var(--muted); font-size: 0.86rem; min-height: 1.2em; }
.bar { width: 100%; height: 5px; background: var(--grid); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--mutual); transition: width 0.25s ease; }

/* ------------------------------------------------------------------ stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.stat-label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat-value { font-size: 1.9rem; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; }
.stat-unit { font-size: 0.9rem; font-weight: 500; color: var(--ink-2); }
.stat-note { font-size: 0.8rem; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------------ chart */
.chart-card { margin: 0 0 20px; padding: 20px 20px 16px; }
.chart-head { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.chart-head h2 { font-size: 1.1rem; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 0; padding: 0; list-style: none; font-size: 0.82rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.key { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.key-you { background: var(--you); }
.key-mutual { background: var(--mutual); }
.key-dormant { border: 2px solid var(--mutual); }
.key-iso { width: 16px; height: 0; border-radius: 0; border-top: 1px dashed var(--axis); }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; touch-action: pan-y; }

.grid-line { stroke: var(--grid); stroke-width: 1; }
.grid-minor { stroke: var(--grid); stroke-width: 1; opacity: 0.4; }
.tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tick-x { text-anchor: middle; }
.tick-y { text-anchor: end; }
.axis-title { fill: var(--muted); font-size: 11.5px; }
.iso-line { stroke: var(--axis); stroke-width: 1; stroke-dasharray: 4 4; }
.iso-label { fill: var(--muted); font-size: 10.5px; }

.dot { fill: var(--mutual); stroke: var(--surface); stroke-width: 2; }
.dot-dormant { fill: none; stroke: var(--mutual); stroke-width: 2; opacity: 0.85; }
.dot-fuzzy { opacity: 0.55; }
.dot-you-fill { fill: var(--you); }
.dot-you { fill: none; stroke: var(--you); stroke-width: 3; }
.you-label { fill: var(--you); font-size: 11px; font-weight: 650; }
.dot-hover { fill: none; stroke: var(--ink); stroke-width: 2; pointer-events: none; }

.tip {
  position: absolute; top: 0; left: 0; pointer-events: none; z-index: 10;
  width: max-content; max-width: 260px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55); font-size: 0.85rem;
}
.tip-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tip-head img, .tip-blank { width: 28px; height: 28px; border-radius: 50%; flex: none; background: var(--grid); object-fit: cover; }
.tip-names { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.tip-handle { color: var(--muted); font-size: 0.78rem; }
.tip-stats { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; }
.tip-stats dt { color: var(--muted); font-size: 0.78rem; }
.tip-stats dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.tip-strong { font-weight: 650; }
.tip-dim, .dim { color: var(--muted); }
.tip-note { margin: 8px 0 0; color: var(--ink-2); font-size: 0.78rem; line-height: 1.35; }
.tip-rank { display: block; margin-top: 6px; color: var(--muted); font-size: 0.78rem; }
.chart-note { color: var(--muted); font-size: 0.83rem; margin: 10px 0 0; max-width: 76ch; }

/* ----------------------------------------------------------------- detail */
.detail-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.detail-av { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--grid); }
.detail-head h3 { font-size: 1.05rem; }
.detail-handle { font-size: 0.85rem; color: var(--muted); text-decoration: none; }
.detail-close { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 1.5rem; line-height: 1; cursor: pointer; }
.detail-verdict { margin: 0 0 14px; color: var(--ink-2); }
.detail-verdict b { color: var(--ink); }
.detail-grid { display: grid; grid-template-columns: max-content 1fr; gap: 4px 20px; margin: 14px 0 0; font-size: 0.88rem; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; }

.spark { margin: 0; }
.spark svg { width: 100%; height: 68px; display: block; }
.spark-line { fill: none; stroke: var(--mutual); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark-cut { stroke: var(--you); stroke-width: 1.5; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; }
.spark-dead { fill: rgba(255, 255, 255, 0.05); }
.spark figcaption { color: var(--muted); font-size: 0.78rem; margin-top: 4px; }

/* ------------------------------------------------------------------ table */
.table-card h2 { font-size: 1.1rem; margin-bottom: 12px; }
.table-scroll { overflow: auto; max-height: 62vh; overscroll-behavior: contain; }
.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { padding: 8px 10px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table th.left, .table td.left { text-align: left; }
.table th {
  position: sticky; top: 0; z-index: 2; background: var(--surface);
  color: var(--muted); font-weight: 550; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.05em; border-bottom: 1px solid var(--axis); cursor: pointer; user-select: none;
}
.table th:hover, .table th.sorted { color: var(--ink-2); }
.table th:focus-visible { outline: 2px solid var(--mutual); outline-offset: -2px; }
.caret { margin-left: 4px; }
.table tbody tr { border-bottom: 1px solid var(--grid); cursor: pointer; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
.table tbody tr.you { background: rgba(217, 89, 38, 0.12); }
.table tbody tr.you:hover { background: rgba(217, 89, 38, 0.18); }
.table tbody tr.dormant td { opacity: 0.72; }
.table td a { color: var(--ink); text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.row-handle { color: var(--muted); margin-left: 6px; font-size: 0.82em; }
.badge {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 20px;
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); border: 1px solid var(--axis);
}
.you-badge { color: var(--you); border-color: var(--you); }
.strong { font-weight: 650; }
.dim-strike { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--axis); }
.run-summary { color: var(--muted); font-size: 0.82rem; margin: 14px 0 12px; }

.foot { margin-top: 40px; color: var(--muted); font-size: 0.85rem; }
.foot a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
