/* ============================================================
   小楠不会取名 · Xiaonan Studio — styles.css
   Step 1: design tokens, glass tiers, 3-layer shadows,
   cursor vars, theme vars, reduced-motion fallback.
   Rule: JS springs drive ALL interaction — no CSS transitions
   on interactive elements.
   ============================================================ */

/* ---------- 1. Theme tokens ---------- */
:root {
  /* color tokens (light default) — 品牌色严格按给定 Hex 注入 */
  --bg-base: #F4F5F7;
  --primary: #2563EB;
  --primary-hover: #1D4ED8;
  --bg: var(--bg-base);
  --bg-2: var(--bg-base);
  --text: #1d1d1f;
  --text-2: rgba(29, 29, 31, .62);
  --text-3: rgba(29, 29, 31, .4);
  --text-muted: rgba(29, 29, 31, .66);  /* 12px 极小提示：浅色底 >= 4.5:1 */

  /* brand gradient: 指向品牌蓝令牌；配色方案仍可覆盖 --brand-* */
  --brand-1: var(--primary);
  --brand-2: var(--primary-hover);
  --brand-3: var(--primary);
  --brand-grad: linear-gradient(120deg, var(--brand-1), var(--brand-2) 55%, var(--brand-3));

  /* 背景光晕色（随配色方案 data-palette 联动） */
  --glow-1: rgba(37, 99, 235, .10);
  --glow-2: rgba(37, 99, 235, .07);
  --glow-3: rgba(29, 78, 216, .10);
  --cursor-glow: rgba(37, 99, 235, .16);

  /* glass tints */
  --glass-tint: rgba(255, 255, 255, .10);   /* tier 1 */
  --glass-tint-deep: rgba(255, 255, 255, .20); /* tier 2 */
  --glass-border: rgba(255,255,255,0.4);
  --glass-blur: 10px;
  --glass-blur-deep: 20px;
  --glass-sat: 170%;
  --glass-sat-deep: 190%;

  /* 3-layer shadow (interactive elements) */
  --shadow-outer: 0 8px 32px -8px rgba(0, 0, 0, .18);
  --shadow-inset-top: inset 0 1px 0 rgba(255, 255, 255, .6);
  --shadow-inset-bottom: inset 0 -1px 0 rgba(255, 255, 255, .15);
  --shadow-3: var(--shadow-outer), var(--shadow-inset-top), var(--shadow-inset-bottom);
  /* intensified ~30% for hover (JS may override via spring) */
  --shadow-3-hover: 0 12px 40px -8px rgba(0, 0, 0, .24), var(--shadow-inset-top), var(--shadow-inset-bottom);

  /* cursor spotlight vars (updated on mousemove) */
  --mx: 50%;
  --my: 50%;
  --spot-size: 340px;
  --spot-alpha: .10;

  /* layout */
  --radius-s: 12px;
  --radius-m: 18px;
  --radius-l: 26px;
  --nav-h: 64px;
  --page-w: 1200px;

  /* type */
  --font-sys: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Roboto, sans-serif;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg-base: #0D1117;
  --bg: var(--bg-base);
  --bg-2: var(--bg-base);
  --text: #f5f5f7;
  --text-2: rgba(245, 245, 247, .6);
  --text-3: rgba(245, 245, 247, .38);
  --text-muted: rgba(245, 245, 247, .62); /* 12px 极小提示：深色底 >= 4.5:1 */

  --brand-1: var(--primary);
  --brand-2: var(--primary-hover);
  --brand-3: var(--primary);

  --glow-1: rgba(37, 99, 235, .09);
  --glow-2: rgba(37, 99, 235, .06);
  --glow-3: rgba(29, 78, 216, .09);
  --cursor-glow: rgba(37, 99, 235, .20);

  --glass-tint: rgba(255, 255, 255, .07);
  --glass-tint-deep: rgba(255, 255, 255, .12);
  --glass-border: rgba(255,255,255,0.08);

  --shadow-outer: 0 8px 32px -8px rgba(0, 0, 0, .55);
  --shadow-inset-top: inset 0 1px 0 rgba(255, 255, 255, .12);
  --shadow-inset-bottom: inset 0 -1px 0 rgba(255, 255, 255, .05);
  --shadow-3-hover: 0 12px 40px -8px rgba(0, 0, 0, .7), var(--shadow-inset-top), var(--shadow-inset-bottom);

  --spot-alpha: .14;

  color-scheme: dark;
}

/* 扩展配色方案：主色跟随所选方案，默认仍是 :root 里的品牌蓝 */
[data-palette="aurora"],
[data-palette="cyber"],
[data-palette="sunset"] {
  --primary: var(--brand-1);
  --primary-hover: var(--brand-2);
}

/* ---------- 2. Reset / base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: auto; /* JS-driven smooth scroll instead */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sys);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, canvas { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }

::selection { background: rgba(37, 99, 235, .26); color: #fff; }

/* focus ring for keyboard users only */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------- 3. Background layers ---------- */
/* base frosted backdrop */
.bg-base {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(1200px 800px at 15% -10%, var(--glow-1), transparent 60%),
    radial-gradient(1000px 700px at 110% 20%, var(--glow-2), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, var(--glow-3), transparent 60%),
    var(--bg);
  pointer-events: none;
}
[data-theme="dark"] .bg-base {
  background:
    radial-gradient(1200px 800px at 15% -10%, var(--glow-1), transparent 60%),
    radial-gradient(1000px 700px at 110% 20%, var(--glow-2), transparent 55%),
    radial-gradient(900px 900px at 50% 120%, var(--glow-3), transparent 60%),
    var(--bg);
}

/* canvas particle layer */
#bg-canvas {
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
}

/* soft glow ball following cursor (JS-positioned) */
.cursor-glow {
  position: fixed;
  z-index: -1;
  width: 520px;
  height: 520px;
  left: 0;
  top: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle, var(--cursor-glow), transparent 65%);
  will-change: transform;
}
[data-theme="dark"] .cursor-glow {
  background: radial-gradient(circle, var(--cursor-glow), transparent 65%);
}

/* ---------- 3.5 主题扩展包配色（全部免费自由切换） ----------
   只覆盖品牌色与光晕令牌，不动 light/dark 基底。 */
[data-palette="aurora"] {
  --brand-1: #8b5cf6;
  --brand-2: #c084fc;
  --brand-3: #60a5fa;
  --glow-1: rgba(139, 92, 246, .12);
  --glow-2: rgba(96, 165, 250, .10);
  --glow-3: rgba(192, 132, 252, .12);
  --cursor-glow: rgba(139, 92, 246, .16);
}
[data-palette="aurora"][data-theme="dark"],
[data-theme="dark"] [data-palette="aurora"] {
  --brand-1: #a78bfa;
  --brand-2: #d8b4fe;
  --brand-3: #93c5fd;
  --glow-1: rgba(167, 139, 250, .10);
  --glow-2: rgba(147, 197, 253, .08);
  --glow-3: rgba(216, 180, 254, .10);
  --cursor-glow: rgba(167, 139, 250, .20);
}
[data-palette="cyber"] {
  --brand-1: #06b6d4;
  --brand-2: #22d3ee;
  --brand-3: #34d399;
  --glow-1: rgba(6, 182, 212, .12);
  --glow-2: rgba(52, 211, 153, .10);
  --glow-3: rgba(34, 211, 238, .12);
  --cursor-glow: rgba(6, 182, 212, .16);
}
[data-palette="cyber"][data-theme="dark"],
[data-theme="dark"] [data-palette="cyber"] {
  --brand-1: #22d3ee;
  --brand-2: #67e8f9;
  --brand-3: #6ee7b7;
  --glow-1: rgba(34, 211, 238, .10);
  --glow-2: rgba(110, 231, 183, .08);
  --glow-3: rgba(103, 232, 249, .10);
  --cursor-glow: rgba(34, 211, 238, .20);
}
[data-palette="sunset"] {
  --brand-1: #f97316;
  --brand-2: #fb7185;
  --brand-3: #fbbf24;
  --glow-1: rgba(249, 115, 22, .12);
  --glow-2: rgba(251, 191, 36, .10);
  --glow-3: rgba(251, 113, 133, .12);
  --cursor-glow: rgba(249, 115, 22, .16);
}
[data-palette="sunset"][data-theme="dark"],
[data-theme="dark"] [data-palette="sunset"] {
  --brand-1: #fb923c;
  --brand-2: #fda4af;
  --brand-3: #fcd34d;
  --glow-1: rgba(251, 146, 60, .10);
  --glow-2: rgba(252, 211, 77, .08);
  --glow-3: rgba(253, 164, 175, .10);
  --cursor-glow: rgba(251, 146, 60, .20);
}

/* 主题切换涟漪层（clip-path 由 JS 弹簧驱动，无 CSS transition） */
.theme-ripple {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  background: var(--bg);
  clip-path: circle(0% at 50% 50%);
  visibility: hidden;
}

/* ---------- 4. Glass tiers ---------- */
.glass-1,
.glass-2 {
  position: relative;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-3);
  isolation: isolate;
}

.glass-2 {
  -webkit-backdrop-filter: blur(var(--glass-blur-deep)) saturate(var(--glass-sat-deep));
  backdrop-filter: blur(var(--glass-blur-deep)) saturate(var(--glass-sat-deep));
  background: var(--glass-tint-deep);
  border-radius: var(--radius-l);
}

/* liquid-glass specular highlight (top edge light) */
.glass-1::before,
.glass-2::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 34%);
  pointer-events: none;
  z-index: 0;
}
[data-theme="dark"] .glass-1::before,
[data-theme="dark"] .glass-2::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, .08), rgba(255, 255, 255, 0) 34%);
}

/* radial spotlight following --mx/--my (hover feedback) */
.spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(
    var(--spot-size) circle at var(--mx) var(--my),
    rgba(255, 255, 255, var(--spot-alpha)),
    transparent 65%
  );
  opacity: 0;
  pointer-events: none;
  z-index: 1;
}
.spotlight.is-hover::after { opacity: 1; }

/* ---------- 5. Interactive base (spring-driven, no CSS transition) ---------- */
.spring-el {
  will-change: transform;
  transform: translateZ(0);
}

/* buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .01em;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 32px -8px rgba(37, 99, 235, .35),
    inset 0 1px 0 rgba(255, 255, 255, .45),
    inset 0 -1px 0 rgba(255, 255, 255, .15);
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-sm { padding: 8px 16px; font-size: 13px; }

/* icon buttons (nav toggles) */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);
  will-change: transform;
}
.icon-btn svg { width: 19px; height: 19px; fill: currentColor; }

/* ---------- 6. Nav ---------- */
.nav {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  width: min(calc(100% - 28px), var(--page-w));
  height: var(--nav-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px 0 24px;
  border-radius: 999px;
  will-change: transform;
}

.nav-brand {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .02em;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  white-space: nowrap;
}

.nav-right { display: flex; align-items: center; gap: 8px; }

/* language segmented control */
.lang-seg {
  position: relative;
  display: flex;
  align-items: center;
  height: 36px;
  padding: 4px;
  border-radius: 999px;
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);
}
.lang-seg button {
  position: relative;
  z-index: 1;
  padding: 0 12px;
  height: 100%;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.lang-seg button[aria-pressed="true"] { color: var(--text); }
.lang-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  height: calc(100% - 6px);
  border-radius: 999px;
  background: rgba(255, 255, 255, .55);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .12), inset 0 1px 0 rgba(255, 255, 255, .8);
  will-change: transform;
  z-index: 0;
}
[data-theme="dark"] .lang-thumb {
  background: rgba(255, 255, 255, .14);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .18);
}

/* ---------- 7. Pages / sections ---------- */
.page {
  display: none;
  padding: calc(var(--nav-h) + 32px) 16px 64px;
  max-width: var(--page-w);
  margin: 0 auto;
}
.page.is-active { display: block; }
/* hero 留白：仅首页底部 +20%（64px → 76px），不影响其他页面与 .section */
#page-home { padding-bottom: 76px; }

.section { margin-bottom: 96px; }
.section-title {
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: -.01em;
  margin-bottom: 8px;
}
.section-sub {
  font-size: 16px;
  color: var(--text-2);
  max-width: 640px;
  line-height: 1.65;
  margin-bottom: 32px;
}

/* hero */
.hero {
  min-height: calc(100vh - var(--nav-h) - 60px);
  min-height: calc(100dvh - var(--nav-h) - 60px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 24px;
  perspective: 1200px;
}
.hero-title {
  font-size: clamp(38px, 7vw, 76px);
  font-weight: 900;
  letter-spacing: -.02em;
  line-height: 1.08;
}
/* 3D letter-flip spans injected by JS */
.hero-title .flip-letter {
  display: inline-block;
  will-change: transform;
  transform-style: preserve-3d;
}
.hero-sub {
  font-size: clamp(15px, 2vw, 18px);
  color: var(--text-2);
  max-width: 560px;
  line-height: 1.7;
}

/* bilibili card（通用 B 站样式卡，/bilibili 面板复用） */
.bili-card {
  width: min(560px, 100%);
  padding: 24px;
  text-align: left;
  will-change: transform, opacity;
  transform-style: preserve-3d;
}

/* ---------- 7b. 首屏个人名片（两层结构） ----------
   外层 .profile-scroll：只挂 perspective（预留滚动挂钩，当前初始即正面）
   内层 .profile-tilt：只做鼠标倾斜 ±8°（JS quickSpring 驱动） */
.profile-scroll {
  width: min(560px, 100%);
  perspective: 1000px;
}
.profile-card {
  position: relative;
  width: 100%;
  padding: 24px;
  text-align: left;
  transform-style: preserve-3d;
  /* 深玻璃 18-25% blur20 saturate170（glass-2 基础上微调） */
  background: rgba(255, 255, 255, .18);
  -webkit-backdrop-filter: blur(20px) saturate(170%);
  backdrop-filter: blur(20px) saturate(170%);
}
[data-theme="dark"] .profile-card { background: rgba(255, 255, 255, .10); }
.profile-tilt {
  position: relative;
  border-radius: inherit;
  transform-style: preserve-3d;
  will-change: transform;
}
/* 光斑：跟随 --mx/--my 的径向聚光 */
.profile-spot {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  --mx: 50%;
  --my: 50%;
  background: radial-gradient(
    420px circle at var(--mx) var(--my),
    rgba(255, 255, 255, .12),
    transparent 62%
  );
}
[data-theme="dark"] .profile-spot {
  background: radial-gradient(
    420px circle at var(--mx) var(--my),
    rgba(255, 255, 255, .08),
    transparent 62%
  );
}
/* 斜角高光 overlay：opacity 淡入允许 transition（规格豁免项），
   位置由 --glare-x/--glare-y 驱动（JS 写，无 transition） */
.profile-glare {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 3;
  opacity: 0;
  transition: opacity .25s;
  --glare-x: 50%;
  --glare-y: 50%;
  --glare-a: rgba(255, 255, 255, .35);
  --glare-b: rgba(255, 255, 255, .08);
  background: radial-gradient(
    120% 120% at var(--glare-x) var(--glare-y),
    var(--glare-a), var(--glare-b) 30%, transparent 55%
  );
  mix-blend-mode: overlay;
}
.profile-glare.is-on { opacity: 1; }
/* VIP：金色/霓虹高光变量（仅外观，不改判定/滚动/按钮） */
.profile-glare.vip {
  --glare-a: rgba(255, 214, 110, .5);
  --glare-b: rgba(148, 125, 255, .22);
}
/* 分层视差初始深度（JS pointermove 追加 translate） */
.profile-avatar { transform: translateZ(60px); will-change: transform; }
.profile-idwrap { transform: translateZ(30px); will-change: transform; }
.profile-actions { transform: translateZ(20px); will-change: transform; }
/* 降级：触屏/减动效 → 静态玻璃卡，保留可读高光 */
.profile-static .profile-glare { display: none; }
.profile-static .profile-avatar,
.profile-static .profile-idwrap,
.profile-static .profile-actions { transform: none; }
.bili-card-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.bili-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 28px;
  font-weight: 800;
  flex: none;
  box-shadow: var(--shadow-3);
}
.bili-name { font-size: 18px; font-weight: 700; }
.bili-sign { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.bili-tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 16px; }
.bili-tag {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .12);
  color: var(--primary);
  border: 1px solid rgba(37, 99, 235, .18);
}
.bili-tag.pink { background: rgba(128, 128, 128, .10); color: var(--text-2); border-color: rgba(128, 128, 128, .22); }
.bili-desc { font-size: 14px; color: var(--text-2); line-height: 1.7; margin-bottom: 16px; }
.bili-actions { display: flex; flex-wrap: wrap; gap: 12px; }

/* 软件库：小标题与展开按钮容器（替代原行内样式） */
.section-title.subhead { font-size: 22px; margin-top: 8px; }
.apps-expand-wrap { text-align: center; margin-top: 32px; }
.apps-expand-wrap .btn[hidden] { display: none; }

/* ---------- 8. Cards grid ---------- */
.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.grid.dense { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }

.tool-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  will-change: transform;
  transform-style: preserve-3d;
  cursor: pointer;
}
.tool-card-top { display: flex; align-items: center; gap: 12px; }
.tool-icon {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-shadow: var(--shadow-3);
  will-change: transform;
}
.tool-icon svg { width: 24px; height: 24px; }
.tool-name { font-size: 16px; font-weight: 700; }
.tool-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.tool-use { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.tool-stats {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.tool-stats b { color: var(--text-2); font-weight: 600; }
.tool-actions { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }

/* ---------- 9b. 首字母图标说明（软件库搜索框下方，12px 灰色提示） ---------- */
#page-apps .search-box { margin-bottom: 8px; }
.icon-note {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0 0 16px;
}

/* ---------- 10. Search ---------- */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  height: 50px;
  border-radius: 999px;
  margin-bottom: 24px;
}
.search-box svg { width: 18px; height: 18px; fill: var(--text-3); flex: none; }
.search-box input {
  flex: 1;
  border: 0;
  background: none;
  outline: none;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  min-width: 0;
}
.search-box input::placeholder { color: var(--text-3); }
.search-box kbd {
  font-family: inherit;
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 4px 8px;
  flex: none;
}
.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: var(--shadow-3), 0 0 0 2px rgba(37, 99, 235, .18);
}

/* category chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 24px; }
.chip {
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  background: var(--glass-tint);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-3);
  will-change: transform;
}
.chip[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
  border-color: transparent;
}

/* ---------- 11. Modal (FLIP target) ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, .35);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.is-open { display: flex; }
.modal {
  width: min(640px, 100%);
  max-height: 84vh;
  overflow: auto;
  padding: 32px;
  will-change: transform;
}

/* ---------- 12. Settings panel ---------- */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
  border-bottom: 1px solid var(--glass-border);
}
.settings-row:last-child { border-bottom: 0; }
/* 设置页分组：外观(1-6) / 数据(7) / 游戏(8-9) —— 纯 CSS 组间距，不重排 DOM、不加容器 */
#page-settings .settings-row:nth-child(7),
#page-settings .settings-row:nth-child(8) { margin-top: 32px; }
.settings-label { font-size: 14px; font-weight: 600; }
.settings-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* toggle switch */
.toggle {
  position: relative;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(120, 120, 128, .28);
  flex: none;
  will-change: transform;
}
.toggle[aria-checked="true"] { background: var(--primary); }
.toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  will-change: transform;
}

/* segmented (settings options) */
.seg {
  display: inline-flex;
  padding: 4px;
  border-radius: 12px;
  background: rgba(120, 120, 128, .16);
  gap: 4px;
}
.seg button {
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  will-change: transform;
}
.seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, .8);
  color: #1d1d1f;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .14);
}
[data-theme="dark"] .seg button[aria-pressed="true"] {
  background: rgba(255, 255, 255, .16);
  color: var(--text);
}

/* range slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 4px;
  border-radius: 4px;
  background: rgba(120, 120, 128, .3);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .3);
  cursor: pointer;
}

/* ---------- 13. Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  z-index: 300;
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  pointer-events: none;
  will-change: transform, opacity;
  opacity: 0;
}

/* ---------- 14. Responsive ---------- */
@media (max-width: 1024px) {
  :root { --page-w: 920px; }
}

@media (max-width: 640px) {
  :root { --nav-h: 56px; --radius-l: 20px; }
  .nav { padding: 0 4px 0 16px; }
  .nav-brand { font-size: 14px; }
  .icon-btn { width: 36px; height: 36px; }
  .lang-seg { height: 32px; }
  .lang-seg button { padding: 0 8px; font-size: 12px; }
  .page { padding: calc(var(--nav-h) + 24px) 12px 64px; }
  .section { margin-bottom: 64px; }
  .grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .grid.dense { grid-template-columns: 1fr 1fr; }
  .tool-card { padding: 12px; }
  .bili-card { padding: 16px; }
  .cursor-glow { display: none; } /* no pointer glow on touch */
}

@media (max-width: 400px) {
  .grid { grid-template-columns: 1fr; }
}

/* ---------- 15. Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .cursor-glow,
  #bg-canvas { display: none; }
  .bg-base {
    background: var(--bg);
  }
  .hero-title .flip-letter { transform: none !important; }
}

/* JS sets this when user picks reduced/off motion in settings */
[data-motion="reduced"] .cursor-glow,
[data-motion="reduced"] #bg-canvas,
[data-motion="off"] .cursor-glow,
[data-motion="off"] #bg-canvas { display: none; }
[data-motion="reduced"] .bg-base,
[data-motion="off"] .bg-base { background: var(--bg); }

/* ---------- 16. Nav links ---------- */
.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0 auto;
}
.nav-links a {
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
  will-change: transform;
}
.nav a.is-active,
.nav-links a.is-active,
.nav-links a[aria-current="page"] {
  color: #fff;
  background: var(--primary);
}
@media (max-width: 768px) {
  .nav-links { display: none; }
}

/* ---------- 17. Icon chip surface (brand-color SVGs stay visible) ---------- */
.tool-icon {
  background: rgba(255, 255, 255, .92);
  /* 图标底色恒为浅色，currentColor 也必须恒为深色：
     否则深色主题下 stroke="currentColor" 的品牌 SVG 会变成浅色压浅底（对比度 1.09:1）。
     沿用 .icon-letter 的同一个色值，不引入新颜色。 */
  color: #0B1220;
  overflow: hidden;
}
[data-theme="dark"] .tool-icon {
  background: rgba(240, 240, 245, .94);
}
/* 首字母占位图标：无官方 SVG 时使用。
   色相按名称首字母分 8 档（icons.js 输出 .tone-N），渐变一律为高明度浅色 + 深色字，
   白字压浅渐变的老问题被消除；浅色/深色主题下文字与底色对比度均 >= 4.5:1。
   图标自身带背景色，因此不随主题变化，也不需要任何行内 style。 */
.icon-letter {
  --icon-a: hsl(258 78% 78%);
  --icon-b: hsl(238 70% 72%);
  width: 100%;
  height: 100%;
  border-radius: inherit;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--icon-a), var(--icon-b));
  color: #0B1220;
  font-weight: 800;
  font-size: 1.2em;
  box-shadow: inset 0 0 0 1px rgba(11, 18, 32, .10);
}
.icon-letter.tone-0 { --icon-a: hsl(4 78% 74%);   --icon-b: hsl(340 70% 70%); }
.icon-letter.tone-1 { --icon-a: hsl(32 82% 74%);  --icon-b: hsl(12 74% 70%); }
.icon-letter.tone-2 { --icon-a: hsl(88 62% 72%);  --icon-b: hsl(68 66% 68%); }
.icon-letter.tone-3 { --icon-a: hsl(152 58% 72%); --icon-b: hsl(132 54% 68%); }
.icon-letter.tone-4 { --icon-a: hsl(184 62% 72%); --icon-b: hsl(164 56% 68%); }
.icon-letter.tone-5 { --icon-a: hsl(212 82% 76%); --icon-b: hsl(192 70% 70%); }
.icon-letter.tone-6 { --icon-a: hsl(258 78% 78%); --icon-b: hsl(238 70% 72%); }
.icon-letter.tone-7 { --icon-a: hsl(308 68% 76%); --icon-b: hsl(288 62% 72%); }

/* ---------- 18. About / misc sections ---------- */
.settings-card { padding: 8px 24px; max-width: 640px; }
.about-card { padding: 32px; max-width: 720px; }
.about-facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 4px; }
.about-facts .bili-tag { font-size: 13px; padding: 8px 12px; }
.about-p { font-size: 14px; color: var(--text-2); line-height: 1.8; margin-top: 12px; }

.ask-card { padding: 32px; max-width: 720px; min-height: 220px; }

.footer {
  text-align: center;
  padding: 32px 16px 48px;
  font-size: 13px;
  color: var(--text-3);
}
.footer-social { display: block; margin-top: 8px; color: var(--text-2); }

/* hero scroll hint */
.scroll-hint {
  font-size: 13px;
  color: var(--text-3);
  letter-spacing: .06em;
  animation: none; /* JS spring bobbing instead */
  will-change: transform;
}

/* home quick links row */
.quick-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; }

/* ---------- 19. Float dock (back-to-top) ---------- */
.float-dock {
  position: fixed;
  right: 18px;
  bottom: 24px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.dock-btn { width: 46px; height: 46px; }
.dock-btn svg { width: 21px; height: 21px; fill: currentColor; }
#backtop-btn { opacity: 0; pointer-events: none; } /* JS spring shows it */
@media (max-width: 640px) {
  .float-dock { right: 12px; bottom: 16px; }
  .dock-btn { width: 42px; height: 42px; }
}

/* ---------- 21. 游戏选择页 ---------- */
.games-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  max-width: 760px;
  margin: 0 auto;
}
.game-card {
  padding: 32px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.game-emoji { font-size: 44px; line-height: 1; }
.game-best { font-size: 13px; color: var(--text-2); }
.game-best b {
  font-size: 18px;
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.game-card .btn { margin-top: 4px; }
@media (max-width: 640px) {
  .games-grid { grid-template-columns: 1fr; gap: 12px; }
  .game-card { padding: 24px 16px; }
}

/* ---------- 22. 设置页左侧全屏 ---------- */
#page-settings .section {
  width: 50vw;
  min-height: calc(100vh - var(--nav-h) - 60px);
  min-height: calc(100dvh - var(--nav-h) - 60px);
  margin: 0 auto 32px 0;
  padding: 32px 32px 64px;
}
#page-settings .settings-card { padding: 4px 24px; }
@media (max-width: 1024px) {
  #page-settings .section { width: min(680px, 92vw); margin: 0 auto 32px; padding: 24px 0 32px; }
}
@media (max-width: 640px) {
  #page-settings .section { width: 100vw; padding: 16px 16px 32px; }
  #page-settings .settings-card { padding: 4px 16px; }
}
/* ---------- 24. 反馈评论区 ---------- */
.fb-input {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  padding: 12px 12px;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  background: rgba(120, 120, 128, .10);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  line-height: 1.6;
}
.fb-input:focus { outline: 2px solid var(--primary); outline-offset: 2px; }
.fb-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 8px 0 4px;
}
.fb-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fb-item {
  padding: 12px 12px;
  border-radius: 12px;
  background: rgba(120, 120, 128, .08);
  border: 1px solid var(--glass-border);
}
.fb-item-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.fb-name { font-size: 13px; font-weight: 700; }
.fb-item.golden .fb-name {
  background: linear-gradient(120deg, #f7b733, #ffd166);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
/* 金色昵称权益：霓虹头像框（静态霓虹光晕，无 CSS transition） */
.fb-avatar {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
  background: var(--brand-grad);
  box-shadow: 0 0 0 2px rgba(247, 183, 51, .65), 0 0 10px rgba(247, 183, 51, .55);
}
.fb-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, .14);
  color: var(--primary);
  font-weight: 700;
}
.fb-badge.gold { background: rgba(247, 183, 51, .2); color: #c98a12; }
.fb-date { font-size: 11px; color: var(--text-3); margin-left: auto; }
.fb-text { font-size: 13px; line-height: 1.6; color: var(--text); word-break: break-word; }
/* 字数实时校验提示：接近上限变橙，达到上限变红（纯状态色，无动画） */
#fb-count.warn { color: #e08a00; }
#fb-count.over { color: #e0453a; font-weight: 700; }

/* VIP 金色外观（仅视觉） */
[data-vip="on"] .profile-card,
[data-vip="on"] .game-card {
  box-shadow: 0 0 0 2px rgba(247, 183, 51, .55), var(--shadow-3);
}

/* ---------- 25. 主题扩展包配色选择器（全部免费自由切换） ---------- */
.palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.palette-swatch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--glass-border);
  background: var(--glass-tint);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-sat));
  box-shadow: var(--shadow-3);
  font-size: 13px;
  font-weight: 600;
  will-change: transform;
}
.palette-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .5);
}
.palette-swatch.is-active {
  box-shadow: 0 0 0 2px var(--primary), var(--shadow-3);
}

/* ---------- 27. 反馈区管理员 ---------- */
.fb-bar-right { display: flex; gap: 8px; align-items: center; }
.fb-admin-bar { display: flex; gap: 8px; margin-top: 8px; }
.fb-del { color: #e0453a; }
.fb-item.is-pinned {
  box-shadow: 0 0 0 2px rgba(247, 183, 51, .5);
  background: rgba(247, 183, 51, .07);
}

/* ---------- 28. 移动端折叠导航 / 流体排版 / 触控区域 ----------
   doesntbreak：320px 起不破版、触控 >=44x44、输入框 16px、dvh、宽内容自带滚动
   responsive-patterns：内容驱动断点（<=768 折叠 / >768 展开）、clamp() 字号阶梯
   注意：.hero-title / .section-title / .hero-sub 原本已是 clamp() 流体值且量级更贴合，
        这里只补通用 h1/h2/body/p 的流体基线，不用小号 clamp 覆盖既有组件类。 */
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
body { font-size: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem); }
p { font-size: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem); }
.section-sub { font-size: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem); }

/* 汉堡图标：三条线，纯 CSS，不引入新图标库 */
.nav-toggle { display: none; }
.nav-bars {
  position: relative;
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.nav-bars::before,
.nav-bars::after {
  content: "";
  position: absolute;
  left: 0;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
.nav-bars::before { top: -6px; }
.nav-bars::after { top: 6px; }
.nav-lang { display: none; }

@media (max-width: 768px) {
  /* 性能：降低玻璃层 blur（只改令牌值，.glass-* 的 backdrop-filter 声明保留） */
  :root { --glass-blur: 6px; --glass-blur-deep: 10px; }

  /* 顶部条：品牌 + 三个 44px 图标按钮，语言切换移进折叠菜单 */
  .nav { padding: 0 6px 0 12px; }
  .nav-brand { font-size: 13px; }
  .nav-right { gap: 4px; }
  .nav-right .lang-seg { display: none; }
  .nav-toggle { display: inline-flex; }
  .icon-btn { width: 44px; height: 44px; }
  .dock-btn { width: 44px; height: 44px; }

  /* 折叠菜单：绝对定位在导航下方，展开时才可见 */
  .nav-links {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    margin: 0;
    padding: 8px;
    border-radius: var(--radius-m);
    /* 不透明底色 + 玻璃高光叠加：展开时下方首页文字不会透上来，菜单文字始终可读 */
    background: linear-gradient(var(--glass-tint-deep), var(--glass-tint-deep)), var(--bg-base);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-3);
    -webkit-backdrop-filter: blur(var(--glass-blur-deep)) saturate(var(--glass-sat-deep));
    backdrop-filter: blur(var(--glass-blur-deep)) saturate(var(--glass-sat-deep));
  }
  .nav.is-open .nav-links { display: flex; }
  .nav-links a { display: flex; align-items: center; min-height: 44px; padding: 8px 16px; font-size: 15px; }
  .nav-lang {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--glass-border);
  }
  .nav-lang button {
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
  }
  .nav-lang button[aria-pressed="true"] { background: var(--primary); color: #fff; }

  /* 触控目标：全部 >= 44x44，相邻目标靠 gap 保持 8px 间距 */
  .btn, .btn-sm { min-height: 44px; }
  .chip { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  .seg button { min-height: 44px; }
  .toggle::after { content: ""; position: absolute; inset: -7px -3px; }
  .tool-actions .btn { min-height: 44px; }

  /* 输入框 16px：避免 iOS Safari 聚焦时自动缩放 */
  input, textarea, select { font-size: 16px; }
  .search-box input, .fb-input { font-size: 16px; }

  /* 小屏无横向滚动：修真正超宽元素，而不是只遮症状 */
  html, body { max-width: 100%; }
  body { overflow-x: clip; }
  .page { padding-left: 12px; padding-right: 12px; }
  #page-settings .section { width: 100%; }
  /* 单列：工具卡片与游戏卡片一律一列，不再挤成两列 */
  .grid, .grid.dense, .hot-grid, .games-grid { grid-template-columns: 1fr; }
  .tool-card, .game-card, .bili-card, .about-card, .ask-card, .settings-card,
  .tool-card *, .settings-row > div, .bili-card-head > div { min-width: 0; }

  /* 工具卡片内部三行结构：
     ① 首字母图标（左）+ 工具名称（右），垂直居中
     ② 描述最多两行（-webkit-line-clamp: 2）
     ③ 「官方下载」「详情」两个按钮等宽平铺，文字居中，触控 >= 44x44 */
  .tool-card { gap: 12px; }
  .tool-card-top { align-items: center; }
  .tool-card-top > div:nth-child(2) { flex: 1; min-width: 0; }
  .tool-icon { width: 48px; height: 48px; }
  .tool-name { font-size: 16px; }
  .tool-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .todo-tag-sm { display: none; }        /* 右上角「图标待换官方」小屏隐藏 */
  .tool-use {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    overflow: hidden;
  }
  .tool-stats { display: none; }         /* 数据口径仍在详情里，卡片保持三行 */
  .tool-actions {
    display: flex;
    gap: 12px;
    width: 100%;
    margin-top: 0;
    padding-top: 0;
  }
  .tool-actions .btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    text-align: center;
    min-height: 44px;
  }
  .tool-name, .tool-use, .section-title, .section-sub, .hero-sub,
  .about-p, .settings-hint, .footer, .chip { overflow-wrap: anywhere; }
  .modal-backdrop { padding: 12px; }
  .modal { max-width: 100%; max-height: 84dvh; padding: 20px; }
  pre, table { max-width: 100%; overflow-x: auto; }

  /* 移动端隐藏光标光晕；降低名片 blur */
  .cursor-glow { display: none; }
  .profile-card {
    -webkit-backdrop-filter: blur(10px) saturate(160%);
    backdrop-filter: blur(10px) saturate(160%);
  }
}

/* 极窄屏（320 / 375）：工具区与游戏区一律单列，避免卡片内容撑破 */
@media (max-width: 400px) {
  .grid, .grid.dense, .hot-grid, .games-grid { grid-template-columns: 1fr; }
  .bili-actions, .quick-row { gap: 8px; }
  .btn { padding: 10px 16px; }
  /* 覆盖旧 640px 断点里的 42px，保证 320/375 仍是 44x44 */
  .dock-btn { width: 44px; height: 44px; }
  #page-settings .section { width: 100%; }
  .nav-brand { max-width: 40%; overflow-wrap: anywhere; }
}

/* ---------- 29. 推荐页：检索框 / 筛选标签 / 多结果卡片 ---------- */
.ask-card { max-width: 1080px; min-height: 0; }
.ask-search { margin-bottom: 16px; }
.ask-filters { margin-bottom: 12px; }
.ask-hint { font-size: 13px; color: var(--text-2); margin-bottom: 16px; }
.ask-results { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 768px) {
  .ask-card { padding: 20px; }
  .ask-results { grid-template-columns: 1fr; }
}

/* ---------- 30. 统一排版工具类（替代所有静态行内 style） ----------
   语义类描述「这是什么」，间距类只描述阶值；全部落在 styles.css，HTML 不再带行内样式。 */
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.bili-panel-narrow { max-width: 560px; margin: 0 auto; }
.about-slot-card { max-width: 720px; }
.settings-row-col { flex-direction: column; align-items: stretch; gap: 4px; }
.section-title-sm { font-size: 22px; }
.tool-name-md { font-size: 16px; }
.tool-name-lg { font-size: 18px; }
.tool-icon-lg { width: 56px; height: 56px; }
.todo-tag-sm { font-size: 11px; padding: 4px 8px; }
