:root {
  --bg: #f3f2ee;
  --card: #fff;
  --ink: #161616;
  --muted: #6b6b6b;
  --line: #e4e2dc;
  --accent: #161616;
  --header: #1a1a1a;
  --font: "IBM Plex Sans", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

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

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  line-height: 1.5;
}

body { min-height: 100vh; }

a { color: inherit; }

.site-header {
  background: var(--header);
  color: #f6f4ef;
  padding: 28px 24px 22px;
}

.header-inner {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

h1 {
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.03em;
}

.tagline {
  margin-top: 6px;
  color: #c8c4bb;
  font-size: 14px;
  max-width: 52em;
}

.source-pill {
  flex: none;
  align-self: center;
  text-decoration: none;
  border: 1px solid #4a4a4a;
  color: #f6f4ef;
  padding: 8px 12px;
  font-size: 13px;
  white-space: nowrap;
}

.source-pill:hover { background: #2a2a2a; }

.tabs {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 24px 0;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 8px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab.is-active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

main {
  max-width: 1240px;
  margin: 0 auto;
  padding: 16px 24px 48px;
}

.panel[hidden] { display: none; }

.chart-card, .table-card, .embed-card {
  background: var(--card);
  border: 1px solid var(--line);
  padding: 20px 20px 16px;
}

.table-card { margin-top: 16px; }

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.chart-head h2, .embed-bar h2, .table-card h2 {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.chart-note, .source-line, .others-intro, footer p {
  color: var(--muted);
  font-size: 13px;
}

.chart-note { margin-top: 4px; max-width: 62em; }

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

.seg {
  display: inline-flex;
  border: 1px solid var(--line);
}

.seg button {
  border: 0;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 9px;
  cursor: pointer;
}

.seg button + button { border-left: 1px solid var(--line); }

.seg button.is-on {
  background: var(--ink);
  color: #fff;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

#chart-wrap {
  position: relative;
  width: 100%;
  height: 620px;
  background: #fff;
}

#chart { width: 100%; height: 100%; display: block; overflow: visible; }

.tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.08);
  padding: 8px 10px;
  font-size: 12px;
  min-width: 160px;
}

.tooltip b { display: block; margin-bottom: 2px; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 8px;
  font-size: 12.5px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.legend-item svg { width: 14px; height: 14px; }

.source-line { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.source-line a { color: var(--ink); }

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid #eee;
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 600; }

th button {
  border: 0;
  background: none;
  font: inherit;
  font-weight: 600;
  color: inherit;
  cursor: pointer;
  padding: 0;
}

.swatch {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 8px;
  vertical-align: middle;
}

.score-bar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.score-bar i {
  display: none;
  width: 110px;
  height: 9px;
  background: rgba(0,0,0,.05);
  position: relative;
}

.score-bar i b {
  position: absolute;
  inset: 0 auto 0 0;
  height: 100%;
}

@media (min-width: 700px) {
  .score-bar i { display: inline-block; }
}

.effort {
  margin-left: 6px;
  color: #8a8a8a;
  font-size: 11.5px;
  font-weight: 400;
}

.embed-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.open-link {
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--ink);
}

iframe {
  width: 100%;
  height: min(78vh, 900px);
  border: 1px solid var(--line);
  background: #fff;
}

.others-intro { margin: 4px 0 16px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.out-card {
  background: #fff;
  border: 1px solid var(--line);
  padding: 16px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
}

.out-card:hover { border-color: #bbb; }

.out-card h3 { font-size: 16px; }

.out-card p { color: var(--muted); font-size: 13px; flex: 1; }

.out-card span { font-size: 13px; font-weight: 600; }

footer {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.axis text, .label-text {
  font-family: var(--font);
  fill: #333;
}

.axis-title { font-weight: 600; fill: #222; }

@media (max-width: 720px) {
  .site-header, main, .tabs, footer { padding-left: 14px; padding-right: 14px; }
  h1 { font-size: 22px; }
  #chart-wrap { height: 520px; }
  .source-pill { display: none; }
}

.models-panel {
  margin-top: 16px;
  border: 1px solid var(--line);
  padding: 12px 14px 10px;
}

.models-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 650;
  margin-bottom: 10px;
}

.models-bar button {
  margin-left: auto;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  cursor: pointer;
}

.model-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2px 12px;
}

.model-picker label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 2px;
}

.model-picker label.is-off { color: #9a9a9a; }

#chart-wrap { background: #fafaf8; }
