/* =====================================================================
   CalcMate — 全站样式（唯一一份 CSS）。

   设计语言照 imgkit 抄：stone-50 页底、白卡片、zinc 边框、neutral 文字、
   indigo-600 主色（#4f39f6，Tailwind v4 的值）、12/20 圆角、两层浅阴影、
   系统字体。浅色/深色两套 token（暗色跟系统，顶栏可切）。
   版式骨架照 calculator.net：正文 728 + 右栏 336 的双栏，右栏自上而下是
   广告位 → 搜索框 → 同类计算器列表；移动端单栏、广告落后。

   零外部依赖：不加载任何第三方字体、图标或脚本。
   ===================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  --page:          #fafaf9;   /* stone-50 整页底色 */
  --bg:            #ffffff;
  --bg-elevated:   #ffffff;
  --bg-sunken:     #f5f5f4;
  --bg-hover:      #f5f5f4;

  --heading:       #171717;
  --text:          #404040;
  --text-muted:    #525252;
  --text-faint:    #737373;

  --border:        #e4e4e7;
  --border-strong: #d4d4d8;

  --accent:        #4f39f6;
  --accent-hover:  #432dd7;
  --accent-soft:   #eef2ff;

  --ok:            #16a34a;
  --ok-soft:       #dcfce7;
  --warn:          #d97706;
  --warn-soft:     #fef3c7;
  --err:           #dc2626;
  --err-soft:      #fee2e2;

  /* 图表六色：主色开头，其余取可分辨色相；深浅两套值，SVG 里只认变量 */
  --ch1: #4f39f6; --ch2: #0d9488; --ch3: #d97706;
  --ch4: #e11d48; --ch5: #7c3aed; --ch6: #64748b;

  --radius:        12px;
  --radius-card:   20px;
  --radius-sm:     8px;
  --radius-pill:   99px;
  --shadow:        0 1px 3px rgba(0,0,0,.10), 0 1px 2px -1px rgba(0,0,0,.10);
  --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.10), 0 4px 6px -4px rgba(0,0,0,.10);

  --nav-h: 60px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
          "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0a0a0a; --bg: #171717; --bg-elevated: #171717;
    --bg-sunken: #262626; --bg-hover: #262626;
    --heading: #f5f5f5; --text: #d4d4d4; --text-muted: #a3a3a3; --text-faint: #737373;
    --border: #2e2e2e; --border-strong: #404040;
    --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #1e1b4b;
    --ok: #4ade80; --ok-soft: #052e16; --warn: #fbbf24; --warn-soft: #451a03;
    --err: #f87171; --err-soft: #450a0a;
    --ch1: #818cf8; --ch2: #2dd4bf; --ch3: #fbbf24;
    --ch4: #fb7185; --ch5: #a78bfa; --ch6: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px -1px rgba(0,0,0,.5);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.5);
  }
}
:root[data-theme="dark"] {
  --page: #0a0a0a; --bg: #171717; --bg-elevated: #171717;
  --bg-sunken: #262626; --bg-hover: #262626;
  --heading: #f5f5f5; --text: #d4d4d4; --text-muted: #a3a3a3; --text-faint: #737373;
  --border: #2e2e2e; --border-strong: #404040;
  --accent: #818cf8; --accent-hover: #a5b4fc; --accent-soft: #1e1b4b;
  --ok: #4ade80; --ok-soft: #052e16; --warn: #fbbf24; --warn-soft: #451a03;
  --err: #f87171; --err-soft: #450a0a;
  --ch1: #818cf8; --ch2: #2dd4bf; --ch3: #fbbf24;
  --ch4: #fb7185; --ch5: #a78bfa; --ch6: #94a3b8;
  --shadow: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px -1px rgba(0,0,0,.5);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.5);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 好几处同时挂了 flex，必须 !important */
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; background: var(--page); overflow-x: clip; }
body {
  margin: 0; background: none; color: var(--text);
  font-family: var(--sans); font-size: 16px; line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }
h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; line-height: 1.25; letter-spacing: -.02em; color: var(--heading); }
p { margin: 0 0 1em; }
code, kbd, var { font-family: var(--mono); }
kbd {
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 4px; padding: .08em .38em; font-size: .8em;
}
::selection { background: var(--accent-soft); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
img, svg { max-width: 100%; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip: rect(0 0 0 0); overflow: hidden; white-space: nowrap;
}
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.mono { font-family: var(--mono); font-size: .92em; }

/* =====================================================================
   顶栏（构建时生成静态 HTML；nav.js 只做交互）
   ===================================================================== */
.cmnav {
  position: sticky; top: 0; z-index: 60;
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.cmnav-in {
  max-width: 1200px; margin: 0 auto; padding: 0 24px;
  height: var(--nav-h); display: flex; align-items: center; gap: 6px;
}
.cmnav-brand {
  display: flex; align-items: center; gap: 9px; margin-right: 14px;
  color: var(--heading); font-weight: 800; font-size: 17.5px; letter-spacing: -.02em;
  flex: none;
}
.cmnav-brand:hover { color: var(--heading); }
.cmnav-brand svg { width: 25px; height: 25px; color: var(--accent); flex: none; }
.cmnav-menu { display: flex; align-items: center; height: 100%; }
.cmnav-wrap { position: relative; height: 100%; }
.cmnav-btn {
  height: 100%; padding: 0 13px; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; position: relative;
}
.cmnav-btn:hover { color: var(--accent); }
.cmnav-btn svg { width: 14px; height: 14px; opacity: .7; transition: transform .15s; }
.cmnav-wrap.open .cmnav-btn { color: var(--accent); }
.cmnav-wrap.open .cmnav-btn svg { transform: rotate(180deg); }
.cmnav-btn::after {
  content: ""; position: absolute; left: 13px; right: 13px; bottom: 0; height: 2px;
  background: var(--accent); border-radius: 2px 2px 0 0; opacity: 0;
}
.cmnav-wrap.open .cmnav-btn::after,
.cmnav-btn.on::after { opacity: 1; }
.cmnav-btn.on { color: var(--accent); }
/* 悬停桥：从按钮斜着挪进面板的十来个像素里别让面板断 */
.cmnav-wrap::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 12px; }

.cmnav-drop {
  position: absolute; top: 100%; left: 0; min-width: 296px; padding: 10px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); display: none;
}
.cmnav-wrap.open > .cmnav-drop { display: block; }
@media (hover: hover) {
  .cmnav-wrap:hover > .cmnav-drop:not(.cmnav-mega) { display: block; }
}
.nd-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
  padding: 8px 11px; border-radius: 9px; color: var(--text); font-size: 14px;
}
.nd-item:hover { background: var(--accent-soft); color: var(--accent); }
.nd-item b { font-weight: 600; }
.nd-vol { font-size: 11.5px; color: var(--text-faint); flex: none; }
.nd-all {
  display: block; margin-top: 6px; padding: 9px 11px;
  border-top: 1px solid var(--border); color: var(--accent); font-size: 13.5px; font-weight: 600;
}
/* mega 面板：固定居中于视口（挂在按钮上会向左溢出视口）；9 列自适应；
   点击开合、不参与悬停开（面板不在按钮正下方，悬停路径接不上）。
   打开态的 display:grid 必须比上面 .cmnav-drop 的 display:block 优先级同级且靠后。 */
.cmnav-wrap.open > .cmnav-mega { display: grid; }
.cmnav-mega {
  position: fixed; top: var(--nav-h, 64px); left: 50%; transform: translateX(-50%);
  width: min(980px, calc(100vw - 48px));
  max-height: calc(100vh - var(--nav-h, 64px) - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  grid-template-columns: repeat(auto-fit, minmax(168px, 1fr));
  gap: 4px 10px; padding: 16px;
}
.cmnav-mega .mega-col { padding: 6px 6px 10px; }
.cmnav-mega .mega-head {
  font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-faint); padding: 4px 11px 6px; display: flex; align-items: center; gap: 7px;
}
.cmnav-mega .mega-head i { width: 7px; height: 7px; border-radius: 50%; background: var(--tile, var(--text-faint)); flex: none; }
.cmnav-mega .nd-item { padding: 6.5px 11px; font-size: 13.5px; }

.cmnav-acts { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.cmnav-search {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text-muted);
  border-radius: 10px; padding: 7px 12px; font: inherit; font-size: 13.5px;
}
.cmnav-search:hover { border-color: var(--accent); color: var(--accent); }
.cmnav-search svg { width: 15px; height: 15px; }
.cmnav-search kbd { font-size: 11px; }
.cmnav-icon {
  width: 38px; height: 38px; border: 0; border-radius: 10px; cursor: pointer;
  background: none; color: var(--text-muted); display: grid; place-items: center;
}
.cmnav-icon:hover { background: var(--bg-hover); color: var(--heading); }
.cmnav-icon svg { width: 19px; height: 19px; }
.cmnav-burger { display: none; }

/* 移动抽屉 */
.cmnav-drawer {
  position: fixed; top: var(--nav-h); left: 0; right: 0; bottom: 0; z-index: 59;
  background: var(--bg-elevated); border-top: 1px solid var(--border);
  overflow: auto; padding: 14px 18px 40px;
}
.cmnav-drawer .dr-sec { border-bottom: 1px solid var(--border); }
.cmnav-drawer .dr-head {
  width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  font: inherit; font-size: 15px; font-weight: 700; color: var(--heading);
  padding: 13px 2px; display: flex; align-items: center; gap: 9px;
}
.cmnav-drawer .dr-head i { width: 8px; height: 8px; border-radius: 50%; background: var(--tile, var(--text-faint)); }
.cmnav-drawer .dr-head svg { width: 15px; height: 15px; margin-left: auto; opacity: .55; transition: transform .15s; }
.cmnav-drawer .dr-sec.open .dr-head svg { transform: rotate(180deg); }
.cmnav-drawer .dr-list { display: none; padding: 0 0 10px; }
.cmnav-drawer .dr-sec.open .dr-list { display: block; }
.cmnav-drawer .dr-list a {
  display: block; padding: 7px 2px 7px 17px; color: var(--text); font-size: 14px;
}
.cmnav-drawer .dr-list a:hover { color: var(--accent); }
.cmnav-drawer .dr-about { display: flex; gap: 18px; padding: 15px 2px; flex-wrap: wrap; }
.cmnav-drawer .dr-about a { color: var(--text-muted); font-size: 13.5px; }

/* =====================================================================
   页面骨架
   ===================================================================== */
.page { padding: 26px 0 10px; }
.crumbs { font-size: 13.5px; color: var(--text-faint); margin-bottom: 14px; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { margin: 0 7px; opacity: .6; }

.cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 34px; }
@media (min-width: 1080px) {
  .cols { grid-template-columns: minmax(0, 1fr) 336px; }
}
.rail { min-width: 0; }
@media (max-width: 1079px) {
  .rail .adslot--rail, .rail .rail-search { display: none; }   /* 广告与搜索框不上移动端 */
}

/* H1：图标由模板内联（分类色） */
.h1row { display: flex; align-items: center; gap: 13px; margin: 2px 0 6px; }
.h1row .h1ic { flex: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--tile, var(--accent)); }
.h1row .h1ic svg { width: 36px; height: 36px; }
.h1row h1 { margin: 0; font-size: clamp(26px, 3.4vw, 34px); }
.h1sub { color: var(--text-muted); font-size: 16.5px; margin: 0 0 20px; max-width: 62ch; }

/* =====================================================================
   计算器卡片：左输入 / 右结果（≥680px 双栏，移动端上下摞）
   ===================================================================== */
.calc-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-card); box-shadow: var(--shadow);
  padding: 24px; margin: 0 0 30px;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px;
  scroll-margin-top: calc(var(--nav-h) + 12px);
}
@media (min-width: 700px) {
  .calc-card { grid-template-columns: minmax(0, 46fr) minmax(0, 54fr); gap: 28px; padding: 26px 28px; }
}

/* ---------- 输入 ---------- */
.calc-form { min-width: 0; }
.field { margin-bottom: 15px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.fl {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 13.5px; font-weight: 600; color: var(--text-muted); margin-bottom: 6px;
}
.fl-u { font-weight: 500; color: var(--text-faint); font-size: 12.5px; }
.field input[type="number"],
.field input[type="text"],
.field input[type="date"],
.field textarea,
.field select {
  width: 100%; font: inherit; font-size: 15.5px; color: var(--heading);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.field textarea { resize: vertical; min-height: 84px; font-family: var(--mono); font-size: 14px; line-height: 1.7; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.fhint { margin: 6px 0 0; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }

.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1 1 auto; accent-color: var(--accent); min-width: 0; }
.range-row .range-num { flex: 0 0 5.4em; text-align: right; }

.radio-row { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.radio-opt { display: inline-flex; align-items: center; gap: 7px; font-size: 14.5px; color: var(--text); cursor: pointer; }
.radio-opt input { accent-color: var(--accent); }

.tabs-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tab {
  flex: 1 1 0; min-width: 96px; font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 9px 10px; cursor: pointer; color: var(--text);
  background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: 10px;
}
.tab:hover { border-color: var(--accent); color: var(--accent); }
.tab[aria-pressed="true"] {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
}

.check-row { display: flex; align-items: flex-start; gap: 9px; font-size: 14.5px; cursor: pointer; color: var(--text); }
.check-row input { accent-color: var(--accent); margin-top: 3px; }
.check-row .fl-t { font-weight: 400; }

.height-imperial { display: flex; align-items: center; gap: 8px; }
.height-imperial input { width: 5.5em; }
.hsep { color: var(--text-faint); font-size: 13.5px; }

.unitswitch { display: inline-flex; gap: 4px; padding: 3px; border-radius: 10px; background: var(--bg-sunken); margin-bottom: 18px; }

/* custom 页面的动作按钮（random 的 Generate again 等） */
.form-actions { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
/* 大于 4 个动作（计算器键盘）→ 等宽网格，按键小块排列 */
.form-actions--grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); gap: 6px; }
.form-actions--grid .calc-action { justify-content: center; padding: 10px 4px; font-size: 14px; }

/* 实时汇率按钮（currency 页；仅构建配置了 FX_API_URL 时出现） */
.live-rates { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.live-rates .lr-btn {
  font: inherit; font-size: 13.5px; font-weight: 600; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text);
  border-radius: var(--radius-pill); padding: 7px 14px;
}
.live-rates .lr-btn:hover { border-color: var(--accent); color: var(--accent); }
.live-rates .lr-btn:disabled { opacity: .6; cursor: default; }
.live-rates .lr-msg { font-size: 12.5px; color: var(--text-faint); }
.live-rates .lr-msg.ok { color: var(--accent); }
.calc-action {
  font: inherit; font-size: 14.5px; font-weight: 600; cursor: pointer;
  padding: 10px 18px; border-radius: 10px; display: inline-flex; align-items: center; gap: 8px;
  background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border-strong);
  transition: border-color .12s, color .12s;
}
.calc-action:hover { border-color: var(--accent); color: var(--accent); }
.calc-action.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.calc-action.primary:hover { background: var(--accent-hover); color: #fff; }
.us-btn {
  font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; border: 0;
  padding: 6px 13px; border-radius: 8px; background: none; color: var(--text-muted);
}
.us-btn[aria-pressed="true"] { background: var(--bg-elevated); color: var(--accent); box-shadow: var(--shadow); }

/* ---------- 结果面板 ---------- */
.calc-result {
  min-width: 0; background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px 20px 16px;
  align-self: start;
}
.r-head { display: flex; align-items: flex-start; gap: 12px; }
.r-headline { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; gap: 14px 28px; }
.rh-item { min-width: 0; }
.rh-l { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-muted); letter-spacing: .01em; }
.rh-v { display: block; font-size: 21px; font-weight: 700; color: var(--heading); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.rh-item.primary .rh-v { font-size: 31px; font-weight: 800; color: var(--accent); }
.rh-sub { display: block; font-size: 12.5px; color: var(--text-faint); margin-top: 2px; }

.copybtn {
  flex: none; font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer;
  color: var(--text-muted); background: var(--bg-elevated);
  border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 11px;
}
.copybtn:hover { border-color: var(--accent); color: var(--accent); }
.copybtn.ok { color: var(--ok); border-color: var(--ok); }

.r-rows { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 12px; }
.r-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 5.5px 0; font-size: 14.5px;
}
.rr-l { color: var(--text-muted); min-width: 0; }
.rr-sub { color: var(--text-faint); font-size: 12.5px; }
/* 值默认不折行（数字拆行很难看），但允许在字间任意断行：
   科学计数法的 309 位十进制、线规的代入长文本这类病理长串如果没有断点，
   会把整页顶出横向滚动条（全站审计实测抓到 4 页）。 */
.rr-v { font-weight: 600; color: var(--heading); font-variant-numeric: tabular-nums;
        overflow-wrap: anywhere; min-width: 0; text-align: right; }
.r-row { flex-wrap: wrap; }
.rr-l { flex: 1 1 auto; }
.rr-v { flex: 0 1 auto; }

.r-note { margin: 14px 0 0; font-size: 13px; color: var(--text-faint); line-height: 1.6; }

.rerror {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--err-soft); color: var(--err); border-radius: var(--radius-sm);
  padding: 12px 14px; font-size: 14.5px; font-weight: 500;
}
.rerror .re-i { font-size: 15px; line-height: 1.4; }

/* 表格 */
.r-table { margin-top: 16px; border-top: 1px solid var(--border); }
details.r-table > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 9px;
  padding: 12px 0 10px; font-size: 14px; font-weight: 700; color: var(--heading);
}
details.r-table > summary::-webkit-details-marker { display: none; }
details.r-table > summary::before {
  content: ""; width: 16px; height: 16px; flex: none;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6l6 6-6 6' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6l6 6-6 6' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform .15s;
  color: var(--text-faint);
}
details.r-table[open] > summary::before { transform: rotate(90deg); }
.r-table .rt-head { display: flex; align-items: center; gap: 9px; padding: 12px 0 10px; font-size: 14px; font-weight: 700; color: var(--heading); }
.rt-n { font-size: 12px; font-weight: 500; color: var(--text-faint); }
.rt-wrap { max-height: 380px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-elevated); }
.rt-wrap table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.rt-wrap th {
  position: sticky; top: 0; background: var(--bg-elevated); text-align: left;
  font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: .02em;
  padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.rt-wrap td { padding: 7.5px 12px; border-bottom: 1px solid var(--border); color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rt-wrap tr:last-child td { border-bottom: 0; }
.rt-wrap tbody tr:hover td { background: var(--bg-sunken); }

/* 图表 */
.r-chart { margin: 18px 0 0; border-top: 1px solid var(--border); padding-top: 12px; }
.r-chart figcaption { font-size: 14px; font-weight: 700; color: var(--heading); margin-bottom: 12px; }
.chart-pie { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.chart-pie svg { width: 168px; height: 168px; flex: none; }
.legend { flex: 1 1 180px; min-width: 0; }
.lg-item { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; font-size: 13.5px; }
.lg-item i { width: 10px; height: 10px; border-radius: 3px; flex: none; align-self: center; }
.lg-l { color: var(--text-muted); min-width: 0; }
.lg-v { margin-left: auto; font-weight: 600; color: var(--heading); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lg-p { font-weight: 500; color: var(--text-faint); }
.legend-row .lg-item { flex: 0 0 auto; }
.legend-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 8px; }

.chart-bars .bar-row { display: flex; align-items: center; gap: 10px; padding: 4.5px 0; font-size: 13.5px; }
.b-l { flex: 0 0 34%; color: var(--text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-track { flex: 1 1 auto; height: 9px; border-radius: 99px; background: var(--border); overflow: hidden; }
.b-track i { display: block; height: 100%; border-radius: 99px; }
.b-v { flex: 0 0 auto; font-weight: 600; color: var(--heading); font-variant-numeric: tabular-nums; }
.chart-line { width: 100%; height: auto; }
.ch-grid { stroke: var(--border); stroke-width: 1; }
.ch-ax { fill: var(--text-faint); font-size: 11px; font-family: var(--sans); }

/* =====================================================================
   正文内容区（H2 各节）
   ===================================================================== */
.prose { min-width: 0; }
.prose h2 { font-size: 23px; margin: 42px 0 14px; }
.prose h3 { font-size: 17px; margin: 26px 0 10px; }
.prose p { font-size: 16px; line-height: 1.75; color: var(--text); max-width: 72ch; }
.prose ul, .prose ol { padding-left: 22px; margin: 0 0 1em; }
.prose li { margin-bottom: 6px; max-width: 68ch; }
.prose b, .prose strong { color: var(--heading); }

/* KaTeX 构建期渲染块（.formula 内的 .fmath；需要 katex.min.css） */
.formula .fmath { text-align: center; overflow-x: auto; padding: 2px 0 4px; }
.formula .fmath .katex-display { margin: 0; }
.formula .fmath .katex { font-size: 1.3em; }
.formula {
  background: var(--bg-sunken); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); padding: 15px 18px; margin: 14px 0;
  font-family: var(--mono); font-size: 14.5px; line-height: 1.9; color: var(--heading);
  overflow-x: auto;
}
.formula .fnote {
  display: block; font-family: var(--sans); font-size: 13.5px; color: var(--text-muted);
  margin-top: 8px; line-height: 1.65;
}
.worked {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 15px 18px; margin: 12px 0;
}
.worked p { margin: 0; font-size: 15px; }
.worked b { color: var(--accent); font-variant-numeric: tabular-nums; }

/* 输出解释：定义表 */
.outkeys { border-top: 1px solid var(--border); margin-top: 10px; }
.outkeys .ok-row { display: grid; grid-template-columns: minmax(140px, 250px) minmax(0, 1fr); gap: 6px 24px; padding: 12px 2px; border-bottom: 1px solid var(--border); }
.outkeys dt { font-weight: 700; color: var(--heading); font-size: 15px; margin: 0; }
.outkeys dd { margin: 0; color: var(--text-muted); font-size: 15px; }

/* FAQ */
.faq { margin-top: 10px; }
.faq details {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--bg-elevated); margin-bottom: 10px; overflow: hidden;
}
.faq summary {
  list-style: none; cursor: pointer; padding: 14px 18px;
  font-size: 15.5px; font-weight: 600; color: var(--heading);
  display: flex; align-items: center; gap: 12px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+"; margin-left: auto; font-size: 20px; font-weight: 400; color: var(--text-faint);
  transition: transform .15s; flex: none;
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq .fa-body { padding: 0 18px 15px; color: var(--text-muted); font-size: 15px; }
.faq .fa-body p { margin: 0; max-width: 68ch; }
.faq .fa-body p + p { margin-top: .6em; }

/* =====================================================================
   卡片网格（首页/分类页/相关推荐共用）
   ===================================================================== */
.sec-head { display: flex; align-items: baseline; gap: 12px; margin: 44px 0 16px; }
.sec-head h2 { margin: 0; font-size: 21px; display: flex; align-items: center; gap: 10px; }
.sec-head .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--tile, var(--accent)); flex: none; }
.sec-head .n { font-size: 13.5px; font-weight: 500; color: var(--text-faint); }
.sec-head .more { margin-left: auto; font-size: 13.5px; font-weight: 600; white-space: nowrap; }

.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }
.card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 16px; padding: 17px 17px 15px; color: inherit;
  transition: box-shadow .16s, transform .16s, border-color .16s;
}
.card:hover { text-decoration: none; color: inherit; box-shadow: var(--shadow-lg); transform: translateY(-2px); border-color: var(--border-strong); }
.card .c-top { display: flex; align-items: center; gap: 10px; }
.card .c-ic { flex: none; width: 30px; height: 30px; display: grid; place-items: center; color: var(--tile, var(--accent)); }
.card .c-ic svg { width: 26px; height: 26px; display: block; }
.card h3 { margin: 0; font-size: 16.5px; letter-spacing: -.015em; }
.card p { margin: 0; font-size: 13.5px; color: var(--text-muted); line-height: 1.6; }
/* 相关推荐用的紧凑版 */
.grid--related { grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); }
.grid--related .card { padding: 14px 15px 13px; }
.grid--related .card h3 { font-size: 15px; }
.grid--related .card p { -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.catbadge { font-size: 11.5px; font-weight: 600; color: var(--tile, var(--accent)); }

/* =====================================================================
   首页
   ===================================================================== */
.hero {
  background:
    radial-gradient(58% 120% at 82% -10%, var(--accent-soft) 0%, transparent 62%),
    var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 58px 0 46px;
}
.hero-in { max-width: 760px; margin: 0 auto; text-align: center; padding: 0 24px; }
.hero h1 { font-size: clamp(30px, 4.6vw, 44px); font-weight: 800; letter-spacing: -.035em; margin-bottom: 12px; }
.hero h1 .gr {
  background-image: linear-gradient(96deg, var(--accent), var(--ch5) 70%, var(--ch4));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p { font-size: 17.5px; color: var(--text-muted); max-width: 46em; margin: 0 auto 26px; }
.hero-search { position: relative; max-width: 540px; margin: 0 auto; text-align: left; }
.hero-search input {
  width: 100%; font: inherit; font-size: 16px; color: var(--heading);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: 14px; padding: 14px 16px 14px 46px; box-shadow: var(--shadow);
}
.hero-search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.hero-search .hs-ic { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); width: 19px; height: 19px; color: var(--text-faint); pointer-events: none; }
.hero-search .sr-out { position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30; }
.hero-pop { margin-top: 20px; display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; align-items: center; }
.hero-pop .hp-lb { font-size: 13px; font-weight: 600; color: var(--text-faint); margin-right: 2px; }
.hero-pop a {
  font-size: 13px; font-weight: 600; color: var(--text);
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-pill);
  padding: 6px 13px;
}
.hero-pop a:hover { border-color: var(--accent); color: var(--accent); }

/* =====================================================================
   右栏：广告位 → 搜索 → 同类计算器
   ===================================================================== */
.rail { display: flex; flex-direction: column; gap: 22px; }

/* 广告位占位框。布局照 calculator.net：右栏顶部 300×250（桌面），
   移动端落在正文下方（.adslot--inline）。接广时把下面这个 div 换成：

   Google AdSense：
     <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-XXXX"
          data-ad-slot="XXXX" data-ad-format="auto" data-full-width-responsive="true"></ins>
   并确保 <head> 里有 <script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-XXXX"></script>
   然后再 push({})：<script>(adsbygoogle = window.adsbygoogle || []).push({});</script>

   Google Ad Manager (calculator.net 用的就是 GPT)：
     先 defineSlot('/XXXX/CalcMate-Rail-Top', [[300,250],[336,280]], 'div-gpt-ad-rail')
     再把 div 换成 <div id='div-gpt-ad-rail' style='min-width:300px;min-height:250px;'>
     最后 googletag.cmd.push(() => googletag.display('div-gpt-ad-rail'))。

   min-height 一定要留（防 CLS，AdSense 审核也看这个）。 */
.adslot {
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
  color: var(--text-faint); font-size: 12px; letter-spacing: .08em; text-align: center;
}
.adslot--rail { width: 100%; min-height: 250px; }
.adslot--inline { min-height: 100px; margin: 34px 0 0; }
@media (min-width: 1080px) { .adslot--inline { display: none; } }
@media (max-width: 1079px) { .adslot--inline { display: flex; } }
.adslot--banner { max-width: 970px; min-height: 90px; margin: 42px auto 0; }
@media (max-width: 760px) { .adslot--banner { min-height: 100px; min-width: 320px; } }

.rail-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 16px 14px;
}
.rail-card h2 { font-size: 13px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); margin: 0 0 10px; }
.rail-search { position: relative; }
.rail-search input {
  width: 100%; font: inherit; font-size: 14px; color: var(--heading);
  background: var(--bg-elevated); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.rail-search input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.rail-search .sr-out { margin-top: 6px; }
.rail-cat .rc-title { display: block; font-size: 13.5px; font-weight: 700; letter-spacing: .02em; }
.rail-cat ul { list-style: none; margin: 10px 0 0; padding: 0; }
.rail-cat li { margin-bottom: 2px; }
.rail-cat a { display: block; padding: 4.5px 8px; border-radius: 7px; font-size: 13.5px; color: var(--text); }
.rail-cat a:hover { background: var(--accent-soft); color: var(--accent); }
.rail-cat a.on { background: var(--accent-soft); color: var(--accent); font-weight: 700; }

/* 搜索结果下拉（右栏与首页共用） */
.sr-out { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); padding: 5px; }
.sr-out:empty { display: none; }
.sr-item { display: flex; align-items: baseline; gap: 10px; padding: 8px 10px; border-radius: 7px; font-size: 14px; color: var(--text); }
.sr-item:hover, .sr-item.on { background: var(--accent-soft); color: var(--accent); }
.sr-n { font-weight: 600; }
.sr-c { margin-left: auto; font-size: 12px; color: var(--text-faint); flex: none; }
.sr-item:hover .sr-c, .sr-item.on .sr-c { color: var(--accent); opacity: .8; }
.sr-none { padding: 10px; font-size: 13.5px; color: var(--text-faint); }

/* =====================================================================
   ⌘K 命令面板
   ===================================================================== */
.cm-palette { position: fixed; inset: 0; z-index: 200; }
.pv-backdrop { position: absolute; inset: 0; background: rgba(16,17,20,.5); backdrop-filter: blur(3px); }
.pv-panel {
  position: relative; max-width: 620px; margin: 9vh auto 0; width: calc(100% - 32px);
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg); overflow: hidden;
  display: flex; flex-direction: column; max-height: 72vh;
}
.pv-input {
  border: 0; outline: none; font: inherit; font-size: 16.5px; color: var(--heading);
  padding: 17px 20px; background: none; border-bottom: 1px solid var(--border);
}
.pv-list { overflow: auto; padding: 6px; }
.pv-sec { font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); padding: 8px 10px 4px; }
.pv-hint {
  display: flex; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-faint);
}
.pv-hint kbd { font-size: 11px; }

/* =====================================================================
   页脚
   ===================================================================== */
.site-footer {
  margin-top: 56px; background: var(--bg-elevated);
  border-top: 1px solid var(--border); padding: 44px 0 26px; font-size: 14px;
}
.site-footer .foot-top { display: flex; flex-wrap: wrap; gap: 34px 64px; justify-content: space-between; }
.site-footer .foot-brand { max-width: 400px; }
.site-footer .fb-name { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; color: var(--heading); }
.site-footer .fb-name svg { width: 22px; height: 22px; color: var(--accent); }
.site-footer .foot-brand p { margin: 10px 0 14px; color: var(--text-muted); font-size: 13.5px; line-height: 1.65; }
.site-footer .foot-all { font-weight: 600; font-size: 14px; color: var(--accent); }
.site-footer .foot-cols { display: flex; gap: 64px; flex-wrap: wrap; }
.site-footer h4 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--text-faint); margin: 0 0 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin-bottom: 6px; }
.site-footer a { color: var(--text-muted); font-size: 13px; }
.site-footer a:hover { color: var(--accent); }
.site-footer .bottom {
  margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center;
  color: var(--text-faint); font-size: 13px;
}
.site-footer .bottom .grow { flex: 1 1 auto; }

/* 回到顶部 */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 40;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg-elevated); border: 1px solid var(--border);
  color: var(--text-muted); cursor: pointer; display: grid; place-items: center;
  box-shadow: var(--shadow-lg); padding: 0;
  opacity: 0; pointer-events: none; transition: opacity .18s, color .12s;
}
.to-top svg { width: 18px; height: 18px; }
.to-top.show { opacity: 1; pointer-events: auto; }
.to-top:hover { color: var(--accent); }

/* =====================================================================
   居中单卡片页（about / contact / privacy / terms / 404）
   ===================================================================== */
.simple { max-width: 760px; margin: 0 auto; padding: 46px 0 10px; }
.simple h1 { font-size: 32px; margin-bottom: 14px; }
.simple .lede { font-size: 17.5px; color: var(--text-muted); max-width: 60ch; }
.simple h2 { font-size: 20px; margin-top: 34px; }
.simple p, .simple li { max-width: 70ch; }
.simple .mailbtn {
  display: inline-block; font-size: 17px; font-weight: 600; padding: 13px 22px;
  border-radius: 12px; background: var(--accent); color: #fff; box-shadow: var(--shadow);
}
.simple .mailbtn:hover { background: var(--accent-hover); color: #fff; }

/* sitemap.html：全站目录（两栏流式排布） */
.sm-grid { columns: 2; column-gap: 44px; margin-top: 6px; }
.sm-cat { break-inside: avoid; margin-bottom: 28px; }
.sm-cat h2 { display: flex; align-items: center; gap: 9px; font-size: 17px; margin: 0 0 10px; }
.sm-dot { width: 9px; height: 9px; border-radius: 3px; background: var(--tile, var(--accent)); flex: none; }
.sm-n { font-size: 12px; font-weight: 600; color: var(--text-faint); border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 1px 8px; }
.sm-list { list-style: none; margin: 0; padding: 0; }
.sm-list li { margin: 0 0 7px; }
.sm-list a { font-size: 14px; }

/* 脚本自愈失败时的降级提示条（HEAL_JS 注入） */
.cm-degraded {
  display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap;
  background: #fef3c7; color: #7c2d12; border-bottom: 1px solid #fcd34d;
  padding: 9px 16px; font-size: 14px;
}
.cm-degraded button {
  font: inherit; font-weight: 600; border: 1px solid #f59e0b; background: #fff;
  color: #7c2d12; border-radius: 8px; padding: 4px 12px; cursor: pointer;
}
.cm-degraded button:hover { background: #fffbeb; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cm-degraded { background: #422006; color: #fde68a; border-bottom-color: #854d0e; }
  :root:not([data-theme="light"]) .cm-degraded button { background: #1c1917; color: #fde68a; border-color: #854d0e; }
}
:root[data-theme="dark"] .cm-degraded { background: #422006; color: #fde68a; border-bottom-color: #854d0e; }
:root[data-theme="dark"] .cm-degraded button { background: #1c1917; color: #fde68a; border-color: #854d0e; }

/* 404 */
.nf-search { max-width: 460px; margin: 26px 0 8px; position: relative; }
.nf-search input { width: 100%; font: inherit; font-size: 15.5px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--heading); }
.nf-pop { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.nf-pop a { font-size: 13.5px; font-weight: 600; border: 1px solid var(--border); border-radius: var(--radius-pill); padding: 7px 14px; color: var(--text); background: var(--bg-elevated); }
.nf-pop a:hover { border-color: var(--accent); color: var(--accent); }

/* =====================================================================
   窄屏
   ===================================================================== */
@media (max-width: 1150px) {
  .cmnav-menu { display: none; }
  .cmnav-burger { display: grid; }
}
@media (max-width: 900px) {
  .hero { padding: 40px 0 34px; }
  .wrap { padding: 0 18px; }
  .cmnav-in { padding: 0 18px; gap: 2px; }
}
@media (max-width: 640px) {
  .wrap { padding: 0 14px; }
  .calc-card { padding: 18px 16px; border-radius: 16px; }
  .calc-result { padding: 16px 15px 13px; }
  .rh-item.primary .rh-v { font-size: 27px; }
  .grid { grid-template-columns: 1fr; }
  .prose h2 { font-size: 21px; margin-top: 34px; }
  .outkeys .ok-row { grid-template-columns: 1fr; gap: 2px; padding: 11px 2px; }
  .site-footer .foot-top { gap: 24px; }
  .site-footer .foot-cols { gap: 30px; }
  .sm-grid { columns: 1; }
  .to-top { right: 12px; bottom: 12px; }
  .cmnav-search .kbd-hint { display: none; }
}

@media print {
  .cmnav, .rail, .adslot, .to-top, .copybtn, .faq, .grid--related, .sec-head .more { display: none !important; }
  body { background: #fff; }
  .calc-card { grid-template-columns: 1fr 1fr; box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .prose h2 { break-after: avoid; }
}
