:root {
  --bg: #ffffff;
  --surface: #f6f7f9;
  --fg: #1a1d21;
  --muted: #6b7280;
  --border: #e3e6ea;
  --accent: #2563eb;
  --success: #16a34a;
  --warning: #d97706;
  --error: #dc2626;
  --c1: #2563eb;
  --c2: #9333ea;
  --c3: #0d9488;
  --seg-ttft: #9ca3af;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --fg: #e6e8eb;
    --muted: #9aa3ae;
    --border: #2a2f38;
    --accent: #60a5fa;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #f87171;
    --c1: #60a5fa;
    --c2: #c084fc;
    --c3: #2dd4bf;
    --seg-ttft: #6b7280;
  }
}

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

html, body {
  margin: 0;
  padding: 0;
  background-color: var(--bg);
  color: var(--fg);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

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

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  background: var(--bg);
}

.header-main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.site-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.header-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

.header-task {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
}
.header-task summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--fg);
  user-select: none;
}
.task-quote {
  margin: 6px 0 0;
  padding: 8px 12px;
  background: var(--surface);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  font-size: 12px;
  color: var(--fg);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.disclaimer-banner {
  margin-top: 12px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted);
}

/* Layout */
.layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Navigation */
.site-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.nav-list {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0 16px;
  overflow-x: auto;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.nav-link {
  display: inline-block;
  padding: 12px 14px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  text-decoration: none;
}
.nav-link:hover {
  color: var(--fg);
  text-decoration: none;
}
.nav-link[aria-current="page"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* Main content */
#app {
  flex: 1;
  padding: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

/* ≥1024px Desktop Grid */
@media (min-width: 1024px) {
  .layout {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto 1fr;
  }

  .site-header {
    grid-column: 1 / -1;
  }

  .site-nav {
    grid-column: 1;
    border-bottom: none;
    border-right: 1px solid var(--border);
    position: sticky;
    top: 0;
    height: calc(100vh - 120px);
    overflow-y: auto;
    padding: 16px 0;
  }

  .nav-list {
    flex-direction: column;
    padding: 0 8px;
    gap: 4px;
    overflow-x: visible;
  }

  .nav-link {
    display: block;
    padding: 10px 14px;
    border-bottom: none;
    border-left: 3px solid transparent;
    border-radius: 4px;
  }
  .nav-link[aria-current="page"] {
    background: var(--surface);
    color: var(--accent);
    border-left-color: var(--accent);
  }

  #app {
    grid-column: 2;
    padding: 24px 32px;
  }

  .table-wrap {
    overflow-x: visible;
  }
}

/* <1024px Mobile table horizontal scroll and freeze first col */
@media (max-width: 1023px) {
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }

  td:first-child, th:first-child {
    position: sticky;
    left: 0;
    background: var(--bg);
    z-index: 2;
    box-shadow: 1px 0 0 var(--border);
  }
}

/* Typography & Sections */
h2 {
  font-size: 18px;
  margin: 28px 0 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
h2:first-child {
  margin-top: 0;
}
h3 {
  font-size: 15px;
  margin: 20px 0 10px;
  font-weight: 600;
}
p {
  margin: 0 0 12px;
}

/* Cards */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.card.card-link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}
.card.card-link:hover {
  text-decoration: none;
  border-color: var(--accent);
  transform: translateY(-1px);
}
.card.card-error {
  border-color: var(--error);
}

.card-title {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.card-value {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 500;
  border-radius: 4px;
  line-height: 1.3;
  vertical-align: middle;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
}
.badge.ok {
  background: color-mix(in srgb, var(--success) 12%, transparent);
  color: var(--success);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}
.badge.timeout {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 30%, transparent);
}
.badge.official {
  background: color-mix(in srgb, var(--c2) 12%, transparent);
  color: var(--c2);
  border-color: color-mix(in srgb, var(--c2) 30%, transparent);
}
.badge.channel {
  background: color-mix(in srgb, var(--c1) 12%, transparent);
  color: var(--c1);
  border-color: color-mix(in srgb, var(--c1) 30%, transparent);
}
.badge.warn {
  background: color-mix(in srgb, var(--warning) 12%, transparent);
  color: var(--warning);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
}

/* Segmented Control (Apple Style) */
.seg {
  display: inline-flex;
  background: color-mix(in srgb, var(--border) 45%, transparent);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
  border: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
  margin-bottom: 14px;
}
.seg button {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 80ms ease;
}
.seg button:hover {
  color: var(--fg);
}
.seg button:active {
  transform: scale(0.96);
}
.seg button.active {
  background: var(--bg);
  color: var(--fg);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Price Highlight */
.price-highlight {
  color: var(--accent);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* Suite Cards */
.suite-cards .card {
  border-radius: 12px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px -2px rgba(0,0,0,0.04);
  transition: transform 140ms cubic-bezier(0.16, 1, 0.3, 1), border-color 140ms ease, box-shadow 140ms ease;
}
.suite-cards .card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px -4px rgba(0,0,0,0.08);
}
.suite-cards .card:active {
  transform: scale(0.985);
  transition: transform 60ms ease-out;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.card-arrow {
  color: var(--muted);
  font-size: 14px;
  transition: transform 120ms ease;
}
.card:hover .card-arrow {
  transform: translateX(3px);
  color: var(--accent);
}
.card-val-sm {
  font-size: 15px;
  font-weight: 700;
  color: var(--fg);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

/* Section Header with Segments */
.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 32px 0 16px;
}
.section-header h2 {
  margin: 0;
}

/* Leaderboard Component */
.lb-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 32px;
}
.lb-row {
  display: grid;
  grid-template-columns: 28px minmax(220px, 340px) 1fr 140px;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 140ms ease, background 140ms ease, transform 100ms ease;
}
.lb-row:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  background: color-mix(in srgb, var(--surface) 80%, var(--bg));
}
.lb-rank {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.lb-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.lb-model {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-channel {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lb-bar-col {
  display: flex;
  align-items: center;
  width: 100%;
}
.lb-bar-track {
  width: 100%;
  height: 10px;
  background: color-mix(in srgb, var(--border) 50%, transparent);
  border-radius: 999px;
  overflow: hidden;
}
.lb-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 300ms cubic-bezier(0.16, 1, 0.3, 1);
}
.lb-val-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
  white-space: nowrap;
}
.lb-val {
  font-size: 13.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.lb-badges {
  display: flex;
  gap: 4px;
}
@media (max-width: 768px) {
  .lb-row {
    grid-template-columns: 24px 1fr auto;
    grid-template-rows: auto auto;
    row-gap: 8px;
  }
  .lb-rank { grid-row: 1; grid-column: 1; }
  .lb-meta { grid-row: 1; grid-column: 2; }
  .lb-val-col { grid-row: 1; grid-column: 3; }
  .lb-bar-col { grid-row: 2; grid-column: 1 / -1; }
}

/* Tables */
.table-wrap {
  margin-bottom: 24px;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  user-select: none;
  white-space: nowrap;
  z-index: 1;
}

thead th.sortable {
  cursor: pointer;
}
thead th.sortable:hover {
  color: var(--fg);
}
thead th .sort-arrow {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  color: var(--accent);
}

tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--surface);
}

.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.best {
  font-weight: 700;
}
.worst {
  color: var(--muted);
}

.sub-note {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-left: 2px;
}

/* Banner / Callout */
.alert-banner {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}
.alert-banner.alert-error {
  border-color: var(--error);
  background: color-mix(in srgb, var(--error) 5%, var(--bg));
}
.alert-title {
  font-weight: 700;
  font-size: 15px;
  color: var(--error);
  margin-bottom: 8px;
}
.alert-quote {
  margin: 6px 0;
  padding-left: 10px;
  border-left: 3px solid var(--error);
  color: var(--fg);
  font-size: 13px;
}
.alert-meta {
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Charts & SVGs */
.chart-container {
  margin-bottom: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 12px;
  font-size: 12px;
  color: var(--muted);
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

svg text {
  fill: var(--fg);
  font-size: 12px;
  font-family: inherit;
}
svg text.muted {
  fill: var(--muted);
}

/* Method blockquote & lists */
blockquote.method-task {
  margin: 0 0 20px;
  padding: 12px 16px;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.6;
}

.def-list, .caveat-list {
  padding-left: 20px;
  margin: 0 0 24px;
}
.def-list li, .caveat-list li {
  margin-bottom: 10px;
  line-height: 1.6;
}

.caption-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}
