:root {
  color-scheme: dark;
  --bg: #0b0e13;
  --panel: #141a24;
  --panel-2: #1a2230;
  --line: #26303f;
  --line-strong: #3a4763;
  --text: #e9edf5;
  --muted: #a9b3c4;
  --accent: #7aa8ff;
  --accent-ink: #08111f;
  --ok: #57cf95;
  --warn: #ffc46b;
  --danger: #ff8f74;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(1100px 420px at 50% -160px, #17243a 0%, rgba(11, 14, 19, 0) 72%);
  color: var(--text);
  font: 16px/1.6 var(--font);
}

h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
ul, ol, dl, dd { margin: 0; padding: 0; }
li { list-style: none; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .92em; color: var(--warn); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -52px; z-index: 20;
  padding: 8px 14px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  font-weight: 700;
}
.skip-link:focus { top: 12px; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 26px 16px 64px; }

/* ---------- hero ---------- */
.hero { padding-bottom: 22px; }
.hero__title {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  font-size: clamp(24px, 5vw, 32px); letter-spacing: .01em;
}
.hero__tagline { margin-top: 8px; color: var(--muted); font-size: 15px; }

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin: 20px 0 14px;
}
.stat { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.stat dt { color: var(--muted); font-size: 12px; letter-spacing: .06em; }
.stat dd { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.hero__disclaimer {
  padding-left: 10px; border-left: 2px solid var(--line-strong);
  color: var(--muted); font-size: 13px;
}
.hero__disclaimer strong { color: var(--text); }

/* ---------- shared ---------- */
.badge {
  padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  border: 1px solid var(--line-strong); color: var(--muted);
}
.badge--ghost { align-self: center; }

.banner {
  margin-bottom: 14px; padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid #6a4d1f; background: #2a2114; color: #ffd79a; font-size: 13px;
}

.panel {
  margin-bottom: 16px; padding: 18px; border: 1px solid var(--line);
  border-radius: 16px; background: var(--panel);
}
.panel__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.panel h2 { font-size: 18px; }
.panel h3 { font-size: 15px; }

.hint { margin-top: 4px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); }

.btn {
  padding: 9px 14px; border: 1px solid transparent; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font: inherit; font-weight: 700;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn--ghost { background: transparent; color: var(--text); border-color: var(--line-strong); font-weight: 600; }
.btn--ghost:hover { background: var(--panel-2); filter: none; }
.btn--mini { padding: 4px 10px; font-size: 12px; font-weight: 600; border-radius: 8px; }

/* ---------- filters ---------- */
.search { display: flex; gap: 8px; }
.search input {
  flex: 1 1 auto; min-width: 0; padding: 11px 14px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: #0e131b; color: var(--text); font: inherit;
}
.search input::placeholder { color: #8b95a6; }

.group { margin: 16px 0 0; padding: 0; border: 0; }
.group legend { padding: 0; margin-bottom: 8px; color: var(--muted); font-size: 13px; letter-spacing: .04em; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 999px;
  background: #0e131b; color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: #1d2c4d; border-color: var(--accent); color: #cfe0ff; font-weight: 600; }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin-top: 16px; }
.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.controls__select { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; }
.controls__select label { color: var(--muted); }
.controls__select select {
  padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: #0e131b; color: var(--text); font: inherit; max-width: 62vw;
}

/* ---------- results ---------- */
.result-count { margin-top: 12px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.firmware-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }

.card { border: 1px solid var(--line); border-radius: var(--radius); background: #101720; overflow: hidden; }
.card[data-open="true"] { border-color: var(--line-strong); }

.row {
  display: grid; align-items: center; gap: 10px 14px; width: 100%;
  grid-template-columns:
    minmax(96px, .85fr) minmax(140px, 1.5fr) minmax(150px, 1.4fr) 78px 98px minmax(140px, auto);
  padding: 13px 16px; border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
}
.row:hover { background: var(--panel-2); }
.cell { min-width: 0; overflow-wrap: anywhere; }
.cell--model { display: flex; flex-direction: column; }
.cell--model .code { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.cell--version { font-variant-numeric: tabular-nums; }
.cell--badges { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.chev { color: var(--muted); font-size: 12px; transition: transform .15s ease; }
.row[aria-expanded="true"] .chev { transform: rotate(180deg); }

.tag { padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.tag--official { border-color: #2f6b4d; background: #14291f; color: #7fe3b0; }
.tag--coolapk { border-color: #2b4f7d; background: #142033; color: #9cc6ff; }
.tag--bilibili { border-color: #7d3b57; background: #2a1520; color: #ff9dc0; }
.tag--xianyu { border-color: #7a6220; background: #292312; color: #ffd98a; }
.tag--pan { border-color: #5b4276; background: #211832; color: #cdaaff; }
.tag--forum { border-color: #2a6672; background: #102429; color: #86dbe8; }
.tag--other { border-color: var(--line-strong); background: #161d28; color: var(--muted); }
.tag--paid { border-color: #8a4a26; background: #2c1a11; color: #ffb083; }
.tag--free { border-color: #2f5d45; background: #12251c; color: #8fe0b4; }

.detail { padding: 4px 16px 16px; border-top: 1px dashed var(--line); }
.detail__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px 20px; padding-top: 14px; }
.detail__item--wide { grid-column: 1 / -1; }
.detail dt { color: var(--muted); font-size: 12px; letter-spacing: .04em; }
.detail dd { margin: 2px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 14px; }
.detail__extra { font-size: 13px; }

/* ---------- download targets ----------
 * 三档能力：可直下（主色） / 下载页（次要） / 需客户端（不可点徽标 + 说明文本）
 * .stats--download 与主统计同栅格，只是把「下载能力」这三格单独成组 */
.stats--download { margin-top: -6px; }
.stat--dl { border-color: var(--line-strong); }
.stats__hint { margin-top: -4px; margin-bottom: 10px; }

/* 三个能力数字是 <button>：键盘可达，aria-pressed 表达当前筛选，样式与统计格一致 */
.stat--action {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text);
  cursor: pointer;
}
.stat--action:hover { border-color: var(--accent); background: var(--panel-2); }
.stat--action[aria-pressed="true"] { border-color: var(--accent); background: #1d2c4d; }
.stat--action .stat__label {
  display: block; color: var(--accent); font-size: 12px; letter-spacing: .06em;
}
.stat--action .stat__value {
  display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.stat--action[aria-pressed="true"] .stat__value { color: #cfe0ff; }

.btn--dl { display: inline-flex; align-items: center; text-decoration: none; }
.btn--dl:hover { text-decoration: none; filter: brightness(1.08); }
.detail__download { align-items: center; }
.dl-note { color: var(--muted); font-size: 12px; }
.dl-hint { color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

.tag--dl-direct { border-color: #2f6b4d; background: #14291f; color: #7fe3b0; }
.tag--dl-page { border-color: #2b4f7d; background: #142033; color: #9cc6ff; }
.tag--dl-app { border-color: #5b4276; background: #211832; color: #cdaaff; }
.tag--dl-none { border-color: var(--line-strong); background: #161d28; color: var(--muted); }

/* 非 http(s) 链接被拦截后只显示文本，永远不带 href */
.link-blocked {
  padding: 2px 8px; border-radius: 8px; border: 1px dashed #6b3a2f;
  background: #1c1410; color: var(--danger); font-size: 13px;
}
.link-blocked__raw { color: #ffd9cf; word-break: break-all; }

/* ---------- states ---------- */
.load-more { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.load-more .btn { padding: 8px 13px; font-size: 13px; }
.load-more .hint { margin-top: 0; }

.state-box {
  margin-top: 14px; padding: 22px 18px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius); background: #0e131b; text-align: center;
}
.state-box__title { font-size: 15px; font-weight: 700; }
.state-box__text { margin-top: 6px; color: var(--muted); font-size: 13px; }
.state-box__text + .btn { margin-top: 14px; }

/* ---------- models ---------- */
.model-groups { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.model-group__title { display: flex; align-items: center; gap: 8px; }
.model-group__count { color: var(--muted); font-size: 12px; font-weight: 500; }
.model-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.model-btn {
  display: inline-flex; align-items: baseline; gap: 8px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #0e131b;
  color: var(--text); font: inherit; font-size: 14px; cursor: pointer; text-align: left;
}
.model-btn:hover { border-color: var(--accent); background: var(--panel-2); }
.model-btn__code { color: var(--accent); font-size: 12px; letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.model-btn__count { color: var(--muted); font-size: 12px; }

.model-more { display: flex; margin-top: 14px; }
.model-more .btn { padding: 7px 12px; font-size: 13px; }

/* ---------- docs / footer ---------- */
.doc p + p { margin-top: 10px; }
.doc__list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: #d5dbe6; }
.doc__list li { padding-left: 18px; position: relative; }
.doc__list li::before { content: "•"; position: absolute; left: 4px; color: var(--accent); }
.doc__sub { margin-top: 16px; font-size: 14px; color: var(--text); }
.doc p { font-size: 14px; color: #d5dbe6; }

.footer { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.footer__note { margin-top: 4px; }
.noscript { max-width: 1080px; margin: 0 auto 24px; padding: 12px 16px; color: var(--warn); }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  .wrap { padding: 18px 12px 48px; }
  .panel { padding: 14px; border-radius: 14px; }
  .row { grid-template-columns: 1fr 1fr; padding: 12px; gap: 10px 12px; }
  .cell--model { grid-column: 1 / -1; grid-row: 1; }
  .cell--badges { grid-column: 1 / -1; justify-content: flex-start; }
  .cell::before {
    content: attr(data-label); display: block;
    color: var(--muted); font-size: 11px; letter-spacing: .06em;
  }
  .cell--model::before { display: none; }
  .search { flex-wrap: wrap; }
  .search input { flex-basis: 100%; }
  .stat--action .stat__value { font-size: 21px; }
  .controls__select select { max-width: 100%; }
}

/* ---------- print ---------- */
@media print {
  :root { color-scheme: light; }
  body { background: #fff; background-image: none; color: #111; }
  .skip-link, .search, .group, .controls, .banner, .noscript, #reset-filters, .btn { display: none !important; }
  .panel, .card, .stat, .state-box { border-color: #bbb; background: #fff; }
  .hero__tagline, .hint, .result-count, .muted, .dl-note, .dl-hint, .detail dt, .footer { color: #444; }
  code, a { color: #0b3d91; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 11px; word-break: break-all; }
  .load-more { display: none !important; }
  .model-btn, .chip { border-color: #bbb; background: #fff; color: #111; }
}
