/* ===== GlycoCalc 样式（独立一份；色板与科研导航站、MassCalc、Grapher 完全一致） =====
   本页主角是「表格里的输入框 + 一长串精确质量」：
   ① 数字一律 tabular-nums，否则 5 位小数逐行对不齐，眼睛没法在两列之间找差值；
   ② 表格要能横向滚动（列分组固定要 8~10 列），表头吸顶；
   ③ 输入框就在格子里，聚焦态必须明显，用户才知道自己在改哪一行。 */
:root {
  --bg: #f5f6f8;
  --bg-card: #ffffff;
  --bg-hover: #f0f2f5;
  --text: #2c3e50;
  --text-sub: #7f8c9b;
  --border: #e8ebef;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, .1);
  --accent-text: #fff;
  --danger: #e2544d;
  --ok: #2f9e5f;
  --shadow: 0 2px 8px rgba(30, 40, 60, .06);
  --bar-bg: #f7f8fa;
  --code-bg: #f4f6f9;
  --tag-bg: #eef2f7;
  --group-line: #dfe5ec;
}

html[data-theme="dark"] {
  --bg: #060a17;
  --bg-card: #0d1424;
  --bg-hover: #1a2336;
  --text: #dce3ec;
  --text-sub: #8794a8;
  --border: #1e2a44;
  --accent: #4d94ff;
  --accent-soft: rgba(77, 148, 255, .16);
  --danger: #ff6b64;
  --ok: #4ade80;
  --shadow: 0 2px 10px rgba(0, 0, 0, .5);
  --bar-bg: #0a1120;
  --code-bg: #101a30;
  --tag-bg: #16213a;
  --group-line: #24334f;
}

* { 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", "Noto Sans CJK SC", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  transition: background .25s, color .25s;
}

/* ===== 顶栏 ===== */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 18px; background: var(--bar-bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar .back { color: var(--accent); text-decoration: none; font-size: 14px; white-space: nowrap; }
.topbar .back:hover { text-decoration: underline; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; flex: none; }
.brand-mark img { width: 26px; height: 26px; }
.brand-text h1 { font-size: 17px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text p { font-size: 12px; color: var(--text-sub); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }
.icon-btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--bg-hover); }
.lang-switch { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.lang-btn {
  border: none; background: var(--bg-card); color: var(--text-sub);
  padding: 6px 10px; font-size: 13px; cursor: pointer; text-decoration: none;
}
.lang-btn + .lang-btn { border-left: 1px solid var(--border); }
.lang-btn.active { background: var(--accent); color: var(--accent-text); }

/* ===== 面板 ===== */
.glyco { max-width: 1240px; margin: 0 auto; padding: 14px 16px 4px; }
.panel {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 16px; box-shadow: var(--shadow); margin-bottom: 14px;
}
/* 面板头：标题靠左、操作靠右，窄屏自动换行（不让按钮把标题挤没） */
.sec-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 10px; }
.sec-head h2 { font-size: 16px; margin-right: auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn {
  border: 1px solid var(--border); background: var(--bg-card); color: var(--text);
  border-radius: 8px; padding: 6px 13px; cursor: pointer; font-size: 13.5px;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn-sm { padding: 3px 9px; font-size: 12px; border-radius: 6px; }
/* 「送进表三」的选中态：不加高亮就看不出哪几行进表三，而表三列数正是由它决定的 */
.btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ===== 表格 ===== */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th, table.data td { padding: 5px 9px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
table.data th {
  background: var(--bar-bg); color: var(--text-sub); font-weight: 600; font-size: 12px;
  position: sticky; top: 0; z-index: 1;
}
table.data th.left, table.data td.left, table.data td.glyco-name { text-align: left; white-space: normal; min-width: 148px; }
table.data td.center, table.data th.center { text-align: center; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-hover); }
/* 列分组分隔线：未衍生 / 全甲基化、离子表里「每个 M 一列」都靠它读出边界 */
table.data th.g, table.data td.g { border-left: 1px solid var(--group-line); }
table.data tr.sum td { font-weight: 600; border-top: 1px solid var(--border); background: var(--code-bg); }
table.data td.mf, table.data .mono { font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
table.data sub, table.data sup { font-size: .78em; line-height: 0; }
/* 「正离子模式 / 负离子模式」分组行：整行跨列，只做视觉分段，不参与 hover 高亮 */
table.data tr.mode-head td {
  background: var(--bar-bg); color: var(--text-sub); font-weight: 600; font-size: 12px;
  text-align: left; letter-spacing: .02em; position: sticky; top: 27px; z-index: 1;
}
/* 与 NIST 原表数字不一致的离子行：左侧一条橙线，核对时一眼定位到那几行 */
table.data tr.nist-diff td:first-child { box-shadow: inset 2px 0 0 var(--danger); }
table.data td.empty { text-align: center; color: var(--text-sub); padding: 18px 10px; white-space: normal; }
table.data td.bad, .warn { color: var(--danger); }
table.data td.good { color: var(--ok); }

/* 格子里的输入框：宽度按最长值（四位数残基 / 七位小数质量）留够，不能挤到换行 */
table.data input.count, .ion-filter input.count {
  width: 78px; text-align: right; font: inherit; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 7px; padding: 4px 7px;
}
table.data input.count.tiny { width: 52px; padding: 3px 5px; }
table.data input.count:focus, .ion-filter input.count:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
table.data td.cell-input { text-align: center; }
table.data td.comp-cell { white-space: normal; text-align: left; }
.comp-inputs { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.comp-inputs label { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; color: var(--text-sub); }

/* ===== 筛选条与已选糖型 ===== */
.ion-filter { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.ion-filter label { display: inline-flex; align-items: center; gap: 5px; }
.ion-filter input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }
.ion-filter .field { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; font-size: 12px; color: var(--text-sub); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 6px 3px 11px;
  background: var(--accent-soft); color: var(--accent); border-radius: 999px; font-size: 12.5px;
}
.chip-x { border: none; background: transparent; color: inherit; cursor: pointer; font-size: 14px; line-height: 1;
  /* 触屏上 14px 的关闭点几乎按不准，把命中区撑到 22px，视觉上仍是一枚小叉 */
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; }
.chip-x:hover { background: var(--accent); color: var(--accent-text); }

/* ===== 说明文字 / 常量折叠 ===== */
.hint { font-size: 12.5px; color: var(--text-sub); margin: 8px 0 0; }
.legend { font-size: 12.5px; color: var(--text-sub); margin-top: 6px; }
.note { font-size: 12px; color: var(--text-sub); margin-top: 8px; }
.tag-ext {
  display: inline-block; font-size: 10.5px; color: var(--text-sub); background: var(--tag-bg);
  border-radius: 4px; padding: 0 5px; margin-left: 4px; vertical-align: 1px;
}
details summary { cursor: pointer; font-size: 16px; font-weight: 600; }
details[open] summary { margin-bottom: 10px; }
details .table-wrap { margin-top: 0; }

/* ===== 说明区（SEO 主体） ===== */
.doc { max-width: 1240px; margin: 10px auto 40px; padding: 18px 20px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.doc h2 { font-size: 16px; margin: 18px 0 6px; }
.doc h2:first-child { margin-top: 0; }
.doc p { font-size: 14px; margin-bottom: 8px; }
.doc ul, .doc ol { margin: 0 0 8px 20px; font-size: 14px; }
.doc li { margin-bottom: 5px; }
.doc dl.faq dt { font-weight: 600; font-size: 14px; margin-top: 10px; }
.doc dl.faq dd { font-size: 14px; color: var(--text-sub); margin-left: 0; }
.doc .rel-links { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.doc .rel-links a {
  display: inline-block; padding: 4px 12px; background: var(--tag-bg);
  border-radius: 999px; color: var(--accent); text-decoration: none; font-size: 13px;
}
.doc .rel-links a:hover { background: var(--accent-soft); text-decoration: none; }
.doc .ver { font-size: 12px; color: var(--text-sub); border-top: 1px solid var(--border); padding-top: 10px; margin-top: 14px; }

/* ===== Toast ===== */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(12px);
  background: var(--text); color: var(--bg-card); padding: 8px 18px; border-radius: 999px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 720px) {
  /* 顶栏一行装不下（返回链接 + 品牌 + 登录位 + 主题 + 三语）：nowrap 会把语言按钮顶出屏幕，
     这里改成两行并收起副标题 */
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar .back { font-size: 13px; }
  .brand { flex: 1 1 auto; }
  .brand-text p { display: none; }
  .spacer { display: none; }
  .glyco { padding: 10px 10px 0; }
  .panel { padding: 12px; }
  .sec-head h2 { font-size: 15px; }
  .ion-filter .field { margin-left: 0; }
  table.data th, table.data td { padding: 4px 7px; }
  table.data td.glyco-name { min-width: 116px; }
  /* 分组行原本吸顶，窄屏下面板更挤，取消吸顶避免盖住表头 */
  table.data tr.mode-head td { position: static; }
}
