/* ══════════════════════════════════════════════════════════════════════════
   RandomDecidePal · base.css —— 全站唯一地基样式
   ──────────────────────────────────────────────────────────────────────────
   🚨 边界铁律（进交付自检，grep 硬验）：
      · 只有本文件可以定义 :root 变量和无前缀的全局类名
      · 工具目录（/t/<id>/）里的 CSS 必须全部包在 .t-<id> 作用域内，
        禁止出现 :root{，禁止重定义本文件里的任何类名
      · 违反的后果见旧版实测：5 个工具复制粘贴之后，逐字节相同的规则块
        只剩 20 条 / 2.6 KB，同一个 .navbar 长出了 5 个版本
   ══════════════════════════════════════════════════════════════════════════ */

/* ── 1 · 令牌 ─────────────────────────────────────────────────────────── */
:root {
  --bg:        #1e293b;
  --bg-deep:   #0f172a;
  --bg-black:  #020617;
  --ink:       #f8fafc;
  --ink-sub:   rgba(248, 250, 252, .62);
  --ink-dim:   rgba(248, 250, 252, .40);

  --brand:     #3b82f6;
  --brand-hi:  #60a5fa;
  --brand-lo:  #2563eb;
  --brand-sh:  #1d4ed8;
  --accent:    #ef4444;
  --ok:        #10b981;

  --panel:     rgba(0, 0, 0, .25);
  --card:      rgba(255, 255, 255, .05);
  --card-hi:   rgba(255, 255, 255, .08);
  --line:      rgba(255, 255, 255, .10);
  --line-hi:   rgba(255, 255, 255, .18);

  --field:     #f8fafc;
  --field-ink: #0f172a;

  --r-s: 6px;
  --r-m: 10px;
  --r-l: 14px;
  --r-xl: 20px;

  --nav-h: 56px;
  --wrap: 1120px;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue',
          'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', Arial, sans-serif;
  /* 数字/结果专用：等宽数位，跳动的数字不会把版面推来推去 */
  --nums: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;

  --ease: cubic-bezier(.2, .7, .3, 1);
}

/* ── 2 · 复位 ─────────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

img, svg, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-hi); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── 3 · 两种页壳 ─────────────────────────────────────────────────────── */
/* 🚨 这里对「app-shell 铁律」做了有意的分流，理由写在 AI_NOTES《S1 · 页壳分流》：
      · .shell-app（工具页）：文档不滚，内层滚 —— 铁律原样适用。
        工具页是定屏交互，正是「底部多一屏空白」病灶的发生场景。
      · .shell-doc（首页/关于/隐私/日后的文章页）：文档正常滚动。
        病理来自「给一个不该滚的文档强塞滚动偏移」；内容页本来就该滚，
        病理不成立；反而锁住 body 会让移动端地址栏永久展开，
        长文阅读白白损失约一成屏幕，且返回时丢失阅读位置。 */

.shell-app,
.shell-app body {
  height: 100vh;                 /* 回落：不认 dvh 的老浏览器走这条 */
  height: 100dvh;                /* 认 dvh 的覆盖上面那条 */
  overflow: hidden;
  overscroll-behavior: none;
}
.shell-app body { display: block; }

.shell-app .scroll {
  position: fixed;
  inset: var(--nav-h) 0 0 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.shell-doc body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.shell-doc main { flex: 1 0 auto; }

/* ── 4 · 导航 ─────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-h);
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg-deep);
  box-shadow: 0 1px 0 var(--line), 0 4px 14px rgba(0, 0, 0, .28);
}
.shell-doc .nav { position: sticky; }

.nav-logo {
  flex: none;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: .3px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
}
.nav-logo:hover { text-decoration: none; }
.nav-logo b { color: var(--brand); font-weight: 800; }

/* 导航条目由 core.js 从 tools.json 渲染。min-height 占住高度，
   避免注册表回来之前/之后的版面跳动（CLS）。 */
.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  min-height: 32px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-links a {
  flex: none;
  padding: 6px 11px;
  border-radius: var(--r-m);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-sub);
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: color .18s var(--ease), background-color .18s var(--ease);
}
.nav-links a:hover { color: var(--ink); background: var(--card); text-decoration: none; }
.nav-links a[aria-current="page"] {
  color: var(--brand-hi);
  background: var(--panel);
  border-color: var(--line);
}
/* C1：可横滚容器里的条目按压不许用 opacity —— 浏览器在「滚还是点」之间
   反复判定时 :active 会一加一撤，表现为快速闪烁 */
.nav-links a:active { opacity: 1 !important; }

/* ── 5 · 版心 ─────────────────────────────────────────────────────────── */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 0 20px;
}
.shell-doc main > .wrap { padding-top: 40px; padding-bottom: 56px; }
.shell-app .scroll > .wrap { padding-top: 24px; padding-bottom: 48px; }

.page-head { margin-bottom: 22px; }
.page-head h1 {
  font-size: clamp(24px, 5vw, 34px);
  line-height: 1.2;
  letter-spacing: -.02em;
  font-weight: 800;
}
.page-head p { margin-top: 8px; color: var(--ink-sub); font-size: 15px; }
.eyebrow {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand);
  margin-bottom: 10px;
}

/* ── 6 · 面板与卡片 ───────────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  padding: 18px;
}
.panel + .panel { margin-top: 16px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2, .panel-head h3 { font-size: 15px; font-weight: 700; letter-spacing: .01em; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
}

.tool-card {
  display: block;
  position: relative;
  padding: 18px;
  border-radius: var(--r-l);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  text-decoration: none;
  transition: background-color .18s var(--ease), border-color .18s var(--ease), transform .18s var(--ease);
}
a.tool-card:hover {
  background: var(--card-hi);
  border-color: var(--line-hi);
  transform: translateY(-2px);
  text-decoration: none;
}
a.tool-card:active { transform: translateY(0); filter: brightness(.94); }
.tool-card .ic { font-size: 26px; line-height: 1; }
.tool-card h3 { margin-top: 12px; font-size: 17px; font-weight: 700; }
.tool-card .brand { margin-left: 7px; font-size: 12px; font-weight: 600; color: var(--ink-dim); letter-spacing: .04em; }
.tool-card p { margin-top: 6px; font-size: 14px; line-height: 1.55; color: var(--ink-sub); }
.tool-card.is-planned { opacity: .55; cursor: default; }
.tool-card .soon {
  position: absolute; top: 14px; right: 14px;
  font-size: 11px; font-weight: 700; letter-spacing: .06em;
  color: var(--ink-dim); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
}

/* ── 7 · 控件 ─────────────────────────────────────────────────────────── */
/* C2/C3：有选中态的元素按压不变；无选中态的按钮用 brightness 变暗，
   不用 opacity —— opacity<1 会独立提升合成层，是白闪的根源 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border: none;
  border-radius: var(--r-m);
  background: var(--brand);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 var(--brand-sh);
  transition: background-color .15s var(--ease), filter .12s var(--ease),
              transform .08s var(--ease), box-shadow .08s var(--ease);
}
.btn:hover:not(:disabled) { background: var(--brand-lo); }
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 0 0 var(--brand-sh); filter: brightness(.92); }
.btn:disabled { background: #475569; box-shadow: 0 3px 0 #334155; cursor: not-allowed; filter: brightness(.85); }

.btn-ghost {
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: transparent;
  color: var(--ink-sub);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s var(--ease), border-color .15s var(--ease), background-color .15s var(--ease);
}
.btn-ghost:hover:not(:disabled) { color: var(--ink); border-color: var(--line-hi); background: var(--card); }
.btn-ghost:active:not(:disabled) { filter: brightness(.9); opacity: 1 !important; }
.btn-ghost:disabled { color: var(--ink-dim); cursor: not-allowed; }
.btn-danger:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }

.field {
  padding: 9px 11px;
  border: 2px solid transparent;
  border-radius: var(--r-m);
  background: var(--field);
  color: var(--field-ink);
  font-weight: 700;
  outline: none;
  transition: border-color .15s var(--ease);
}
.field:focus { border-color: var(--brand); }
.field-row { display: flex; align-items: center; gap: 8px; }
.field-row label { font-size: 14px; font-weight: 700; color: var(--ink-sub); white-space: nowrap; }
.field-num { width: 76px; text-align: center; }

/* 键盘可达性：始终留一个看得见的焦点环 */
:focus-visible { outline: 2px solid var(--brand-hi); outline-offset: 2px; border-radius: 4px; }

/* ── 8 · 列表 ─────────────────────────────────────────────────────────── */
.list { list-style: none; }
.list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14px;
}
.list li:last-child { border-bottom: none; }
.list .meta { color: var(--ink-dim); font-size: 13px; font-variant-numeric: tabular-nums; }
.list .val { font-weight: 700; white-space: nowrap; }
.scroll-y {
  max-height: 190px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.scroll-y::-webkit-scrollbar { width: 4px; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--line-hi); border-radius: 2px; }

.empty { padding: 22px 4px; text-align: center; color: var(--ink-dim); font-size: 14px; }

/* ── 9 · Toast ────────────────────────────────────────────────────────── */
.rdp-toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  transform: translate(-50%, 12px);
  z-index: 9600;
  max-width: min(88vw, 420px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(2, 6, 23, .94);
  border: 1px solid var(--line-hi);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.rdp-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── 10 · 弹窗 ────────────────────────────────────────────────────────── */
/* A1 的守卫在 core.js（记 downTarget，click 捕获阶段判定）；
   A6：高度上限优先用 core.js 实测的 --vvh，回落 svh/dvh/vh */
.rdp-mask {
  position: fixed;
  inset: 0;
  z-index: 9700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(2, 6, 23, .66);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.rdp-dlg {
  width: min(94vw, 400px);
  max-height: 76vh;
  max-height: 76svh;
  max-height: var(--vvh76, 76dvh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 22px;
  border-radius: var(--r-xl);
  background: var(--bg);
  border: 1px solid var(--line-hi);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  animation: rdp-pop .16s var(--ease);
}
@keyframes rdp-pop { from { opacity: 0; transform: scale(.97) translateY(6px); } to { opacity: 1; transform: none; } }
.rdp-dlg h3 { font-size: 17px; font-weight: 800; }
.rdp-dlg p { margin-top: 9px; font-size: 14px; line-height: 1.6; color: var(--ink-sub); }
.rdp-dlg .row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.rdp-dlg .row .btn, .rdp-dlg .row .btn-ghost { padding: 10px 18px; font-size: 15px; }

/* ── 11 · 页脚 ────────────────────────────────────────────────────────── */
.foot {
  flex-shrink: 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom, 0px));
  background: var(--bg-black);
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
}
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; margin-bottom: 10px; }
.foot a { color: var(--ink-sub); }
.foot a:hover { color: var(--ink); }

/* ── 12 · 长文排版（关于/隐私/日后的文章页共用）───────────────────────── */
.prose { max-width: 720px; font-size: 16px; line-height: 1.78; color: rgba(248, 250, 252, .86); }
.prose h2 { margin: 34px 0 12px; font-size: 20px; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.prose h3 { margin: 24px 0 8px; font-size: 16px; font-weight: 700; color: var(--ink); }
.prose p { margin: 12px 0; }
.prose ul, .prose ol { margin: 12px 0 12px 22px; }
.prose li { margin: 6px 0; }
.prose strong { color: var(--ink); font-weight: 700; }
.prose hr { margin: 30px 0; border: none; border-top: 1px solid var(--line); }
.prose .note { color: var(--ink-dim); font-size: 14px; }

/* ── 13 · 工具 ────────────────────────────────────────────────────────── */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.nums { font-family: var(--nums); font-variant-numeric: tabular-nums; }

/* ── 14 · 降低动态效果 ────────────────────────────────────────────────── */
/* 注意：骰子的滚动动画是功能本身，不能删；这里压到 0.2s 意思到即可 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .12s !important;
  }
}

/* ── 15 · 窄屏 ────────────────────────────────────────────────────────── */
@media (max-width: 620px) {
  :root { --nav-h: 52px; }
  .nav { gap: 10px; padding: 0 12px; }
  .nav-logo { font-size: 15px; }
  .wrap { padding: 0 14px; }
  .shell-doc main > .wrap { padding-top: 28px; padding-bottom: 40px; }
  .panel { padding: 15px; }
  .grid { grid-template-columns: 1fr; }
}
