/* ------------------------------------------------------------- *
 *  OpenBuoy — design system                                     *
 *  Palette: deep harbor + lifering coral, with sand highlights. *
 * ------------------------------------------------------------- */

@font-face {
  font-family: "OB Display";
  src: local("Inter"), local("Segoe UI Variable"), local("system-ui");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --font-sans: "Inter", "Segoe UI Variable", "Segoe UI", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --font-display: "OB Display", "Inter", ui-sans-serif, system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  /* light theme */
  --bg: #f3f6f5;
  --bg-elev: #ffffff;
  --bg-soft: #eaf1ef;
  --bg-glass: rgba(255, 255, 255, 0.78);
  --ink: #0c1f23;
  --ink-2: #2c3f43;
  --ink-3: #5b6e72;
  --muted: #7a8c90;
  --line: #d6e1de;
  --line-soft: #e5ebe9;

  --brand: #0a4a55;
  --brand-2: #0e7e78;
  --brand-3: #16b3a4;
  --brand-deep: #072d36;
  --accent: #ff6b3d;
  --accent-2: #e84d2c;
  --gold: #f0b330;
  --kelp: #1f3b3a;

  --good: #16b3a4;
  --good-ink: #0d5a55;
  --watch: #e6a832;
  --watch-ink: #7a571a;
  --rough: #e2473a;
  --rough-ink: #8a1f17;

  --shadow-sm: 0 1px 2px rgba(7, 45, 54, 0.06);
  --shadow-md: 0 6px 22px rgba(7, 45, 54, 0.10);
  --shadow-lg: 0 18px 50px rgba(7, 45, 54, 0.14);
  --shadow-pop: 0 24px 60px rgba(7, 45, 54, 0.20);

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #061b21;
    --bg-elev: #0c2a32;
    --bg-soft: #0a242b;
    --bg-glass: rgba(12, 42, 50, 0.72);
    --ink: #e7f1ee;
    --ink-2: #c5d3d0;
    --ink-3: #91a3a1;
    --muted: #7a8d8c;
    --line: #1d3d45;
    --line-soft: #133038;

    --brand: #16b3a4;
    --brand-2: #2ec5b6;
    --brand-3: #6ee0d2;
    --brand-deep: #ffffff;
    --kelp: #d2e9e5;

    --good: #2ec5b6;
    --good-ink: #b5f0e8;
    --watch: #f4c160;
    --watch-ink: #f8dca0;
    --rough: #ff7560;
    --rough-ink: #ffd0c8;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
    --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.65);
  }
}

[data-theme="light"] {
  color-scheme: light;
}
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #061b21;
  --bg-elev: #0c2a32;
  --bg-soft: #0a242b;
  --bg-glass: rgba(12, 42, 50, 0.72);
  --ink: #e7f1ee;
  --ink-2: #c5d3d0;
  --ink-3: #91a3a1;
  --muted: #7a8d8c;
  --line: #1d3d45;
  --line-soft: #133038;
  --brand: #16b3a4;
  --brand-2: #2ec5b6;
  --brand-3: #6ee0d2;
  --brand-deep: #ffffff;
  --kelp: #d2e9e5;
  --good: #2ec5b6;
  --good-ink: #b5f0e8;
  --watch: #f4c160;
  --watch-ink: #f8dca0;
  --rough: #ff7560;
  --rough-ink: #ffd0c8;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 22px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-pop: 0 24px 60px rgba(0, 0, 0, 0.65);
}

/* -------------- base -------------- */

* { box-sizing: border-box; }
*::selection { background: color-mix(in srgb, var(--brand) 30%, transparent); }

html { background: var(--bg); }
html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-feature-settings: "ss01", "cv11", "tnum";
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar { flex: 0 0 auto; }
.shell  { flex: 1 0 auto; }
.footer { flex: 0 0 auto; margin-top: auto; }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4, p { margin: 0; }
h1 { font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.005em; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand);
  color: white;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 1000;
}
.skip-link:focus { left: 0; }

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

/* -------------- topbar -------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 12px clamp(14px, 3vw, 28px);
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark { border-radius: 9px; box-shadow: var(--shadow-sm); }
.brand-text { display: grid; line-height: 1.1; }
.brand-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.01em;
}
.brand-tag {
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}

@media (max-width: 720px) {
  .brand-tag { display: none; }
}

.search-shell { position: relative; min-width: 0; }
.search-control {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 8px 0 14px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
  transition: border-color 120ms, box-shadow 120ms;
}
.search-control:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent);
}
.search-control input {
  flex: 1;
  border: 0;
  background: transparent;
  outline: none;
  font-size: 15px;
  min-width: 0;
}
.search-control input::placeholder { color: var(--ink-3); }
.search-icon { width: 18px; height: 18px; color: var(--ink-3); flex-shrink: 0; }
.locate-button {
  width: 34px; height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  display: grid; place-items: center;
}
.locate-button:hover { background: var(--bg-soft); color: var(--brand); }
.locate-button svg { width: 18px; height: 18px; }

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(60vh, 480px);
  overflow: auto;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  z-index: 100;
}
.search-result {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
}
.search-result:hover,
.search-result.is-active {
  background: var(--bg-soft);
}
.search-result .flag {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  color: var(--brand);
  font-weight: 700;
  font-size: 11px;
}
.search-result strong { display: block; font-size: 14px; }
.search-result span { color: var(--ink-3); font-size: 12px; }
.search-result .coords { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.search-empty { padding: 16px; color: var(--ink-3); font-size: 13px; text-align: center; }

.topbar-actions { display: flex; align-items: center; gap: 6px; }
.ghost-button, .primary-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 13px;
  text-decoration: none;
}
.ghost-button:hover { color: var(--brand); border-color: var(--brand); text-decoration: none; }
.ghost-button svg { width: 16px; height: 16px; }
.primary-link {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff !important;
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
}
.primary-link:hover { transform: translateY(-1px); text-decoration: none !important; }

/* Topbar Install button — coral accent so it reads as a CTA, not nav. */
.install-trigger {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff !important;
  border-color: transparent;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent);
  font-weight: 700;
}
.install-trigger:hover {
  color: #fff !important;
  border-color: transparent;
  transform: translateY(-1px);
}
.install-trigger[hidden] { display: none !important; }

#theme-toggle { width: 38px; padding: 0; justify-content: center; }
#theme-toggle .moon { display: none; }
[data-theme="dark"] #theme-toggle .sun { display: none; }
[data-theme="dark"] #theme-toggle .moon { display: block; }
@media (prefers-color-scheme: dark) {
  body:not([data-theme="light"]) #theme-toggle .sun { display: none; }
  body:not([data-theme="light"]) #theme-toggle .moon { display: block; }
}

@media (max-width: 720px) {
  .topbar {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    gap: 10px;
  }
  .brand { grid-column: 1; grid-row: 1; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .search-shell { grid-column: 1 / -1; grid-row: 2; }
  .ghost-button span { display: none; }
}

/* -------------- shell -------------- */

.shell {
  width: min(1620px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2.5vw, 28px) 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel {
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 18px;
  position: relative;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel-head h2 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 700; }
.panel-head p {
  margin-top: 4px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 500;
}

/* -------------- hero -------------- */

.hero {
  position: relative;
  padding: clamp(18px, 3vw, 32px);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg,
      color-mix(in srgb, var(--brand) 22%, transparent) 0%,
      color-mix(in srgb, var(--brand-deep) 35%, transparent) 100%),
    var(--bg-elev);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(700px 250px at 10% 0%, color-mix(in srgb, var(--brand-3) 22%, transparent), transparent 70%),
    radial-gradient(500px 200px at 100% 100%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.hero > * { position: relative; }

.hero-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.hero-eyebrow {
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 4px;
}
.hero-name {
  font-size: clamp(28px, 5vw, 52px);
  line-height: 1.02;
  margin-bottom: 6px;
}
.hero-coord {
  color: var(--ink-3);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0;
}

.hero-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.chip-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-glass);
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
}
.chip-button svg { width: 16px; height: 16px; }
.chip-button:hover { border-color: var(--brand); color: var(--brand); }

.hero-snapshot {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1100px) { .hero-snapshot { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .hero-snapshot { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.snap-card {
  padding: 14px;
  border-radius: var(--radius);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  display: flex; flex-direction: column;
  min-height: 92px;
}
.snap-label {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.snap-card strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
}
.snap-detail {
  margin-top: auto;
  padding-top: 6px;
  color: var(--ink-3);
  font-size: 12px;
}

.snap-condition[data-tone="good"]   { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--good) 50%, transparent); background: color-mix(in srgb, var(--good) 12%, var(--bg-glass)); }
.snap-condition[data-tone="watch"]  { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--watch) 50%, transparent); background: color-mix(in srgb, var(--watch) 12%, var(--bg-glass)); }
.snap-condition[data-tone="rough"]  { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--rough) 60%, transparent); background: color-mix(in srgb, var(--rough) 14%, var(--bg-glass)); }
.snap-condition[data-tone="muted"]  { color: var(--ink-3); }
.snap-condition[data-tone="good"] strong  { color: var(--good-ink); }
.snap-condition[data-tone="watch"] strong { color: var(--watch-ink); }
.snap-condition[data-tone="rough"] strong { color: var(--rough-ink); }

/* -------------- strip row (spots + units) -------------- */

.strip-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}
@media (max-width: 1000px) {
  .strip-row { grid-template-columns: 1fr; }
}

.strip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  min-height: 48px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.strip-label {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0 6px;
  flex-shrink: 0;
}
.quick-spots {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1;
  padding: 0 4px;
}
.quick-spots::-webkit-scrollbar { height: 4px; }
.quick-spots::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

.quick-spots button {
  flex-shrink: 0;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--bg-soft);
  color: var(--ink);
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: background 120ms, transform 120ms, color 120ms;
}
.quick-spots button:hover {
  background: color-mix(in srgb, var(--brand) 14%, var(--bg-soft));
  color: var(--brand);
}
.quick-spots button.is-active {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}

.strip-units {
  flex-wrap: wrap;
  padding: 6px 8px;
}

.segmented {
  display: inline-flex;
  align-items: center;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}
.segmented span {
  padding: 0 8px;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.segmented button {
  min-width: 36px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 12px;
  transition: color 120ms, background 120ms;
}
.segmented button:hover { color: var(--brand); }
.segmented button.is-active {
  background: var(--bg-elev);
  color: var(--brand);
  box-shadow: var(--shadow-sm);
}

.favorites-band {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.favorite-chip {
  display: inline-flex;
  align-items: center;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.favorite-chip button {
  height: 34px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  font-weight: 600;
  font-size: 13px;
  color: var(--ink);
}
.favorite-chip button:hover { color: var(--brand); }
.favorite-chip button[data-remove] {
  width: 32px;
  padding: 0;
  color: var(--ink-3);
  border-left: 1px solid var(--line);
  font-size: 16px;
  line-height: 1;
}
.favorite-chip.is-active { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 30%, transparent); }

/* -------------- status + alerts -------------- */

.status-line {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-glass);
  color: var(--ink-2);
  font-size: 13px;
}
.status-line[data-tone="error"] { border-color: color-mix(in srgb, var(--rough) 50%, transparent); background: color-mix(in srgb, var(--rough) 8%, var(--bg-elev)); color: var(--rough-ink); }

.alert-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}
.alert-strip:empty { display: none; }
.alert-card {
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--rough) 26%, transparent);
  border-left: 4px solid var(--rough);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--rough) 8%, var(--bg-elev));
  color: var(--ink);
}
.alert-card.is-clear {
  border-color: var(--line);
  border-left-color: var(--good);
  background: color-mix(in srgb, var(--good) 7%, var(--bg-elev));
}
.alert-card strong { display: block; font-size: 14px; }
.alert-card span { display: block; margin-top: 4px; color: var(--ink-3); font-size: 12px; }
.alert-card p { margin-top: 8px; font-size: 13px; color: var(--ink-2); }

/* -------------- hero grid (map + stations + observations) -------------- */

.hero-grid {
  display: grid;
  grid-template-columns: minmax(440px, 1.6fr) minmax(260px, 320px) minmax(360px, 440px);
  gap: 16px;
}
@media (max-width: 1320px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .map-panel { grid-column: 1 / -1; }
}
@media (max-width: 820px) {
  .hero-grid { grid-template-columns: 1fr; }
}

.map-panel {
  padding: 0;
  overflow: hidden;
}
.map-panel .panel-head {
  margin: 0;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.map-stage-wrap {
  position: relative;
}

.map-floating-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.map-floating-controls > .map-layers {
  pointer-events: auto;
  background: var(--bg-glass);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-md);
}
.map-floating-controls .map-layers button {
  height: 30px;
  padding: 0 12px;
  font-weight: 700;
}

.map-icon-button {
  pointer-events: auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-glass);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  color: var(--ink-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
}
.map-icon-button:hover { color: var(--brand); border-color: var(--brand); }
.map-icon-button svg { width: 15px; height: 15px; }
.map-icon-button .exit { display: none; }
.map-panel[data-fullscreen="1"] .map-icon-button .enter { display: none; }
.map-panel[data-fullscreen="1"] .map-icon-button .exit { display: block; }

/* Fullscreen mode — true edge-to-edge map. */
.map-panel[data-fullscreen="1"] {
  position: fixed;
  inset: 0;
  z-index: 9999;
  border-radius: 0;
  margin: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  box-shadow: none;
}
.map-panel[data-fullscreen="1"] .panel-head { display: none; }
.map-panel[data-fullscreen="1"] .map-stage-wrap {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}
.map-panel[data-fullscreen="1"] .map-stage { height: 100%; }

/* Compact horizontal control bar in fullscreen. */
.map-panel[data-fullscreen="1"] .map-floating-controls {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  top: 14px;
  right: 14px;
  left: auto;
  gap: 6px;
}
.map-panel[data-fullscreen="1"] .map-floating-controls .map-layers {
  padding: 2px;
}
.map-panel[data-fullscreen="1"] .map-floating-controls .map-layers button {
  height: 26px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
}
.map-panel[data-fullscreen="1"] .map-icon-button {
  width: 28px;
  height: 28px;
}
.map-panel[data-fullscreen="1"] .map-icon-button svg { width: 14px; height: 14px; }

@media (max-width: 720px) {
  .map-floating-controls {
    top: 10px;
    right: 10px;
    left: 10px;
    flex-direction: row;
    flex-wrap: wrap;
  }
  .map-floating-controls > .map-layers {
    flex: 1 1 auto;
    justify-content: center;
  }
}
.map-layers { display: inline-flex; gap: 4px; padding: 3px; background: var(--bg-soft); border-radius: 999px; border: 1px solid var(--line); }
.map-layers button {
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.map-layers button.is-active { background: var(--bg-elev); color: var(--brand); box-shadow: var(--shadow-sm); }

.map-stage {
  width: 100%;
  height: 560px;
  background: var(--bg-soft);
}
@media (max-width: 1320px) { .map-stage { height: 460px; } }
@media (max-width: 820px)  { .map-stage { height: 380px; } }

/* leaflet overrides */
.leaflet-container { font: inherit; background: var(--bg-soft); }
.leaflet-popup-content-wrapper {
  background: var(--bg-elev);
  color: var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  border: 1px solid var(--line);
}
.leaflet-popup-tip { background: var(--bg-elev); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-content strong { display: block; font-size: 14px; margin-bottom: 4px; }
.leaflet-popup-content button {
  margin-top: 8px;
  padding: 6px 10px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: white;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12px;
}
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--bg-elev) 88%, transparent) !important;
  color: var(--ink-3) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--brand-2) !important; }
.leaflet-bar a {
  background: var(--bg-elev) !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
}
.leaflet-bar a:hover { background: var(--bg-soft) !important; }

.buoy-marker {
  width: 14px; height: 14px;
  border-radius: 999px;
  background: var(--brand-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 30%, transparent), 0 1px 4px rgba(0,0,0,0.4);
  border: 2px solid var(--bg-elev);
  cursor: pointer;
  transition: transform 100ms;
}
.buoy-marker:hover { transform: scale(1.2); }
.buoy-marker.is-selected {
  background: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 30%, transparent), 0 1px 6px rgba(0,0,0,0.4);
  width: 18px; height: 18px;
}
.buoy-marker.is-met { background: var(--brand-2); }
.buoy-marker.is-water { background: var(--gold); }
.buoy-marker.is-current { background: var(--accent); }

.map-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Soft heatmap fill — blur is set dynamically per overlay type via JS. */
.leaflet-pane.leaflet-overlay-fill-pane {
  /* sensible default if JS hasn't run yet */
  filter: blur(8px) saturate(115%);
  -webkit-filter: blur(8px) saturate(115%);
  opacity: 0.75;
}

.overlay-arrow-glyph {
  display: block;
  width: 18px; height: 18px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7), 0 0 1px rgba(0, 0, 0, 0.55);
  transform: rotate(var(--dir, 0deg));
  transform-origin: center;
  pointer-events: none;
  user-select: none;
}

.overlay-num-label {
  display: block;
  width: 28px;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  color: rgba(255, 255, 255, 0.92);
  text-shadow:
    0 0 2px rgba(0, 0, 0, 0.85),
    0 1px 2px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  user-select: none;
}

.overlay-hint, .overlay-loader {
  position: absolute;
  z-index: 500;
  pointer-events: none;
}
.overlay-hint {
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  box-shadow: var(--shadow-md);
}
.overlay-loader {
  bottom: 14px;
  right: 14px;
  display: flex;
  gap: 4px;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.overlay-loader i {
  width: 6px; height: 6px;
  border-radius: 99px;
  background: var(--brand);
  animation: bounce 1s infinite;
}
.overlay-loader i:nth-child(2) { animation-delay: 0.15s; }
.overlay-loader i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.overlay-legend {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 500;
  background: var(--bg-glass);
  backdrop-filter: blur(10px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  font-size: 11px;
  color: var(--ink-2);
}
.overlay-legend .legend-title {
  display: block;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-size: 10px;
  margin-bottom: 6px;
}
.overlay-legend .legend-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0;
  width: 180px;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.overlay-legend .legend-bar i { display: block; height: 100%; }
.overlay-legend .legend-ticks {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--ink-3);
  text-align: left;
}

.spot-marker {
  width: 18px; height: 18px;
  border-radius: 999px;
  background: var(--accent);
  border: 3px solid var(--bg-elev);
  box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent), 0 4px 14px rgba(232, 77, 44, 0.45);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 28%, transparent), 0 4px 14px rgba(232, 77, 44, 0.45); }
  50%      { box-shadow: 0 0 0 12px color-mix(in srgb, var(--accent) 12%, transparent), 0 4px 14px rgba(232, 77, 44, 0.45); }
}

/* -------------- station list -------------- */

.station-panel { display: flex; flex-direction: column; min-height: 0; }
.station-list {
  display: grid;
  gap: 6px;
  max-height: 540px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 6px 2px 0;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--brand) 40%, transparent) transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}
.station-list::-webkit-scrollbar { width: 8px; }
.station-list::-webkit-scrollbar-track { background: transparent; }
.station-list::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: 99px;
}

.station-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  transition: background 120ms, border-color 120ms;
}
.station-item:hover { background: var(--bg-soft); border-color: var(--line); }
.station-item.is-active {
  background: color-mix(in srgb, var(--brand) 12%, var(--bg-elev));
  border-color: color-mix(in srgb, var(--brand) 40%, transparent);
}
.station-item .dot {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--brand-2);
}
.station-item .dot.is-water { background: var(--gold); }
.station-item .dot.is-current { background: var(--accent); }
.station-item .dot.is-quiet { background: var(--ink-3); }
.station-item-body { min-width: 0; }
.station-item-body strong { display: block; font-size: 13px; line-height: 1.2; }
.station-item-body span { display: block; color: var(--ink-3); font-size: 11px; margin-top: 2px; }
.station-distance {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-3);
  white-space: nowrap;
}

/* -------------- now panel -------------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
@media (max-width: 600px) { .metrics { grid-template-columns: 1fr; } }
.metrics article {
  position: relative;
  padding: 12px 12px 22px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--bg-soft);
  min-height: 88px;
}
.metrics article[data-source="model"] {
  background: linear-gradient(180deg, color-mix(in srgb, var(--brand) 6%, var(--bg-soft)) 0%, var(--bg-soft) 100%);
  border-color: color-mix(in srgb, var(--brand) 22%, var(--line-soft));
  border-style: dashed;
}
.metrics article[data-source="none"] { opacity: 0.78; }
.metrics span {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.metrics strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.metrics article[data-source="model"] strong { color: var(--ink-2); }

.metric-source {
  position: absolute !important;
  bottom: 8px;
  right: 10px;
  font-size: 9px !important;
  font-weight: 800 !important;
  letter-spacing: 0.12em !important;
  padding: 2px 6px;
  border-radius: 99px;
  text-transform: uppercase;
  color: var(--brand-2) !important;
  background: color-mix(in srgb, var(--brand) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 25%, transparent);
}
.metrics article[data-source="model"] .metric-source {
  color: var(--ink-3) !important;
  background: color-mix(in srgb, var(--brand) 8%, transparent);
  border-color: color-mix(in srgb, var(--brand) 20%, transparent);
}
.metrics article[data-source="model"] .metric-source::before {
  content: "≈ ";
  font-weight: 900;
}
.metrics article[data-source="none"] .metric-source { display: none; }

.trend { margin-top: 16px; }
.trend-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
}

#wave-chart, .tide-chart { width: 100%; height: 140px; display: block; }
.tide-chart { height: 180px; }
.chart-area { fill: color-mix(in srgb, var(--brand-2) 18%, transparent); }
.chart-area.coral { fill: color-mix(in srgb, var(--accent) 18%, transparent); }
.chart-line { fill: none; stroke: var(--brand-2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.chart-line.coral { stroke: var(--accent); }
.chart-grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; opacity: 0.6; }
.chart-tick { fill: var(--ink-3); font-size: 10px; font-family: var(--font-mono); }

/* -------------- planner / hourly -------------- */

.planner-section { padding: 18px; }
.planner-tabs { display: inline-flex; padding: 3px; background: var(--bg-soft); border: 1px solid var(--line); border-radius: 999px; gap: 2px; }
.planner-tabs button {
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}
.planner-tabs button.is-active { background: var(--bg-elev); color: var(--brand); box-shadow: var(--shadow-sm); }

.best-windows {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
@media (max-width: 1100px) { .best-windows { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px)  { .best-windows { grid-template-columns: 1fr 1fr; } }

.best-windows-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.best-windows-head h3 {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0;
}
.best-windows-head p {
  color: var(--ink-3);
  font-size: 12px;
  margin: 0;
  flex: 1 1 220px;
  text-align: right;
}

.best-window {
  position: relative;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--bg-elev), var(--bg-soft));
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 116px;
  overflow: hidden;
}
.best-window::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 4px;
  background: var(--good);
  width: var(--score, 0%);
  transition: width 240ms;
}
.best-window[data-tone="watch"]::after { background: var(--watch); }
.best-window[data-tone="rough"]::after { background: var(--rough); }

.bw-when {
  color: var(--ink-3);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.bw-score {
  display: flex;
  align-items: baseline;
  gap: 4px;
  font-family: var(--font-display);
}
.bw-score b {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--good-ink);
  line-height: 1;
}
.bw-score small {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--ink-3);
}
.best-window[data-tone="watch"] .bw-score b { color: var(--watch-ink); }
.best-window[data-tone="rough"] .bw-score b { color: var(--rough-ink); }

.bw-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  margin: 4px 0 0;
  padding: 0;
}
.bw-stats > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.bw-stats dt {
  color: var(--ink-3);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.bw-stats dd {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* daily summary cards */
.daily-cards {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.daily-cards:empty { display: none; }

.daily-card {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 12px 10px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  text-align: left;
  cursor: pointer;
  transition: transform 120ms, border-color 120ms, background 120ms;
  overflow: hidden;
  font-family: inherit;
}
.daily-card:hover { transform: translateY(-1px); border-color: var(--brand); background: var(--bg-elev); }
.daily-card[data-tone="good"]  { box-shadow: inset 3px 0 0 var(--good); }
.daily-card[data-tone="watch"] { box-shadow: inset 3px 0 0 var(--watch); }
.daily-card[data-tone="rough"] { box-shadow: inset 3px 0 0 var(--rough); }

.dc-day {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}
.dc-day strong {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink);
}
.dc-day em {
  font-style: normal;
  font-size: 11px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.dc-icon {
  display: block;
  width: 28px;
  height: 28px;
  color: var(--brand);
}
.daily-card[data-tone="watch"] .dc-icon { color: var(--watch); }
.daily-card[data-tone="rough"] .dc-icon { color: var(--rough); }
.dc-icon svg { width: 100%; height: 100%; }

.dc-temp,
.dc-wave,
.dc-wind {
  display: block;
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.dc-temp small,
.dc-wave small {
  margin-left: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
}

.dc-score {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.dc-score i {
  flex: 1 1 auto;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--good) 0%, var(--good) calc(var(--score, 0%)), color-mix(in srgb, var(--ink-3) 25%, transparent) calc(var(--score, 0%)), color-mix(in srgb, var(--ink-3) 25%, transparent) 100%);
}
.daily-card[data-tone="watch"] .dc-score i {
  background: linear-gradient(90deg, var(--watch) 0%, var(--watch) calc(var(--score, 0%)), color-mix(in srgb, var(--ink-3) 25%, transparent) calc(var(--score, 0%)), color-mix(in srgb, var(--ink-3) 25%, transparent) 100%);
}
.daily-card[data-tone="rough"] .dc-score i {
  background: linear-gradient(90deg, var(--rough) 0%, var(--rough) calc(var(--score, 0%)), color-mix(in srgb, var(--ink-3) 25%, transparent) calc(var(--score, 0%)), color-mix(in srgb, var(--ink-3) 25%, transparent) 100%);
}
.dc-score b {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

@media (max-width: 720px) {
  .daily-cards {
    grid-auto-flow: column;
    grid-auto-columns: 130px;
    overflow-x: auto;
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
  }
  .daily-cards::-webkit-scrollbar { height: 4px; }
  .daily-cards::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
}

/* hourly canvas — horizontally scrollable timeline */
.hourly-canvas {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--brand) 40%, transparent) transparent;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
}
.hourly-canvas::-webkit-scrollbar { height: 8px; }
.hourly-canvas::-webkit-scrollbar-track { background: transparent; }
.hourly-canvas::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: 99px;
}
.hourly-headline {
  padding: 10px 14px 0;
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
  position: sticky;
  left: 0;
}
.hourly-grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 60px;
  gap: 0;
  padding: 0;
}
.hourly-cell.is-day-start { scroll-snap-align: start; }
.hourly-cell {
  position: relative;
  padding: 12px 6px 8px;
  border-right: 1px solid var(--line-soft);
  text-align: center;
  display: grid;
  gap: 4px;
  background: transparent;
  border-top: 0;
  border-bottom: 0;
  border-left: 0;
  cursor: default;
}
.hourly-cell.is-day-start {
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--brand-2) 5%, transparent);
}
.hourly-cell:hover { background: color-mix(in srgb, var(--brand) 10%, transparent); }
.hourly-cell .h-time { color: var(--ink-3); font-size: 11px; font-weight: 600; font-family: var(--font-mono); }
.hourly-cell .h-day  { color: var(--ink-3); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.hourly-cell .h-bar  {
  width: 100%;
  height: 56px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 4px 0;
}
.hourly-cell .h-bar i {
  display: block;
  width: 14px;
  background: linear-gradient(180deg, var(--brand-3), var(--brand-2));
  border-radius: 4px 4px 1px 1px;
  min-height: 2px;
}
.hourly-cell[data-score="watch"] .h-bar i { background: linear-gradient(180deg, var(--watch), #c98c20); }
.hourly-cell[data-score="rough"] .h-bar i { background: linear-gradient(180deg, var(--rough), #a4271b); }
.hourly-cell .h-wind { font-size: 12px; font-weight: 700; color: var(--ink); }
.hourly-cell .h-arrow {
  display: inline-block;
  font-size: 14px;
  color: var(--ink-3);
  transform: rotate(var(--dir, 0deg));
  transition: transform 200ms;
}
.hourly-cell .h-precip {
  height: 3px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--brand-2) 20%, transparent);
  overflow: hidden;
  margin-top: 4px;
}
.hourly-cell .h-precip i { display: block; height: 100%; background: var(--brand-2); width: var(--p, 0%); }

/* -------------- planner grid -------------- */

.planner-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 0.8fr);
  gap: 16px;
}
@media (max-width: 1100px) { .planner-grid { grid-template-columns: 1fr; } }

.tide-extremes {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}
.tide-extremes article {
  flex: 1 1 120px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--bg-soft);
}
.tide-extremes article span {
  display: block;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
}
.tide-extremes article strong { display: block; font-size: 16px; font-weight: 700; margin-top: 2px; }

.forecast-list { display: grid; gap: 8px; }
.forecast-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid var(--line-soft);
}
.forecast-row:first-child { border-top: 0; padding-top: 0; }
.forecast-row strong { font-size: 13px; }
.forecast-values {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 4px;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--brand) 40%, transparent) transparent;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.forecast-values::-webkit-scrollbar { height: 6px; }
.forecast-values::-webkit-scrollbar-track { background: transparent; }
.forecast-values::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--brand) 35%, transparent);
  border-radius: 99px;
}
.forecast-pill {
  flex-shrink: 0;
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  border-radius: var(--radius);
}
.forecast-pill span { display: block; color: var(--ink-3); font-size: 10px; font-weight: 600; }
.forecast-pill b { display: block; margin-top: 2px; font-size: 13px; font-weight: 700; }

/* -------------- footer -------------- */

.footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  padding: 22px clamp(14px, 3vw, 32px);
  border-top: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--ink-3);
  font-size: 13px;
  flex-wrap: wrap;
}
.footer strong { color: var(--ink); font-family: var(--font-display); font-size: 15px; }
.footer p { margin-top: 6px; max-width: 520px; line-height: 1.5; }
.footer nav { display: flex; gap: 14px; flex-wrap: wrap; }
.footer nav a { color: var(--ink-2); font-weight: 600; }
.footer .credit { margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.footer .credit a { color: var(--ink-2); font-weight: 600; }
.footer .credit a:hover { color: var(--brand); }

.empty {
  color: var(--ink-3);
  font-size: 13px;
  padding: 14px;
  text-align: center;
  background: var(--bg-soft);
  border-radius: var(--radius);
}

/* PWA install prompt — bottom-anchored, dismissible, mobile-first. */
.install-banner {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  z-index: 1000;
  animation: install-slide-up 280ms ease;
}
@keyframes install-slide-up {
  from { transform: translate(-50%, 24px); opacity: 0; }
  to   { transform: translate(-50%, 0);    opacity: 1; }
}
.install-banner[hidden] { display: none !important; }
.install-mark { border-radius: 9px; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.install-text { display: grid; line-height: 1.25; min-width: 0; }
.install-text strong { font-size: 14px; }
.install-text span {
  margin-top: 2px;
  color: var(--ink-3);
  font-size: 12px;
}
.install-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.install-primary {
  height: 36px;
  padding: 0 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: white;
  border: 0;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 30%, transparent);
}
.install-primary:hover { transform: translateY(-1px); }
.install-primary[hidden] { display: none; }
.install-dismiss {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.install-dismiss:hover { color: var(--ink); border-color: var(--ink-3); }

@media (max-width: 480px) {
  .install-banner {
    width: calc(100% - 20px);
    padding: 10px 12px;
  }
  .install-text strong { font-size: 13px; }
  .install-text span { font-size: 11px; }
}

.skeleton {
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--brand) 12%, transparent), transparent) 0 0/200% 100% no-repeat,
    var(--bg-soft);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer {
  to { background-position: -200% 0, 0 0; }
}

/* ===== Mobile polish ===== */

/* Notch + home-indicator safe areas (iPhone X+, modern Androids in landscape) */
.topbar {
  padding-top: max(12px, env(safe-area-inset-top));
  padding-left: max(clamp(14px, 3vw, 28px), env(safe-area-inset-left));
  padding-right: max(clamp(14px, 3vw, 28px), env(safe-area-inset-right));
}
.shell {
  padding-left: max(clamp(12px, 2.5vw, 28px), env(safe-area-inset-left));
  padding-right: max(clamp(12px, 2.5vw, 28px), env(safe-area-inset-right));
}
.footer {
  padding-bottom: max(22px, env(safe-area-inset-bottom));
}

/* Disable hover-transforms on touch devices so cards don't get stuck "raised". */
@media (hover: none) {
  .quick-spots button:hover,
  .station-item:hover,
  .daily-card:hover,
  .chip-button:hover,
  .ghost-button:hover,
  .install-primary:hover {
    transform: none !important;
  }
}

@media (max-width: 720px) {
  .hero-head { flex-direction: column; align-items: flex-start; }
  .panel-head { flex-direction: column; }
  .planner-tabs { align-self: flex-start; }

  /* All interactive surfaces at iOS HIG minimum tap target. */
  .quick-spots button { height: 38px; padding: 0 16px; font-size: 14px; }
  .segmented button { min-width: 40px; height: 32px; }
  .ghost-button { height: 40px; }
  .chip-button { height: 40px; padding: 0 16px; }
  .search-control { height: 46px; }
  .locate-button { width: 40px; height: 40px; }
  .map-layers button { min-height: 32px; padding: 0 12px; }

  .hero { padding: 18px; }
  .hero-name { font-size: 30px; text-wrap: balance; overflow-wrap: anywhere; }
  .hero-coord { font-size: 12px; }
  .snap-card strong { font-size: 22px; }

  .station-list { max-height: 320px; }

  .footer { flex-direction: column; gap: 12px; }
  .footer nav { gap: 12px; }

  /* Best-windows on tablet: 3 columns reads better than 2 stretched cards. */
  .best-windows { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .best-windows-head p { text-align: left; flex-basis: 100%; }
}

/* Phones */
@media (max-width: 560px) {
  .shell { padding-top: 14px; padding-bottom: 24px; gap: 14px; }
  .panel { padding: 14px; }
  .hero { padding: 16px; }
  .hero-name { font-size: clamp(24px, 7vw, 30px); }

  .hero-actions { width: 100%; }
  .hero-actions .chip-button { flex: 1; justify-content: center; }

  .quick-spots { padding: 0 2px; }
  .strip { padding: 4px 8px; min-height: 44px; }
  .strip-units { gap: 6px; }

  .planner-section { padding: 14px; }
  .best-windows { grid-template-columns: 1fr 1fr; gap: 8px; }
  .best-window { padding: 10px 12px; min-height: 110px; }
  .bw-score b { font-size: 24px; }
  .bw-stats dd { font-size: 12px; }

  .map-stage { height: 320px; }

  /* Ensure overlay legend and loader stay readable at small map heights. */
  .overlay-legend { padding: 8px 10px; }
  .overlay-legend .legend-bar { width: 140px; }
}

/* Very narrow / iPhone SE 1st gen */
@media (max-width: 380px) {
  .shell { padding-left: max(8px, env(safe-area-inset-left)); padding-right: max(8px, env(safe-area-inset-right)); }
  .hero { padding: 14px; }
  .snap-card { padding: 12px 10px; min-height: 84px; }
  .snap-card strong { font-size: 19px; }
  .snap-detail { font-size: 11px; }
  .ghost-button span,
  .chip-button span { display: none; }       /* icons-only on tiny screens */
  .ghost-button, .chip-button { width: 40px; padding: 0; justify-content: center; }
  .planner-tabs button { padding: 0 10px; font-size: 11px; }
  .best-windows { grid-template-columns: 1fr; }
  .bw-stats { grid-template-columns: 1fr 1fr 1fr; }
}

/* Prevent any accidental horizontal overflow at narrow widths. */
html, body { overflow-x: clip; }

/* fine-tune focus visibility */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: inherit;
}
button:focus-visible,
a:focus-visible {
  outline-offset: 3px;
}
