/* ByWave 全站设计令牌：所有页面的颜色、表面、边框、文字与页眉度量只从这里取。
   深色是站点一直以来的样子（各页 :root 的自有值在深色下优先，本文件只补缺省）；
   浅色由 html[data-theme="light"] 整套覆盖——浅色是与深色同一秩序的真实设计：
   中性浅底、白色表面、同一套间距/圆角/字型，强调色按浅底对比度加深，不是反色。
   页面强调色（计划的暖橙、抽奖的紫粉、后台的紫）只保留在强调色相上，
   中性色、表面、文字、度量全站共享，页眉与内容因此是同一个系统。 */

:root {
  --bg: #050816;
  --bg-2: #0a0f22;
  --surface: rgba(255, 255, 255, .05);
  --surface-2: rgba(255, 255, 255, .09);
  --border: rgba(255, 255, 255, .12);
  --border-soft: rgba(255, 255, 255, .08);
  --line: rgba(255, 255, 255, .14);
  --line-soft: rgba(255, 255, 255, .08);
  --text: #ecf3ff;
  --muted: #9cb3d9;
  --accent: #6ea8ff;
  --accent-2: #7c5cff;
  --cyan: #22d3ee;
  --up: #63b995;
  --down: #e06c60;
  --green: #65f6c2;
  --red: #ff8b8b;
  --gold: #ffd166;
  --warm: #ff9966;
  --warm-2: #ffd166;
  --pink: #ff6b9d;
  --purple: #a78bfa;
  --header-bg: rgba(255, 255, 255, .08);
  --head-link: #d7e7ff;
  --shadow: 0 20px 80px rgba(0, 0, 0, .45);
  /* 细节令牌：动效时长、全站焦点度量、占位符、表单焦点环、选区、滚动条、自动填充底
     （本文件末尾的「细节统一层」消费这些令牌，各页不再各自另立数值） */
  --dur: .15s;
  --focus-w: 2px;
  --focus-offset: 2px;
  --placeholder: #8b9cb8;
  --field-border: rgba(255, 209, 102, .45);
  --field-ring: rgba(255, 209, 102, .12);
  --selection-bg: rgba(110, 168, 255, .38);
  --scroll-thumb: rgba(255, 255, 255, .22);
  --autofill-bg: #0d1526;
  /* 旧变量名映射到共享令牌，各页原有 var() 引用自动归队 */
  --card-border: var(--border);
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --panel-border: var(--border);
  --primary: var(--accent);
  --secondary: var(--accent-2);
}
html[data-theme="dark"] { color-scheme: dark; }
html { background: var(--bg); }

/* ---------- 浅色主题：整套令牌覆盖（特异性高于各页 :root，深色值不残留） ---------- */
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f0f3f7;
  --bg-2: #e6ecf3;
  --surface: #ffffff;
  --surface-2: #eef2f7;
  --border: rgba(18, 34, 58, .16);
  --border-soft: rgba(18, 34, 58, .09);
  --line: rgba(18, 34, 58, .18);
  --line-soft: rgba(18, 34, 58, .09);
  --text: #17233b;
  --muted: #52657e;
  --accent: #2a63cc;
  --accent-2: #6a4bd8;
  --cyan: #0a759b;
  --up: #177245;
  --down: #c0392b;
  --green: #0e7c56;
  --red: #c22f42;
  --gold: #8d6400;
  --warm: #b54f0d;
  --warm-2: #8d6400;
  --pink: #cb2a63;
  --purple: #6a4bd8;
  --header-bg: rgba(255, 255, 255, .85);
  --head-link: #24466e;
  --shadow: 0 18px 50px rgba(23, 43, 66, .13);
  /* 细节令牌的浅色值：占位符与焦点环按白底对比度加深，不沿用深色字面值 */
  --placeholder: #5c6f87;
  --field-border: rgba(141, 100, 0, .55);
  --field-ring: rgba(141, 100, 0, .18);
  --selection-bg: rgba(47, 107, 216, .22);
  --scroll-thumb: rgba(18, 34, 58, .28);
  --autofill-bg: #ffffff;
  --card-border: var(--border);
  --panel: var(--surface);
  --panel-2: var(--surface-2);
  --panel-border: var(--border);
  --primary: var(--accent);
  --secondary: var(--accent-2);
}

/* ---------- 浅色下共享组件的表面修正（页眉与内容同一套表面） ---------- */
html[data-theme="light"] body {
  background: var(--bg);
  color: var(--text);
}
/* 深色主题的氛围层（光晕、网格、星空）在浅色下收起，避免浅底上发灰发脏 */
html[data-theme="light"] body::before,
html[data-theme="light"] body::after { opacity: .10; }
html[data-theme="light"] .grid-overlay,
html[data-theme="light"] .scanline,
html[data-theme="light"] .stars-bg { display: none; }
html[data-theme="light"] .glass {
  background: rgba(255, 255, 255, .82);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
html[data-theme="light"] .topbar {
  background: var(--header-bg);
  border-color: var(--border);
  box-shadow: var(--shadow);
}
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea {
  background: #ffffff;
  color: var(--text);
  border-color: var(--border);
}
html[data-theme="light"] table { border-color: var(--border-soft); }
html[data-theme="light"] th { background: var(--surface-2); color: var(--text); }
html[data-theme="light"] th,
html[data-theme="light"] td { border-color: var(--border-soft); }

/* ---------- 外观开关：页眉里的三态按钮（跟随系统 / 浅色 / 深色） ---------- */
.theme-toggle {
  appearance: none;
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 44px; padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit; font-size: .85rem; line-height: 1.2;
  cursor: pointer; white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: border-color var(--dur) ease, background-color var(--dur) ease;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 浅色下各页专属字面色的修正（深色保持原样） ---------- */
/* 页脚备案链接：各页原为半透明淡色，浅色下统一回次级文字色 */
html[data-theme="light"] .footer .icp a { color: var(--muted); }
/* 首页：导航链接、标题渐变字与各类小标签原本是为深底设计的近白色 */
html[data-theme="light"] .nav-links a { color: var(--head-link); }
html[data-theme="light"] .nav-links a:hover { background: rgba(18, 34, 58, .06); }
html[data-theme="light"] .nav-links .nav-username { color: var(--muted); }
html[data-theme="light"] .gradient-text { background-color: var(--text); filter: none; }
html[data-theme="light"] .gradient-warm { background-color: #cf6a12; filter: none; }
html[data-theme="light"] .eyebrow {
  color: var(--text); background: var(--surface-2); border-color: var(--border);
}
html[data-theme="light"] .section-tag {
  color: var(--accent); background: rgba(42, 99, 204, .10); border-color: rgba(42, 99, 204, .30);
}
html[data-theme="light"] .section-tag.life {
  color: #ac4f0a; background: rgba(217, 95, 30, .10); border-color: rgba(217, 95, 30, .30);
}
html[data-theme="light"] .tag {
  color: var(--text); background: var(--surface-2); border-color: var(--border);
}
/* 计划页：hero 是全站唯一不用 .glass 的暖色面板，浅色下换成浅暖表面，
   标题/说明/元信息片与顶栏账号区随之回到可读对比度；进度数字回金色文字值 */
html[data-theme="light"] .hero:not(.glass) {
  background: #fdf1de; border-color: rgba(217, 95, 30, .35);
}
html[data-theme="light"] #plan-title { color: var(--text); }
html[data-theme="light"] #plan-desc { color: var(--muted); }
html[data-theme="light"] .hero-eyebrow {
  color: #ac4f0a; background: rgba(217, 95, 30, .10); border-color: rgba(217, 95, 30, .30);
}
html[data-theme="light"] .hero:not(.glass) .chip {
  color: #7a4a16; background: rgba(255, 255, 255, .55); border-color: rgba(217, 95, 30, .30);
}
html[data-theme="light"] .hero:not(.glass) .chip strong { color: #7a4a16; }
html[data-theme="light"] .hero-visual {
  background: rgba(217, 95, 30, .18); border-color: rgba(217, 95, 30, .25);
}
html[data-theme="light"] .nav-auth a { color: var(--warm); }
html[data-theme="light"] .nav-auth-name { color: var(--muted); }
html[data-theme="light"] .progress-stats strong { color: var(--gold); }
/* 404 页：巨号数字同样是裁剪字、卡片投影为深底设计、导航与备案链接为近白色 */
html[data-theme="light"] .code { background-color: var(--text); filter: none; }
html[data-theme="light"] main.card {
  background: var(--surface); border-color: var(--border);
  box-shadow: 0 12px 32px rgba(23, 35, 59, .10);
}
html[data-theme="light"] .site-nav a { color: var(--head-link); }
html[data-theme="light"] .site-nav a:hover { background: rgba(18, 34, 58, .06); }
html[data-theme="light"] .site-foot .icp a { color: var(--muted); }

/* ---------- 细节统一层：焦点、选区、滚动条、占位符、自动填充、点按反馈、徽章 ----------
   全站微细节只从这里出：各页原先各自画的焦点环/徽章/占位符色已收回，
   分节强调色（门户金、股票天蓝、SSO 紫）由各分节样式以同度量覆盖颜色，
   宽度与偏移全站一律 var(--focus-w) / var(--focus-offset)。 */

/* 品牌徽章：全站同一个标记（48px、16px 圆角、紫底双圆点），各页不再各自重画；
   SSO 卡片内是 44px 小一号变体（sso.css 只覆盖尺寸与圆点位置，画法相同） */
.brand-badge {
  width: 48px; height: 48px; border-radius: 16px; position: relative;
  background: rgba(124, 92, 255, .92);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
  overflow: hidden; flex: 0 0 auto;
}
.brand-badge::before, .brand-badge::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .22);
}
.brand-badge::before { width: 36px; height: 36px; top: -10px; left: -8px; }
.brand-badge::after { width: 16px; height: 16px; right: 8px; bottom: 8px; box-shadow: 0 0 24px rgba(255, 255, 255, .5); }
a.brand-badge:hover { text-decoration: none; }

/* 焦点：:where() 作地板，只兜底没有任何分节规则的元素（如 summary、tabindex 块），
   不与分节的同度量规则抢级联；偏移地板压过服务器存量 responsive.css 的 3px */
:where(:focus-visible) {
  outline: var(--focus-w) solid var(--gold);
  outline-offset: var(--focus-offset);
}
html :is(button, a, input, select, textarea, summary):focus-visible {
  outline-offset: var(--focus-offset);
}
/* 浅色下 responsive.css 的字面金 #ffd166 在白底上几乎看不见，统一回令牌金（深金） */
html[data-theme="light"] :is(button, a, input, select, textarea, summary):focus-visible {
  outline-color: var(--gold);
}

/* 表单焦点：门户三页（计划/抽奖/后台）共用一圈软环，宽度与颜色只从令牌取，
   深色金环、浅色换深金令牌保证白底可见；分节自有处理（股票描边、SSO 轮廓）不经此处 */
.field:focus, textarea:focus, select:focus {
  border-color: var(--field-border);
  box-shadow: 0 0 0 4px var(--field-ring);
}

/* 占位符：双主题都给足对比（深色原为浏览器默认灰、浅色原 #8494ab 均约 3:1） */
input::placeholder, textarea::placeholder { color: var(--placeholder); opacity: 1; }

/* 自动填充：压掉浏览器自带的亮黄/白底，回到本页输入面，文字与光标用正文色 */
input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--autofill-bg) inset;
  transition: background-color 99999s ease-in-out 0s;
}

/* 文本选区：双主题各一档强调色淡底 */
::selection { background: var(--selection-bg); }

/* 滚动条：细条、低对比拇指，双主题随令牌；标准属性 + webkit 双写 */
* { scrollbar-width: thin; scrollbar-color: var(--scroll-thumb) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb); border-radius: 8px;
  border: 2px solid transparent; background-clip: padding-box;
}
::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }

/* 点按：移动端去掉系统默认的半透明灰高光（此前只有 SSO 与外观开关设了） */
a, button, input, select, textarea, summary, label, [role="button"] {
  -webkit-tap-highlight-color: transparent;
}

/* 按压反馈：按钮按下时统一压暗一档（不位移、不改布局；已有 transform 按压态的元素不受影响） */
button:active, .btn:active { filter: brightness(.94); }

/* 表格数字：等宽对齐（股票表本已在分节样式里声明，这里兜底其余页面的表格） */
table { font-variant-numeric: tabular-nums; }

/* ---------- 加载反馈层：骨架屏 + 转圈 + 按钮忙碌态 ----------
   异步区域在数据回来之前必须让用户看得出「正在加载」，而不是空白或假的空状态：
   骨架块的尺寸贴合最终内容（行高、内边距、间距同量级），颜色只用共享令牌，
   深浅两套主题通用。减动效时本文件末尾的全局规则会把脉冲与转圈停成静态块。 */
@keyframes bw-spin { to { transform: rotate(360deg); } }
@keyframes bw-skel-pulse { from { opacity: .45; } to { opacity: .9; } }
.bw-sr-only {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.bw-spinner {
  display: inline-block; flex: 0 0 auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: bw-spin .7s linear infinite;
  vertical-align: -4px;
}
.bw-spinner.sm { width: 14px; height: 14px; vertical-align: -2px; }
.bw-skel {
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  animation: bw-skel-pulse 1.15s ease-in-out infinite alternate;
}
.bw-skel-line {
  display: block; height: 14px; border-radius: 7px;
  background: var(--surface-2);
  animation: bw-skel-pulse 1.15s ease-in-out infinite alternate;
}
.bw-skel-line.w38 { width: 38%; }
.bw-skel-line.w55 { width: 55%; }
.bw-skel-line.w72 { width: 72%; }
.bw-skel-line.w88 { width: 88%; }
/* 列表行骨架：与各页列表行同量级（内边距 16px、行间距 12px、两行文字的高度） */
.bw-skel-row {
  padding: 16px; margin-bottom: 12px;
  display: flex; flex-direction: column; gap: 9px;
}
/* 区域加载提示（转圈 + 一句话）：用在没有固定行结构的区域，如启动确认 */
.bw-load-note {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 22px 16px; color: var(--muted); font-size: .9rem; text-align: center;
}
/* 按钮忙碌态：JS 在等待开始时加 .bw-busy、结束时摘掉；左侧转圈且不可重复点 */
.bw-busy { pointer-events: none; opacity: .78; }
button.bw-busy::before, .btn.bw-busy::before, .mini-btn.bw-busy::before {
  content: ""; flex: 0 0 auto;
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: bw-spin .7s linear infinite;
}

/* ---------- 减动效：尊重系统「减少动态效果」 ----------
   全站氛围动画（光晕漂移、星点闪烁、平滑滚动）在此统一停下，
   状态过渡缩短到近乎即时（保留状态变化本身，不保留过程）。
   与 layout.css 里 body[data-page] 的同名规则同口径，此处覆盖其余页面；
   抽奖转盘的转动由 lottery.html 的脚本另行判断（同为 reduce 时直接出结果）。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
