:root {
  --traid-ink: #05060b;
  --traid-blue: #2563eb;
  --traid-blue-bright: #4f8cff;
  --traid-purple: #7c3aed;
  --traid-purple-bright: #9b6cff;
  --traid-gradient: linear-gradient(135deg, var(--traid-purple) 0%, var(--traid-blue) 100%);
  --traid-theme-duration: 333ms;
  --traid-theme-ease: ease;
}

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: var(--traid-theme-duration);
  animation-timing-function: var(--traid-theme-ease);
}

html.traid-theme-transition *,
html.traid-theme-transition *::before,
html.traid-theme-transition *::after {
  transition-property: color, background-color, border-color, outline-color, box-shadow, fill, stroke, opacity, filter !important;
  transition-duration: var(--traid-theme-duration) !important;
  transition-timing-function: var(--traid-theme-ease) !important;
}

.traid-logo-stack {
  position: relative;
  display: block;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 9px;
}
.traid-logo {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}
.traid-logo-stack .traid-logo {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--traid-theme-duration) var(--traid-theme-ease);
}
html[data-theme="light"] .traid-logo-stack .traid-logo-light { opacity: 1; }
html[data-theme="dark"] .traid-logo-stack .traid-logo-dark { opacity: 1; }
.home-logo { width: 34px; height: 34px; }
.terminal-logo { width: 38px; height: 38px; }

.traid-theme-toggle {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--home-line, var(--line, rgba(160,174,198,.2)));
  border-radius: 10px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  transition: border-color var(--traid-theme-duration) var(--traid-theme-ease), background-color var(--traid-theme-duration) var(--traid-theme-ease), color var(--traid-theme-duration) var(--traid-theme-ease), transform .16s ease;
}
.traid-theme-toggle:hover { transform: translateY(-1px); border-color: rgba(79,140,255,.52); }
.traid-theme-toggle:focus-visible { outline: 2px solid var(--traid-blue-bright); outline-offset: 2px; }
.home-header .traid-theme-toggle { margin-left: 2px; }
.top-actions .traid-theme-toggle { width: 35px; height: 35px; border-radius: 9px; }

.home-kicker,
.text-button { color: var(--traid-blue-bright) !important; }
.home-button.primary,
.primary-button:not(.buy):not(.sell),
.firebase-google-button { background: var(--traid-gradient) !important; color: #fff !important; }
.segmented button.active,
.watch-item.active { border-color: rgba(79,140,255,.32) !important; }
.swatch.forecast { background: var(--traid-gradient) !important; }
.switch-control input:checked + .switch { background: var(--traid-gradient) !important; }

html[data-theme="light"] {
  --home-bg: #f4f6fb;
  --home-bg-soft: #eef2f8;
  --home-panel: #ffffff;
  --home-panel-2: #f7f9fc;
  --home-line: rgba(38,52,74,.13);
  --home-line-strong: rgba(38,52,74,.22);
  --home-text: #101521;
  --home-muted: #5e6a7c;
  --home-faint: #7d8898;
  --home-blue: var(--traid-blue);
  --home-violet: var(--traid-purple);
  --home-teal: #0f9f91;
  --home-red: #d83b57;
}
html[data-theme="light"] body.home-body { background: var(--home-bg); color: var(--home-text); }
html[data-theme="light"] .home-header { background: rgba(247,249,253,.88); border-color: rgba(38,52,74,.11); }
html[data-theme="light"] .home-nav a,
html[data-theme="light"] .home-nav button { color: #536074; }
html[data-theme="light"] .home-nav a:hover,
html[data-theme="light"] .home-nav button:hover { color: #111827; }
html[data-theme="light"] .home-header-cta { color: #111827 !important; background: #fff; }
html[data-theme="light"] .home-hero h1 span { color: #667387; }
html[data-theme="light"] .home-button.secondary { background: #fff; color: #1b2432; }
html[data-theme="light"] .home-system-strip,
html[data-theme="light"] .home-replay,
html[data-theme="light"] .home-mobile-section,
html[data-theme="light"] .home-waitlist { background: #eef2f8; }
html[data-theme="light"] .home-system-grid strong,
html[data-theme="light"] .home-context-item strong,
html[data-theme="light"] .home-process-row h3,
html[data-theme="light"] .market-row strong { color: #172033; }
html[data-theme="light"] .home-evidence-card { background: transparent; }
html[data-theme="light"] .price-card { background: #fff; }
html[data-theme="light"] .price-card.featured { background: #f9fbff; border-color: rgba(79,140,255,.32); }
html[data-theme="light"] .home-footer { background: #f4f6fb; }
html[data-theme="light"] .home-menu { color: #172033; background: #fff; }
html[data-theme="light"] .waitlist-dialog { background: #fff; color: #111827; }
html[data-theme="light"] .waitlist-field input,
html[data-theme="light"] .waitlist-field select { background: #f7f9fc; color: #111827; }
html[data-theme="light"] .waitlist-close { color: #263246; background: #f7f9fc; }
html[data-theme="light"] .waitlist-success-detail strong { color: #172033; }

html[data-theme="light"] {
  --bg: #edf1f7;
  --surface: rgba(255,255,255,.94);
  --surface-2: #f7f9fc;
  --surface-3: #eef2f8;
  --line: rgba(38,52,74,.12);
  --line-strong: rgba(38,52,74,.22);
  --text: #111827;
  --muted: #667287;
  --blue: var(--traid-blue);
  --blue-2: var(--traid-blue-bright);
  --purple: var(--traid-purple);
  --purple-2: var(--traid-purple-bright);
  --cyan: #0891b2;
  --green: #0f9f91;
  --red: #dc3f5b;
  --amber: #b7791f;
  --shadow: 0 18px 55px rgba(34,48,72,.10);
}
html[data-theme="light"] body:not(.home-body) {
  color: var(--text);
  background: #edf1f7;
}
html[data-theme="light"] .topbar { background: rgba(247,249,253,.9); }
html[data-theme="light"] .panel { background: linear-gradient(180deg, rgba(255,255,255,.98), rgba(246,249,253,.98)); }
html[data-theme="light"] .panel::before { background: linear-gradient(90deg, transparent, rgba(37,99,235,.18), rgba(124,58,237,.18), transparent); }
html[data-theme="light"] .icon-button,
html[data-theme="light"] .ghost-button,
html[data-theme="light"] .danger-outline,
html[data-theme="light"] .pill,
html[data-theme="light"] .firebase-account-button,
html[data-theme="light"] .firebase-google-button,
html[data-theme="light"] .firebase-phone-button,
html[data-theme="light"] .firebase-signout-button { background: rgba(255,255,255,.82); }
html[data-theme="light"] .firebase-google-button { background: var(--traid-gradient) !important; color: #fff !important; }
html[data-theme="light"] .select-control,
html[data-theme="light"] input,
html[data-theme="light"] select,
html[data-theme="light"] textarea,
html[data-theme="light"] .segmented { background: rgba(248,250,253,.96); color: var(--text); }
html[data-theme="light"] .watch-item.active { background: linear-gradient(135deg, rgba(37,99,235,.08), rgba(124,58,237,.06)); }
html[data-theme="light"] .chart-wrap { background: #f8fafc; }
html[data-theme="light"] .forecast-label { color: #5b21b6; background: rgba(124,58,237,.07); border-color: rgba(124,58,237,.18); }
html[data-theme="light"] .stale-overlay { background: rgba(247,249,253,.76); }
html[data-theme="light"] .firebase-auth-backdrop { background: rgba(23,31,45,.42); }
html[data-theme="light"] .firebase-auth-card { background: linear-gradient(180deg,#fff,#f5f8fc); color: var(--text); }
html[data-theme="light"] .firebase-profile { background: #f7f9fc; }
html[data-theme="light"] .mobile-nav { background: rgba(247,249,253,.95); }
html[data-theme="light"] .drawer { background: #fff; color: var(--text); }

/* Theme-aware Traid cursor for fine-pointer devices only. The source assets are
   180x180, so 85px/85px is ~47%/47%: 3% left and 3% up from exact center. */
@media (hover: hover) and (pointer: fine) {
  html[data-theme="light"],
  html[data-theme="light"] body,
  html[data-theme="light"] body * {
    cursor: url('/assets/branding/traid-cursor-dark.png') 85 85, auto !important;
  }

  html[data-theme="dark"],
  html[data-theme="dark"] body,
  html[data-theme="dark"] body * {
    cursor: url('/assets/branding/traid-cursor-light.png') 85 85, auto !important;
  }
}

@media (max-width: 760px) {
  .home-header .traid-theme-toggle { margin-left: auto; }
  .home-menu { margin-left: 0 !important; }
  html[data-theme="light"] .home-nav { background: #fff; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) { animation-duration: .01ms; }
  html.traid-theme-transition *,
  html.traid-theme-transition *::before,
  html.traid-theme-transition *::after,
  .traid-logo-stack .traid-logo { transition-duration: .01ms !important; }
}
