:root {
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-7: 2rem;
  --space-8: 3rem;
  --space-9: 4.5rem;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --text-display-size: clamp(1.875rem, 1.3rem + 2vw, 2.625rem);
  --text-display-tracking: -0.02em;
  --text-display-leading: 1.08;

  --text-title-size: 1.1875rem;
  --text-title-tracking: -0.012em;
  --text-title-leading: 1.25;

  --text-eyebrow-size: 0.8125rem;
  --text-eyebrow-tracking: 0.07em;
  --text-eyebrow-leading: 1.2;

  --text-body-size: 1rem;
  --text-body-tracking: 0em;
  --text-body-leading: 1.6;

  --text-body-sm-size: 0.9375rem;
  --text-body-sm-tracking: 0.003em;
  --text-body-sm-leading: 1.55;

  --text-caption-size: 0.8125rem;
  --text-caption-tracking: 0.01em;
  --text-caption-leading: 1.4;

  --ease-standard: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration-fast: 140ms;
  --duration-standard: 320ms;

  --elevation-card: 0 1px 2px rgba(0, 0, 0, 0.18), 0 8px 24px -8px rgba(0, 0, 0, 0.3);
  --elevation-card-hover: 0 2px 4px rgba(0, 0, 0, 0.2), 0 20px 44px -12px rgba(0, 0, 0, 0.45);
  --elevation-sheet: 0 12px 40px rgba(0, 0, 0, 0.32), 0 2px 8px rgba(0, 0, 0, 0.24);

  --accent: var(--primary);
  --accent-strong: var(--primary-light);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-0: #060c1c;
    --bg-1: #0a1330;
    --bg-2: #0e1b40;
    --fg-0: rgba(255, 255, 255, 0.96);
    --fg-1: rgba(255, 255, 255, 0.72);
    --fg-2: rgba(255, 255, 255, 0.55);
    --accent-fg: #ffffff;
    --hairline: rgba(255, 255, 255, 0.1);
    --material-thin: rgba(10, 17, 40, 0.55);
    --material-thick: rgba(6, 11, 26, 0.75);
    --material-sheet: rgba(10, 16, 34, 0.92);
    --surface-card: rgba(255, 255, 255, 0.06);
    --surface-card-hover: rgba(255, 255, 255, 0.1);
    --surface-icon: rgba(255, 255, 255, 0.08);
    --surface-sunken: rgba(0, 0, 0, 0.2);
    --scrim: rgba(3, 6, 14, 0.55);
  }
}

@media (prefers-color-scheme: light) {
  :root {
    --bg-0: #eef1f6;
    --bg-1: #f3f5f9;
    --bg-2: #dfe6f2;
    --fg-0: rgba(10, 15, 30, 0.94);
    --fg-1: rgba(10, 15, 30, 0.68);
    --fg-2: rgba(10, 15, 30, 0.5);
    --accent-fg: #ffffff;
    --hairline: rgba(10, 15, 30, 0.09);
    --material-thin: rgba(255, 255, 255, 0.62);
    --material-thick: rgba(255, 255, 255, 0.8);
    --material-sheet: rgba(255, 255, 255, 0.96);
    --surface-card: rgba(255, 255, 255, 0.72);
    --surface-card-hover: rgba(255, 255, 255, 0.9);
    --surface-icon: rgba(10, 15, 30, 0.06);
    --surface-sunken: rgba(10, 15, 30, 0.04);
    --scrim: rgba(10, 15, 30, 0.28);
  }
}

html[data-theme="dark"] {
  --bg-0: #060c1c;
  --bg-1: #0a1330;
  --bg-2: #0e1b40;
  --fg-0: rgba(255, 255, 255, 0.96);
  --fg-1: rgba(255, 255, 255, 0.72);
  --fg-2: rgba(255, 255, 255, 0.55);
  --accent-fg: #ffffff;
  --hairline: rgba(255, 255, 255, 0.1);
  --material-thin: rgba(10, 17, 40, 0.55);
  --material-thick: rgba(6, 11, 26, 0.75);
  --material-sheet: rgba(10, 16, 34, 0.92);
  --surface-card: rgba(255, 255, 255, 0.06);
  --surface-card-hover: rgba(255, 255, 255, 0.1);
  --surface-icon: rgba(255, 255, 255, 0.08);
  --surface-sunken: rgba(0, 0, 0, 0.2);
  --scrim: rgba(3, 6, 14, 0.55);
}

html[data-theme="light"] {
  --bg-0: #eef1f6;
  --bg-1: #f3f5f9;
  --bg-2: #e6eaf2;
  --fg-0: rgba(10, 15, 30, 0.94);
  --fg-1: rgba(10, 15, 30, 0.68);
  --fg-2: rgba(10, 15, 30, 0.48);
  --accent-fg: #ffffff;
  --hairline: rgba(10, 15, 30, 0.08);
  --material-thin: rgba(255, 255, 255, 0.6);
  --material-thick: rgba(255, 255, 255, 0.78);
  --material-sheet: rgba(255, 255, 255, 0.96);
  --surface-card: rgba(255, 255, 255, 0.72);
  --surface-card-hover: rgba(255, 255, 255, 0.92);
  --surface-icon: rgba(10, 15, 30, 0.06);
  --surface-sunken: rgba(10, 15, 30, 0.04);
  --scrim: rgba(10, 15, 30, 0.28);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) body.home-shell .futuristic-background::before,
  html:not([data-theme]) body.prep-shell .futuristic-background::before,
  html:not([data-theme]) body.cold-shell .futuristic-background::before,
  html:not([data-theme]) body.summary-shell .futuristic-background::before,
  html:not([data-theme]) body.scope-shell .futuristic-background::before,
  html:not([data-theme]) body.dash-shell .futuristic-background::before,
  html:not([data-theme]) body.comp-shell .futuristic-background::before,
  html:not([data-theme]) body.forecast-shell .futuristic-background::before,
  html:not([data-theme]) body.chat-hist-shell .futuristic-background::before,
  html:not([data-theme]) body.feedback-shell .futuristic-background::before {
    opacity: 0;
  }
}

html[data-theme="light"] body.home-shell .futuristic-background::before,
html[data-theme="light"] body.prep-shell .futuristic-background::before,
html[data-theme="light"] body.cold-shell .futuristic-background::before,
html[data-theme="light"] body.summary-shell .futuristic-background::before,
html[data-theme="light"] body.scope-shell .futuristic-background::before,
html[data-theme="light"] body.dash-shell .futuristic-background::before,
html[data-theme="light"] body.comp-shell .futuristic-background::before,
html[data-theme="light"] body.forecast-shell .futuristic-background::before,
html[data-theme="light"] body.chat-hist-shell .futuristic-background::before,
html[data-theme="light"] body.feedback-shell .futuristic-background::before {
  opacity: 0;
}

html[data-theme="dark"] body.home-shell .futuristic-background::before,
html[data-theme="dark"] body.prep-shell .futuristic-background::before,
html[data-theme="dark"] body.cold-shell .futuristic-background::before,
html[data-theme="dark"] body.summary-shell .futuristic-background::before,
html[data-theme="dark"] body.scope-shell .futuristic-background::before,
html[data-theme="dark"] body.dash-shell .futuristic-background::before,
html[data-theme="dark"] body.comp-shell .futuristic-background::before,
html[data-theme="dark"] body.forecast-shell .futuristic-background::before,
html[data-theme="dark"] body.chat-hist-shell .futuristic-background::before,
html[data-theme="dark"] body.feedback-shell .futuristic-background::before {
  opacity: 0.22;
}

@media (prefers-contrast: more) {
  body.home-shell {
    --hairline: currentColor;
  }
  .home-tool-card,
  .home-metric-card {
    border-width: 1.5px !important;
  }
}

@media (prefers-reduced-transparency: reduce) {
  :root {
    --material-thin: var(--bg-1);
    --material-thick: var(--bg-1);
    --material-sheet: var(--bg-1);
  }
}

.blue-toast-container {
  position: fixed;
  top: max(1rem, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10002;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: min(30rem, calc(100vw - 2rem));
  pointer-events: none;
}

.blue-toast {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 2.25rem 0.875rem 1rem;
  border-radius: var(--radius-md, 14px);
  background: var(--material-sheet, rgba(20, 20, 30, 0.92));
  border: 1px solid var(--hairline, rgba(255, 255, 255, 0.12));
  box-shadow: var(--elevation-sheet, 0 12px 40px rgba(0, 0, 0, 0.32));
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  color: var(--fg-0, #ffffff);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.45;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
  transition: opacity 220ms cubic-bezier(0.2, 0.7, 0.2, 1), transform 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

.blue-toast--in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.blue-toast--out {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}

.blue-toast::before {
  content: '';
  flex-shrink: 0;
  width: 4px;
  align-self: stretch;
  border-radius: var(--radius-pill, 999px);
  background: var(--accent-strong, #60a5fa);
}

.blue-toast--error::before {
  background: #ff453a;
}

.blue-toast--success::before {
  background: #30d158;
}

.blue-toast-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-pill, 999px);
  background: transparent;
  color: var(--fg-2, rgba(255, 255, 255, 0.55));
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}

.blue-toast-close:hover {
  background: var(--surface-icon, rgba(255, 255, 255, 0.08));
  color: var(--fg-0, #ffffff);
}

@media (prefers-reduced-motion: reduce) {
  .blue-toast {
    transition: opacity 200ms ease;
    transform: none;
  }
  .blue-toast--in,
  .blue-toast--out {
    transform: none;
  }
}

.header-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.125rem;
  height: 2.125rem;
  padding: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  background: rgba(10, 17, 40, 0.6);
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  flex-shrink: 0;
  backdrop-filter: blur(6px);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.14s ease;
}

.header-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.8);
  color: #ffffff;
}

.header-theme-toggle:active {
  transform: scale(0.94);
}

.header-theme-icon {
  display: none;
  width: 1.05rem;
  height: 1.05rem;
}

.header-theme-toggle:not([aria-pressed]) .header-theme-icon--sun,
.header-theme-toggle[aria-pressed="false"] .header-theme-icon--sun,
.header-theme-toggle[aria-pressed="true"] .header-theme-icon--moon {
  display: block;
}

:root {
  --header-edge-width: 1px;
  --header-edge-color: rgba(10, 15, 30, 0.12);
  --header-edge-shadow: 0 1px 12px rgba(10, 15, 30, 0.06);
}

html[data-theme="dark"] {
  --header-edge-width: 2px;
  --header-edge-color: rgba(255, 255, 255, 0.1);
  --header-edge-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --header-edge-width: 2px;
    --header-edge-color: rgba(255, 255, 255, 0.1);
    --header-edge-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  }
}

html body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header {
  border-bottom: var(--header-edge-width) solid var(--header-edge-color);
  box-shadow: var(--header-edge-shadow);
}

html[data-theme="dark"] body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header {
  background: #000e1f;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

html[data-theme="dark"] body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header::after {
  display: none;
}

html[data-theme="dark"] body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header-title,
html[data-theme="dark"] body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header-title-white {
  color: #ffffff;
}

html[data-theme="dark"] body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header-subtitle {
  color: rgba(255, 255, 255, 0.8);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme]) body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header {
    background: #000e1f;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  html:not([data-theme]) body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header::after {
    display: none;
  }

  html:not([data-theme]) body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header-title,
  html:not([data-theme]) body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header-title-white {
    color: #ffffff;
  }

  html:not([data-theme]) body:is(.home-shell, .prep-shell, .cold-shell, .summary-shell, .comp-shell) .header-subtitle {
    color: rgba(255, 255, 255, 0.8);
  }
}
