/*
  EarningsGPT UI system
  Purpose: Central tokens and components for a consistent, premium interface.
  Conventions: Use CSS variables; mobile-first tweaks via media queries; motion respects reduced‑motion.
*/
:root {
  /* Color system */
  --bg: #ffffff;
  --ink: #0a0e27;
  --sub: #364153;
  --muted: #667085;
  --border: #eef0f3;
  --accent: #00bfa6;
  --accent-ink: #052a25;

  /* Typography */
  --font-sans: "Plus Jakarta Sans", ui-sans-serif, system-ui,
    -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  --font-display: "Space Grotesk", ui-sans-serif, system-ui,
    -apple-system, Segoe UI, Roboto, Helvetica, Arial;

  /* Type scale */
  --fs-0: 0.875rem; /* 14 */
  --fs-1: 0.9375rem; /* 15 */
  --fs-2: 1rem; /* 16 */
  --fs-3: 1.125rem; /* 18 */
  --fs-4: 1.25rem; /* 20 */
  --fs-5: 1.5rem; /* 24 */
  --fs-6: 1.875rem; /* 30 */
  --fs-7: 2.25rem; /* 36 */
  --fs-8: clamp(2.4rem, 6vw, 4.75rem); /* Hero */

  /* Layout */
  --container: 960px;
  --radius: 12px;

  /* Spacing */
  --s-2: 0.5rem;
  --s-3: 0.75rem;
  --s-4: 1rem;
  --s-6: 1.5rem;
  --s-8: 2rem;
  --s-12: 3rem;
  --s-16: 4rem;
  --s-24: 6rem;
  --s-32: 8rem;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
  margin: 0;
  padding: 0;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-kerning: normal;
  font-feature-settings: "ss01" 1, "ss02" 1, "tnum" 1, "liga" 1,
    "zero" 1;
  font-variant-numeric: tabular-nums lining-nums;
  font-synthesis-weight: none;
  font-synthesis-style: none;
  font-optical-sizing: auto;
  hanging-punctuation: first last;
}

p,
li {
  text-wrap: pretty;
  hyphens: auto;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
  text-underline-offset: 3px;
  text-decoration-thickness: 0.08em;
}

.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--s-6);
}

/* Header */
.site-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: saturate(1.1) blur(6px);
  -webkit-backdrop-filter: saturate(1.1) blur(6px);
  transition: transform 0.3s ease;
}

/* During programmatic auto-scroll, reduce blur to prevent composition hitches */
body[data-autoscrolling="true"] .site-header { backdrop-filter: none !important; -webkit-backdrop-filter: none !important; }

.nav {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.015em;
  font-size: 1.625rem;
  line-height: 1;
  white-space: nowrap;
}

.brand em {
  color: var(--accent);
  font-style: normal;
  letter-spacing: -0.01em;
}

/* Brand animations: gentle load-in, hover underline, and accent shimmer */
@media (prefers-reduced-motion: no-preference) {
  @keyframes brandIn {
    from { opacity: 0; transform: translateY(6px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
  }
}

.brand {
  position: relative;
  will-change: transform, opacity;
}

/* On-load reveal (respects reduced motion) */
@media (prefers-reduced-motion: no-preference) {
  .brand { animation: brandIn 420ms cubic-bezier(0.22, 1, 0.36, 1) both; }
}

/* Underline that glides in on hover/focus */
.brand::after {
  content: "";
  position: absolute;
  left: 0;
  right: auto;
  bottom: -6px;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), rgba(0,191,166,0.15));
  border-radius: 2px;
  transition: width 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

@media (hover: hover) {
  .brand:hover::after, .brand:focus-visible::after { width: 100%; }
  .brand:hover { transform: translateY(-1px); }
}

/* Accent shimmer for GPT */
/* Uses background-clip text for a modern, premium feel */
@media (prefers-reduced-motion: no-preference) {
  .brand em {
    color: transparent;
    background-image: linear-gradient(90deg, var(--accent) 0%, #1ad1bd 50%, var(--accent) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    transition: background-position 700ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  @media (hover: hover) {
    .brand:hover em { background-position: 100% 0; }
  }
}

/* Brand shimmer when JS cadence fires */
@media (prefers-reduced-motion: no-preference) {
  .brand.brand-pulse em { background-position: 100% 0; transition: background-position 900ms cubic-bezier(0.22, 1, 0.36, 1); }
}

/* Footer brand: share underline microinteraction */
.brand-small {
  position: relative;
}
.brand-small::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -4px;
  height: 2px;
  width: 0;
  background: linear-gradient(90deg, var(--accent), rgba(0,191,166,0.15));
  border-radius: 2px;
  transition: width 300ms cubic-bezier(0.22, 1, 0.36, 1);
}
@media (hover: hover) {
  .brand-small:hover::after, .brand-small:focus-visible::after { width: 100%; }
}

/* Positioning for canvas-based orbit around brand */
.brand { position: relative; }
.brand .brand-orbit {
  position: absolute;
  pointer-events: none;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  filter: saturate(1.1);
}

.nav-actions {
  display: flex;
  gap: var(--s-4);
  align-items: center;
  font-size: var(--fs-2);
}

.link {
  color: var(--sub);
  font-weight: 600;
  letter-spacing: 0.005em;
}

.link:hover,
.link:focus-visible {
  color: var(--ink);
  outline: none;
  text-decoration: underline;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid #cfd5dd;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: transform 120ms ease, background-color 120ms ease,
    border-color 120ms ease;
  font-size: var(--fs-2);
  line-height: 1;
  touch-action: manipulation;
}

.btn:hover {
  transform: translateY(-1px);
  border-color: #b8c1cb;
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: #09a792;
}

.btn-primary:hover {
  border-color: #0a8f7d;
}

/* Sections */
section,
header.hero {
  padding-block: clamp(var(--s-24), 12vw, var(--s-32));
  border-bottom: 1px solid var(--border);
}

/* Subpages: compact top spacing */
.subpage main > section:first-of-type,
.subpage main > header.hero:first-of-type {
  padding-top: var(--s-8);
}

/* Right-center dots navigation (fixed position across pages) */
.page-dots {
  position: fixed;
  right: max(36px, env(safe-area-inset-right) + 20px);
  top: 50%;
  --dot-size: 56px;
  --dot-gap: 14px;
  transform: translateY(-50%) translateZ(0);
  display: flex;
  flex-direction: column;
  gap: var(--dot-gap);
  z-index: 120;
  backface-visibility: hidden;
}

.dot-btn {
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 50%;
  border: 3px solid var(--accent);
  box-sizing: border-box;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 110ms cubic-bezier(0.22, 1, 0.36, 1);
  will-change: transform;
  backface-visibility: hidden;
  transform: translateZ(0);
  touch-action: manipulation;
}

@media (hover: hover) {
  .dot-btn:hover { transform: scale(1.03); }
}
@media (hover: none) {
  .dot-btn { transition: none; }
}

.dot-btn::after {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  transition: none; /* instant color swap */
}

.dot-btn.active::after { background: #fff; }
.dot-btn.active { background: var(--accent); border-width: 3px; }

/* Stage banner */
.stage-banner {
  background: #eefcf9;
  border-bottom: 1px solid #c7efe7;
  color: var(--accent-ink);
  font-weight: 700;
  font-size: var(--fs-1);
  letter-spacing: 0.01em;
  padding-block: var(--s-2);
}

.stage-banner .inner {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  text-align: center;
}

header.hero {
  text-align: center;
  margin-top: 0;
  padding-top: clamp(var(--s-24), 12vw, var(--s-32));
  position: relative;
  overflow: hidden;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--sub);
  font-weight: 700;
  font-size: var(--fs-1);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 6px;
}

.hero-title {
  margin: var(--s-4) 0 var(--s-3);
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.02;
  font-size: var(--fs-8);
  text-wrap: balance;
}

.hero-kicker {
  color: var(--sub);
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  max-width: 56ch;
  margin: 0 auto;
  letter-spacing: 0.005em;
}

.hero-cta {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
  margin-top: var(--s-8);
}

/* Conversion-led motion hooks */
@media (prefers-reduced-motion: no-preference) {
  @keyframes titleHighlight {
    0% { background-position: 0 110%; }
    20% { background-position: 0 100%; }
    100% { background-position: 0 110%; }
  }
}
.hero-title.cadence {
  background-image: linear-gradient(180deg, transparent 60%, rgba(0,191,166,0.22) 60%, rgba(0,191,166,0.22) 86%, transparent 86%);
  background-size: 100% 200%;
  background-repeat: no-repeat;
}
@media (prefers-reduced-motion: no-preference) {
  .hero-title.cadence { animation: titleHighlight 1000ms cubic-bezier(0.22,1,0.36,1); }
}

.cta-proof {
  font-size: var(--fs-1);
  color: var(--muted);
  letter-spacing: 0.01em;
  margin-top: 6px;
  text-align: center;
}
@media (prefers-reduced-motion: no-preference) {
  @keyframes fadeInQuick { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: translateY(0); } }
  .fade-in { animation: fadeInQuick 420ms cubic-bezier(0.22,1,0.36,1); }
}

.stage-fade { opacity: 1; transition: opacity 300ms ease; }
.stage-fade.is-updating { opacity: 0; }

/* Spectral overlay + CTA glow hooks */
.spectral-canvas, .glass-canvas { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
header.hero > .container { position: relative; z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  @keyframes ctaPulse {
    0% { box-shadow: 0 0 0 rgba(0,191,166,0); transform: translateY(0); }
    25% { box-shadow: 0 12px 34px rgba(0,191,166,0.26); transform: translateY(-1px); }
    100% { box-shadow: 0 0 0 rgba(0,191,166,0); transform: translateY(0); }
  }
  .cta-glow { animation: ctaPulse 1100ms cubic-bezier(0.22, 1, 0.36, 1); }
}

/* Slightly tighter hero CTA on subpages to keep action in view */
.subpage .hero-cta { margin-top: var(--s-6); }

/* Make primary actions feel substantial without changing copy */
.hero-cta .btn { min-width: 180px; }

/* Section titles */
.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  margin: 0 0 var(--s-4);
  text-wrap: balance;
}

/* Utilities */
.maxw-62ch { max-width: 62ch; }
.mt-s3 { margin-top: var(--s-3); }
.justify-start { justify-content: flex-start; }
.justify-center { justify-content: center; }
.text-center { text-align: center; }
.mx-auto { margin-inline: auto; }

.section-title + p,
.section-title + .list-item {
  margin-top: 0;
}

.list {
  display: grid;
  gap: var(--s-6);
  max-width: 62ch;
}

.list-item {
  font-size: var(--fs-3);
  line-height: 1.75;
  color: var(--ink);
  letter-spacing: 0.005em;
}

/* Improve scanability of key points without adding text */
.list .list-item { position: relative; padding-left: 18px; }
.list .list-item::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.9em;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.list-item strong {
  font-weight: 700;
}

/* Gallery */
.gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 4px;
  row-gap: 0;
  max-width: 1080px;
  margin-inline: auto;
}

.demo-card {
  padding: 0 !important;
  margin: 0 !important;
  margin-top: -35px !important;
  margin-bottom: -35px !important;
  border: none;
  background: transparent;
  line-height: 0;
  font-size: 0;
  display: block;
}

.demo-media {
  aspect-ratio: 4 / 3;
  border: none;
  background: transparent;
  width: 100%;
  display: block;
}

@media (max-width: 720px) {
  .gallery {
    grid-template-columns: 1fr;
    column-gap: 4px;
    row-gap: 0;
    max-width: 100%;
  }
  .demo-card { padding: 0; }
}

.disclaimer {
  color: var(--muted);
  font-size: var(--fs-1);
  margin-top: var(--s-8);
  font-style: italic;
  max-width: 62ch;
}

/* Dashboards (interactive, image-free) */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-6);
  max-width: 1440px;
  margin-inline: auto;
  margin-top: var(--s-12);
}

@media (max-width: 960px) { .dashboard-grid { grid-template-columns: 1fr; gap: var(--s-4); } }

.dash-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(10, 14, 39, 0.06);
  transition: transform 160ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 160ms ease;
}
.dash-card[data-size="l"] { grid-column: 1 / -1; }
.dash-card:hover, .dash-card:focus-within {
  transform: translateY(-3px);
  box-shadow: 0 16px 40px rgba(10, 14, 39, 0.10);
}
.dash-card[aria-expanded="true"] { box-shadow: 0 16px 36px rgba(10, 14, 39, 0.14); }

.dash-head {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-6);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #fafdfc 0%, #ffffff 100%);
}

/* Mobile-optimized dashboard layout */
@media (max-width: 640px) {
  .dash-head {
    padding: var(--s-4);
    gap: var(--s-2);
  }
}
.dash-head:focus-within { outline: 0; box-shadow: inset 0 0 0 2px rgba(0,191,166,0.2); }
.dash-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: clamp(1.1rem, 2.2vw, 1.35rem);
}

@media (max-width: 640px) {
  .dash-title {
    font-size: 1.1rem;
    line-height: 1.2;
  }
}
.dash-head .dash-hint { color: var(--muted); font-size: var(--fs-1); }
.dash-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-6);
}

@media (max-width: 640px) {
  .dash-metrics {
    gap: var(--s-2) var(--s-4);
  }
}
.dash-toggle {
  justify-self: end;
  margin-left: auto;
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: var(--fs-1);
}

@media (max-width: 640px) {
  .dash-toggle {
    height: 44px;
    padding: 0 16px;
    font-size: var(--fs-2);
    min-width: 100px;
    touch-action: manipulation;
  }
}
.dash-toggle:focus-visible { box-shadow: 0 0 0 4px rgba(0,191,166,0.16); }
.dash-content { max-height: 0; overflow: hidden; transition: max-height 260ms ease; }
.dash-card[aria-expanded="true"] .dash-content { max-height: 2000px; }
.kpi { display: grid; gap: 2px; min-width: 88px; }
.kpi-label { color: var(--muted); font-weight: 700; font-size: var(--fs-1); letter-spacing: .04em; text-transform: uppercase; }
.kpi-value { font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; }

@media (max-width: 640px) {
  .kpi {
    min-width: 72px;
    gap: 1px;
  }
  .kpi-label {
    font-size: var(--fs-0);
    letter-spacing: .02em;
  }
  .kpi-value {
    font-size: var(--fs-1);
    font-weight: 700;
  }
}

.dash-canvas { width: 100%; height: auto; display: block; background: linear-gradient(180deg, #fcfefd 0%, #ffffff 100%); border: 1px solid #eef2f6; border-radius: 10px; }

@media (max-width: 640px) {
  .dash-canvas {
    border-radius: 8px;
    /* Visually taller charts on phones for readability */
    min-height: 300px;
  }
}

/* KPI sign coloring */
.kpi-value.pos { color: var(--accent); }
.kpi-value.neg { color: #b91c1c; }

/* Summary chips accent */
.dash-chip { border-left: 3px solid var(--accent); }

/* Canvas color system for charts */
:root {
  --chart-green: #00bfa6;
  --chart-red: #b91c1c;
  --chart-blue: #2563eb;
  --chart-amber: #f59e0b;
  --chart-purple: #7c3aed;
  --chart-slate: #94a3b8;
}

.dash-details {
  padding: var(--s-4) var(--s-6);
  color: var(--sub);
  border-top: 1px solid var(--border);
  font-size: var(--fs-1);
  letter-spacing: .01em;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: max-height 220ms ease, opacity 220ms ease;
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .dash-details {
    padding: var(--s-3) var(--s-4);
    font-size: var(--fs-0);
  }
}
.dash-card:hover .dash-details, .dash-card:focus-within .dash-details {
  max-height: 120px;
  opacity: 1;
}

/* Methodology note under dashboards */
.dash-note {
  max-width: 1080px;
  margin: var(--s-6) auto 0;
  color: var(--muted);
  font-size: var(--fs-1);
  letter-spacing: 0.01em;
}

.dash-intro {
  max-width: 1080px;
  margin: var(--s-6) auto var(--s-4);
  color: var(--sub);
  font-size: var(--fs-2);
  letter-spacing: 0.01em;
}

/* Team */
.team-grid {
  display: grid;
  gap: var(--s-8);
  align-items: start;
}

@media (min-width: 720px) {
  .team-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.member {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--s-8);
  background: #fff;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto;
  gap: var(--s-4);
  min-height: 100%;
}

.member-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: var(--fs-5);
  margin: 0 0 var(--s-2);
}

.member-role {
  color: var(--sub);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin-bottom: var(--s-2);
}

.member-tagline {
  color: var(--sub);
  font-size: var(--fs-2);
  margin: 0 0 var(--s-2);
}

.member-bio {
  color: var(--ink);
  font-size: var(--fs-3);
  line-height: 1.7;
  margin: 0 0 var(--s-2);
}

.member-links a {
  color: var(--accent);
  font-weight: 700;
}

/* Avatar */
.avatar {
  display: inline-block;
  width: 168px;
  height: 168px;
  margin-bottom: var(--s-4);
  border-radius: 50%;
  border: 2px solid var(--border);
  overflow: hidden;
  background: #fff;
  place-self: start;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

/* Form */
.form {
  display: grid;
  gap: var(--s-6);
  max-width: 640px;
}

.row {
  display: grid;
  gap: var(--s-6);
}

@media (min-width: 720px) {
  .row-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.label {
  display: block;
  font-weight: 700;
  margin-bottom: var(--s-2);
  letter-spacing: 0.01em;
  font-size: var(--fs-2);
  color: var(--ink);
}

.input,
.select,
.textarea {
  width: 100%;
  height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  font: inherit;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
  font-size: var(--fs-2);
  letter-spacing: 0.005em;
}

.textarea {
  height: 160px;
  resize: vertical;
  line-height: 1.6;
}

.input::placeholder,
.textarea::placeholder {
  color: #9aa3af;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: #cbd5e1;
  box-shadow: 0 0 0 4px rgba(0, 191, 166, 0.16);
}

.help {
  color: var(--muted);
  font-size: var(--fs-1);
  margin-top: var(--s-2);
  letter-spacing: 0.005em;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.status {
  color: var(--sub);
  font-weight: 600;
  min-height: 1.2em;
  letter-spacing: 0.01em;
}

/* Footer */
.site-footer {
  padding-block: var(--s-16);
  color: var(--muted);
}

.footer-top {
  display: grid;
  gap: var(--s-4);
  align-items: start;
}

@media (min-width: 720px) {
  .footer-top {
    grid-template-columns: 1fr auto;
    align-items: center;
  }
}

.brand-small {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  font-size: 1.05rem;
}

.footer-links {
  display: grid;
  gap: 6px;
  justify-items: end;
  text-align: right;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.005em;
}

/* Accessibility */
:focus-visible {
  outline: 3px solid rgba(0, 191, 166, 0.5);
  outline-offset: 2px;
  border-radius: 10px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* Page transitions */
@media (prefers-reduced-motion: no-preference) {
  @keyframes pageIn { from { opacity: 0; transform: translate3d(0, 24px, 0); } to { opacity: 1; transform: translate3d(0, 0, 0); } }
  @keyframes pageOut { from { opacity: 1; transform: translate3d(0, 0, 0); } to { opacity: 0; transform: translate3d(0, -24px, 0); } }
}

/* Safer spacing for right-side dots (avoid corners and notches) */
.page-dots { right: max(36px, env(safe-area-inset-right) + 20px); }

/* Page content shell for transitions */
.page-shell { will-change: transform, opacity; backface-visibility: hidden; transform: translateZ(0); contain: content; }
.page-shell.animate-in { animation: pageIn 240ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.page-shell.animate-out { animation: pageOut 160ms cubic-bezier(0.22, 1, 0.36, 1) both; }

@media (prefers-reduced-motion: reduce) {
  .page-shell.animate-in,
  .page-shell.animate-out { animation: none !important; }
}

/* High-refresh tuned durations */
.page-shell.animate-in { animation-duration: 260ms; }
.page-shell.animate-out { animation-duration: 180ms; }

/* Ensure stable layout height */
.page-shell { min-height: 100vh; }

/* Mobile and tablet refinements (no desktop changes) */
@media (max-width: 640px) {
  /* Simplify top nav: keep primary action, hide secondary links */
  .nav-actions .link { display: none; }
  /* Reduce GPU blur risk during auto-scroll by lowering filter strength */
  .site-header { backdrop-filter: saturate(1.0) blur(3px); -webkit-backdrop-filter: saturate(1.0) blur(3px); }

  /* Mobile: show only collapsed dashboard headers (no charts) */
  .dash-actions, .dash-toggle { display: none !important; }
  .dash-content { display: none !important; max-height: 0 !important; overflow: hidden !important; }
}

@media (max-width: 480px) {
  /* Tighter section spacing on small phones */
  section,
  header.hero { padding-block: var(--s-16); }
  header.hero { padding-top: var(--s-16); }

  /* Bottom-centered pager dots to avoid content overlap */
  .page-dots {
    left: 50%;
    right: auto;
    top: auto;
    bottom: max(16px, env(safe-area-inset-bottom) + 10px);
    transform: translateX(-50%);
    flex-direction: row;
    gap: 10px;
    --dot-size: 44px;
  }
  /* Ensure content never sits under the pager */
  .page-shell { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

  /* Compact header/nav and buttons */
  .nav { height: 64px; }
  .btn { height: 44px; padding: 0 14px; font-size: var(--fs-1); }

  /* Safer edge padding */
  .container {
    padding-inline: var(--s-4);
    padding-left: max(var(--s-4), calc(env(safe-area-inset-left) + 12px));
    padding-right: max(var(--s-4), calc(env(safe-area-inset-right) + 12px));
  }

  /* Remove negative margins from demo cards on phones */
  .demo-card { margin: 0 !important; }

  /* Slightly smaller avatars and tighter cards */
  .avatar { width: 128px; height: 128px; }
  .member { padding: var(--s-6); }

  /* Friendlier hero type scale for narrow screens */
  .hero-title { font-size: clamp(2rem, 8.5vw, 2.75rem); }
  .hero-kicker { font-size: clamp(0.98rem, 3.5vw, 1.1rem); }

  /* Form comfort */
  .textarea { height: 120px; }

  /* Subtle banner tightening */
  .stage-banner { font-size: var(--fs-0); padding-block: 6px; }

  /* Footer alignment for narrow widths */
  .footer-links { justify-items: start; text-align: left; }
  .footer-links { overflow-wrap: anywhere; }
  /* Primary actions: wrap and become full-width if needed */
  .hero-cta { flex-wrap: wrap; }
  .hero-cta .btn { width: 100%; max-width: 440px; }

    /* Form actions: stack and make primary action full-width on phones */
    .form-actions { flex-direction: column; align-items: stretch; }
    .form-actions .btn { width: 100%; max-width: 440px; }
    .form-actions .status { order: 2; margin-top: 6px; }
}

@media (max-width: 840px) {
  /* Keep gallery single column on smaller tablets to avoid squish */
  .gallery { grid-template-columns: 1fr; max-width: 100%; }
  .dashboard-grid { grid-template-columns: 1fr; gap: var(--s-6); padding-inline: 0; }
}

@media (max-width: 820px) {
  /* Avoid nav overflow on small tablets: keep primary action only */
  .nav-actions .link { display: none; }
}

/* Slightly smaller pager dots on small tablets for better fit */
@media (min-width: 641px) and (max-width: 840px) {
  .page-dots { --dot-size: 50px; --dot-gap: 12px; }
}

/* Ultra-narrow phones: ensure brand fits beside the primary action */
@media (max-width: 360px) {
  .brand { font-size: 1.43rem; }
}

@media (min-width: 481px) and (max-width: 720px) {
  /* Shrink and tighten pager dots on small tablets/large phones */
  .page-dots { --dot-size: 44px; --dot-gap: 10px; }
}

/* Ultra-short viewports: free up space by hiding banner */
@media (max-height: 580px) and (max-width: 640px) {
  .stage-banner { display: none; }
}

/* Lightweight top loading indicator */
.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--accent);
  z-index: 200;
  pointer-events: none;
  transform: translateZ(0);
}
body.loading .loading-bar {
  width: 70%;
  animation: loadingBar 1.1s ease-in-out infinite;
}
@keyframes loadingBar {
  0% { width: 10%; opacity: 0.9; }
  50% { width: 55%; opacity: 0.95; }
  100% { width: 90%; opacity: 1; }
}

/* Loading quote overlay (shows only during transition) */
.loading-quote {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: #ffffff;
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(10, 14, 39, 0.12);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: var(--fs-2);
  line-height: 1.5;
  text-align: center;
  max-width: min(82vw, 640px);
  z-index: 201;
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
}
body.loading .loading-quote { opacity: 1; }

/* Build version badge */
/* Footer build version (subtle, inside footer) */
.footer-build { color: var(--muted); font-size: var(--fs-0); letter-spacing: 0.02em; margin-top: 6px; }

/* Auto-scroll toggle (legacy text button retained but unused) */
/* Auto-scroll single toggle (legacy) */
.auto-scroll-toggle { position: fixed; left: max(12px, env(safe-area-inset-left) + 8px); bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 211; height: 36px; padding: 0 12px; font-size: var(--fs-1); border-radius: 999px; box-shadow: 0 10px 28px rgba(10,14,39,0.12); }
@media (max-width: 640px) { .auto-scroll-toggle { bottom: calc(76px + env(safe-area-inset-bottom)); } }

/* New: compact floating icon for auto-scroll toggle (no state indication in the icon itself) */
.auto-scroll-fab {
  position: fixed;
  left: max(12px, env(safe-area-inset-left) + 10px);
  bottom: max(16px, env(safe-area-inset-bottom) + 14px);
  z-index: 221;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(10,14,39,0.12);
}
.auto-scroll-fab:active { transform: translateY(1px); }
.auto-scroll-fab svg { width: 20px; height: 20px; display: block; }
@media (max-width: 640px) {
  .auto-scroll-fab { bottom: calc(76px + env(safe-area-inset-bottom)); }
}

/* Brief confirmation bubble showing ON/OFF as a different icon (not persistent) */
.auto-toast {
  position: fixed;
  left: calc(max(12px, env(safe-area-inset-left) + 10px) + 52px);
  bottom: max(22px, env(safe-area-inset-bottom) + 20px);
  z-index: 221;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: #0a0e27;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 28px rgba(10,14,39,0.22);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}
.auto-toast.show { opacity: 1; transform: translateY(0); }
.auto-toast svg { width: 18px; height: 18px; display: block; }

@media (prefers-reduced-motion: no-preference) {
  .reveal-up { opacity: 0; transform: translateY(8px); will-change: transform, opacity; }
  .reveal-up.show { opacity: 1; transform: translateY(0); transition: opacity 420ms cubic-bezier(0.22, 1, 0.36, 1), transform 420ms cubic-bezier(0.22, 1, 0.36, 1); }
}


.chart-tip { position: fixed; pointer-events: none; background: #0a0e27; color: #fff; font-size: 12px; line-height: 1.4; padding: 6px 8px; border-radius: 6px; box-shadow: 0 6px 18px rgba(10,14,39,0.25); z-index: 1000; opacity: 0; transition: opacity 120ms ease; max-width: 260px; }
.chart-tip.show { opacity: 1; }

@media (max-width: 640px) {
  .chart-tip {
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    max-width: 90vw;
    text-align: center;
  }
}

.dash-head { position: relative; }
.dash-actions { display: flex; gap: 8px; align-items: center; margin-left: auto; }
.dash-btn { height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--ink); font-weight: 700; font-size: 12px; letter-spacing: .01em; }
.dash-btn:hover, .dash-btn:focus-visible { border-color: #cbd5e1; box-shadow: 0 0 0 3px rgba(0,191,166,0.12); }

@media (max-width: 640px) {
  .dash-actions {
    gap: 6px;
  }
  .dash-btn {
    height: 36px;
    padding: 0 12px;
    font-size: var(--fs-0);
    min-width: 44px;
    touch-action: manipulation;
  }
}

.dash-summary { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--s-3); margin: var(--s-6) auto 0; max-width: 1080px; }
.dash-chip { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
.dash-chip .k { color: var(--muted); font-weight: 700; font-size: var(--fs-1); letter-spacing: .04em; text-transform: uppercase; }
.dash-chip .v { font-weight: 800; letter-spacing: .01em; font-variant-numeric: tabular-nums; font-size: clamp(1rem, 2vw, 1.2rem); }

@media (max-width: 640px) {
  .dash-summary {
    gap: var(--s-2);
    margin: var(--s-4) auto 0;
  }
  .dash-chip { padding: 10px 12px; gap: 1px; }
  .dash-chip .k { font-size: var(--fs-0); letter-spacing: .02em; }
  .dash-chip .v { font-size: 1rem; font-weight: 700; }
}

/* (Reverted) Mobile KPI strip: allow natural wrapping (no horizontal scroll) */

  /* Sticky CTA (conversion) */
  .sticky-cta { position: fixed; right: max(16px, env(safe-area-inset-right) + 12px); bottom: max(16px, env(safe-area-inset-bottom) + 12px); z-index: 220; display: none; transform: translateZ(0); }
  .sticky-cta.show { display: block; }
  .sticky-cta .cta-inner { display: flex; gap: 8px; align-items: center; background: #ffffff; border: 1px solid var(--border); border-radius: 999px; padding: 6px; box-shadow: 0 10px 28px rgba(10, 14, 39, 0.12); }
  .sticky-cta .cta-label { display: none; color: var(--sub); font-weight: 700; font-size: var(--fs-1); letter-spacing: 0.01em; margin-inline: 6px 4px; }
  .sticky-cta .btn { height: 40px; padding: 0 14px; }
  .sticky-cta .cta-close { background: transparent; border: 1px solid var(--border); color: var(--sub); border-radius: 999px; height: 32px; padding: 0 10px; font-weight: 700; }
  @media (min-width: 640px) { .sticky-cta .cta-label { display: inline; } }
  @media (max-width: 640px) { .sticky-cta { left: 50%; right: auto; transform: translateX(-50%); } }

  /* Modal (exit-intent / lead capture) */
  .modal-backdrop { position: fixed; inset: 0; background: rgba(10,14,39,0.5); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); z-index: 250; opacity: 0; pointer-events: none; transition: opacity 160ms ease; }
  .modal-backdrop.show { opacity: 1; pointer-events: auto; }
  .modal { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(0.98); background: #ffffff; color: var(--ink); width: min(92vw, 560px); max-height: 86vh; overflow: auto; border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 14px 44px rgba(10,14,39,0.22); z-index: 251; opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
  .modal.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
  .modal-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
  .modal-title { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.01em; font-size: 1.25rem; margin: 0; }
  .modal-body { padding: 16px; }
  .modal-actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
  .modal-close { height: 32px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border); background: #fff; color: var(--ink); font-weight: 700; }
  .modal .help { margin-top: 8px; }
  .modal .status { min-height: 1.2em; }
  @media (max-width: 480px) { .modal { width: min(94vw, 520px); } }
