/* Harness Comparison — phosphor (dark) / printout (light).
   Tokens first; component styles keep flat specificity (single class). */

:root {
  --mono: ui-monospace, "Cascadia Code", "SF Mono", "JetBrains Mono", Menlo,
    Consolas, "Liberation Mono", monospace;
  --prose: -apple-system, "Segoe UI", system-ui, Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

:root[data-theme="dark"] {
  --bg: #0f141a;
  --surface: #151c23;
  --raised: #1a232c;
  --line: #26303a;
  --ink: #d6e0e6;
  --muted: #7e8c96;
  --accent: #e8a33d;
  --on-accent: #171208;
  --link: #6fbfdd;
  --term-bg: #0a0e12;
  --shadow: 0 12px 40px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eff1f2;
  --surface: #fbfcfc;
  --raised: #f4f6f7;
  --line: #d5dade;
  --ink: #21262b;
  --muted: #59636b;
  --accent: #a96500;
  --on-accent: #fff8ec;
  --link: #0e6e9e;
  --term-bg: #1a2027;
  --shadow: 0 10px 30px rgb(30 40 50 / 0.12);
  color-scheme: light;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.55;
}

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

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

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

/* ---------- chrome ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.6rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }

.brand-glyph {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 4px;
  font-weight: 700;
}

.nav { display: flex; gap: 1rem; flex: 1; }

.nav a {
  color: var(--muted);
  padding: 0.15rem 0.1rem;
  border-bottom: 2px solid transparent;
}
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] {
  color: var(--ink);
  border-bottom-color: var(--accent);
}

.toggles { display: flex; gap: 0.5rem; }

.toggle {
  padding: 0.25rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
}
.toggle:hover { color: var(--ink); border-color: var(--muted); }

.view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1.25rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ---------- hero terminal ---------- */

.hero { margin-bottom: 2rem; }

.hero-title {
  margin: 0 0 0.35rem;
  font-size: clamp(1.6rem, 4.5vw, 2.6rem);
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.hero-tagline {
  margin: 0 0 1.25rem;
  color: var(--muted);
  font-family: var(--prose);
  font-size: 1.02rem;
}

.term {
  background: var(--term-bg);
  color: #cfd8de;
  border: 1px solid color-mix(in srgb, var(--line) 60%, var(--term-bg));
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.term-head {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.8rem;
  border-bottom: 1px solid rgb(255 255 255 / 0.07);
  color: #5d6a74;
  font-size: 11px;
}

.term-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #3a444d;
}
.term-dot:first-child { background: #e8a33d; }

.term-body {
  padding: 0.9rem 1.1rem 1rem;
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
}

.term-line { white-space: pre; }
.term-line.is-hidden { visibility: hidden; }

.term-prompt { color: #6fbfdd; }
.term-cmd { color: #f2f6f8; }
.term-key { color: #7e8c96; }
.term-accent { color: #e8a33d; }

.term-caret {
  display: inline-block;
  width: 0.55em; height: 1.05em;
  vertical-align: text-bottom;
  background: #e8a33d;
}
@media (prefers-reduced-motion: no-preference) {
  .term-caret { animation: blink 1s steps(1) infinite; }
}
@keyframes blink { 50% { opacity: 0; } }

.term-rank { color: #cfd8de; }
.term-rank a { color: #f2f6f8; }
.term-bar { color: #e8a33d; letter-spacing: 0.08em; }

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

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin: 1.6rem 0 0.75rem;
}

.search {
  flex: 1 1 220px;
  max-width: 340px;
  padding: 0.45rem 0.7rem;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
}
.search::placeholder { color: var(--muted); }

.chip {
  padding: 0.28rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
}
.chip:hover { color: var(--ink); border-color: var(--muted); }
.chip[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.sort-hint {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

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

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.board {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 13px;
}

.board th {
  position: sticky;
  top: 0;
  background: var(--raised);
  border-bottom: 1px solid var(--line);
  padding: 0;
  text-align: right;
  white-space: nowrap;
}

.board th.is-name { text-align: left; }

.th-btn {
  display: block;
  width: 100%;
  padding: 0.55rem 0.6rem;
  text-align: inherit;
  color: var(--muted);
  font-weight: 600;
}
.th-btn:hover { color: var(--ink); }
.th-btn.is-sorted { color: var(--accent); }

.board td {
  padding: 0.42rem 0.6rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.board tbody tr { cursor: pointer; }
.board tbody tr:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.board tbody tr:last-child td { border-bottom: none; }

.td-rank { color: var(--muted); width: 2.5rem; }

.td-name { text-align: left; }
.td-name a { color: var(--ink); font-weight: 600; }

.lang-badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--muted);
  font-size: 10.5px;
}

.tier-mark { color: var(--accent); margin-left: 0.35rem; }

.td-total { font-weight: 700; }

.score-cell { min-width: 3.2rem; }

.score-pill {
  display: inline-block;
  min-width: 2.9rem;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  text-align: right;
}

.td-pick { width: 2rem; text-align: center; }
.pick-box { accent-color: var(--accent); cursor: pointer; }

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 1.5rem;
  cursor: default;
}

/* ---------- notes sections ---------- */

.notes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.note-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem 1.2rem;
}

.note-card h2 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.note-card ul { margin: 0; padding-left: 1.1rem; }
.note-card li {
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-family: var(--prose);
  font-size: 13.5px;
}
.note-card li strong { color: var(--ink); }

/* ---------- detail page ---------- */

.crumbs {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 13px;
}

.detail-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.8rem;
  margin-bottom: 0.4rem;
}

.detail-head h1 {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  letter-spacing: -0.02em;
}

.rank-chip {
  padding: 0.15rem 0.6rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 6px;
  font-weight: 700;
}

.total-chip { color: var(--muted); }
.total-chip strong { color: var(--ink); font-size: 1.15em; }

.detail-desc {
  margin: 0 0 0.8rem;
  color: var(--muted);
  font-family: var(--prose);
  max-width: 70ch;
}

.meta-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.6rem;
  margin-bottom: 1rem;
  font-size: 12.5px;
  color: var(--muted);
}
.meta-grid b { color: var(--ink); font-weight: 600; }

.tier-badges { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.2rem; }

.tier-badge {
  padding: 0.2rem 0.6rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  color: var(--accent);
  font-size: 12px;
}

.legend { color: var(--muted); font-size: 12px; margin: 0 0 1rem; font-family: var(--prose); }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 1rem;
}

.topic-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.9rem 1.1rem;
}

.topic-card h2 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 0.7rem;
  font-size: 0.9rem;
}

.topic-num { color: var(--muted); margin-right: 0.4rem; }
.topic-mean { color: var(--accent); font-weight: 700; }

.item-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.22rem 0;
  font-size: 12.5px;
}

.item-label { flex: 1; color: var(--muted); }
.item-row .item-score { width: 1.2rem; text-align: right; font-weight: 700; }

.meter { display: inline-flex; gap: 2px; }

.meter i {
  width: 9px; height: 12px;
  border-radius: 2px;
  background: color-mix(in srgb, var(--line) 70%, transparent);
}
.meter i.on { background: var(--accent); }

.item-star {
  width: 1.05em;
  flex: none;
  color: var(--accent);
  cursor: help;
}

.report-sec { margin-top: 2.2rem; }

.report-sec h2 {
  font-size: 1.1rem;
  border-top: 1px solid var(--line);
  padding-top: 1.4rem;
}

.report-note { color: var(--muted); font-size: 12.5px; font-family: var(--prose); }

/* rendered markdown (reports + methodology) */

.md {
  font-family: var(--prose);
  font-size: 14.5px;
  max-width: 82ch;
}
.md h1 { font-family: var(--mono); font-size: 1.5rem; letter-spacing: -0.01em; }
.md h2 { font-family: var(--mono); font-size: 1.15rem; margin-top: 2rem; }
.md h3 { font-family: var(--mono); font-size: 0.98rem; margin-top: 1.4rem; }
.md code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.08em 0.35em;
}
.md pre {
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem 1rem;
  overflow-x: auto;
}
.md pre code { background: none; border: none; padding: 0; }
.md table { border-collapse: collapse; font-size: 13px; }
.md th, .md td { border: 1px solid var(--line); padding: 0.3rem 0.6rem; }
.md th { background: var(--raised); }
.md blockquote {
  margin: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

/* ---------- compare ---------- */

.compare-bar {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.9rem;
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
  font-size: 13px;
  max-width: min(92vw, 640px);
}

.compare-names { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.compare-go {
  padding: 0.3rem 0.8rem;
  background: var(--accent);
  color: var(--on-accent);
  border-radius: 6px;
  font-weight: 700;
  white-space: nowrap;
}
.compare-go[disabled] { opacity: 0.45; cursor: not-allowed; }

.compare-clear { color: var(--muted); }

.cmp-table { border-collapse: collapse; width: 100%; max-width: 760px; font-size: 13px; }

.cmp-table th, .cmp-table td {
  padding: 0.35rem 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cmp-table th { color: var(--ink); }
.cmp-table td:first-child, .cmp-table th:first-child { text-align: left; color: var(--muted); }

.cmp-topic td {
  background: var(--raised);
  font-weight: 700;
  color: var(--ink);
}

.cmp-table .cmp-best { color: var(--accent); font-weight: 700; }

/* ---------- matrix + excluded ---------- */

.page-title { margin: 0 0 0.3rem; font-size: clamp(1.4rem, 3.5vw, 2rem); letter-spacing: -0.02em; }
.page-note { color: var(--muted); font-family: var(--prose); margin: 0 0 1.4rem; max-width: 75ch; }

.matrix-table { border-collapse: collapse; width: 100%; max-width: 820px; font-size: 13px; }
.matrix-table th, .matrix-table td {
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  text-align: left;
}
.matrix-table th { color: var(--muted); font-weight: 600; }
.matrix-table .mx-topic td {
  background: var(--raised);
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.mx-id { color: var(--muted); width: 3rem; }

.excluded-list { margin: 0.5rem 0 0; padding: 0; list-style: none; max-width: 82ch; }
.excluded-list li {
  padding: 0.55rem 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
  font-family: var(--prose);
  font-size: 13.5px;
  color: var(--muted);
}
.excluded-list a { font-family: var(--mono); font-weight: 600; }

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

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 0.5rem 1rem; }
  .nav { order: 3; width: 100%; }
  .board { min-width: 760px; }
  .view { padding: 1.25rem 0.9rem 3.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation: none !important; transition: none !important; }
}
