:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --panel-strong: #f8fafc;
  --text: #1b2430;
  --muted: #657184;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --blue: #2454a6;
  --amber: #b86b00;
  --warn: #9a5b00;
  --danger: #b42318;
  --good: #087443;
  --shadow: 0 12px 30px rgba(20, 31, 48, 0.08);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11171c;
  --panel: #192127;
  --panel-strong: #202a31;
  --text: #e5edf1;
  --muted: #a3b2bd;
  --line: #35434d;
  --accent: #1a9b8d;
  --accent-dark: #27b3a3;
  --blue: #74a8ff;
  --amber: #f1b657;
  --warn: #f4c76a;
  --danger: #ff7a73;
  --good: #51cf9b;
  --shadow: 0 16px 36px rgba(0, 0, 0, 0.26);
}

:root[data-theme="dark"] ::selection {
  background: rgba(49, 186, 169, 0.35);
  color: #ffffff;
}

.theme-toggle {
  flex: 0 0 38px;
  display: inline-grid;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--panel);
  color: var(--text);
  box-shadow: none;
  cursor: pointer;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--accent);
  background: var(--panel-strong);
  color: var(--accent);
}

.theme-toggle:focus-visible {
  outline: 3px solid rgba(26, 155, 141, 0.28);
  outline-offset: 2px;
}

.theme-toggle-icon {
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  font-size: 19px;
  line-height: 1;
}

:root[data-theme="light"] .theme-toggle-icon::before {
  content: "☾";
}

:root[data-theme="dark"] .theme-toggle-icon::before {
  content: "☀";
}

.theme-toggle-floating {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  z-index: 100;
  box-shadow: var(--shadow);
}

:root[data-theme="dark"] body:not(.arb-page):not(.manual-page):not(.theme-page-sim):not(.theme-page-smartmoney) {
  background:
    linear-gradient(180deg, #162027 0, #131a20 300px, var(--bg) 100%);
}

:root[data-theme="dark"] :is(input, select, textarea) {
  border-color: var(--line);
  background: #141c22;
  color: var(--text);
}

:root[data-theme="dark"] :is(input, select, textarea)::placeholder {
  color: #81909b;
}

:root[data-theme="dark"] .tag {
  border-color: var(--line);
  background: var(--panel-strong);
}

:root[data-theme="dark"] select option {
  background: #192127;
  color: var(--text);
}

:root[data-theme="dark"] :is(button.ghost, .link-button, .account-button, .icon-button, .ghost-link) {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

:root[data-theme="dark"] :is(button.ghost, .link-button, .account-button, .icon-button, .ghost-link):hover {
  border-color: #52616c;
  background: var(--panel-strong);
}

/* Main workstation, corpus, smart money, trench, and market king. */
:root[data-theme="dark"] :is(
  .sidebar,
  .type-tabs,
  .topbar,
  .detail-panel,
  .strategy-card,
  .xzl-panel,
  .xzl-item,
  .x-call-details,
  .binance-ai-box,
  .king-card,
  .king-plan-card,
  .king-testnet-card,
  .king-pulse-card,
  .king-pulse-side,
  .king-runtime-panel,
  .king-runtime-card,
  .king-module-card,
  .smart-trader-card,
  .smart-order-card,
  .meme-module,
  .meme-chain-panel,
  .meme-token,
  .gold-chain-panel,
  .gold-token,
  .rabbit-card,
  .sword-card,
  .fish-card,
  .ra-card,
  .meme-viewer-analysis-module,
  .auth-card,
  .auth-panel,
  .admin-dialog
) {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

:root[data-theme="dark"] :is(.xzl-page, .market-king-page) {
  background: var(--panel-strong);
}

:root[data-theme="dark"] :is(.auth-body, .auth-shell) {
  background:
    linear-gradient(135deg, #111a1f 0%, #14211f 45%, #111a1f 100%);
}

:root[data-theme="dark"] :is(.auth-card, .auth-panel, .admin-dialog-head) {
  background: rgba(25, 33, 39, 0.96);
}

:root[data-theme="dark"] .admin-modal-backdrop {
  background: rgba(3, 8, 12, 0.68);
}

:root[data-theme="dark"] :is(.table-wrap, .rabbit-merged-wrap, .king-table-wrap, .king-token-table, .auth-table-wrap) {
  border-color: var(--line);
}

:root[data-theme="dark"] body:not(.arb-page):not(.manual-page):not(.theme-page-sim):not(.theme-page-smartmoney) table {
  background: var(--panel);
}

:root[data-theme="dark"] body:not(.arb-page):not(.manual-page):not(.theme-page-sim):not(.theme-page-smartmoney) th {
  border-color: var(--line);
  background: #202a31;
  color: var(--muted);
}

:root[data-theme="dark"] body:not(.arb-page):not(.manual-page):not(.theme-page-sim):not(.theme-page-smartmoney) td {
  border-color: var(--line);
}

:root[data-theme="dark"] body:not(.arb-page):not(.manual-page):not(.theme-page-sim):not(.theme-page-smartmoney) tbody tr:hover {
  background: rgba(72, 164, 153, 0.1);
}

:root[data-theme="dark"] :is(
  .muted-card,
  .king-rule-grid,
  .king-review-factor,
  .king-plan-symbol small,
  .king-token-row.head,
  .rabbit-card.muted-card,
  .sword-card.muted-card,
  .fish-card.muted-card,
  .meme-module-note,
  .smart-mini-table,
  .meme-copy-toast
) {
  border-color: var(--line);
  background: var(--panel-strong);
  color: var(--muted);
}

:root[data-theme="dark"] :is(
  .symbol,
  .king-rule-grid b,
  .king-plan-head strong,
  .king-plan-symbol span,
  .king-testnet-head strong,
  .king-pulse-card strong,
  .king-chat-head strong,
  .king-pulse-side-title,
  .king-pulse-row strong,
  .king-pulse-row b,
  .king-runtime-card strong,
  .king-token-head h4,
  .king-token-row strong,
  .king-module-card strong
) {
  color: var(--text);
}

:root[data-theme="dark"] :is(
  .king-plan-detail p,
  .king-review-cell summary,
  .king-review-cell p,
  .king-discipline-cell,
  .king-chat-body,
  .king-pulse-columns h4,
  .king-runtime-mini h4,
  .king-runtime-columns h4,
  .king-module-card p,
  .x-call-details p
) {
  color: #c4d0d7;
}

:root[data-theme="dark"] :is(.status-pill.ok, .good-tag, .positive, .king-pulse-card.mood.risk-on) {
  color: #58d9a5;
}

:root[data-theme="dark"] :is(.status-pill.bad, .danger-tag, .negative, .king-pulse-card.mood.defensive) {
  color: #ff8c84;
}

:root[data-theme="dark"] :is(.status-pill.warn, .king-pulse-card.mood.heated) {
  color: #f3c66d;
}

:root[data-theme="dark"] .status-pill.ok,
:root[data-theme="dark"] .king-pulse-card.mood.risk-on {
  border-color: rgba(82, 217, 164, 0.32);
  background: rgba(82, 217, 164, 0.09);
}

:root[data-theme="dark"] .status-pill.bad,
:root[data-theme="dark"] .king-pulse-card.mood.defensive {
  border-color: rgba(255, 140, 132, 0.3);
  background: rgba(255, 140, 132, 0.08);
}

:root[data-theme="dark"] .king-pulse-card.mood.heated {
  border-color: rgba(243, 198, 109, 0.3);
  background: rgba(243, 198, 109, 0.08);
}

:root[data-theme="dark"] :is(.king-chat-msg.from-claude, .king-chat-msg.from-codex, .king-chat-msg.from-user) {
  border-color: var(--line);
  background: #1c252c;
}

:root[data-theme="dark"] :is(.rabbit-merged, .king-table) th:first-child,
:root[data-theme="dark"] :is(.rabbit-merged, .king-table) td:first-child {
  background: var(--panel);
}

:root[data-theme="dark"] .rabbit-merged tr.open td:first-child {
  background: rgba(241, 182, 87, 0.11);
}

:root[data-theme="dark"] :is(.meme-token .meme-chip.neutral, .meme-rank-chip, .rank-stay, .ra-skip, .ra-daily-chip) {
  background: #26313a;
  color: #c3d0d8;
}

:root[data-theme="dark"] :is(.meme-token .meme-chip.attention, .gold-token .meme-chip.drawdown) {
  background: rgba(241, 182, 87, 0.12);
  color: #f2c675;
}

:root[data-theme="dark"] :is(.meme-token .meme-chip.social, .meme-social-score) {
  --social-base-color: #1c2933;
}

/* Intraday workspace and 市场大王 have several legacy light panels of their own. */
:root[data-theme="dark"] :is(
  .notice,
  .spot-module,
  .fish-module,
  .rabbit-module,
  .rabbit-settings-panel,
  .rabbit-setting-block,
  .rabbit-metric,
  .sword-metric,
  .fish-rating,
  .fish-metric,
  .rabbit-history-empty,
  .rabbit-codex-cards div,
  .ra-card,
  .ra-sug,
  .king-ladder-card,
  .king-stats span,
  .king-testnet-grid span,
  .king-pulse-side,
  .king-pulse-row,
  .king-pulse-details,
  .king-runtime-meta-row,
  .king-token-table
) {
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

:root[data-theme="dark"] :is(.fish-rating.high, .rabbit-type.up, .ra-sug-action) {
  background: rgba(81, 207, 155, 0.12);
}

:root[data-theme="dark"] :is(.fish-rating.mid, .ra-sug-info) {
  background: rgba(116, 168, 255, 0.12);
}

:root[data-theme="dark"] :is(.fish-rating.low, .ra-sug-warn) {
  background: rgba(241, 182, 87, 0.12);
}

:root[data-theme="dark"] .notice.busy {
  border-color: rgba(241, 182, 87, 0.34);
  background: rgba(241, 182, 87, 0.1);
  color: #f3c875;
}

:root[data-theme="dark"] .notice.error {
  border-color: rgba(255, 122, 115, 0.32);
  background: rgba(255, 122, 115, 0.09);
  color: #ff9b95;
}

:root[data-theme="dark"] .notice.good {
  border-color: rgba(81, 207, 155, 0.3);
  background: rgba(81, 207, 155, 0.09);
  color: #73dca9;
}

:root[data-theme="dark"] :is(
  .rabbit-setting-row label,
  .rabbit-settings-meta,
  .rabbit-metric span,
  .rabbit-reason,
  .sword-metric span,
  .sword-reason,
  .fish-metric span,
  .fish-reason,
  .fish-position,
  .fish-strategy,
  .ra-card span,
  .ra-spark-label,
  .ra-sub
) {
  color: var(--muted);
}

:root[data-theme="dark"] :is(.rabbit-setting-block-head span, .sword-card .market-pill) {
  border-color: var(--line);
  background: #26313a;
  color: #cbd7df;
}

:root[data-theme="dark"] .rabbit-codex-note {
  border-left-color: rgba(116, 168, 255, 0.62);
  background: rgba(116, 168, 255, 0.1);
  color: #cddbe5;
}

:root[data-theme="dark"] .rabbit-codex-order-table tr.rabbit-order-open td {
  background: rgba(241, 182, 87, 0.1);
}

:root[data-theme="dark"] .rabbit-history-empty {
  border-color: rgba(163, 178, 189, 0.42);
}

:root[data-theme="dark"] :is(.fish-type, .rabbit-type.up) {
  color: #67d5b2;
}

:root[data-theme="dark"] .rabbit-type.down {
  background: rgba(255, 122, 115, 0.1);
  color: #ff9c95;
}

:root[data-theme="dark"] .fish-rating span {
  color: #f3c875;
}

/* 战壕的浏览量表、叙事卡和移动端详情需要覆盖其独立的浅色定义。 */
:root[data-theme="dark"] .meme-viewer-analysis-module {
  border-color: rgba(53, 128, 110, 0.58);
  background: linear-gradient(180deg, #182923 0%, #192127 72%);
}

:root[data-theme="dark"] :is(.viewer-analysis-threshold, .viewer-analysis-threshold small) {
  color: #b7c7bf;
}

:root[data-theme="dark"] .viewer-analysis-threshold input {
  border-color: #39564d;
  background: #111a1e;
  color: #edf7f2;
}

@media (min-width: 761px) {
  :root[data-theme="dark"] .meme-viewer-analysis-list {
    border-color: #344b45;
    background: #172127;
  }

  :root[data-theme="dark"] .meme-viewer-analysis-row {
    border-color: #30414a;
    background: #172127;
    color: #d7e3e8;
  }

  :root[data-theme="dark"] .viewer-analysis-head {
    background: #20362f;
    color: #c5e5d7;
  }
}

:root[data-theme="dark"] :is(.viewer-analysis-token small, .meme-viewer-analysis-row small) {
  color: #a8bac5;
}

:root[data-theme="dark"] .viewer-analysis-views strong {
  color: #67d5b2;
}

:root[data-theme="dark"] .viewer-analysis-views .is-up {
  color: #72dca9;
}

:root[data-theme="dark"] .viewer-analysis-views .is-down {
  color: #ff968f;
}

:root[data-theme="dark"] .viewer-analysis-narrative {
  color: #d2e4da;
}

:root[data-theme="dark"] .viewer-analysis-narrative strong {
  color: #aabcc8;
}

:root[data-theme="dark"] :is(.viewer-gmgn-link, .meme-copy-ca) {
  border-color: #3e695b;
  background: #1d302a;
  color: #81dfbd;
}

:root[data-theme="dark"] :is(.viewer-gmgn-link:hover, .meme-copy-ca:hover, .meme-copy-ca.is-copied) {
  border-color: #57c99f;
  background: #16745a;
  color: #ffffff;
}

:root[data-theme="dark"] .meme-chain-head {
  border-color: #34434d;
}

:root[data-theme="dark"] .platform-icon {
  background: #27323b;
  color: #cbd7df;
}

:root[data-theme="dark"] :is(.meme-token .xzl-meta span, .meme-token .meme-chip) {
  background: #26313a;
  color: #d2dee5;
}

:root[data-theme="dark"] .meme-token .meme-chip.attention {
  background: rgba(241, 182, 87, 0.13);
  color: #f2c675;
}

:root[data-theme="dark"] .meme-token .meme-chip.source {
  background: rgba(116, 168, 255, 0.13);
  color: #9ec1ff;
}

:root[data-theme="dark"] .meme-token .meme-chip.smart {
  background: rgba(81, 207, 155, 0.12);
  color: #79dbae;
}

:root[data-theme="dark"] .meme-token .meme-chip.marketcap {
  background: rgba(26, 155, 141, 0.16);
  color: #70dec9;
}

:root[data-theme="dark"] .meme-token .meme-chip.social-score {
  --social-base-color: #1c2933;
  border-color: rgba(116, 168, 255, 0.34);
  color: #9fc2ff;
}

:root[data-theme="dark"] .meme-token .meme-chip.social-score.score-high {
  --social-base-color: #30271d;
  border-color: rgba(241, 182, 87, 0.34);
  color: #f2c675;
}

:root[data-theme="dark"] .meme-token .meme-chip.social-score.score-low {
  --social-base-color: #26313a;
  border-color: rgba(163, 178, 189, 0.3);
  color: #c3d0d8;
}

:root[data-theme="dark"] :is(.meme-cap, .holder-change.up) {
  color: #70dec9;
}

:root[data-theme="dark"] .holder-change.up {
  background: rgba(81, 207, 155, 0.12);
}

:root[data-theme="dark"] .holder-change.down {
  background: rgba(255, 122, 115, 0.11);
  color: #ff9c95;
}

:root[data-theme="dark"] .why-buy-answer {
  border-color: #399b77;
  background: rgba(81, 207, 155, 0.09);
  color: #d2e7dc;
}

:root[data-theme="dark"] .binance-ai-box p {
  color: #d9e5eb;
}

:root[data-theme="dark"] .binance-ai-box strong {
  color: #91b8ff;
}

:root[data-theme="dark"] :is(.x-call-details summary, .x-call-details p) {
  color: #cad9e1;
}

:root[data-theme="dark"] :is(.viewer-analysis-mobile-card, .viewer-analysis-mobile-stats > span, .meme-mobile-extra) {
  border-color: #344a43;
  background: #192127;
  color: var(--text);
}

:root[data-theme="dark"] :is(.viewer-analysis-mobile-name strong, .viewer-analysis-mobile-stats strong) {
  color: #e5edf1;
}

:root[data-theme="dark"] :is(.viewer-analysis-mobile-name small, .viewer-analysis-mobile-stats small, .viewer-analysis-mobile-stats em) {
  color: #a8bac5;
}

:root[data-theme="dark"] .viewer-analysis-mobile-narrative {
  border-color: #34434d;
}

:root[data-theme="dark"] .viewer-analysis-mobile-narrative summary {
  color: #8fe0c1;
}

:root[data-theme="dark"] .viewer-analysis-mobile-narrative p {
  color: #d3e1e7;
}

:root[data-theme="dark"] .meme-mobile-extra > summary {
  color: #9fc2ff;
}

:root[data-theme="dark"] .meme-mobile-extra-content {
  border-color: #34434d;
}

/* 屎里淘金复用叙事卡的密度；保留复盘字段，但不再使用大块浅色数据格。 */
:root[data-theme="dark"] .gold-mine-module {
  border-color: rgba(241, 182, 87, 0.3);
  background: linear-gradient(180deg, #24231d 0%, #192127 72%);
}

:root[data-theme="dark"] .gold-filter-choice {
  border-color: #4b4a3d;
  background: #202a31;
  color: #cbd7df;
}

:root[data-theme="dark"] .gold-filter-choice:hover {
  border-color: #d9a84b;
  color: #f3c875;
}

:root[data-theme="dark"] .gold-filter-choice.is-active {
  border-color: #b98125;
  background: #9b691e;
  color: #ffffff;
}

:root[data-theme="dark"] .gold-chain-panel {
  border-color: #4d4938;
  background: #192127;
}

:root[data-theme="dark"] .gold-token {
  border-left-color: #d59b39;
}

:root[data-theme="dark"] .gold-token .meme-chip.drawdown {
  background: rgba(255, 122, 115, 0.12);
  color: #ffaaa4;
}

:root[data-theme="dark"] .gold-ai-b {
  border-color: rgba(116, 168, 255, 0.3);
  background: #1c2933;
  color: #d9e5eb;
}

:root[data-theme="dark"] .gold-ai-b strong {
  color: #91b8ff;
  font-size: 11px;
  white-space: nowrap;
}

:root[data-theme="dark"] .gold-meta .migration-age-old {
  color: #aebdca;
}

/* 聪明钱的会话、空态、仓位和最新操作原本各自写死浅色背景。 */
:root[data-theme="dark"] :is(
  .smart-detail,
  .smart-position-card,
  .smart-order-card,
  .smart-empty,
  .smart-chip,
  .smart-metrics span
) {
  border-color: var(--line);
  background: #202a31;
  color: #d7e3e8;
}

:root[data-theme="dark"] .smart-order-card.is-new {
  border-color: rgba(81, 207, 155, 0.42);
  background: linear-gradient(180deg, #17332d 0%, #202a31 100%);
  box-shadow: none;
}

:root[data-theme="dark"] .smart-trader-card.off {
  opacity: 1;
  border-color: rgba(241, 182, 87, 0.32);
  background: #1d252b;
}

:root[data-theme="dark"] :is(.smart-detail h4, .smart-chip b) {
  color: #e5edf1;
}

:root[data-theme="dark"] :is(.smart-chip small, .smart-metrics b, .smart-empty, .smart-time) {
  color: #aebfca;
}

:root[data-theme="dark"] .smart-chip button {
  background: #2a3540;
  color: #ff9c95;
}

:root[data-theme="dark"] :is(.smart-session-details, .smart-history-details) {
  border-color: #3b4a54;
}

:root[data-theme="dark"] :is(.smart-session-details summary, .smart-history-details summary) {
  color: #9fc2ff;
}

:root[data-theme="dark"] .smart-session-message.success {
  color: #79dbae;
}

:root[data-theme="dark"] .smart-session-message.error {
  color: #ff9c95;
}

:root[data-theme="dark"] :is(.smart-side, .smart-action) {
  background: #28343d;
}

:root[data-theme="dark"] :is(.smart-side.long, .smart-action.long, .smart-pnl.positive) {
  color: #79dbae;
}

:root[data-theme="dark"] :is(.smart-side.short, .smart-action.short, .smart-pnl.negative) {
  color: #ff9c95;
}

:root[data-theme="dark"] .smart-action.close {
  color: #9fc2ff;
}

:root[data-theme="dark"] .good-tag {
  border-color: rgba(81, 207, 155, 0.28);
  background: rgba(81, 207, 155, 0.12);
  color: #79dbae;
}

:root[data-theme="dark"] .danger-tag {
  border-color: rgba(255, 122, 115, 0.28);
  background: rgba(255, 122, 115, 0.1);
  color: #ff9c95;
}

:root[data-theme="dark"] .new-count {
  border-color: rgba(81, 207, 155, 0.3);
  background: rgba(81, 207, 155, 0.14);
  color: #8fe0c1;
}

/* 市场大王中的动态卡片也不再保留白底或浅色正文。 */
:root[data-theme="dark"] :is(.king-plan-card.actionable, .king-module-card.token-consumer) {
  background: #1d2930;
}

:root[data-theme="dark"] :is(.king-ladder-card.protect span, .king-status.open, .king-mode.paper, .king-tier.protect, .king-plan-head b, .king-review-cell summary b) {
  color: #9fc2ff;
}

:root[data-theme="dark"] .king-ladder-card.harvest span,
:root[data-theme="dark"] .king-tier.harvest {
  color: #79dbae;
}

:root[data-theme="dark"] .king-ladder-card.expand span,
:root[data-theme="dark"] .king-tier.expand {
  color: #f2c675;
}

:root[data-theme="dark"] :is(.king-plan-symbol em, .king-plan-symbol small, .king-plan-levels span) {
  background: #26313a;
  color: #d2dee5;
}

:root[data-theme="dark"] .king-token-row {
  border-color: var(--line);
  color: #d3e0e6;
}

:root[data-theme="dark"] :is(.king-module-card span, .king-module-card small) {
  color: #aebfca;
}

/* 顶部账户信息、AI 工作日志和手机底部链切换条也使用同一低眩光色阶。 */
:root[data-theme="dark"] .auth-user-pill {
  border-color: rgba(81, 207, 155, 0.32);
  background: rgba(81, 207, 155, 0.12);
  color: #8fe0c1;
}

:root[data-theme="dark"] .ai-log-grid section {
  border-color: var(--line);
  background: #202a31;
}

:root[data-theme="dark"] .ai-log-grid h4 {
  color: #d6e2e8;
}

:root[data-theme="dark"] .ai-log-grid pre {
  color: #c5d3db;
}

@media (max-width: 760px) {
  :root[data-theme="dark"] .meme-mobile-chain-tabs {
    border-color: #3b4b55;
    background: rgba(25, 33, 39, 0.96);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.38);
  }

  :root[data-theme="dark"] .meme-mobile-chain-tabs button {
    background: #26313a;
    color: #d6e2e8;
  }

  :root[data-theme="dark"] .meme-mobile-chain-tabs button.active {
    background: #16745a;
    color: #ffffff;
  }
}

/* ArbDesk has a dedicated visual system, but now follows the same day/night switch. */
:root[data-theme="dark"] :is(body.arb-page, body.manual-page) {
  --bg: #07110f;
  --panel: #0e1b18;
  --panel-2: #12231f;
  --line: rgba(190, 224, 212, 0.13);
  --text: #ecf5f1;
  --muted: #8ea49c;
  --green: #54d8a4;
  --green-2: #1c9970;
  --gold: #efc36a;
  --red: #ff887f;
  --blue: #82b8ff;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

:root[data-theme="light"] :is(body.arb-page, body.manual-page) {
  --bg: #eef5f2;
  --panel: #ffffff;
  --panel-2: #f5f9f7;
  --line: #d4e1db;
  --text: #172a22;
  --muted: #62766d;
  --green: #087a58;
  --green-2: #0b6d50;
  --gold: #9f7018;
  --red: #be4e47;
  --blue: #286d9e;
  --shadow: 0 16px 38px rgba(24, 52, 42, 0.1);
}

:root[data-theme="light"] :is(body.arb-page, body.manual-page) {
  background:
    radial-gradient(circle at 20% -10%, rgba(17, 139, 95, 0.13), transparent 38rem),
    var(--bg);
}

:root[data-theme="light"] :is(.arb-nav, .manual-toolbar) {
  background: rgba(250, 253, 251, 0.92);
}

:root[data-theme="light"] :is(.arb-page th, .manual-page .arb-nav) {
  color: #587168;
}

:root[data-theme="light"] .arb-page th {
  background: #e8f1ed;
}

:root[data-theme="light"] :is(.arb-page .reasoning-section, .arb-page .current-layer) {
  background: linear-gradient(145deg, #f6faf8, #edf6f2);
}

:root[data-theme="light"] :is(.arb-page .case-card, .arb-page .validation-row) {
  background: #ffffff;
}

:root[data-theme="light"] :is(.arb-page .case-card p, .arb-page .validation-row p, .arb-page .decision-banner p) {
  color: #53675e;
}

:root[data-theme="light"] .arb-page :is(input, select) {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

:root[data-theme="light"] .manual-page .manual-sidebar {
  background: rgba(255, 255, 255, 0.95);
}

:root[data-theme="light"] .manual-page .manual-toolbar {
  background: rgba(250, 253, 251, 0.95);
}

:root[data-theme="light"] .manual-page .manual-search {
  background: #ffffff;
}

:root[data-theme="dark"] .manual-page .manual-paper {
  border-color: #33463e;
  background: #17211e;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

:root[data-theme="dark"] .manual-page :is(.manual-status, .manual-content) {
  color: #dce7df;
}

:root[data-theme="dark"] .manual-page :is(.manual-status small, .manual-content h1 + p) {
  color: #a9bbb1;
}

:root[data-theme="dark"] .manual-page :is(.manual-content h1, .manual-content h2, .manual-content h3) {
  border-color: #34463e;
  color: #eef6f1;
}

:root[data-theme="dark"] .manual-page :is(.online-callout, .manual-content blockquote) {
  border-color: #3f6d5b;
  background: #1e312a;
  color: #d4e8dd;
}

:root[data-theme="dark"] .manual-page :is(.online-callout span, .manual-content blockquote p) {
  color: #b2d0c1;
}

:root[data-theme="dark"] .manual-page .manual-content code {
  border-color: #3d5148;
  background: #22312b;
  color: #ffb7ad;
}

:root[data-theme="dark"] .manual-page .manual-content a {
  color: #65d5ae;
}

:root[data-theme="dark"] .manual-page .manual-content .table-wrap {
  border-color: #3b4d45;
  background: #1b2722;
}

:root[data-theme="dark"] .manual-page .manual-content table {
  color: #d9e7df;
}

:root[data-theme="dark"] .manual-page .manual-content th {
  background: #244739;
  color: #eff9f3;
}

:root[data-theme="dark"] .manual-page .manual-content td {
  border-color: #364940;
}

:root[data-theme="dark"] .manual-page .manual-content tbody tr:nth-child(even) {
  background: #1d2a25;
}

/* ArbDesk replay simulator. */
:root[data-theme="dark"] body.theme-page-sim {
  --bg: #050b0a;
  --surface: #0c1513;
  --surface-2: #111e1b;
  --surface-3: #162723;
  --line: rgba(205, 231, 221, 0.12);
  --text: #edf6f2;
  --muted: #869c94;
  --green: #50dda7;
  --green-deep: #16956a;
  --red: #ff8278;
  --gold: #edc36e;
  --blue: #7eb9ff;
  --shadow: 0 20px 70px rgba(0, 0, 0, 0.3);
}

:root[data-theme="light"] body.theme-page-sim {
  --bg: #eef5f2;
  --surface: #ffffff;
  --surface-2: #f4f8f6;
  --surface-3: #e9f1ed;
  --line: #d2e0d9;
  --text: #162a22;
  --muted: #61776d;
  --green: #087a58;
  --green-deep: #0b6d50;
  --red: #bf4d45;
  --gold: #9f7018;
  --blue: #2c6f9f;
  --shadow: 0 18px 42px rgba(28, 57, 46, 0.11);
}

:root[data-theme="light"] body.theme-page-sim {
  background:
    radial-gradient(circle at 14% -10%, rgba(18, 133, 94, 0.14), transparent 34rem),
    radial-gradient(circle at 95% 8%, rgba(47, 100, 121, 0.07), transparent 28rem),
    var(--bg);
}

:root[data-theme="light"] .theme-page-sim :is(.sim-nav, .scenario-toolbar) {
  background: rgba(250, 253, 251, 0.93);
}

:root[data-theme="light"] .theme-page-sim :is(select, input) {
  border-color: var(--line);
  background: #ffffff;
  color: var(--text);
}

:root[data-theme="light"] .theme-page-sim th {
  background: #e8f1ed;
  color: #587168;
}

:root[data-theme="light"] .theme-page-sim :is(.memory-card, .current-card) {
  background: #f7fbf8;
}

:root[data-theme="light"] .theme-page-sim :is(.event-narrative, .tape-row p, #resultNotes) {
  color: #536b60;
}

:root[data-theme="light"] .theme-page-sim .toast {
  background: #ffffff;
  color: var(--text);
}

/* Standalone smart-money fallback page. */
:root[data-theme="dark"] body.theme-page-smartmoney {
  background: #10161b;
  color: #e7edf1;
}

:root[data-theme="dark"] .theme-page-smartmoney :is(header, .trader) {
  border-color: #33404a;
  background: #151d23;
}

:root[data-theme="dark"] .theme-page-smartmoney :is(.card, .chip, input) {
  border-color: #36434d;
  background: #1c252c;
  color: #e7edf1;
}

:root[data-theme="dark"] .theme-page-smartmoney :is(.pill, button.ghost, a.ghost) {
  background: #27323b;
  color: #c8d3da;
}

:root[data-theme="dark"] .theme-page-smartmoney :is(.muted, .hint, .chip small, h3) {
  color: #9fb0ba;
}

:root[data-theme="light"] body.theme-page-smartmoney {
  background: #f2f6f7;
  color: #17252c;
}

:root[data-theme="light"] .theme-page-smartmoney :is(header, .trader) {
  border-color: #d5e0e5;
  background: #ffffff;
}

:root[data-theme="light"] .theme-page-smartmoney :is(.card, .chip, input) {
  border-color: #d7e2e7;
  background: #f7fafb;
  color: #17252c;
}

:root[data-theme="light"] .theme-page-smartmoney :is(.pill, button.ghost, a.ghost) {
  background: #eaf0f3;
  color: #526671;
}

:root[data-theme="light"] .theme-page-smartmoney :is(.muted, .hint, .chip small, h3) {
  color: #657985;
}

@media (max-width: 760px) {
  .theme-toggle {
    flex-basis: 36px;
    width: 36px;
    min-width: 36px;
    min-height: 36px;
    height: 36px;
  }

  .account-toolbar .theme-toggle {
    position: sticky;
    left: 0;
    z-index: 3;
    order: -1;
    background: var(--panel);
    box-shadow: 8px 0 14px rgba(17, 23, 28, 0.12);
  }

  :root[data-theme="dark"] .account-toolbar .theme-toggle {
    box-shadow: 8px 0 14px rgba(0, 0, 0, 0.3);
  }

  .theme-toggle-floating {
    top: max(10px, env(safe-area-inset-top));
    right: max(10px, env(safe-area-inset-right));
  }
}

@media print {
  .theme-toggle {
    display: none !important;
  }
}
