/* Effective mode is set before paint; chart and CSS palettes share that mode. */
:root { color-scheme:light dark; }
html { min-height:100%; background:#fafafa; }
html[data-color-mode="light"] { color-scheme:light; --red:#bd343e; --green:#187043; --amber:#87580e; }
html[data-color-mode="light"] :is(.discovery-meta,.discovery-stock-status,.discovery-stock-source,.discovery-note,.discovery-footer,
  .playbook-note,.playbook-core-heading small,.focus-group small,.focus-stock>small,.focus-stock details>small,
  .selection-focus>footer,.focus-empty,.pool-meta,.pool-rules,.ee-asof,.ee-row small,.ee-tabs button span,
  .atlas-chart-controls small,.stock-chart-credit,.knowledge-coverage small,.knowledge-method summary span,
  .knowledge-rule summary span,.knowledge-rule small,.knowledge-method small,.knowledge-checks>small) { color:#596571; }
html[data-color-mode="light"] .stock-chart-credit a { color:#1767b6; }
html[data-color-mode="light"] .stock-chart-legend .ma5 { color:#92600e; }
html[data-color-mode="light"] :is(.stock-chart-legend .change-up,.ee-up,.signal-scan-metric.scan-up,.negative) { color:#bd343e; }
html[data-color-mode="light"] .signal-scan-metric.scan-down { color:#167457; }
html[data-color-mode="light"] .pipeline-stages b, html[data-color-mode="light"] .warning { color:#87580e; }
html[data-color-mode="light"] .positive { color:#187043; }

html[data-color-mode="dark"], html[data-color-mode="dark"] .mobile-app {
  color-scheme:dark;
  --bg:#101012; --page:#101012; --surface:#1c1c1e; --surface-2:#242427; --surface-soft:#242427;
  --ink:#f2f2f7; --text:#f2f2f7; --muted:#b0b0ba; --line:#38383e; --line-strong:#54545c;
  --blue:#79cedb; --teal:#79cedb; --blue-soft:#203436; --accent:#79d1c6; --accent-soft:#203432;
  --red:#ff737c; --red-soft:#3c252b; --green:#62cba6; --green-soft:#20392e;
  --amber:#e5b563; --amber-soft:#383024; --shadow:0 8px 28px #00000040;
  --glass:linear-gradient(155deg,rgba(72,72,78,.64),rgba(38,38,44,.44));
  --glass-edge:rgba(255,255,255,.16); --glass-shadow:inset 0 1px 0 #ffffff1a,0 2px 8px #00000030;
}
html[data-color-mode="dark"], html[data-color-mode="dark"] body { background-color:var(--page); color:var(--ink); }
html[data-color-mode="dark"] .mobile-app .mobile-shell,
html[data-color-mode="dark"] .mobile-app .mobile-header,
html[data-color-mode="dark"] .mobile-app .review-tab-nav { background:var(--page); }
html[data-color-mode="dark"] .mobile-app .mobile-page-nav {
  background:linear-gradient(155deg,rgba(64,64,70,.60),rgba(30,30,35,.38) 52%,rgba(45,48,52,.42));
  border-color:#ffffff26; box-shadow:inset 0 1px 0 #ffffff24,0 8px 28px #00000059;
}
html[data-color-mode="dark"] .mobile-app .mobile-page-nav button { color:#d1d1da; }
html[data-color-mode="dark"] .mobile-app .mobile-page-nav button.active {
  color:#a2eee5; background:linear-gradient(155deg,rgba(116,139,143,.36),rgba(81,102,106,.22));
  box-shadow:inset 0 1px 0 #ffffff30,inset 0 0 0 1px #ffffff17,0 2px 8px #00000026;
}
html[data-color-mode="dark"] .mobile-app :is(.icon-button,.reader-nav button,.review-tab-nav button,.m-refine-tabs button,.core-track-switch button,.signal-filters button,.stock-exclusion-buttons button,.stock-chart-mode button,.chart-sequence-bar button,.m-stock-pager button,.m-stock-filters>summary) {
  color:#dadbe2; border-color:#ffffff21; background:var(--glass); box-shadow:var(--glass-shadow);
}
html[data-color-mode="dark"] .mobile-app :is(.reader-nav button[aria-current=page],.review-tab-nav button[aria-selected=true],.m-refine-tabs button[aria-pressed=true],.core-track-switch button.active,.signal-filters button.active,.stock-exclusion-buttons button[aria-pressed=true],.stock-chart-mode button.active) {
  color:#a2eee5; background:linear-gradient(145deg,#354849,#263739); border-color:#648283;
}
html[data-color-mode="dark"] .brand-mark, html[data-color-mode="dark"] .mobile-app .brand-mark,
html[data-color-mode="dark"] .login-brand>img { background:#ed2438; }
html[data-color-mode="dark"] img[src^="/static/mobile-assets/"][src$=".svg"] { filter:brightness(0) invert(.9); }
html[data-color-mode="dark"] .mobile-app .app-disclosure>summary::after { filter:invert(1); }
html[data-color-mode="dark"] .stock-chart-legend .ma5 { color:#e5b563; }
html[data-color-mode="dark"] .stock-chart-legend .ma10 { color:#7bb8f5; }
html[data-color-mode="dark"] .stock-chart-legend .ma20 { color:#d99ad0; }
html[data-color-mode="dark"] .stock-chart-legend .change-up { color:var(--red); }
html[data-color-mode="dark"] .stock-chart-legend .change-down { color:var(--green); }
html[data-color-mode="dark"] :is(.stock-chart-host,.atlas-plot) { background:#1c1c1e; }
html[data-color-mode="dark"] .stock-chart-backdrop { background:rgba(0,0,0,.62); }
html[data-color-mode="dark"] .stock-chart-loading { background:rgba(28,28,30,.92); color:var(--text); }
html[data-color-mode="dark"] button.primary { background:#79d1c6; border-color:#79d1c6; color:#112929; }
html[data-color-mode="dark"] :is(input,select,textarea) { color-scheme:dark; }
html[data-color-mode="dark"] input::placeholder { color:#a6a6b0; opacity:1; }
html[data-color-mode="dark"] ::selection { background:#42606a; color:#fff; }

.header-appearance-actions { display:flex; align-items:center; gap:8px; flex:0 0 auto; }
.mobile-header { gap:10px; }
.mobile-header > .brand-lockup { flex:1; min-width:0; }
.mobile-app #headerMeta { white-space:normal; }
html .theme-picker {
  position:relative; display:grid; place-items:center; flex:0 0 44px; width:44px; height:44px;
  margin:0; padding:0; border:1px solid rgba(100,110,120,.14); border-radius:50%;
  background:linear-gradient(155deg,rgba(255,255,255,.82),rgba(245,248,250,.44));
  box-shadow:inset 0 1px 0 #ffffffc9,0 2px 8px #172b3d08;
  backdrop-filter:blur(18px) saturate(140%); -webkit-backdrop-filter:blur(18px) saturate(140%);
  box-sizing:border-box;
}
html .theme-picker > img { width:20px; height:20px; pointer-events:none; }
html .theme-picker > select {
  position:absolute; inset:0; opacity:0; width:100%; height:100%; min-width:0; min-height:44px;
  margin:0; padding:0; border:0; cursor:pointer; font-size:16px; touch-action:manipulation;
}
html .theme-picker:focus-within { outline:2px solid var(--blue,#086b76); outline-offset:3px; }
html[data-color-mode="dark"] .theme-picker { border-color:#ffffff21; background:var(--glass); box-shadow:var(--glass-shadow); }
@media (prefers-contrast:more), (prefers-reduced-transparency:reduce) {
  html .theme-picker { background:#fff; backdrop-filter:none; -webkit-backdrop-filter:none; box-shadow:none; border-color:#596571; }
  html[data-color-mode="dark"] .theme-picker,
  html[data-color-mode="dark"] .mobile-app .mobile-page-nav,
  html[data-color-mode="dark"] .mobile-app .mobile-page-nav button.active,
  html[data-color-mode="dark"] .mobile-app :is(.icon-button,.reader-nav button,.review-tab-nav button,.stock-chart-mode button,.signal-filters button) {
    background:#242427; backdrop-filter:none; -webkit-backdrop-filter:none; border-color:#8e8e98; box-shadow:none;
  }
  html[data-color-mode="dark"] .mobile-app .mobile-page-nav button.active { background:#38494b; color:#fff; }
}
