/* LM-Arena frontend — shared stylesheet.
   Dark, technical theme. No framework, no build step. */

:root {
  --bg: #0a0d10;
  --bg-alt: #0d1114;
  --surface: #12171b;
  --surface-2: #171d22;
  --surface-3: #1c2329;
  --border: #232b31;
  --border-strong: #303a41;
  --text-primary: #e4eaee;
  --text-secondary: #93a1aa;
  --text-muted: #5c6870;

  --accent: #ffb454;       /* amber — signal / active / CTA */
  --accent-soft: rgba(255, 180, 84, 0.14);
  --teal: #59c9c6;         /* cyan-teal — data / links */
  --teal-soft: rgba(89, 201, 198, 0.14);
  --good: #4caf6d;
  --good-soft: rgba(76, 175, 109, 0.14);
  --bad: #e2685a;
  --bad-soft: rgba(226, 104, 90, 0.14);
  --focus: #7fd9ff;

  --mono: ui-monospace, "JetBrains Mono", "Cascadia Code", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 3px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
}

body {
  background-image:
    linear-gradient(180deg, var(--bg-alt) 0%, var(--bg) 340px);
  min-height: 100vh;
}

a { color: var(--teal); }
a:hover { color: var(--accent); }

::selection { background: var(--accent-soft); color: var(--text-primary); }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

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

.shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px 64px;
}

.topbar {
  border-bottom: 1px solid var(--border);
  padding: 28px 0 20px;
  margin-bottom: 28px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.wordmark {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.02em;
  color: var(--text-secondary);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.wordmark .prompt { color: var(--accent); }
.wordmark .name { color: var(--text-primary); font-weight: 600; }

.topnav {
  display: flex;
  gap: 4px;
  font-family: var(--mono);
  font-size: 13px;
}

.topnav a {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  text-decoration: none;
  transition: border-color 0.12s, color 0.12s;
}

.topnav a:hover,
.topnav a.active {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.topnav a.active {
  color: var(--accent);
  border-color: var(--accent-soft);
  background: var(--accent-soft);
}

h1.page-title {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

p.page-sub {
  color: var(--text-secondary);
  margin: 0 0 28px;
  font-size: 14px;
}

/* ---------- status strip (refresh indicator) ---------- */

.livebar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-muted);
}

.livedot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 3px var(--good-soft);
  flex: none;
}

@media (prefers-reduced-motion: no-preference) {
  .livedot { animation: pulse 2.4s ease-in-out infinite; }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ---------- category tabs ---------- */

.tabs {
  display: flex;
  gap: 2px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  padding-bottom: 0;
}

.tab {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 8px 13px;
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  position: relative;
  top: 1px;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
  color: var(--accent);
  border-color: var(--border);
  background: var(--surface);
  border-bottom: 1px solid var(--surface);
}

.tab .code {
  color: var(--text-muted);
  margin-right: 6px;
}

.tab.active .code { color: var(--accent); }

/* ---------- leaderboard table ---------- */

.board {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}

.board-head {
  display: grid;
  grid-template-columns: 44px 1fr 90px 90px 190px 28px;
  gap: 12px;
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-alt);
}

.row {
  border-bottom: 1px solid var(--border);
}

.row:last-child { border-bottom: none; }

.row-main {
  display: grid;
  grid-template-columns: 44px 1fr 90px 90px 190px 28px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  background: var(--surface);
  transition: background 0.1s;
}

.row-main:hover { background: var(--surface-2); }

.row.expanded .row-main {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.rank {
  font-family: var(--mono);
  color: var(--text-muted);
  font-size: 13px;
}

.rank.top1 { color: var(--accent); }
.rank.top2 { color: var(--text-primary); }
.rank.top3 { color: var(--text-secondary); }

.model-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.model-name {
  font-weight: 600;
  font-size: 14.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-meta {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.metric {
  font-family: var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.metric .num {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.metric .lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
}

/* category readout strip: 8 tiny bars, oscilloscope-style */

.readout {
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 30px;
}

.readout .cell {
  flex: 1;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: var(--bg-alt);
  border: 1px solid var(--border);
  border-radius: 1px;
  position: relative;
}

.readout .cell.focused {
  border-color: var(--accent);
}

.readout .cell .fill {
  width: 100%;
  border-radius: 0 0 1px 1px;
  transition: height 0.25s ease;
  min-height: 2px;
}

.readout .cell.na .fill {
  background: none;
  border-top: 1px dashed var(--border-strong);
  height: 1px !important;
  min-height: 1px;
}

.fill.tier-bad { background: var(--bad); }
.fill.tier-warn { background: var(--accent); }
.fill.tier-good { background: var(--good); }

.chev {
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 12px;
  text-align: center;
  transition: transform 0.15s;
}

.row.expanded .chev { transform: rotate(90deg); color: var(--accent); }

/* ---------- expanded run detail ---------- */

.runs {
  background: var(--bg-alt);
  padding: 4px 16px 14px;
}

.run-row {
  display: grid;
  grid-template-columns: 20px 1fr 90px 190px 100px;
  gap: 12px;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 13px;
}

.run-row:last-child { border-bottom: none; }

.run-user {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-family: var(--mono);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
  width: fit-content;
}

.badge.finished { color: var(--good); background: var(--good-soft); }
.badge.running { color: var(--accent); background: var(--accent-soft); }

.run-total {
  font-family: var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.run-date {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: right;
}

.mini-readout {
  display: flex;
  gap: 2px;
  height: 16px;
  align-items: flex-end;
}

.mini-readout .cell {
  flex: 1;
  height: 100%;
  background: var(--surface-3);
  border-radius: 1px;
  display: flex;
  align-items: flex-end;
}

.mini-readout .fill { width: 100%; border-radius: 0 0 1px 1px; min-height: 1px; }

.empty-state,
.error-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-family: var(--mono);
  font-size: 13px;
}

.error-state { color: var(--bad); }

.legend {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 16px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--text-muted);
}

.legend .sw {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  margin-right: 5px;
  vertical-align: -1px;
}

/* ---------- forms (new-run.html) ---------- */

.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 28px;
  max-width: 520px;
}

.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 7px;
  letter-spacing: 0.02em;
}

.field input {
  width: 100%;
  background: var(--bg-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 14.5px;
  padding: 10px 12px;
  transition: border-color 0.12s;
}

.field input:focus {
  border-color: var(--teal);
}

.field .hint {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 6px;
}

.btn {
  font-family: var(--mono);
  font-size: 13.5px;
  font-weight: 500;
  padding: 11px 20px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: filter 0.12s, background 0.12s;
}

.btn-primary {
  background: var(--accent);
  color: #1a1206;
}

.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: 0.5; cursor: default; filter: none; }

.btn-ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-ghost:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.form-error {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--bad);
  background: var(--bad-soft);
  border: 1px solid rgba(226, 104, 90, 0.35);
  border-radius: var(--radius);
  padding: 10px 12px;
  margin-bottom: 18px;
  display: none;
}

.form-error.show { display: block; }

/* result panel after token issue */

.result {
  display: none;
}

.result.show { display: block; }

.token-box {
  font-family: var(--mono);
  font-size: 15px;
  letter-spacing: 0.03em;
  background: var(--bg-alt);
  border: 1px solid var(--teal);
  border-radius: var(--radius);
  padding: 14px 16px;
  color: var(--teal);
  word-break: break-all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.copy-btn {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  border-radius: var(--radius);
  padding: 7px 11px;
  cursor: pointer;
  white-space: nowrap;
  flex: none;
}

.copy-btn:hover { color: var(--text-primary); border-color: var(--teal); }
.copy-btn.copied { color: var(--good); border-color: var(--good); }

.instruction-box {
  background: var(--bg-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.instruction-box .tok {
  color: var(--teal);
  font-family: var(--mono);
}

.section-label {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 22px 0 8px;
}

.section-label:first-child { margin-top: 0; }

.run-meta-line {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.run-meta-line .v { color: var(--text-primary); }

/* ---------- footer ---------- */

.foot {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-muted);
}

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

@media (max-width: 720px) {
  .board-head { display: none; }

  .row-main {
    grid-template-columns: 28px 1fr 28px;
    grid-template-areas:
      "rank name chev"
      "meta meta meta"
      "readout readout readout";
    row-gap: 8px;
  }

  .row-main .rank { grid-area: rank; }
  .row-main .model-cell { grid-area: name; }
  .row-main .chev { grid-area: chev; }
  .row-main .metric.median-cell { grid-area: meta; text-align: left; }
  .row-main .metric.best-cell { display: none; }
  .row-main .readout { grid-area: readout; }

  .run-row {
    grid-template-columns: 1fr;
    row-gap: 6px;
  }

  .run-date { text-align: left; }
  .run-total { text-align: left; }
}
