/* ============================================================
   手机评测数据库 —— 深色科技风（移动优先 · 完全自适应）
   品牌侧栏菜单 + 列表式产品（缩略图 / 型号 / 比较按钮）
   断点：<768 手机（抽屉式侧栏）｜ ≥768 平板/桌面（固定侧栏）
   ============================================================ */
:root {
  --bg: #0e1015;
  --bg-soft: #161921;
  --card: #1b1f2a;
  --card-2: #202634;
  --line: #2a3040;
  --line-soft: #242a38;
  --text: #e8ecf4;
  --text-2: #a6adbb;
  --text-3: #6f7686;
  --accent: #3b82f6;
  --accent-2: #22d3ee;
  --best: #22c55e;
  --best-bg: rgba(34, 197, 94, .16);
  --worst: #ef4444;
  --worst-bg: rgba(239, 68, 68, .16);
  --gold: #f59e0b;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
}

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

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
  touch-action: manipulation;
}

button, input, select { font-family: inherit; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: rgba(14, 16, 21, .9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.logo { font-size: 24px; flex: 0 0 auto; }
.brand-txt { min-width: 0; }
.title { font-size: 16px; font-weight: 700; letter-spacing: .5px; white-space: nowrap; }
.subtitle { display: none; }
.tabs { display: flex; gap: 6px; flex: 0 0 auto; }
.tab {
  border: 1px solid var(--line); background: var(--card);
  color: var(--text-2); padding: 9px 13px; border-radius: 999px;
  cursor: pointer; font-size: 14px; transition: .15s; white-space: nowrap; min-height: 40px;
}
.tab:hover { border-color: var(--accent); color: var(--text); }
.tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-color: transparent; }
.badge {
  display: inline-block; min-width: 18px; text-align: center;
  background: rgba(0,0,0,.25); color: #fff; border-radius: 999px;
  font-size: 11px; padding: 0 5px; margin-left: 2px;
}

/* ---------- 主体 ---------- */
main { width: 100%; max-width: 1280px; margin: 0 auto; padding: 14px 14px 130px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.menu-toggle {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  padding: 12px 14px; border-radius: 12px; font-size: 14px; cursor: pointer; min-height: 46px;
}
#search {
  flex: 1 1 200px; min-width: 120px;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 13px 14px; border-radius: 12px; font-size: 15px; outline: none; min-height: 46px;
}
#search:focus { border-color: var(--accent); }
.fold-toggle {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 14px; cursor: pointer; white-space: nowrap;
  min-height: 46px; padding: 0 4px;
}
.fold-toggle input { accent-color: var(--accent); width: 20px; height: 20px; }
#sort {
  flex: 1 1 160px; min-width: 0;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  padding: 12px; border-radius: 12px; font-size: 14px; outline: none; cursor: pointer; min-height: 46px;
}

/* ---------- 目录：侧栏 + 列表 ---------- */
.catalog { display: block; }

/* 品牌侧栏（手机：抽屉） */
.side-mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 70; }
.side-menu {
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 80;
  width: 260px; max-width: 84vw;
  background: var(--bg-soft); border-right: 1px solid var(--line);
  padding: 18px 14px;
  padding-top: calc(18px + env(safe-area-inset-top));
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  transform: translateX(-105%); transition: transform .25s ease;
}
.side-menu.open { transform: translateX(0); }
.side-title { font-size: 13px; color: var(--text-3); padding: 4px 12px 10px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; border: none; background: transparent; color: var(--text-2);
  padding: 12px 13px; border-radius: 10px; cursor: pointer; font-size: 15px;
  text-align: left; min-height: 44px;
}
.menu-item:hover { background: var(--card-2); color: var(--text); }
.menu-item.active { background: var(--accent); color: #fff; }
.menu-item .count { font-size: 12px; opacity: .65; }
.menu-item.active .count { opacity: 1; }

/* 产品列表（缩略图 + 型号 + 比较按钮） */
.phone-list { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; transition: .15s;
}
.list-item:active { border-color: var(--accent); }
.li-thumb {
  width: 56px; height: 56px; border-radius: 12px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.li-thumb .pimg { width: 64%; height: 64%; object-fit: contain; }
.li-name { flex: 1; min-width: 0; font-size: 15px; font-weight: 600; line-height: 1.35; }
.li-cmp {
  flex: 0 0 auto; border: 1px solid var(--accent); color: var(--accent); background: transparent;
  border-radius: 9px; padding: 9px 15px; font-size: 13px; cursor: pointer; min-height: 40px;
}
.li-cmp.on { background: var(--best); border-color: var(--best); color: #fff; }

.empty { text-align: center; color: var(--text-3); padding: 60px 0; }

/* ---------- 产品详情 ---------- */
.detail-top { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.detail-title { flex: 1; font-size: 16px; font-weight: 700; }
.back-btn, .clear-btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text-2);
  padding: 10px 14px; border-radius: 11px; cursor: pointer; font-size: 13px; min-height: 42px;
}
.back-btn:hover, .clear-btn:hover { color: var(--text); border-color: var(--accent); }
.detail-cmp-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 11px;
  padding: 11px 16px; cursor: pointer; font-size: 14px; font-weight: 600; min-height: 42px;
}
.detail-cmp-btn.on { background: var(--best); }

.detail-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.detail-img {
  width: 76px; height: 76px; border-radius: 16px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.detail-img .pimg { width: 58%; height: 58%; object-fit: contain; }
.detail-info { min-width: 0; }
.detail-info h2 { font-size: 19px; line-height: 1.3; }
.detail-info .sub { color: var(--text-3); font-size: 13px; margin-top: 2px; }
.detail-info .price { color: var(--gold); font-weight: 700; font-size: 16px; margin-top: 4px; }

.detail-specs { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0; }
.spec-pill { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; font-size: 12px; color: var(--text-2); }
.spec-pill b { color: var(--text); }

.detail-section { margin-top: 18px; }
.detail-section > h3 {
  font-size: 14px; color: var(--accent-2); padding: 9px 12px; background: var(--card-2);
  border-radius: 8px; margin-bottom: 8px;
}
.detail-section > .group-label { font-size: 13px; font-weight: 600; color: var(--text); margin: 12px 2px 6px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.detail-table td:first-child { color: var(--text-2); width: 58%; }
.detail-table td:last-child { text-align: right; font-weight: 600; }
.detail-table td:last-child small { color: var(--text-3); font-weight: 400; }

/* ---------- 底部对比栏 ---------- */
.cmp-bar {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(660px, calc(100% - 24px)); z-index: 60;
  background: rgba(27, 31, 42, .97); backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
  padding: 10px 12px; display: flex; align-items: center; gap: 10px;
}
.cmp-items {
  flex: 1; display: flex; gap: 8px; overflow-x: auto; min-height: 40px; align-items: center;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.cmp-items::-webkit-scrollbar { display: none; }
.cmp-chip {
  display: flex; align-items: center; gap: 6px; flex: 0 0 auto;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 999px;
  padding: 6px 6px 6px 12px; font-size: 13px; min-height: 34px;
}
.cmp-chip b { font-weight: 600; }
.cmp-chip .rm { cursor: pointer; color: var(--text-3); font-size: 18px; padding: 0 6px; }
.cmp-chip .rm:hover { color: var(--worst); }
.cmp-go {
  background: var(--accent); color: #fff; border: none; border-radius: 11px;
  padding: 12px 16px; cursor: pointer; font-size: 14px; font-weight: 600; white-space: nowrap; min-height: 44px;
}
.cmp-go:hover { filter: brightness(1.1); }

/* ---------- 对比视图（分块 + 横向对比行） ---------- */
.compare-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.compare-head h2 { font-size: 18px; flex: 1; }
.legend { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); margin-bottom: 10px; flex-wrap: wrap; }
.lg { border-radius: 6px; padding: 2px 8px; font-weight: 600; }
.lg-best { background: var(--best-bg); color: var(--best); }
.lg-worst { background: var(--worst-bg); color: var(--worst); }
.scroll-hint { text-align: center; color: var(--text-3); font-size: 12px; margin: 4px 0 10px; }

.cmp-block {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; margin-bottom: 18px;
}
.cmp-cat { padding: 11px 14px; margin: 0; font-size: 14px; color: var(--accent-2); background: var(--card-2); }
.table-scroll {
  overflow-x: auto; background: var(--card);
  -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
table.cmp { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
table.cmp th, table.cmp td { border-bottom: 1px solid var(--line-soft); padding: 10px 10px; text-align: center; vertical-align: middle; }

/* 表头（首列冻结） */
table.cmp thead th { background: var(--card-2); }
table.cmp thead th:first-child {
  position: sticky; left: 0; z-index: 3; box-shadow: 1px 0 0 var(--line-soft);
}
.cmp-photo { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; }
.cmp-photo .av {
  width: 32px; height: 32px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px;
}
.cmp-photo .n { font-size: 12px; font-weight: 600; line-height: 1.25; }
.cmp-photo .x { cursor: pointer; color: var(--text-3); font-size: 11px; padding: 2px 6px; }
.cmp-photo .x:hover { color: var(--worst); }

tr.group td { background: rgba(59, 130, 246, .08); color: var(--text); font-weight: 600; text-align: left; }

/* 评测项标签列：冻结在左，窄列可换行 */
tr.metric th {
  text-align: left; color: var(--text-2); font-weight: 400;
  white-space: normal; min-width: 92px; max-width: 150px;
  position: sticky; left: 0; z-index: 2; background: var(--card);
  box-shadow: 1px 0 0 var(--line-soft);
}
tr.metric th .u { color: var(--text-3); font-size: 11px; }
td .val { font-weight: 600; }
td .val.dim { color: var(--text-3); font-weight: 400; }
td.best .val { color: var(--best); }
td.worst .val { color: var(--worst); }
td.best { background: var(--best-bg); }
td.worst { background: var(--worst-bg); }

/* ---------- 免责声明 ---------- */
.disclaimer { text-align: center; color: var(--text-3); font-size: 12px; padding: 8px 16px 24px; }

/* ============================================================
   平板及以上（≥768px）：固定侧栏
   ============================================================ */
@media (min-width: 768px) {
  .topbar { padding: 12px 24px; padding-top: calc(12px + env(safe-area-inset-top)); }
  .logo { font-size: 26px; }
  .title { font-size: 17px; }
  .subtitle { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .tab { padding: 9px 16px; }

  main { padding: 20px 28px 110px; }
  .menu-toggle { display: none; }
  .side-mask { display: none; }

  .catalog { display: flex; gap: 22px; align-items: flex-start; }
  .side-menu {
    position: sticky; top: 72px; align-self: flex-start;
    width: 170px; max-width: none; flex: 0 0 170px;
    background: transparent; border-right: none; padding: 0;
    transform: none; overflow: visible; z-index: auto;
  }
  .phone-list-wrap { flex: 1; min-width: 0; }
  .phone-list { margin-top: 0; }
  #sort { flex: 0 0 auto; }

  .scroll-hint { display: none; }
  tr.metric th { max-width: 220px; }
  .cmp-photo { min-width: 100px; }
  .cmp-bar { bottom: 16px; }
}

/* ============================================================
   桌面（≥960px）
   ============================================================ */
@media (min-width: 960px) {
  .list-item:hover { border-color: var(--accent); }
}
