@layer reset, base, components, utilities;

/* ---- Custom properties ---- */
:root {
  /* Colors (OKLCH) */
  --color-bg-deep:      oklch(0.07 0.03 240);
  --color-bg-primary:   oklch(0.11 0.04 240);
  --color-bg-elevated:  oklch(0.15 0.04 240);
  --color-bg-card:      oklch(0.13 0.04 240 / 0.55);
  --color-accent:       oklch(0.78 0.18 165);
  --color-accent-dim:   oklch(0.78 0.18 165 / 0.12);
  --color-accent-glow:  oklch(0.78 0.18 165 / 0.15);
  --color-blue:         oklch(0.65 0.15 260);
  --color-blue-dim:     oklch(0.65 0.15 260 / 0.10);
  --color-amber:        oklch(0.75 0.15 70);
  --color-text:         oklch(0.92 0.01 80);
  --color-text-dim:     oklch(0.66 0.03 240);
  --color-text-muted:   oklch(0.42 0.03 240);
  --color-border:       oklch(1 0 0 / 0.06);
  --color-border-subtle: oklch(1 0 0 / 0.04);

  /* Chart/JS-consumed variables */
  --color-nav-scroll:   oklch(0.07 0.03 240 / 0.85);
  --color-tooltip-bg:   oklch(0.1 0.04 240 / 0.92);
  --color-tooltip-text: #eee8df;
  --color-tooltip-sub:  #94a0b4;
  --color-tooltip-border: oklch(0.78 0.18 165 / 0.15);
  --color-chart-fill-0: rgba(0, 223, 162, 0.10);
  --color-chart-fill-1: rgba(0, 223, 162, 0.01);
  --color-chart-tick:   #4c5c72;
  --color-chart-dot-border: oklch(0.11 0.04 240);
  --color-night-shade:  oklch(0.03 0.04 260 / 0.55);

  /* Spacing */
  --space-2xs: 0.25rem;
  --space-xs:  0.5rem;
  --space-sm:  0.75rem;
  --space-md:  1rem;
  --space-lg:  1.5rem;
  --space-xl:  2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;
  --space-4xl: 6rem;

  /* Typography */
  --font-display: "Bricolage Grotesque", sans-serif;
  --font-body:    "DM Sans", sans-serif;
  --font-mono:    "SFMono-Regular", "Cascadia Code", "Fira Code", monospace;

  --text-xs:   0.75rem;
  --text-sm:   0.875rem;
  --text-base: 1rem;
  --text-lg:   1.125rem;
  --text-2xl:  1.5rem;
  --text-3xl:  clamp(1.5rem, 4vw, 1.875rem);
  --text-4xl:  clamp(2rem, 5vw, 2.5rem);
  --text-5xl:  clamp(2.5rem, 6vw, 3.5rem);
  --text-hero: clamp(3.5rem, 10vw, 7rem);

  /* Effects */
  --radius-md: 0.75rem;
  --radius-lg: 1.25rem;
  --glass-blur: 24px;

  /* Z-index */
  --z-nav: 50;
  --z-grain: 9999;
}

/* ---- Light theme variable overrides (must be unlayered to beat :root) ---- */
[data-theme="light"] {
  --color-bg-deep:      oklch(0.97 0.005 80);
  --color-bg-primary:   oklch(0.95 0.005 80);
  --color-bg-elevated:  oklch(0.98 0.003 80);
  --color-bg-card:      oklch(1 0 0 / 0.75);
  --color-accent:       oklch(0.45 0.2 165);
  --color-accent-dim:   oklch(0.45 0.2 165 / 0.08);
  --color-accent-glow:  oklch(0.45 0.2 165 / 0.08);
  --color-blue:         oklch(0.45 0.15 260);
  --color-blue-dim:     oklch(0.45 0.15 260 / 0.06);
  --color-amber:        oklch(0.55 0.15 70);
  --color-text:         oklch(0.15 0.02 240);
  --color-text-dim:     oklch(0.4 0.02 240);
  --color-text-muted:   oklch(0.6 0.02 240);
  --color-border:       oklch(0 0 0 / 0.1);
  --color-border-subtle: oklch(0 0 0 / 0.06);

  --color-nav-scroll:   oklch(0.97 0.005 80 / 0.88);
  --color-tooltip-bg:   oklch(1 0 0 / 0.92);
  --color-tooltip-text: #1a1a2e;
  --color-tooltip-sub:  #555;
  --color-tooltip-border: oklch(0 0 0 / 0.1);
  --color-chart-fill-0: rgba(0, 160, 120, 0.12);
  --color-chart-fill-1: rgba(0, 160, 120, 0.02);
  --color-chart-tick:   #888;
  --color-chart-dot-border: oklch(1 0 0);
  --color-night-shade:  oklch(0.2 0.04 260 / 0.25);
}


/* ---- Reset ---- */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
}


/* ---- Base ---- */
@layer base {
  body {
    font-family: var(--font-body);
    background: var(--color-bg-deep);
    color: var(--color-text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }

  a { color: inherit; text-decoration: none; }
  img { max-inline-size: 100%; display: block; }
  pre { margin: 0; }

  ::-webkit-scrollbar { width: 6px; }
  ::-webkit-scrollbar-track { background: var(--color-bg-deep); }
  ::-webkit-scrollbar-thumb { background: oklch(0.2 0.03 240); border-radius: 3px; }
}


/* ---- Components ---- */
@layer components {

  /* -- Grain overlay -- */
  .grain::after {
    content: "";
    position: fixed;
    inset: 0;
    opacity: 0.025;
    pointer-events: none;
    z-index: var(--z-grain);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 256px;
  }


  /* -- Navigation -- */
  .nav {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: var(--z-nav);
    transition: background 0.3s, backdrop-filter 0.3s;
  }

  .nav__inner {
    max-inline-size: 72rem;
    margin-inline: auto;
    padding: var(--space-lg) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .nav__logo {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    color: var(--color-accent);
    letter-spacing: -0.02em;
    transition: color 0.2s;
  }
  .nav__logo:hover { color: var(--color-text); }
  .nav__logo-icon { width: 1.5rem; height: 1.5rem; }

  .nav__links {
    display: flex;
    align-items: center;
    gap: var(--space-xl);
    font-size: var(--text-sm);
    letter-spacing: 0.03em;
  }

  .nav__links a {
    color: var(--color-text-dim);
    transition: color 0.2s;
  }
  .nav__links a:hover { color: var(--color-text); }

  .nav__cta {
    padding: 0.35rem 1rem;
    border-radius: 99rem;
    background: var(--color-accent-dim);
    border: 1px solid oklch(0.78 0.18 165 / 0.2);
    color: var(--color-accent) !important;
    font-weight: 500;
    font-size: var(--text-xs);
    letter-spacing: 0.02em;
    transition: background 0.2s, border-color 0.2s;
  }

  .nav__cta:hover {
    background: oklch(0.78 0.18 165 / 0.15);
    border-color: oklch(0.78 0.18 165 / 0.3);
    color: var(--color-accent) !important;
  }


  /* -- Preferences dropdown -- */
  .prefs {
    position: relative;
  }

  .prefs__trigger {
    display: grid;
    place-items: center;
    inline-size: 2rem;
    block-size: 2rem;
    border: none;
    background: none;
    color: var(--color-text-dim);
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
  }

  .prefs__trigger:hover {
    color: var(--color-text);
    background: oklch(1 0 0 / 0.06);
  }

  .prefs__trigger svg {
    inline-size: 1.1rem;
    block-size: 1.1rem;
  }

  .prefs__menu {
    position: absolute;
    inset-block-start: calc(100% + var(--space-xs));
    inset-inline-end: 0;
    min-inline-size: 11rem;
    background: oklch(0.12 0.04 240 / 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-xs);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px) scale(0.97);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
    z-index: 100;
  }

  .prefs__menu--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
  }

  .prefs__label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding: var(--space-xs) var(--space-sm);
    padding-block-start: var(--space-sm);
  }

  .prefs__group {
    display: flex;
    gap: 2px;
    padding: 0 var(--space-xs) var(--space-xs);
  }

  .prefs__option {
    flex: 1;
    padding: 0.3rem 0;
    border: none;
    background: none;
    color: var(--color-text-dim);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    text-align: center;
  }

  .prefs__option:hover {
    color: var(--color-text);
    background: oklch(1 0 0 / 0.06);
  }

  .prefs__option--active {
    color: var(--color-accent);
    background: var(--color-accent-dim);
  }

  .prefs__divider {
    block-size: 1px;
    background: var(--color-border);
    margin: var(--space-2xs) var(--space-xs);
  }

  .prefs__btn {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    inline-size: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: none;
    background: none;
    color: var(--color-text-dim);
    font-family: var(--font-body);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    text-align: start;
  }

  .prefs__btn:hover {
    color: var(--color-text);
    background: oklch(1 0 0 / 0.06);
  }

  .prefs__btn svg {
    inline-size: 0.9rem;
    block-size: 0.9rem;
    flex-shrink: 0;
  }


  /* -- Light theme component overrides -- */
  [data-theme="light"] .grain::after { opacity: 0.012; }

  /* Glass cards — light frosted look with subtle shadow */
  [data-theme="light"] .glass {
    background: oklch(1 0 0 / 0.65);
    border-color: oklch(0 0 0 / 0.08);
    box-shadow: 0 1px 3px oklch(0 0 0 / 0.04), 0 8px 24px oklch(0 0 0 / 0.03);
  }

  /* Nav scroll state handled in JS — CSS overrides for static nav */
  [data-theme="light"] .nav { color: var(--color-text); }

  /* Hero map */
  [data-theme="light"] .hero__map path {
    stroke: oklch(0.45 0.2 165 / 0.18);
    fill: oklch(0.45 0.2 165 / 0.04);
  }

  [data-theme="light"] .hero__station-dot { fill: oklch(0.45 0.2 165); }
  [data-theme="light"] .hero__station-glow { fill: oklch(0.45 0.2 165); }

  /* Hero title glow */
  [data-theme="light"] .hero__title {
    text-shadow: none;
  }

  /* Wave underline */
  [data-theme="light"] .hero__wave-underline path {
    stroke: oklch(0.45 0.2 165 / 0.35);
  }

  /* Footer waves */
  [data-theme="light"] .waves svg path {
    fill: oklch(0.45 0.2 165 / 0.06);
  }
  [data-theme="light"] .waves svg:nth-child(2) path {
    fill: oklch(0.45 0.2 165 / 0.1);
  }

  /* Footer */
  [data-theme="light"] .footer {
    border-color: oklch(0 0 0 / 0.06);
  }

  /* Code blocks */
  [data-theme="light"] .code-block {
    background: oklch(0.96 0.005 240);
    border-color: oklch(0 0 0 / 0.08);
    color: oklch(0.35 0.02 240);
  }
  [data-theme="light"] .code-block .key { color: oklch(0.4 0.2 165); }
  [data-theme="light"] .code-block .str { color: oklch(0.5 0.15 70); }
  [data-theme="light"] .code-block .num { color: oklch(0.4 0.18 165); }

  /* Event highlight */
  [data-theme="light"] .event--next {
    background: oklch(0.45 0.2 165 / 0.06);
    border-color: oklch(0.45 0.2 165 / 0.12);
  }

  /* Event icons */
  [data-theme="light"] .event__icon--high {
    background: oklch(0.45 0.2 165 / 0.1);
    color: oklch(0.4 0.2 165);
  }
  [data-theme="light"] .event__icon--low {
    background: oklch(0.45 0.15 260 / 0.08);
    color: oklch(0.4 0.15 260);
  }

  /* Station card status */
  [data-theme="light"] .station-card__status {
    background: oklch(0 0 0 / 0.02);
    border-color: oklch(0 0 0 / 0.06);
  }

  /* Preferences dropdown */
  [data-theme="light"] .prefs__menu {
    background: oklch(1 0 0 / 0.92);
    border-color: oklch(0 0 0 / 0.1);
    box-shadow: 0 4px 16px oklch(0 0 0 / 0.08);
  }
  [data-theme="light"] .prefs__option--active {
    background: oklch(0.45 0.2 165 / 0.1);
    color: oklch(0.4 0.2 165);
  }
  [data-theme="light"] .prefs__option:hover,
  [data-theme="light"] .prefs__btn:hover {
    background: oklch(0 0 0 / 0.04);
  }

  /* Scrollbar */
  [data-theme="light"] ::-webkit-scrollbar-track { background: var(--color-bg-deep); }
  [data-theme="light"] ::-webkit-scrollbar-thumb { background: oklch(0.8 0.01 240); }


  /* -- Hero -- */
  .hero {
    position: relative;
    padding-block: 7rem 3rem;
    text-align: center;
    overflow: hidden;
    background: transparent;
  }

  .hero__map {
    position: absolute;
    inset: 0;
    inset-inline-end: 35%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    opacity: 0;
    animation: hero-map-in 2s ease-out 0.3s forwards;
    z-index: 0;
  }

  @keyframes hero-map-in {
    to { opacity: 1; }
  }

  .hero__map svg {
    block-size: 140%;
    width: auto;
  }

  .hero__station-dot {
    opacity: 0.25;
    animation: station-dot-ping ease-in-out infinite;
  }

  .hero__station-glow {
    opacity: 0;
    animation: station-glow-ping ease-in-out infinite;
  }

  @keyframes station-dot-ping {
    0%, 4%, 100% { opacity: 0.25; }
    2% { opacity: 1; }
  }

  @keyframes station-glow-ping {
    0%, 4%, 100% { opacity: 0; }
    2% { opacity: 0.4; }
  }

  .hero__content {
    position: relative;
    z-index: 1;
  }

  .hero + .section,
  .hero ~ .section {
    position: relative;
    z-index: 1;
  }

  .hero__title {
    font-family: var(--font-display);
    font-size: var(--text-hero);
    line-height: 0.9;
    color: var(--color-text);
    letter-spacing: -0.02em;
    text-shadow: 0 0 80px oklch(0.78 0.18 165 / 0.2);
  }

  .hero__wave-underline {
    display: block;
    inline-size: 100%;
    block-size: 0.75rem;
    margin-block-start: 0.25rem;
  }

  .hero__subtitle {
    margin-block-start: var(--space-md);
    font-size: var(--text-lg);
    color: var(--color-text-dim);
    max-inline-size: 32rem;
    margin-inline: auto;
  }


  /* -- Waves -- */
  .waves {
    position: relative;
    z-index: 1;
    overflow: hidden;
    block-size: 80px;
    margin-block-start: -1px;
  }

  .waves svg {
    position: absolute;
    inset-block-end: 0;
    inline-size: 200%;
    min-inline-size: 1440px;
    block-size: 100%;
  }

  .waves svg:nth-child(1) { animation: wave-drift 8s ease-in-out infinite alternate; opacity: 0.6; }
  .waves svg.waves__solid { animation: wave-drift 6s ease-in-out infinite alternate-reverse; opacity: 1; }

  @keyframes wave-drift {
    from { transform: translateX(0); }
    to { transform: translateX(-25%); }
  }


  /* -- Glass card -- */
  .glass {
    background: var(--color-bg-card);
    backdrop-filter: blur(var(--glass-blur));
    -webkit-backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
  }


  /* -- Station card -- */
  .station-card { padding: var(--space-xl); }

  .station-card__label {
    font-size: var(--text-xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.6;
    margin-block-end: var(--space-2xs);
  }

  .station-card__name {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    color: var(--color-text);
  }

  .station-card__region {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-block-start: var(--space-2xs);
  }

  .station-card__coords {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    text-align: end;
    line-height: 1.8;
  }

  .station-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-block-end: var(--space-xl);
  }

  /* -- Station picker -- */
  .station-picker__list {
    position: absolute;
    inset-inline: 0;
    inset-block-start: 100%;
    z-index: 20;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-block-start: var(--space-xs);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
  }

  .station-picker__list--open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
  }

  .station-picker__input {
    inline-size: 100%;
    padding: var(--space-sm) var(--space-md);
    background: none;
    border: none;
    border-block-end: 1px solid var(--color-border-subtle);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    outline: none;
  }

  .station-picker__input::placeholder { color: var(--color-text-muted); }

  .station-picker__items {
    max-block-size: 240px;
    overflow-y: auto;
    padding: var(--space-2xs);
  }

  .station-picker__item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    inline-size: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: none;
    background: none;
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    cursor: pointer;
    border-radius: 6px;
    text-align: start;
    transition: background 0.1s;
  }

  .station-picker__item:hover { background: oklch(1 0 0 / 0.06); }
  .station-picker__item--active { color: var(--color-accent); }

  .station-picker__item-region {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .station-card { position: relative; overflow: visible; }

  .station-card__name--picker {
    cursor: pointer;
    display: inline-flex;
    align-items: baseline;
    gap: var(--space-xs);
  }

  .station-card__chevron {
    inline-size: 0.6em;
    block-size: 0.6em;
    opacity: 0.4;
    flex-shrink: 0;
    transition: opacity 0.15s;
  }

  .station-card__name--picker:hover .station-card__chevron { opacity: 0.7; }

  .station-card__status {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    background: oklch(1 0 0 / 0.03);
    border: 1px solid var(--color-border-subtle);
  }

  .station-card__status-indicator {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-sm);
    font-weight: 500;
  }

  .station-card__status-value {
    margin-inline-start: auto;
    text-align: end;
  }

  .station-card__status-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .station-card__status-height {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    color: var(--color-text);
  }


  /* -- Events card -- */
  .events-card { padding: var(--space-xl); }

  .events-card__date {
    font-size: var(--text-xs);
    letter-spacing: 0.2em;
    text-transform: uppercase;
    color: oklch(0.5 0.02 240);
    margin-block-end: var(--space-lg);
  }

  .events-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    list-style: none;
  }


  /* -- Event row -- */
  .event {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    transition: background 0.15s, border-color 0.15s;
  }

  .event--next {
    background: var(--color-accent-dim);
    border-color: oklch(0.78 0.18 165 / 0.2);
  }

  .event__icon {
    position: relative;
    display: grid;
    place-items: center;
    inline-size: 2.25rem;
    block-size: 2.25rem;
    border-radius: 50%;
    flex-shrink: 0;
  }

  .event__icon--high { background: var(--color-accent-dim); color: var(--color-accent); }
  .event__icon--low  { background: var(--color-blue-dim); color: var(--color-blue); }

  .event__icon svg { inline-size: 1rem; block-size: 1rem; }

  .event__pulse {
    position: absolute;
    inset-block-start: -2px;
    inset-inline-end: -2px;
    inline-size: 0.75rem;
    block-size: 0.75rem;
    background: var(--color-accent);
    border-radius: 50%;
    animation: pulse-glow 2.5s ease-in-out infinite;
  }

  @keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 0 0 oklch(0.78 0.18 165 / 0.4); }
    50%      { box-shadow: 0 0 0 6px oklch(0.78 0.18 165 / 0); }
  }

  .event__details { flex: 1; min-inline-size: 0; }

  .event__type {
    font-size: var(--text-sm);
    color: var(--color-text-dim);
  }
  .event--next .event__type { color: var(--color-text); }

  .event__time {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .event__next-label {
    color: var(--color-accent);
    opacity: 0.7;
    margin-inline-start: var(--space-xs);
  }

  .event__height {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
  }

  .event__height--high { color: var(--color-accent); }
  .event__height--low  { color: var(--color-blue); }

  .event__height-unit {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }


  /* -- Chart -- */
  .chart-container { padding: var(--space-md) var(--space-xl); }

  .chart-canvas { position: relative; block-size: 360px; }

  .chart-scrollbar {
    position: relative;
    block-size: 6px;
    margin: var(--space-sm) var(--space-xl) var(--space-xs);
    background: oklch(1 0 0 / 0.04);
    border-radius: 3px;
    cursor: pointer;
  }

  .chart-scrollbar__thumb {
    position: absolute;
    inset-block: 0;
    background: var(--color-accent-dim);
    border: 1px solid oklch(0.78 0.18 165 / 0.2);
    border-radius: 3px;
    cursor: grab;
    transition: background 0.15s;
  }

  .chart-scrollbar__thumb:hover,
  .chart-scrollbar__thumb--active {
    background: oklch(0.78 0.18 165 / 0.25);
    cursor: grabbing;
  }

  @media (pointer: coarse) {
    .chart-scrollbar {
      block-size: 16px;
      border-radius: 8px;
      margin-block: var(--space-md);
    }
    .chart-scrollbar__thumb {
      border-radius: 8px;
    }
  }

  .chart-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xl);
    margin-block-start: var(--space-lg);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }

  .chart-legend__item {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
  }

  .chart-legend__dot {
    inline-size: 0.75rem;
    block-size: 0.75rem;
    border-radius: 50%;
  }

  .chart-legend__dot--high  { background: var(--color-accent); }
  .chart-legend__dot--low   { background: var(--color-blue); }

  .chart-legend__line {
    inline-size: 1.5rem;
    border-block-start: 1px dashed var(--color-amber);
  }


  /* -- Section -- */
  .section {
    padding-inline: var(--space-xl);
  }

  .section__inner {
    max-inline-size: 60rem;
    margin-inline: auto;
  }

  .section__heading {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    color: var(--color-text);
    letter-spacing: -0.02em;
  }

  .section__subheading {
    margin-block-start: var(--space-md);
    color: var(--color-text-dim);
  }


  /* -- Grid -- */
  .card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-lg);
    max-inline-size: 52rem;
    margin-inline: auto;
  }

  @media (min-width: 48rem) {
    .card-grid { grid-template-columns: 1fr 1fr; }
  }


  /* -- Code block -- */
  .code-block {
    background: oklch(0.06 0.02 240 / 0.8);
    border: 1px solid oklch(1 0 0 / 0.05);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--color-text-dim);
  }

  .code-block .key  { color: var(--color-accent); }
  .code-block .str  { color: var(--color-amber); }
  .code-block .num  { color: oklch(0.85 0.15 165); }


  /* -- API section -- */
  .api-section {
    padding-block: var(--space-4xl);
    border-block-start: 1px solid var(--color-border-subtle);
    text-align: center;
  }

  .api-section__label {
    font-size: var(--text-xs);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.6;
    margin-block-end: var(--space-md);
  }

  .api-section__title {
    font-family: var(--font-display);
    font-size: var(--text-5xl);
    color: var(--color-text);
    letter-spacing: -0.02em;
  }

  .api-section__description {
    margin-block-start: var(--space-lg);
    color: var(--color-text-dim);
    max-inline-size: 32rem;
    margin-inline: auto;
    line-height: 1.7;
  }


  /* -- Dashboard Map Background -- */
  .dash-map {
    position: fixed;
    top: 40%;
    left: 5%;
    width: 40%;
    height: 85vh;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 0;
    animation: fade-in 2s ease-out;
  }

  .dash-map svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
  }

  .dash-map path {
    fill: oklch(0.78 0.18 165 / 0.06);
    stroke: oklch(0.78 0.18 165 / 0.18);
    stroke-width: 1.5;
  }

  .dash-map .hero__station-dot {
    opacity: 0.4;
  }

  .dash-map .hero__station-glow {
    opacity: 0.15;
  }

  [data-theme="light"] .dash-map path {
    fill: oklch(0.45 0.2 165 / 0.05);
    stroke: oklch(0.45 0.2 165 / 0.12);
  }

  @media (max-width: 48rem) {
    .dash-map { display: none; }
  }

  /* -- Dashboard Search -- */
  .dash-search {
    max-inline-size: 40rem;
    margin-inline: auto;
    padding: var(--space-4xl) var(--space-lg) 0;
    position: relative;
    z-index: 30;
  }

  .dash-search__bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-lg);
    background: var(--color-bg-card);
    backdrop-filter: blur(var(--glass-blur));
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    transition: border-color 0.2s, background 0.2s;
    position: relative;
  }

  .dash-search__bar:hover {
    border-color: oklch(0.78 0.18 165 / 0.2);
    background: var(--color-bg-elevated);
  }

  .dash-search__icon {
    width: 1.125rem;
    height: 1.125rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
  }

  .dash-search__input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--color-text);
    min-width: 0;
  }

  .dash-search__input::placeholder {
    color: var(--color-text);
    opacity: 1;
  }

  .dash-search__input:focus::placeholder {
    color: var(--color-text-dim);
  }

  .dash-search__region {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-left: auto;
  }

  .dash-search__chevron {
    width: 1rem;
    height: 1rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
  }

  .dash-search__bar .station-picker__list {
    inset-inline: 0;
    z-index: 40;
    max-height: 320px;
    border-radius: var(--radius-lg);
  }

  .dash-search .station-picker__item-name {
    color: var(--color-text);
  }

  .dash-search .station-picker__input {
    color: var(--color-text);
  }

  .dash-search .station-picker__input::placeholder {
    color: var(--color-text-dim);
  }

  /* -- Dashboard -- */
  .dash {
    max-inline-size: 40rem;
    margin-inline: auto;
    padding: var(--space-lg) var(--space-lg) var(--space-3xl);
  }

  .dash__inner {
    background: oklch(0.11 0.04 240 / 0.35);
    backdrop-filter: blur(20px);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
  }

  /* Current Status */
  .dash__status {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-md);
    padding: var(--space-xl) var(--space-xl) var(--space-sm);
  }

  .dash__height {
    display: flex;
    align-items: baseline;
  }

  .dash__height-value {
    font-family: var(--font-display);
    font-size: clamp(2rem, 6vw, 2.75rem);
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--color-text);
    line-height: 1;
  }

  .dash__height-unit {
    font-family: var(--font-display);
    font-size: var(--text-lg);
    font-weight: 400;
    color: var(--color-text-dim);
    margin-left: 0.15em;
  }

  .dash__tide-status {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
  }

  .dash__arrow {
    width: 1.25rem;
    height: 1.25rem;
  }

  .dash__arrow--rising { color: var(--color-accent); }
  .dash__arrow--falling { color: var(--color-blue); }

  .dash__status-text {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
  }

  .dash__status-text--rising { color: var(--color-accent); }
  .dash__status-text--falling { color: var(--color-blue); }

  /* Chart */
  .dash__chart { padding: 0 var(--space-xs); }

  .dash__chart-canvas {
    height: 200px;
    position: relative;
  }

  /* Date Row */
  .dash__date {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-xl);
    border-top: 1px solid var(--color-border);
  }

  .dash__day {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
  }

  .dash__date-text {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
  }

  /* Events Row */
  .dash__events {
    display: flex;
    gap: 1px;
    background: var(--color-border);
    border-top: 1px solid var(--color-border);
  }

  .dash-event {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2xs);
    padding: var(--space-md) var(--space-xs);
    background: var(--color-bg-card);
    position: relative;
    transition: background 0.2s;
  }

  .dash-event--next {
    background: var(--color-accent-dim);
  }

  .dash-event__type {
    font-size: var(--text-xs);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
  }

  .dash-event--high .dash-event__type { color: var(--color-accent); }
  .dash-event--low .dash-event__type { color: var(--color-blue); }

  .dash-event__time {
    font-size: var(--text-sm);
    color: var(--color-text-dim);
  }

  .dash-event__height {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .dash-event--high .dash-event__height { color: var(--color-accent); }
  .dash-event--low .dash-event__height { color: var(--color-blue); }

  .dash-event__next-dot {
    position: absolute;
    top: var(--space-xs);
    right: var(--space-xs);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--color-accent);
    animation: pulse-glow 2s ease-in-out infinite;
  }

  @media (max-width: 30rem) {
    .dash-search { padding-inline: var(--space-sm); }
    .dash { padding-inline: var(--space-sm); }
    .dash__status { padding: var(--space-md) var(--space-md) var(--space-xs); }
    .dash__date { padding-inline: var(--space-md); }
    .dash-event__height { font-size: var(--text-lg); }
  }

  @media (min-width: 48rem) {
    .dash-search, .dash { max-inline-size: 44rem; }
  }

  @media (min-width: 64rem) {
    .dash-search, .dash { max-inline-size: 52rem; }
    .dash__chart-canvas { height: 240px; }
  }

  /* Light theme overrides */
  [data-theme="light"] .dash__inner {
    background: oklch(1 0 0 / 0.7);
    box-shadow: 0 1px 3px oklch(0 0 0 / 0.06), 0 8px 24px oklch(0 0 0 / 0.04);
  }

  [data-theme="light"] .dash-search__bar {
    background: oklch(1 0 0 / 0.75);
    box-shadow: 0 1px 3px oklch(0 0 0 / 0.04);
  }

  [data-theme="light"] .dash__events {
    background: oklch(0 0 0 / 0.06);
  }

  [data-theme="light"] .dash-event {
    background: oklch(1 0 0 / 0.7);
  }

  [data-theme="light"] .dash-event--next {
    background: oklch(0.78 0.18 165 / 0.08);
  }

  [data-theme="light"] .dash__date {
    border-color: oklch(0 0 0 / 0.06);
  }

  /* -- Button -- */
  .btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-xl);
    border-radius: 99rem;
    font-size: var(--text-sm);
    font-weight: 500;
    letter-spacing: 0.03em;
    transition: background 0.2s, border-color 0.2s;
  }

  .btn--accent {
    background: var(--color-accent-dim);
    border: 1px solid oklch(0.78 0.18 165 / 0.2);
    color: var(--color-accent);
  }

  .btn--accent:hover {
    background: oklch(0.78 0.18 165 / 0.15);
    border-color: oklch(0.78 0.18 165 / 0.3);
  }

  .btn--ghost {
    background: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-dim);
  }

  .btn--ghost:hover {
    border-color: var(--color-text-muted);
    color: var(--color-text);
  }

  /* -- Docs Intro -- */
  .docs-intro {
    text-align: center;
    padding-block: var(--space-2xl) var(--space-3xl);
    border-bottom: 1px solid var(--color-border);
    margin-block-end: var(--space-2xl);
  }

  .docs-intro__title {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: 700;
    letter-spacing: -0.02em;
  }

  .docs-intro__description {
    color: var(--color-text-dim);
    max-inline-size: 28rem;
    margin-inline: auto;
    margin-block-start: var(--space-md);
    line-height: 1.7;
  }

  .docs-intro__actions {
    display: flex;
    justify-content: center;
    gap: var(--space-md);
    margin-block-start: var(--space-xl);
  }

  .btn svg { inline-size: 1rem; block-size: 1rem; }


  /* -- Docs -- */
  .docs-header {
    padding-block-start: 8rem;
    margin-block-end: var(--space-4xl);
  }

  .docs-header__label {
    font-size: var(--text-xs);
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--color-accent);
    opacity: 0.6;
    margin-block-end: var(--space-md);
  }

  .docs-header__title {
    font-family: var(--font-display);
    font-size: var(--text-5xl);
    color: var(--color-text);
    letter-spacing: -0.02em;
  }

  .docs-header__description {
    margin-block-start: var(--space-lg);
    color: var(--color-text-dim);
    max-inline-size: 36rem;
    line-height: 1.7;
  }

  .docs-base-url {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    margin-block-start: var(--space-xl);
  }

  .docs-base-url__label {
    color: var(--color-text-muted);
    font-size: var(--text-xs);
  }

  .docs-base-url__value {
    color: var(--color-accent);
    font-size: var(--text-sm);
  }

  .endpoints { display: flex; flex-direction: column; gap: var(--space-2xl); }

  .endpoint { overflow: hidden; }
  .endpoint__header { padding: var(--space-xl); }
  .endpoint__response { padding: var(--space-xl); border-block-start: 1px solid var(--color-border-subtle); }

  .endpoint__method-line {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-block-end: var(--space-md);
  }

  .endpoint__badge {
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    background: var(--color-accent-dim);
    color: var(--color-accent);
    font-size: var(--text-xs);
    font-weight: 700;
    letter-spacing: 0.1em;
  }

  .endpoint__path {
    font-size: var(--text-lg);
    color: var(--color-text);
  }

  .endpoint__path-param { color: var(--color-amber); }

  .endpoint__description {
    font-size: var(--text-sm);
    color: var(--color-text-dim);
  }

  .endpoint__section-label {
    font-size: var(--text-xs);
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-block-end: var(--space-sm);
  }

  .endpoint__params {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-block-start: var(--space-lg);
  }

  .endpoint__param {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: var(--space-xs);
    font-size: var(--text-sm);
  }

  .endpoint__param-name {
    color: var(--color-amber);
    font-family: var(--font-mono);
  }

  .endpoint__param-desc { color: var(--color-text-dim); }


  /* -- Footer -- */
  .footer {
    position: relative;
    z-index: 1;
    border-block-start: 1px solid oklch(1 0 0 / 0.05);
    background: var(--color-bg-deep);
  }

  .footer__inner {
    max-inline-size: 72rem;
    margin-inline: auto;
    padding: var(--space-2xl) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .footer__logo {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
  }
}


/* ---- Utilities ---- */
@layer utilities {
  .text-center { text-align: center; }
  .text-start  { text-align: start; }
  .text-accent { color: var(--color-accent); }
  .text-blue   { color: var(--color-blue); }
  .text-muted  { color: var(--color-text-muted); }
  .text-dim    { color: var(--color-text-dim); }

  .mt-sm  { margin-block-start: var(--space-sm); }
  .mt-md  { margin-block-start: var(--space-md); }
  .mt-lg  { margin-block-start: var(--space-lg); }
  .mt-xl  { margin-block-start: var(--space-xl); }
  .mt-2xl { margin-block-start: var(--space-2xl); }
  .mt-3xl { margin-block-start: var(--space-3xl); }

  .pt-md  { padding-block-start: var(--space-md); }

  .inline-block { display: inline-block; }
  .relative { position: relative; }
  .max-w-sm { max-inline-size: 32rem; }
  .max-w-md { max-inline-size: 40rem; }
  .max-w-lg { max-inline-size: 52rem; }
  .lh-relaxed { line-height: 1.8; }


  /* -- Section spacing variants -- */
  .section--hero { padding-block: 7rem 3rem; }
  .section--tight { padding-block: var(--space-lg) var(--space-2xl); }
  .section--chart { padding-block: var(--space-md) var(--space-4xl); }
  .section--page { padding-block: 8rem var(--space-4xl); }

  /* -- Status icon -- */
  .icon-sm { inline-size: 1.25rem; block-size: 1.25rem; }

  /* -- Tide chart legend dots -- */
  .chart-legend__dot--sunrise { background: oklch(0.85 0.18 70); }
  .chart-legend__dot--sunset  { background: oklch(0.70 0.15 30); }

  /* -- Footer -- */
  .footer__links { display: flex; gap: var(--space-lg); font-size: var(--text-xs); }
  .footer__link  { color: var(--color-text-muted); text-decoration: none; }
  .footer__link:hover { color: var(--color-text-dim); }

  /* -- Prose (terms, legal) -- */
  .prose { padding: var(--space-xl); font-size: var(--text-sm); color: var(--color-text-dim); line-height: 1.8; }
  .prose h2 { font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-text); margin-block: var(--space-xl) var(--space-sm); }
  .prose h2:first-child { margin-block-start: 0; }
  .prose a { color: var(--color-accent); }

  /* Entrance animations */
  @keyframes fade-up {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .animate-in        { animation: fade-up 0.7s ease-out both; }
  .animate-in.delay-1 { animation-delay: 0.1s; }
  .animate-in.delay-2 { animation-delay: 0.2s; }
  .animate-in.delay-3 { animation-delay: 0.3s; }
}
