/* ============================================================
 * digipick · 样式
 * 单文件、零依赖、移动优先
 * ============================================================ */

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --surface-2: #1c2330;
  --line:      #2a3444;
  --text:      #e6edf3;
  --muted:     #8b98a8;
  --accent:    #4b9fff;
  --accent-dim:rgba(75, 159, 255, .14);
  --good:      #3fb950;
  --warn:      #d29922;
  --radius:    12px;
  --radius-sm: 8px;
  --shadow:    0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.28);
  --maxw:      1140px;
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.6;
  font-size: 15px;
}

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 18px; }

/* ---------- 顶栏 ---------- */
.site-header {
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #121821, var(--bg));
  padding: 20px 0 18px;
}
.header-inner { display: flex; flex-direction: column; gap: 6px; }
.logo {
  display: inline-flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-size: 21px; font-weight: 700; letter-spacing: .3px;
}
.logo-mark { color: var(--accent); font-size: 15px; }
.tagline { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- 预算控制台 ---------- */
.console {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin: 22px 0 26px;
  box-shadow: var(--shadow);
}

.console-row {
  display: flex; align-items: center; gap: 14px;
}
.console-row--wrap { flex-wrap: wrap; margin-top: 16px; }
.console-row--between {
  justify-content: space-between; flex-wrap: wrap;
  margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line);
}

.budget-label {
  font-size: 13px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
}
.budget-value {
  margin-left: auto;
  font-size: 30px; font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.budget-prefix { font-size: 18px; opacity: .8; margin-right: 1px; }

/* 滑块 */
#budget {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 28px; margin: 6px 0 2px;
  background: transparent; cursor: pointer;
}
#budget::-webkit-slider-runnable-track {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--accent) var(--fill, 0%), var(--line) var(--fill, 0%));
}
#budget::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; margin-top: -8px;
  border-radius: 50%; background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
#budget::-moz-range-track {
  height: 6px; border-radius: 3px; background: var(--line);
}
#budget::-moz-range-progress {
  height: 6px; border-radius: 3px; background: var(--accent);
}
#budget::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent);
}
#budget:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

/* 预算预设 */
.presets { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.preset {
  font: inherit; font-size: 12.5px;
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 11px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.preset:hover { color: var(--text); border-color: #3d4b60; }
.preset[aria-pressed="true"] {
  color: var(--accent); border-color: var(--accent); background: var(--accent-dim);
}

/* 品类分段控件 */
.seg {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 999px;
}
.seg button {
  font: inherit; font-size: 13.5px;
  color: var(--muted); background: transparent;
  border: 0; border-radius: 999px;
  padding: 5px 15px; cursor: pointer;
  transition: color .15s, background .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] {
  color: #fff; background: var(--accent); font-weight: 600;
}

/* 搜索 */
.search {
  flex: 1 1 240px; min-width: 0;
  font: inherit; font-size: 14px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 9px 16px;
  transition: border-color .15s;
}
.search::placeholder { color: #5f6b7c; }
.search:focus { outline: none; border-color: var(--accent); }

.result-count { margin: 0; font-size: 13.5px; color: var(--muted); }
.result-count b { color: var(--text); font-variant-numeric: tabular-nums; }

.sort-label {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
}
#sort {
  font: inherit; font-size: 13.5px;
  color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 6px 10px; cursor: pointer;
}
#sort:focus { outline: none; border-color: var(--accent); }

/* ---------- 结果网格 ---------- */
.results {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  padding-bottom: 20px;
}

.card {
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 17px 15px;
  transition: border-color .18s, transform .18s;
}
.card:hover { border-color: #3d4b60; transform: translateY(-2px); }

/* 最贴合预算的一张卡 */
.card--best { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-dim); }

.card-top { display: flex; align-items: flex-start; gap: 10px; }
.card-brand {
  flex: 0 0 auto; font-size: 11.5px; font-weight: 600;
  color: var(--accent); background: var(--accent-dim);
  border-radius: 5px; padding: 2px 7px; margin-top: 3px;
  letter-spacing: .3px;
}
.card-name { margin: 0; font-size: 16.5px; font-weight: 650; line-height: 1.35; }

.card-price {
  margin: 11px 0 2px;
  display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap;
}
.price-main {
  font-size: 25px; font-weight: 700; color: var(--text);
  font-variant-numeric: tabular-nums; line-height: 1;
}
.price-rmb { font-size: 15px; font-weight: 600; opacity: .75; margin-right: 1px; }
.price-fit { font-size: 12.5px; color: var(--muted); }
.price-fit--best { color: var(--good); font-weight: 600; }
.price-fit--over { color: var(--warn); }

/* 参数表 */
.specs {
  margin: 13px 0 0; padding: 12px 0 0;
  border-top: 1px solid var(--line);
  display: grid; grid-template-columns: auto 1fr; gap: 5px 14px;
  font-size: 13px;
}
.specs dt { color: var(--muted); white-space: nowrap; }
.specs dd { margin: 0; color: var(--text); }

/* 卖点标签 */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 13px 0 0; }
.tag {
  font-size: 12px; color: #b9c6d6;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 2px 8px;
}

/* 推荐理由 */
.forwho {
  margin: 12px 0 0; padding: 9px 12px;
  font-size: 12.8px; color: #c3cfdd;
  background: var(--surface-2);
  border-left: 2px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.forwho b { color: var(--muted); font-weight: 500; }

/* 底部操作区 */
.card-foot {
  display: flex; align-items: center; gap: 10px;
  margin-top: auto; padding-top: 14px;
}
.btn {
  font: inherit; font-size: 13.5px; font-weight: 600;
  border: 0; border-radius: var(--radius-sm);
  padding: 9px 15px; cursor: pointer;
  text-decoration: none; text-align: center;
  transition: background .15s, opacity .15s;
}
.btn-buy { flex: 1; color: #fff; background: var(--accent); }
.btn-buy:hover { background: #3b8ae8; }
.btn-ghost {
  color: var(--muted); background: transparent;
  border: 1px solid var(--line); font-weight: 500;
}
.btn-ghost:hover { color: var(--text); border-color: #3d4b60; }

/* 无推广链接时的状态 */
.no-link {
  flex: 1; font-size: 12.5px; color: var(--muted);
  text-align: left; line-height: 1.4;
}

/* 空状态 */
.empty {
  text-align: center; color: var(--muted);
  padding: 48px 18px 60px; font-size: 15px;
}
.empty-hint { font-size: 13px; opacity: .8; }

/* ============================================================
 * 以下为静态生成页面（产品详情页 / 首页索引）的样式
 * 由 build.mjs 生成的页面使用
 * ============================================================ */

/* ---------- 面包屑 ---------- */
.crumbs {
  margin: 20px 0 4px;
  font-size: 13px; color: var(--muted);
}
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs span { color: var(--text); }

/* ---------- 产品详情页 ---------- */
.pdetail {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin: 12px 0 26px;
}
.pdetail h1 {
  margin: 0 0 4px;
  font-size: 26px; font-weight: 700; line-height: 1.3;
}
.pdetail h2 {
  margin: 28px 0 10px;
  font-size: 16px; font-weight: 650;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.pdetail p { margin: 0 0 10px; line-height: 1.75; }

.pdetail-price {
  margin: 10px 0 14px !important;
  font-size: 30px; font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.price-note {
  display: inline-block; margin-left: 10px;
  font-size: 12.5px; font-weight: 400; color: var(--muted);
  vertical-align: middle;
}

/* 参数表 */
.spectable {
  width: 100%; border-collapse: collapse;
  margin: 4px 0 8px; font-size: 14px;
}
.spectable th, .spectable td {
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.spectable th {
  width: 118px; font-weight: 500;
  color: var(--muted); white-space: nowrap;
  background: var(--surface-2);
}
.spectable tr:last-child th,
.spectable tr:last-child td { border-bottom: 0; }
.spectable td { color: var(--text); }

.buyhint {
  margin-top: 16px !important;
  padding: 10px 14px;
  font-size: 13px; color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
}

/* ---------- 首页静态产品索引 ---------- */
.allproducts {
  margin: 34px 0 10px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}
.allproducts h1 {
  margin: 0 0 6px;
  font-size: 20px; font-weight: 700;
}
.seclist { margin: 22px 0; }
.seclist h2 {
  margin: 0 0 10px;
  font-size: 15px; font-weight: 650;
  color: var(--accent);
}

.plist {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.plist li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 9px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 14px;
}
.plist a {
  color: var(--text); text-decoration: none;
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.plist a:hover { color: var(--accent); }
.plist-price {
  color: var(--muted); font-size: 13px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}

/* 禁用 JS 时的提示 */
.noscript {
  margin: 0 0 14px; padding: 10px 14px;
  font-size: 13px; color: #ffd894;
  background: #3a2f16; border: 1px solid #5c4a1f;
  border-radius: var(--radius-sm);
}

@media (max-width: 560px) {
  .pdetail { padding: 18px; }
  .pdetail h1 { font-size: 21px; }
  .pdetail-price { font-size: 25px !important; }
  .spectable th { width: 88px; font-size: 13px; }
  .spectable th, .spectable td { padding: 8px 9px; }
  .plist { grid-template-columns: 1fr; }
}

/* ---------- 脚本错误横幅 ----------
 * 只在出问题时出现。正式上线前可以连同 index.html 里那段
 * 错误监听脚本一起删掉。 */
.jserr {
  position: sticky; top: 0; z-index: 100;
  margin: 0; padding: 12px 18px;
  background: #4a1d1d;
  border-bottom: 1px solid #7d2b2b;
  color: #ffb4b4;
  font-size: 13px; line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

/* ---------- 加载态 ---------- */
.loading {
  grid-column: 1 / -1;
  margin: 0; padding: 40px 18px;
  text-align: center; color: var(--muted); font-size: 14px;
}

/* ---------- 页脚 ---------- */
.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 30px; padding: 22px 0 34px;
}
.disclaimer {
  margin: 0 0 9px; font-size: 12.5px;
  color: #7c8899; line-height: 1.7; max-width: 780px;
}
.disclaimer strong { color: #9aa7b6; font-weight: 600; }
.disclaimer.muted { color: #67717f; }

/* ---------- 小屏微调 ---------- */
@media (max-width: 560px) {
  body { font-size: 14.5px; }
  .results { grid-template-columns: 1fr; }
  .console { padding: 16px; }
  .budget-value { font-size: 26px; }
  .seg { width: 100%; overflow-x: auto; }
  .seg button { padding: 5px 12px; white-space: nowrap; }
  .search { flex-basis: 100%; }
  .console-row--between { gap: 10px; }
}

/* 尊重系统的减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
  .card:hover { transform: none; }
}
