/* 颜色语义层：业务样式只消费变量，涨红跌绿在所有主题下保持不变。 */
:root {
  --card: var(--surface);
  --surface-raised: #ffffff;
  --surface-hover: #f1f4f8;
  --overlay: rgba(31, 35, 41, .42);
  --header-start: #1f2a44;
  --header-end: #2b3a5e;
  --focus-ring: rgba(43, 108, 255, .28);
  --info-bg: #edf3ff;
  --info-border: #bfd2ff;
  --warning-bg: #fff7e6;
  --warning-border: #ffe0a3;
  --warning-text: #8a5a00;
  --danger-bg: #fff1f0;
  --danger-border: #ffccc7;
  --danger-text: #a8071a;
  --chart-bg: #ffffff;
  --chart-grid: #d8dde3;
  --chart-text: #59616a;
  --floating-bg: rgba(255, 255, 255, .96);
  color-scheme: light;
}

html[data-theme='dark'] {
  --bg: #0f1216;
  --surface: #171b20;
  --surface-2: #1e242b;
  --surface-raised: #222830;
  --surface-hover: #272e37;
  --border: #303741;
  --text: #eef2f6;
  --text-sub: #a5adb7;
  --text-weak: #727b86;
  --brand: #6f9cff;
  --brand-weak: #1d3158;
  --up: #ff6268;
  --up-bg: #3a2025;
  --down: #4fd28e;
  --down-bg: #173629;
  --flat: #a5adb7;
  --shadow: 0 8px 24px rgba(0, 0, 0, .24);
  --overlay: rgba(0, 0, 0, .68);
  --header-start: #111820;
  --header-end: #1b2735;
  --focus-ring: rgba(111, 156, 255, .34);
  --info-bg: #172842;
  --info-border: #2b4c78;
  --warning-bg: #342916;
  --warning-border: #665126;
  --warning-text: #f3ca70;
  --danger-bg: #382023;
  --danger-border: #72383e;
  --danger-text: #ff9da2;
  --chart-bg: #15191e;
  --chart-grid: #343b44;
  --chart-text: #aeb6bf;
  --floating-bg: rgba(23, 27, 32, .96);
  color-scheme: dark;
}

body { transition: background-color .16s ease, color .16s ease; }
.app-header { background: linear-gradient(135deg, var(--header-start), var(--header-end)); }
.modal__mask { background: var(--overlay); }
.guest-banner { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning-text); }
.day-empty { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger-text); }
.state-box--info { background: var(--info-bg); border-color: var(--info-border); }

.theme-select {
  height: 30px;
  max-width: 82px;
  padding: 0 24px 0 9px;
  border: 1px solid rgba(255, 255, 255, .30);
  border-radius: 16px;
  background: rgba(255, 255, 255, .10);
  color: #fff;
  font: 600 12px/1 inherit;
  cursor: pointer;
}
.theme-select:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 1px; }
.theme-select option { background: var(--surface); color: var(--text); }

html[data-theme='dark'] .factor-tab.is-resonance-selected,
html[data-theme='dark'] .chip.is-on { background: var(--brand-weak); }
html[data-theme='dark'] .tag--factor { background: #262d35; }
html[data-theme='dark'] .stock-star { color: #59616a; }
html[data-theme='dark'] .stock-star.is-on { color: #f0b429; }
html[data-theme='dark'] .modal__panel,
html[data-theme='dark'] .auth-tabs,
html[data-theme='dark'] .admin-tabs { background: var(--surface); color: var(--text); }
html[data-theme='dark'] .btn--ghost { background: var(--surface-2); color: var(--text); }
html[data-theme='dark'] .watch-btn.is-on { background: #342916; }
html[data-theme='dark'] .concept-opt { background: var(--surface-2); color: var(--text); }
html[data-theme='dark'] .account-row,
html[data-theme='dark'] .admin-row,
html[data-theme='dark'] .redeem-gen,
html[data-theme='dark'] .redeem-row,
html[data-theme='dark'] .chart-permission-card,
html[data-theme='dark'] .chart-user-permission { background: var(--surface-2); border-color: var(--border); }
html[data-theme='dark'] .chart-permission-category h4 { color: #aeb8c7; }
html[data-theme='dark'] .chart-group-indicator.is-allow {
  background: #172a46;
  border-color: #5f8ee8;
}
html[data-theme='dark'] .chart-group-indicator.is-allow b { color: #f4f7fb; }
html[data-theme='dark'] .chart-group-indicator.is-purchase {
  background: #352a16;
  border-color: #b98632;
}
html[data-theme='dark'] .chart-group-indicator.is-purchase b { color: #ffe6a8; }
html[data-theme='dark'] .chart-user-indicator.is-purchase em { color: #e7b85d; }
html[data-theme='dark'] .chart-group-indicator small,
html[data-theme='dark'] .chart-user-indicator small { color: #b8c2d1; }
html[data-theme='dark'] .route-loading__content { background: rgba(23, 27, 32, .97); }
html[data-theme='dark'] .resonance-card,
html[data-theme='dark'] .chart-card { background: var(--surface); border-color: var(--border); }
html[data-theme='dark'] .resonance-card:hover { background: var(--surface-hover); }
html[data-theme='dark'] .chart-tabs .chart-tab:not(.is-on) {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
html[data-theme='dark'] .chart-info-row,
html[data-theme='dark'] .chart-ai-progress,
html[data-theme='dark'] .chart-ai-section { background: var(--surface-2); border-color: var(--border); }

@media (max-width: 520px) {
  .theme-select { width: 66px; max-width: 66px; padding-left: 7px; font-size: 11px; }
  .app-header__right { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  body { transition: none; }
}
