/* ============================================================
 * 中转站在线率榜 · Design System v3
 * Style: Clean Light（清爽亮色 / 卡片式）
 * Colors: BG #F5F7FA / Card #FFF / Accent Indigo #4F46E5
 * 规则: 白卡片 + 柔和阴影 + 圆角 · 语义色浅底 pill · 细分割线
 *         亮色为主 · 暗色主题同步 · 150ms 过渡 · 焦点可见 · WCAG AA
 * ============================================================ */

:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1e293b;
  --ink-2: #475569;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --head-bg: #f8fafc;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #dc2626;
  --err-soft: #fef2f2;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .12);
  --page-max: 1100px;
  --page-max-wide: 1360px;
  --font-mono: "Fira Code", "Cascadia Code", "SF Mono", Consolas, monospace;
  --radius: 14px;
}
html[data-theme="dark"] {
  --bg: #0f1420;
  --card: #171e2e;
  --ink: #e2e8f0;
  --ink-2: #cbd5e1;
  --ink-3: #94a3b8;
  --ink-4: #64748b;
  --line: #2a3447;
  --line-strong: #3a465e;
  --head-bg: #1c2436;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: rgba(129, 140, 248, .14);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --err: #f87171;
  --err-soft: rgba(248, 113, 113, .12);
  --shadow: 0 1px 3px rgba(0, 0, 0, .3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  transition: background .2s, color .2s;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
button { font-family: inherit; cursor: pointer; }
code { font-family: var(--font-mono); font-size: .92em; background: var(--head-bg); padding: 1px 5px; border-radius: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.topbar-inner {
  max-width: var(--page-max); margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 16px;
}
.logo { display: flex; align-items: center; gap: 9px; flex-shrink: 0; }
.logo svg { width: 26px; height: 26px; }
.logo span { font-size: 16px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.logo em { font-style: normal; color: var(--ink-3); font-weight: 600; }

.search-wrap { position: relative; flex: 1; max-width: 420px; display: flex; align-items: center; }
.search-ico { position: absolute; left: 12px; width: 15px; height: 15px; color: var(--ink-4); pointer-events: none; }
.search-wrap input[type="search"] {
  width: 100%; padding: 8px 14px 8px 35px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink);
  font-size: 13.5px; outline: none; transition: border .15s, background .15s, box-shadow .15s;
}
.search-wrap input[type="search"]:focus {
  border-color: var(--accent); background: var(--card);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.search-wrap input[type="search"]::placeholder { color: var(--ink-4); }

.topbar-actions { display: flex; gap: 8px; flex-shrink: 0; margin-left: auto; }
.chip-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--ink-2); transition: all .15s;
}
.chip-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.chip-btn svg { width: 17px; height: 17px; }

/* ---------- 页头 ---------- */
.hero-compact {
  max-width: var(--page-max); margin: 0 auto;
  padding: 40px 20px 8px;
  display: grid; grid-template-columns: 1fr auto; gap: 16px 40px; align-items: center;
}
.hero h1 {
  font-size: clamp(26px, 4vw, 38px); font-weight: 800;
  line-height: 1.15; letter-spacing: -.02em;
}
.hero h1 .dot { color: var(--accent); }
.hero-desc {
  font-size: 12.5px; color: var(--ink-3); line-height: 1.75; max-width: 340px;
  padding-bottom: 4px;
}
.hero-desc b { color: var(--ink); font-family: var(--font-mono); font-weight: 600; }
.hero-desc a { color: var(--accent); }

/* ---------- 数据卡片（大数字） ---------- */
.statline {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-top: 22px; padding: 20px 24px;
}
.statline-item { padding-right: 36px; margin-right: 36px; border-right: 1px solid var(--line); }
.statline-item:last-child { border-right: none; margin-right: 0; padding-right: 0; }
.statline-item b {
  display: block; font-size: clamp(24px, 3vw, 32px); font-weight: 800;
  line-height: 1.15; letter-spacing: -.02em; color: var(--accent);
  font-variant-numeric: tabular-nums; font-feature-settings: "tnum";
}
.statline-item span { display: block; font-size: 11.5px; font-weight: 500; color: var(--ink-3); margin-top: 3px; }
.statline-loading { display: flex; align-items: center; gap: 8px; color: var(--ink-3); font-size: 13px; border: none; }

.spinner {
  width: 14px; height: 14px; flex: none;
  border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block; vertical-align: -2px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 容器与区块 ---------- */
.container { max-width: var(--page-max); margin: 0 auto; padding: 8px 20px 60px; }
.container-wide { max-width: var(--page-max-wide); }
.rank-section { margin-top: 32px; }
.section-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.section-title .title-sub { font-size: 12px; font-weight: 400; color: var(--ink-3); }
.section-title .title-sub a { color: var(--accent); }

/* ---------- 过滤工具行 ---------- */
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.f-label { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }
.f-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.f-chip {
  font-size: 12.5px; font-weight: 600; padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  transition: all .15s;
}
.f-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.f-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
html[data-theme="dark"] .f-chip.active { color: #10142a; }
.f-select {
  font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  cursor: pointer;
}
.f-select:hover { border-color: var(--accent); }
.f-count { font-size: 12px; color: var(--ink-4); margin-left: auto; font-variant-numeric: tabular-nums; }
.live-toolbar { margin-bottom: 12px; }

/* ---------- 表格（白卡片） ---------- */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.relay-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 960px; }
.relay-table thead th {
  padding: 11px 14px; text-align: left;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  background: var(--head-bg);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.relay-table thead th:first-child { border-top-left-radius: var(--radius); }
.relay-table thead th:last-child { border-top-right-radius: var(--radius); }
/* 表头排序：可点击 + 方向箭头 */
.relay-table thead th[data-key] { cursor: pointer; user-select: none; transition: color .15s; }
.relay-table thead th[data-key]:hover { color: var(--ink); }
.relay-table thead th[data-key]::after {
  content: "↕"; display: inline-block; margin-left: 5px;
  font-size: 10px; color: var(--ink-4); font-weight: 400;
  vertical-align: 1px;
}
.relay-table thead th.sorted-asc::after,
.relay-table thead th.sorted-desc::after { color: var(--accent); font-weight: 700; }
.relay-table thead th.sorted-asc::after { content: "↑"; }
.relay-table thead th.sorted-desc::after { content: "↓"; }
.relay-table thead th.sorted-asc,
.relay-table thead th.sorted-desc { color: var(--accent); }
.relay-table td {
  padding: 10px 14px; vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
.relay-table tbody tr:last-child td { border-bottom: none; }
.relay-table thead th:first-child,
.relay-table tbody td:first-child { padding-left: 18px; }
.relay-table thead th:last-child,
.relay-table tbody td:last-child { padding-right: 32px; }
.relay-table tbody tr { transition: background .12s; }
.relay-table tbody tr:hover { background: var(--accent-soft); }
.dim-cell { color: var(--ink-4); }
.cell-sub {
  display: block; font-size: 10.5px; color: var(--ink-4); margin-top: 1px;
  max-width: 190px; white-space: normal; overflow: hidden; text-overflow: ellipsis;
  font-family: var(--font-mono);
}

/* 模型筛选表头 */
.p-filter { cursor: pointer; user-select: none; transition: color .15s; }
.p-filter:hover { color: var(--ink); }
.p-filter.filtered { color: var(--accent); }
.filter-count-tag {
  display: inline-block; margin-left: 5px; padding: 0 6px;
  font-size: 10px; font-weight: 700; line-height: 16px;
  border-radius: 999px;
  background: var(--accent); color: #fff;
  font-variant-numeric: tabular-nums;
}
html[data-theme="dark"] .filter-count-tag { color: #10142a; }

/* 站点列 */
.c-site { min-width: 185px; }
.station-cell { display: flex; flex-direction: column; gap: 2px; }
.station-name-row { display: flex; align-items: center; gap: 8px; }
.favicon.sm {
  width: 22px; height: 22px; border-radius: 6px; font-size: 11px;
  font-weight: 700; color: #fff; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: var(--font-mono);
}
.station-name { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.station-name:hover { color: var(--accent); }

/* 数据 pill（状态徽章：soft 底 + 同色细边 + 指示圆点） */
.lv-pill {
  font-size: 11.5px; font-weight: 600; padding: 2.5px 9px; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}
.lv-pill::before {
  content: ""; flex: none;
  width: 5px; height: 5px; border-radius: 50%;
  background: currentColor;
}
.lv-cn       { background: var(--accent-soft); color: var(--accent); }
.lv-global   { background: var(--head-bg); color: var(--ink-3); }
.lv-up-good  { background: var(--ok-soft); color: var(--ok); }
.lv-up-mid   { background: var(--accent-soft); color: var(--accent); }
.lv-up-bad   { background: var(--err-soft); color: var(--err); }
.lv-ms-fast  { background: var(--ok-soft); color: var(--ok); }
.lv-ms-mid   { background: var(--warn-soft); color: var(--warn); }
.lv-ms-slow  { background: var(--err-soft); color: var(--err); }
.lv-engine   { background: var(--head-bg); color: var(--ink-2); font-family: var(--font-mono); font-size: 11px; }
.lv-engine::before { display: none; }
.lv-api-ok   { background: var(--ok-soft); color: var(--ok); }
.lv-api-ok::before { display: none; }
.lv-api-auth { background: var(--warn-soft); color: var(--warn); }
.lv-api-bad  { background: var(--err-soft); color: var(--err); }

.lv-models { display: flex; gap: 4px; flex-wrap: wrap; max-width: 110px; }
.lv-model {
  font-size: 10px; padding: 1px 6px; border-radius: 4px;
  background: var(--head-bg); color: var(--ink-2); font-weight: 600;
  border: 1px solid var(--line); white-space: nowrap;
}
.lv-count { color: var(--ink); font-size: 13px; font-weight: 700; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lv-score { font-weight: 700; color: var(--accent); font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

.live-loading, .live-empty { text-align: center; color: var(--ink-3); padding: 40px 12px !important; font-size: 13px; }
.live-empty-tip { margin-top: 12px; font-size: 13px; color: var(--ink-3); text-align: center; padding: 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--card); }
.live-error {
  margin-top: 12px; padding: 13px 15px; border-radius: 10px;
  background: var(--err-soft); color: var(--err); font-size: 13px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.live-error button {
  padding: 5px 14px; border-radius: 999px;
  border: 1px solid var(--err); background: transparent; color: var(--err);
  font-weight: 700; cursor: pointer; transition: all .15s;
}
.live-error button:hover { background: var(--err); color: #fff; }
.live-note { margin-top: 14px; font-size: 12px; color: var(--ink-3); line-height: 1.8; }
.live-note b { color: var(--ink); font-weight: 600; }

/* ---------- 模型筛选弹层 ---------- */
.filter-pop {
  position: fixed; z-index: 300;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 14px;
  max-width: 340px;
}
.filter-pop-title { font-size: 11.5px; font-weight: 600; color: var(--ink-3); margin-bottom: 8px; }
.filter-pop .f-chip { font-size: 12px; padding: 4px 12px; }

/* ---------- 基准价表 ---------- */
.price-table { min-width: 840px; }
.p-family { min-width: 86px; }
.fam-pill {
  font-size: 11.5px; font-weight: 600; padding: 2.5px 9px; border-radius: 6px;
  display: inline-block; white-space: nowrap;
  background: color-mix(in srgb, currentColor 10%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 24%, transparent);
}
.fam-OpenAI   { color: var(--ok); }
.fam-Claude   { color: var(--warn); }
.fam-Gemini   { color: var(--accent); }
.fam-DeepSeek { color: var(--accent); }
.fam-Qwen     { color: #7c3aed; }
.fam-豆包      { color: #0e7490; }
.fam-Kimi     { color: #be123c; }
.fam-GLM      { color: #b45309; }
html[data-theme="dark"] .fam-Qwen { color: #c4b5fd; }
html[data-theme="dark"] .fam-豆包 { color: #67e8f9; }
html[data-theme="dark"] .fam-Kimi { color: #fda4af; }
.p-name { min-width: 150px; font-weight: 600; white-space: nowrap; }
.p-off { min-width: 130px; color: var(--ink-3); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.p-min { min-width: 95px; font-weight: 700; color: var(--ok); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.p-disc { min-width: 76px; }
.disc-pill {
  font-size: 11.5px; font-weight: 700; padding: 2.5px 9px; border-radius: 6px;
  display: inline-block; font-variant-numeric: tabular-nums; white-space: nowrap;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
}
.disc-pill.d-ultra { background: var(--ok-soft); color: var(--ok); }
.disc-pill.d-low   { background: var(--accent-soft); color: var(--accent); }
.disc-pill.d-mid   { background: var(--head-bg); color: var(--ink-3); }
.p-sites { min-width: 76px; color: var(--ink-3); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ---------- 数据说明 ---------- */
.legend {
  margin-top: 28px; padding: 20px 24px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.legend h3 { font-size: 13px; font-weight: 700; margin-bottom: 10px; color: var(--ink); }
.legend ul { padding-left: 18px; display: flex; flex-direction: column; gap: 5px; }
.legend li { font-size: 12.5px; color: var(--ink-3); line-height: 1.7; }
.legend .dim { margin-top: 10px; font-size: 11.5px; color: var(--ink-4); }

/* ---------- 空状态 ---------- */
.empty-tip { margin-top: 14px; font-size: 13px; color: var(--ink-3); text-align: center; padding: 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius); background: var(--card); }

/* ---------- 内容页（关于/联系/隐私共用） ---------- */
.page-topbar { position: sticky; top: 0; z-index: 100; background: var(--card); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); }
.page-topbar .inner {
  max-width: var(--page-max); margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13.5px;
}
.page-topbar .back { color: var(--accent); font-weight: 600; }
.page-topbar .home { color: var(--ink-3); }
.page { max-width: 720px; margin: 0 auto; padding: 40px 20px 60px; }
.page h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; margin-bottom: 8px; }
.page h2 { font-size: 16px; margin: 30px 0 10px; }
.page p { font-size: 14px; color: var(--ink); margin-bottom: 12px; line-height: 1.8; }
.page ul { padding-left: 20px; margin-bottom: 12px; }
.page li { font-size: 13.5px; color: var(--ink-2); line-height: 1.9; }
.page .lede { font-size: 15px; color: var(--ink-3); margin-bottom: 28px; }
.page .card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 16px;
}

/* ---------- 页脚 & 回顶 ---------- */
.footer {
  padding: 28px 0 36px;
  text-align: center; color: var(--ink-3); font-size: 12px; line-height: 2;
}
.footer a { color: var(--accent); }
.footer .dim { color: var(--ink-4); }
.footer-links a { margin: 0 4px; }
.back-top {
  position: fixed; right: 20px; bottom: 26px; z-index: 50;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: var(--shadow-lg);
  color: var(--ink-2); font-size: 16px;
  transition: all .15s;
}
.back-top:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .search-wrap { order: 3; flex-basis: 100%; max-width: none; }
  .hero-compact { padding: 24px 14px 6px; grid-template-columns: 1fr; }
  .statline { padding: 16px 18px; margin-top: 16px; gap: 14px 0; }
  .statline-item { padding-right: 20px; margin-right: 20px; }
  .statline-item b { font-size: 22px; }
  .f-count { display: none; }
  .relay-table { font-size: 12px; }
  .container { padding: 8px 14px 46px; }
}
@media (max-width: 400px) {
  .statline-item:nth-child(5) { border-left: none; padding-left: 0; margin-left: 0; }
}
