/* =====================================================================
   元器件替代判定
   ---------------------------------------------------------------------
   暗色 · 极简几何。约束自己只用这几样东西：
     直角、1px 线、平面色阶、对齐、留白。
   不用：阴影、圆角、渐变、图标、装饰性色块、衬线字。

   颜色只有两个用途：
     · 交互（焦点、链接、当前项）= 一个低饱和冷蓝；
     · 判定结论（A–E / 否决）= 一条低饱和色阶。
   其余全部是中性灰阶。

   版面：**铺满整个视口宽度**。这里是"桌面上的工作台"，不是文章页，
   所以没有 max-width、没有 margin:auto 居中容器 —— 左右两侧不留大片空白，
   分栏用 1px 竖线切分，两个栏目各自滚动。
   ===================================================================== */

:root {
  /* 平面色阶：靠层级分面，不靠阴影 */
  --bg: #131519;
  --panel: #191c21;
  --panel-2: #1f2329;
  --panel-3: #262b32;
  --line: #2b3138;
  --line-2: #3a4149;

  /* 文字 */
  --text: #e7e9ec;
  --text-2: #9ba2ab;
  --text-3: #6c737c;

  /* 交互 */
  --accent: #7aa7dd;
  --accent-dim: #24384f;

  /* 判定色阶：仅用于结论，低饱和 */
  --a: #59a97e;
  --b: #86a94f;
  --c: #c9a13f;
  --d: #cd7b4d;
  --e: #cc5f5f;
  --x: #6c737c;

  /* 8px rhythm */
  --sp-1: 8px;
  --sp-2: 16px;
  --sp-3: 24px;
  --sp-4: 40px;
  /* 12px floor: nothing in the UI is smaller than this */
  --fs-min: 12px;
  --fs-body: 14px;
  --fs-row: 13.5px;
  --fs-note: 12.5px;
  --lh-body: 1.7;
  --lh-row: 1.45;
  /* 贴边留出的走线宽度：只是为了不让文字顶到屏幕边缘，不是居中留白 */
  --gutter: 12px;
  --pane-pad: 20px;
  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--fs-body)/var(--lh-body) var(--font);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.num, dd.num, .score, .pkey, .code, code {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

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

:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.hidden { display: none !important; }
.ta-r { text-align: right; }
.dim { color: var(--text-3); }

/* ---------------------------------------------------------------- 顶栏 */
/* 一条底线收口，不填色、不浮起。只放标识与目录库状态 —— 搜索框在首页正文里。 */
.appbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  height: 46px;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--line);
}
.appnav { display: flex; align-items: baseline; gap: var(--sp-2); min-width: 0; }
.navlink { font-size: var(--fs-row); white-space: nowrap; }
.wordmark { font-size: 15px; font-weight: 600; color: var(--text); letter-spacing: 0.01em; }
.wordmark:hover { text-decoration: none; color: var(--accent); }
.catalog-status { color: var(--text-3); font-size: var(--fs-note); }
.catalog-status b { color: var(--text-2); font-weight: 500; }
.stale-warn { margin-left: var(--sp-1); color: var(--c); }

/* ---------------------------------------------------------------- 视图骨架 */
#app { flex: 1 1 auto; min-height: 0; display: flex; }

.view { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; min-height: 0; }

/* 首页与品类页整页滚动；详情页不滚动，两个栏目各自滚动 */
.view-home { overflow-y: auto; }
.view-class { overflow: hidden; }

.scroll-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-2) var(--pane-pad) var(--sp-4); }

.block-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  margin-bottom: var(--sp-1);
}
.block-head h2, .block-head h3 { margin: 0; font-size: var(--fs-body); font-weight: 600; }
.block-note { color: var(--text-3); font-size: var(--fs-note); font-weight: 400; }
.link-plain {
  background: none; border: none; padding: 0;
  color: var(--accent); cursor: pointer;
  font: inherit; font-size: var(--fs-row);
}
.link-plain:hover { text-decoration: underline; text-underline-offset: 3px; }

.placeholder { color: var(--text-2); font-size: var(--fs-body); padding: var(--sp-3) 0; max-width: 62ch; }
.placeholder .link-plain { font-size: inherit; }

/* ---------------------------------------------------------------- 首页 */
/* 搜索框落在"上方偏中"的位置，而不是贴着顶栏 */
.home-top {
  padding: clamp(40px, 13vh, 160px) var(--gutter) var(--sp-4);
  text-align: center;
}
.home-title {
  margin: 0 0 var(--sp-3);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.search-row { display: flex; gap: var(--sp-1); max-width: 800px; margin: 0 auto; align-items: stretch; }
/* 联想面板是针对这个盒子绝对定位的。少了 position: relative，它会改为相对初始包含块
   定位，于是 top: 100% 变成"整页的底部"——联想项在 DOM 里存在，却在屏幕外，
   用户看到的就是"输入没反应"。 */
.field-input { position: relative; min-width: 0; }
.search-row .field-input { flex: 1 1 auto; min-width: 0; }
.search-row .btn-primary { padding: 0 var(--sp-3); }
.search-state { margin: var(--sp-1) 0 0; font-size: var(--fs-note); color: var(--accent); }

.block { padding: 0 var(--gutter) var(--sp-4); }

/* 品类块：1px 间隙 + 底色充当分隔线，铺满整行 */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}
.tile {
  background: var(--bg);
  padding: 11px 13px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  color: var(--text);
}
.tile:hover { background: var(--panel); text-decoration: none; }
.tile-name { font-size: var(--fs-row); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-n { color: var(--text-3); font-size: var(--fs-note); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: baseline; gap: 6px;
  border: 1px solid var(--line-2);
  padding: 4px 9px;
  font-size: var(--fs-row);
  color: var(--text);
  max-width: 260px;
}
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip-mpn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-code { color: var(--text-3); font-size: var(--fs-note); }

.home-results { padding: 0 var(--gutter) var(--sp-4); }

.colophon {
  padding: var(--sp-2) var(--gutter) var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-note);
  border-top: 1px solid var(--line);
}
.colophon p { margin: 0; max-width: 110ch; }
.colophon code { background: var(--panel-2); padding: 1px 5px; font-size: var(--fs-note); }

/* ---------------------------------------------------------------- 输入控件 */
input[type="search"], select, input[type="number"] {
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-radius: 0;
  padding: 11px 13px;
  width: 100%;
}
input[type="search"] { font-size: 15px; }
input[type="search"]::placeholder { color: var(--text-3); }
input[type="number"] { width: 76px; padding: 4px 7px; font-size: var(--fs-row); }
input:focus, select:focus { border-color: var(--accent); outline: none; }

.btn-primary {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--bg);
  background: var(--text);
  border: 1px solid var(--text);
  border-radius: 0;
  padding: 11px 20px;
  cursor: pointer;
  white-space: nowrap;
}
.btn-primary:hover { background: #fff; border-color: #fff; }
.btn-primary:disabled { opacity: 0.5; cursor: progress; }

.inline-opt {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: var(--fs-row); color: var(--text-2); cursor: pointer;
}
.inline-opt input[type="checkbox"] { accent-color: var(--accent); width: 13px; height: 13px; margin: 0; }

.controls { display: flex; flex-wrap: wrap; gap: 6px var(--sp-2); align-items: center; }
.controls .inline-opt { white-space: nowrap; }

/* 联想列表 */
.suggest {
  position: absolute;
  z-index: 40;
  top: 100%;
  left: 0; right: 0;
  max-height: 380px;
  overflow: auto;
  text-align: left;
  background: var(--panel-2);
  border: 1px solid var(--line-2);
  border-top: none;
}
.sug {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 16px;
  padding: 7px 11px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.sug:last-of-type { border-bottom: none; }
.sug:hover, .sug.active { background: var(--panel-3); }
.sug-ident { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.sug .mpn { font-weight: 500; }
.sug .code { color: var(--text-3); font-size: var(--fs-note); }
.sug-sub { grid-column: 1; color: var(--text-3); font-size: var(--fs-note); }
.sug-num { grid-row: 1 / span 2; grid-column: 2; color: var(--text-2); font-size: var(--fs-note); white-space: nowrap; }
.sug-empty { padding: 12px; color: var(--text-2); font-size: var(--fs-body); }

/* ---------------------------------------------------------------- 品类页 */
.class-head {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-2) var(--pane-pad) var(--sp-1);
  border-bottom: 1px solid var(--line);
}
.class-ident h1 { margin: 0; font-size: 18px; font-weight: 600; }
.class-ident p { margin: 2px 0 0; }

/* 首字母跳转条：一整行，铺满 */
.letters {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  padding: 1px var(--gutter) 0;
  border-bottom: 1px solid var(--line);
}
.letter {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 24px; padding: 0 5px;
  font-size: var(--fs-note); color: var(--text-2);
}
.letter:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.letter.active { background: var(--accent-dim); color: var(--text); }

/* ---------------------------------------------------------------- 料号表 */
.parts-table, .cand-table { width: 100%; border-collapse: collapse; }
.parts-table { table-layout: auto; }
.parts-table thead th, .cand-table thead th {
  position: sticky;
  top: calc(var(--sp-2) * -1);
  z-index: 2;
  background: var(--bg);
  text-align: left;
  font-size: var(--fs-note);
  font-weight: 400;
  color: var(--text-3);
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--line-2);
  white-space: nowrap;
}
.parts-table thead th.ta-r, .cand-table thead th.ta-r { text-align: right; }
.part-row { cursor: pointer; border-bottom: 1px solid var(--line); }
.part-row:hover { background: var(--panel); }
.part-row td { padding: 7px 10px 7px 0; font-size: var(--fs-row); vertical-align: middle; }
.part-row td:last-child { padding-right: 0; }
.part-row .idx { color: var(--text-3); width: 56px; }
.part-row .mpn { font-weight: 500; }
.part-row .code { color: var(--text-3); font-size: var(--fs-note); margin-left: 8px; }

/* ---------------------------------------------------------------- 详情页
   左栏＝原器件，右栏＝候选。两栏各占一半，贴到视口左右边缘，中间一条 1px 竖线。 */
.view-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}
.pane { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.pane-left { border-right: 1px solid var(--line-2); }
.pane-right { position: relative; background: var(--bg); }

.pane-head {
  flex: 0 0 auto;
  padding: var(--sp-2) var(--pane-pad);
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.pane-label { display: block; font-size: var(--fs-note); color: var(--text-3); margin-bottom: 3px; }

.target-ident { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tl-mpn { font-size: 19px; font-weight: 600; letter-spacing: -0.01em; word-break: break-word; }
.tl-code { color: var(--text-3); font-size: var(--fs-row); }
.verdict-line { font-size: var(--fs-row); }

.factstrip { display: flex; flex-wrap: wrap; margin: var(--sp-1) 0 0; }
.factstrip > div {
  padding: 4px 16px 4px 0;
  margin-right: 16px;
  border-right: 1px solid var(--line);
  min-width: 92px;
}
.factstrip > div:last-child { border-right: none; margin-right: 0; }
.factstrip dt { font-size: var(--fs-note); color: var(--text-3); margin-bottom: 1px; }
.factstrip dd { margin: 0; font-size: var(--fs-row); }
.dim-note { color: var(--text-3); font-size: var(--fs-note); margin-left: 6px; }

.target-desc { margin: var(--sp-2) 0 0; color: var(--text-3); font-size: var(--fs-note); }
.detail-link { margin: var(--sp-1) 0 0; }

.cn-flag { color: var(--a); font-size: var(--fs-note); margin-left: 6px; }
/* 国别未确认：不是"不是国产"，而是"不知道"。用灰色斜体把它和"确定国产"区分开，
   同时让"只看国产"的盲区在名单上就看得见。 */
.unknown-flag { color: var(--text-3); font-size: var(--fs-note); margin-left: 6px; border-bottom: 1px dotted var(--line-2); cursor: help; }
.plain-flag { color: var(--text-3); font-size: var(--fs-note); margin-left: 6px; }
.warn-flag { color: var(--c); font-size: var(--fs-note); margin-left: 6px; }
.warn-text { color: var(--c); font-weight: 400; }

.subs-summary { color: var(--text-2); font-size: var(--fs-row); margin-bottom: var(--sp-1); }
.subs-summary b { color: var(--text); font-weight: 600; }
.sum-line { margin-bottom: 2px; }
.sum-line.dim { color: var(--text-3); font-size: var(--fs-note); }
/* "含国别未确认"是从属开关：缩进一格，表示它只在"只看国产"打开时才有意义 */
.controls .sub-opt { padding-left: 8px; border-left: 2px solid var(--line-2); }

/* 候选表 */
.cand-table { table-layout: fixed; }
.cand-table col.col-grade { width: 34px; }
.cand-table col.col-verdict { width: 84px; }
.cand-table col.col-stock { width: 72px; }
.cand-table col.col-price { width: 80px; }
.cand-table col.col-score { width: 60px; }
.cand-table thead th { padding: 6px 10px 6px 0; }
.cand-row { cursor: pointer; border-bottom: 1px solid var(--line); }
.cand-row:hover { background: var(--panel); }
.cand-row.tone-x { opacity: 0.62; }
.cand-row td { padding: 8px 10px 8px 0; vertical-align: middle; font-size: var(--fs-row); line-height: var(--lh-row); }
.cand-row td:last-child { padding-right: 0; }
.cand-row td.cell-grade { padding-left: 8px; border-left: 2px solid transparent; }
.tone-a td.cell-grade { border-left-color: var(--a); }
.tone-b td.cell-grade { border-left-color: var(--b); }
.tone-c td.cell-grade { border-left-color: var(--c); }
.tone-d td.cell-grade { border-left-color: var(--d); }
.tone-e td.cell-grade { border-left-color: var(--e); }
.tone-x td.cell-grade { border-left-color: var(--x); }

/* 等级与分数共用同一套色阶；颜色含义见判定说明 */
.grade {
  display: inline-block;
  min-width: 15px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  border-bottom: 2px solid currentColor;
  padding-bottom: 1px;
}
.tone-a .grade, .tone-a .score { color: var(--a); }
.tone-b .grade, .tone-b .score { color: var(--b); }
.tone-c .grade, .tone-c .score { color: var(--c); }
.tone-d .grade, .tone-d .score { color: var(--d); }
.tone-e .grade, .tone-e .score { color: var(--e); }
.tone-x .grade, .tone-x .score { color: var(--x); }

.cell-id { min-width: 0; }
/* 翻页/换筛选时旧列表还在屏幕上，先暗下来表示"正在换"。
   手机网络下这一步可能接近一秒，没有反馈就会被当成"点了没反应"。 */
.subs.loading { opacity: 0.45; }
.subs.loading .cand-row { cursor: progress; }
.cell-id .mpn { font-weight: 500; }
.cell-id .code { color: var(--text-3); font-size: var(--fs-note); margin-left: 8px; }
.cell-sub { color: var(--text-3); font-size: var(--fs-note); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-verdict { color: var(--text-2); white-space: nowrap; }
.score { text-align: right; font-size: 16px; font-weight: 600; white-space: nowrap; }
.meter { height: 2px; background: var(--panel-3); margin-top: 3px; }
.meter > i { display: block; height: 100%; background: currentColor; }

/* ---------------------------------------------------------------- 候选抽屉
   弹出在右栏内部：右栏不滚动的那一层里绝对定位，所以列表滚到哪里都不影响它。 */
.drawer {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: var(--bg);
  border-left: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.drawer-head {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--pane-pad);
  border-bottom: 1px solid var(--line-2);
  background: var(--panel);
}
.drawer-ident { min-width: 0; }
.drawer-ident .tl-mpn { margin-right: 8px; }
.drawer-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: var(--sp-2) var(--pane-pad) var(--sp-4); }

/* ---------------------------------------------------------------- 参数面板 */
.param-panel { margin-top: var(--sp-3); }
.param-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.param-head h2, .param-head h3 { margin: 0; font-size: var(--fs-body); font-weight: 600; }
.param-head .cov { color: var(--text-3); font-size: var(--fs-note); }
.param-table { width: 100%; border-collapse: collapse; font-size: var(--fs-row); line-height: var(--lh-row); }
.param-table { table-layout: fixed; }
.param-table thead th {
  text-align: left;
  font-weight: 400;
  color: var(--text-3);
  font-size: var(--fs-note);
  border-bottom: 1px solid var(--line-2);
  padding: 6px 10px 6px 0;
}
.param-table thead th:nth-child(1) { width: 22%; }
.param-table thead th:nth-child(2) { width: 32%; }
.param-table thead th:nth-child(3) { width: 24%; }
.param-table thead th:nth-child(4) { width: 22%; }
.param-table td {
  text-align: left;
  padding: 7px 10px 7px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  word-break: break-word;
}
.param-table td.plabel { color: var(--text-2); }
.param-table td.pval { color: var(--text); }
.param-table td.pnorm { color: var(--text-2); }
.param-table td.pkey { color: var(--text-3); font-size: var(--fs-note); }
.param-table tr.missing td.pval { color: var(--c); }
.missing-badge { color: var(--c); font-size: var(--fs-note); }
.missing-note, .note-band {
  margin-top: var(--sp-2);
  padding: var(--sp-1) 0 var(--sp-1) 12px;
  border-left: 2px solid var(--c);
  color: #cdb478;
  font-size: var(--fs-row);
}
.missing-note ul, .note-band ul { margin: 4px 0 0; padding-left: 16px; }
.note-band.limit { border-color: var(--accent); color: #9dbcd8; }
.note-band b { display: block; margin-bottom: 3px; font-weight: 500; }
.note-band p { margin: 3px 0 0; }
.src-note { margin-top: var(--sp-1); color: var(--text-3); font-size: var(--fs-note); max-width: 96ch; }

/* 关键判据的数据密度：不是"我们验证过了"，而是"这个字段数据集里大多没有"。
   用一条细量表就够，颜色只表达"缺失到什么程度"。 */
.density { margin-top: var(--sp-3); border-top: 1px solid var(--line-2); padding-top: var(--sp-2); }
.density .block-head { margin-bottom: var(--sp-1); }
.density-note { margin: 0 0 var(--sp-2); color: var(--text-3); font-size: var(--fs-note); max-width: 86ch; }
.density-note b { color: var(--text-2); font-weight: 500; }
.density-list { list-style: none; margin: 0; padding: 0; }
.density-list li {
  display: grid;
  grid-template-columns: minmax(96px, 168px) 1fr 48px;
  gap: 10px;
  align-items: center;
  padding: 3px 0;
  font-size: var(--fs-row);
}
.density-label { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.density-bar { display: block; height: 2px; background: var(--panel-3); }
.density-bar > i { display: block; height: 100%; background: var(--c); }
.density-pct { text-align: right; color: var(--c); }
.density-bad .density-bar > i { background: var(--e); }
.density-bad .density-pct { color: var(--e); }

/* ---------------------------------------------------------------- 对比表 */
.cmp-sec { margin-top: var(--sp-3); border-top: 1px solid var(--line-2); padding-top: var(--sp-2); }
.cmp-sec .block-head { margin-bottom: var(--sp-1); }
.cmp-opts { display: flex; gap: var(--sp-2); }
.cmp { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cmp th, .cmp td { text-align: left; font-size: var(--fs-row); vertical-align: top; padding: 7px 12px 7px 0; border-bottom: 1px solid var(--line); line-height: var(--lh-row); word-break: break-word; }
.cmp thead th { color: var(--text-2); font-weight: 400; font-size: var(--fs-note); border-bottom: 1px solid var(--line-2); }
.cmp th.cmp-param { width: 34%; color: var(--text-2); font-weight: 400; }
.cmp-label { display: inline-block; }
.cmp-flag { float: right; margin-left: 8px; color: var(--text-3); font-size: var(--fs-note); }
.cmp-risky .cmp-flag, .cmp-risky .cmp-label { color: var(--text); }
.cmp-code { display: block; color: var(--text-3); font-size: var(--fs-note); }
.cmp-cell { color: var(--text); }
.cmp-cell.cell-dataset { color: var(--text-3); }
.cmp-cell.cell-missing, .cmp-cell.cell-none { color: var(--c); }
/* 只有风险着色：满足/有余量/更优都用中性色，否则整张表全是色，等于没有颜色 */
.cmp-cell.cmp-warn { color: var(--c); }
.cmp-cell.cmp-worse, .cmp-cell.cmp-fail { color: var(--e); }
.cmp-cell.cmp-veto { color: var(--x); }
.cmp-foot { margin: var(--sp-1) 0 0; color: var(--text-3); font-size: var(--fs-note); }

.issues-list { list-style: none; margin: var(--sp-2) 0 0; padding: 0; }
.issues-list li {
  margin-bottom: 4px;
  padding: 6px 0 6px 12px;
  border-left: 2px solid var(--line-2);
  font-size: var(--fs-row);
  color: var(--text-2);
}
.issue-veto { border-left-color: var(--e) !important; color: #d9a2a2 !important; }
.issue-gap { border-left-color: var(--c) !important; color: #cdb478 !important; }
.issue-info { border-left-color: var(--accent) !important; color: #9dbcd8 !important; }
.issue-ok { border-left-color: var(--a) !important; color: var(--text-3) !important; }

.dim { margin-top: var(--sp-2); }
.dim-head { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: baseline; font-size: var(--fs-row); }
.dim-label { font-weight: 500; }
.dim-head .w { color: var(--text-3); font-size: var(--fs-note); }
.dim-head .dim-score { font-size: 14px; font-weight: 600; }
.dim .meter { height: 3px; margin-top: 4px; }

/* ---------------------------------------------------------------- 分页 */
.pager { padding: var(--sp-2) 0 0; }
.pager-inner { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; font-size: var(--fs-row); }
.pg {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 26px; padding: 0 8px;
  border: 1px solid var(--line-2);
  color: var(--text-2);
}
.pg:hover { border-color: var(--accent); color: var(--text); text-decoration: none; }
.pg.active { background: var(--accent-dim); border-color: var(--accent); color: var(--text); }
.pg.disabled { opacity: 0.4; }
.pg.gap { border-color: transparent; }
.pg-info { margin-left: var(--sp-1); color: var(--text-3); font-size: var(--fs-note); }

/* ---------------------------------------------------------------- 折叠区 */
.reveal { margin-top: var(--sp-2); border-top: 1px solid var(--line); }
.reveal > summary {
  display: flex; align-items: baseline; gap: var(--sp-1);
  cursor: pointer; padding: var(--sp-2) 0;
  font-size: var(--fs-row); color: var(--text-2); list-style: none;
}
.reveal > summary::-webkit-details-marker { display: none; }
.reveal > summary::before { content: "▸"; color: var(--text-3); font-size: var(--fs-note); }
.reveal[open] > summary::before { content: "▾"; }
.reveal > summary:hover { color: var(--text); }
.reveal-body { padding-bottom: var(--sp-2); }
.reveal-body > *:first-child { margin-top: 0; }

/* ---------------------------------------------------------------- 通告 */
/* 固定贴底：任何一个视图里出错都能看到，且不用为它挤压版面 */
.notice-error {
  position: fixed;
  left: var(--gutter);
  right: var(--gutter);
  bottom: var(--gutter);
  z-index: 60;
  padding: 10px 14px;
  border: 1px solid var(--e);
  background: var(--panel-2);
  color: #d9a2a2;
  font-size: var(--fs-body);
  cursor: pointer;
}
.notice-error b { display: block; margin-bottom: 2px; font-weight: 500; }
.notice-error p { margin: 0; }
.notice-error pre { white-space: pre-wrap; margin: 6px 0 0; font-size: var(--fs-min); }

/* ---------------------------------------------------------------- 窄屏切换条
   只在窄屏出现：两栏并排是"横着比"，手机上做不到，改成一次看一栏。
   桌面端它是 display:none，不参与栅格，也不占地方。 */
.paneswitch {
  display: none;
  flex: 0 0 auto;
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.pane-btn {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  background: var(--panel);
  border: 0;
  color: var(--text-2);
  font: inherit;
  font-size: var(--fs-row);
  cursor: pointer;
}
.pane-btn.active { background: var(--accent-dim); color: var(--text); }
.pane-btn .num { color: var(--text); font-weight: 600; }
.pane-btn .mpn-inline { color: var(--text); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pane-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: -2px; }

/* ---------------------------------------------------------------- 响应 */

/* 平板横屏 / 小笔记本：两栏改成上下堆叠，各自仍然独立滚动 */
@media (max-width: 1100px) {
  .view-detail { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) minmax(0, 1fr); }
  .pane-left { border-right: none; border-bottom: 1px solid var(--line-2); }
  .hide-narrow { display: none; }
}

/* ================================================================= 手机
   这里不是"把桌面版缩一缩"，而是换一套交互：
     · 一次只看一栏（切换条），因为手机上两栏堆叠要划过大半屏参数才看到候选；
     · 整页一条滚动条，不再嵌套滚动（触屏上嵌套滚动很难用）；
     · 表格行变卡片，不再靠藏列来硬塞；
     · 触控目标 ≥44px，输入框 16px（小于 16px 时 iOS 会放大整页）。 */
@media (max-width: 820px) {
  html { -webkit-text-size-adjust: 100%; }
  /* 移动浏览器地址栏会伸缩，100% 会把内容切掉，dvh 跟随动态视口 */
  @supports (height: 100dvh) {
    html, body { height: 100dvh; }
  }

  /* 触屏：去掉点按高亮，保留惯性滚动 */
  * { -webkit-tap-highlight-color: transparent; }
  .view-home, .view-class, .view-detail, .drawer-body, .letters, .suggest {
    -webkit-overflow-scrolling: touch;
  }

  /* 安全区：刘海与底部手势条 */
  .appbar {
    height: 48px;
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
  }
  /* 顶栏三样东西在 390px 上会挤到"元器件替代判定"折成两行。
     做法不是砍信息，而是：标题不许折行，状态文字让位并省略号收尾。 */
  .appnav { min-width: 0; gap: 10px; }
  .wordmark { white-space: nowrap; flex: 0 0 auto; font-size: 14px; }
  .navlink { padding: 10px 0; white-space: nowrap; flex: 0 0 auto; }
  .catalog-status {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 34vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .notice-error {
    left: max(var(--gutter), env(safe-area-inset-left));
    right: max(var(--gutter), env(safe-area-inset-right));
    bottom: max(var(--gutter), env(safe-area-inset-bottom));
  }

  /* 输入框：iOS 在字号 <16px 的输入框获得焦点时会缩放整个页面 */
  input, textarea, select, .field-input input { font-size: 16px; }

  /* 触控目标：翻页与开关一律 ≥44px */
  .pg { min-width: 44px; height: 44px; padding: 0 10px; }
  .pager-inner { gap: 6px; }
  .inline-opt { min-height: 38px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
  .inline-opt input[type="checkbox"] { width: 20px; height: 20px; }
  .reveal > summary { min-height: 44px; align-items: center; }

  /* ── 首页 ── */
  .home-top { padding: 24px var(--gutter) var(--sp-3); }
  .home-title { font-size: 18px; }
  /* 搜索：输入框独占一行，按钮在下面整行——打字时看得见全宽，按钮也好按 */
  .search-row { flex-direction: column; gap: 8px; }
  .search-row .btn-primary { height: 46px; padding: 0 var(--sp-2); }
  .suggest { max-height: 46vh; overflow-y: auto; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 13px 12px 14px; }
  .tile-name { font-size: var(--fs-body); }
  .chip { padding: 9px 11px; max-width: 100%; }
  .factstrip > div { min-width: 78px; padding: 4px 12px 4px 0; margin-right: 12px; }

  /* ── 品类页：整页滚动，首字母条横向滑动 ── */
  .view-class { overflow-y: auto; }
  .class-head { padding: var(--sp-2) var(--gutter); }
  .letters {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 0 var(--gutter);
  }
  .letters::-webkit-scrollbar { display: none; }
  .letter { flex: 0 0 auto; min-width: 36px; height: 42px; font-size: var(--fs-row); }
  .scroll-body { flex: 0 0 auto; overflow: visible; min-height: 0; padding: var(--sp-2) var(--gutter) var(--sp-4); }
  .parts-table thead th, .cand-table thead th { top: 0; }

  /* ── 详情页：一次一栏 ── */
  .view-detail { display: block; overflow-y: auto; }
  .paneswitch { display: flex; }
  .pane { display: none; }
  .pane.pane-active { display: flex; }
  .pane-left { border-right: none; border-bottom: none; }
  .pane-head { padding: var(--sp-2) var(--gutter); }
  .view-detail .scroll-body { padding: var(--sp-2) var(--gutter) var(--sp-4); }
  .target-ident { gap: 6px; }
  .tl-mpn { font-size: 17px; }
  /* 切换条上已经写着「原器件 STM32F103C8T6」，栏内标题再写一次"原器件"就是重复。
     只藏这个标签，型号和料号号（切换条上没有的）照旧显示。 */
  .pane-left .pane-label { display: none; }

  /* 候选抽屉：手机上铺满全屏，而不是嵌在右栏里 */
  .drawer {
    position: fixed;
    inset: 0;
    z-index: 50;
    border-left: none;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .drawer-head { padding: var(--sp-2) var(--gutter); align-items: center; }
  .drawer-body { padding: var(--sp-2) var(--gutter) var(--sp-4); }
  #closeDrawer { min-width: 44px; min-height: 44px; }

  /* 对比表：窄屏不横向滚动（那会让人以为"第三列不见了"），
     改成压缩参数列宽 + 允许换行，三列始终都在。 */
  .cmp th, .cmp td { padding: 7px 8px 7px 0; font-size: var(--fs-note); }
  .cmp th.cmp-param { width: 30%; }
  .cmp-flag { float: none; display: block; margin: 0; }
  .density-list li { grid-template-columns: minmax(72px, 38%) 1fr 40px; gap: 8px; font-size: var(--fs-note); }
  .density-note, .src-note { max-width: none; }
  .missing-note, .note-band { padding-left: 10px; }
}

/* 手机竖屏：表格行改卡片。
   藏列能把表格塞进 390px，但那是"少给你信息"，不是适配；
   卡片能同时保住 型号/厂商/库存/结论/评分。 */
@media (max-width: 620px) {
  /* 注意选择器权重：`.parts-table tr` 是 0-1-1，比单独一个 `.part-row`（0-1-0）高，
     所以行必须写成 `tr.part-row` 才能拿回 grid 布局——否则行是 block、
     下面的 grid-area 全部失效，卡片就变成"每个单元格竖着堆一列"。 */
  .parts-table, .parts-table tbody, .parts-table td,
  .cand-table, .cand-table tbody, .cand-table td { display: block; }
  .parts-table colgroup, .parts-table thead,
  .cand-table colgroup, .cand-table thead { display: none; }

  /* 卡片模式下把"厂商"放回来：它比单价有用，也不占额外一行 */
  .part-row td.hide-narrow { display: block; }

  .parts-table tr.part-row {
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 2px;
    padding: 11px 0 11px;
    border-bottom: 1px solid var(--line);
  }
  .part-row td { padding: 0; }
  /* 桌面版给序号定了 width:56px（表格里够用），在 32px 的网格列里它会溢出，
     右对齐后数字正好落到型号文字底下——看起来就是"序号不见了"。 */
  .part-row .idx { grid-area: 1 / 1 / 3 / 2; width: auto; color: var(--text-3); }
  .part-row td:nth-child(2) { grid-area: 1 / 2 / 2 / 3; }
  .part-row td:nth-child(3) { grid-area: 2 / 2 / 3 / 3; color: var(--text-3); font-size: var(--fs-note); }
  .part-row td:nth-child(4), .part-row td:nth-child(6) { display: none; } /* 封装 / 单价：手机上省掉 */
  .part-row td:nth-child(5) { grid-area: 1 / 3 / 2 / 4; text-align: right; color: var(--text-2); }

  .cand-table tr.cand-row {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    grid-template-rows: auto auto;
    column-gap: 10px;
    row-gap: 3px;
    padding: 11px 10px 12px;
    border-bottom: 1px solid var(--line);
    border-left: 2px solid transparent;
  }
  .cand-row td { padding: 0; }
  .cand-row td.cell-grade { grid-area: 1 / 1 / 3 / 2; padding-left: 0; border-left: none; align-self: start; padding-top: 1px; }
  .cand-row td.cell-id { grid-area: 1 / 2 / 2 / 3; }
  /* 库存 / 单价这两个单元格在标记里没有类名（只有 ta-r num），所以按列序号定位。
     之前写成 td.cell-stock / td.cell-price，选择器永远不匹配 —— 结果"手机上隐藏单价"
     根本没生效，价格单元格还会掉进网格自动布局里。CSS 死规则审计把这条抓出来了。 */
  .cand-row td:nth-child(4) { grid-area: 2 / 2 / 3 / 3; text-align: left; color: var(--text-3); font-size: var(--fs-note); }
  .cand-row td:nth-child(5) { display: none; }
  .cand-row td.cell-verdict { grid-area: 2 / 3 / 3 / 4; text-align: right; font-size: var(--fs-note); }
  .cand-row td.score { grid-area: 1 / 3 / 2 / 4; }
  /* 卡片里允许换行：桌面端的单行省略号在窄屏会把厂商和警告都吃掉 */
  .cell-sub { white-space: normal; }
  /* 等级色带从"单元格左边框"改成"整张卡片左边框"，卡片模式下才看得见 */
  .tone-a { border-left-color: var(--a); }
  .tone-b { border-left-color: var(--b); }
  .tone-c { border-left-color: var(--c); }
  .tone-d { border-left-color: var(--d); }
  .tone-e { border-left-color: var(--e); }
  .tone-x { border-left-color: var(--x); }
  .parts-table thead th, .cand-table thead th { position: static; }
}

/* 更窄（小屏手机）：再收一档内边距，保证 320px 也不横向溢出 */
@media (max-width: 380px) {
  :root { --gutter: 10px; --pane-pad: 10px; }
  .tiles { grid-template-columns: minmax(0, 1fr); }
  .home-title { font-size: 17px; }
  .pane-btn { font-size: var(--fs-note); }
}

/* 触屏设备：hover 会"卡住"在最后点过的那一行上。改成点按反馈。 */
@media (hover: none) {
  .cand-row:hover, .part-row:hover, .tile:hover, .chip:hover, .letter:hover, .pg:hover { background: none; }
  .cand-row:active, .part-row:active, .tile:active, .pg:active { background: var(--panel-2); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
