:root {
  --bg: #0b1220;
  --bg-2: #0f172a;
  --surface: #111a2e;
  --surface-2: #18243e;
  --border: #1f2d4a;
  --text: #e6ecf5;
  --text-dim: #94a3b8;
  --text-dimmer: #64748b;
  --accent: #38bdf8;
  --gold: #fbbf24;
  --gold-soft: #fde68a;
  --blue: #3b82f6;
  --good: #34d399;
  --warn: #f59e0b;
  --bad: #f87171;
  --forest: #1e5f3e;
  --forest-soft: #2e7d4f;
  --forest-glow: rgba(46,125,79,.35);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 10px 30px -10px rgba(0,0,0,.5);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); min-height: 100vh; }
body {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(56,189,248,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(251,191,36,.07), transparent 60%),
    var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
}

button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px); position: sticky; top: 0; background: rgba(11,18,32,.78); z-index: 50;
  padding-top: max(14px, env(safe-area-inset-top));
}
.brand { display: flex; gap: 14px; align-items: center; color: var(--accent); }
.brand h1 { margin: 0; font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; }
.brand .sub { margin: 2px 0 0; font-size: 12px; color: var(--text-dim); }
.app-version { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text-dimmer); margin-left: 4px; }
.topbar-right { display: flex; gap: 10px; align-items: center; }

.status {
  font-size: 11px; padding: 6px 12px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  font-family: 'JetBrains Mono', monospace; white-space: nowrap;
}
.status.loading { color: var(--accent); border-color: rgba(56,189,248,.4); }
.status.error { color: var(--bad); border-color: rgba(248,113,113,.4); }
.status.ok { color: var(--good); border-color: rgba(52,211,153,.4); }

.status-wrap { display: flex; align-items: center; gap: 6px; }

/* ---------- Centered rotating loading overlay ---------- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 500;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 22px;
  background: rgba(6, 12, 20, 0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  opacity: 0; transition: opacity .2s ease;
}
.loading-overlay[hidden] { display: none; }
.loading-overlay.is-visible { opacity: 1; }

.loading-orbit-stage {
  position: relative;
  width: clamp(150px, 32vw, 200px); height: clamp(150px, 32vw, 200px);
  display: flex; align-items: center; justify-content: center;
}
.loading-pulse-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 2px solid #38bdf8; opacity: 0;
  animation: loadingPulseRing 2.4s ease-out infinite;
}
.loading-pulse-ring.r2 { animation-delay: .8s; }
.loading-pulse-ring.r3 { animation-delay: 1.6s; }
@keyframes loadingPulseRing {
  0% { transform: scale(0.55); opacity: .75; }
  100% { transform: scale(1); opacity: 0; }
}
.loading-core {
  position: relative; z-index: 2;
  width: 46%; height: 46%; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #38bdf8, #0369a1 70%);
  box-shadow: 0 0 30px 6px rgba(56,189,248,.55), inset 0 0 14px rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  animation: loadingCorePulse 1.6s ease-in-out infinite;
}
@keyframes loadingCorePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.06); }
}
.loading-timer {
  font-family: 'JetBrains Mono', monospace; font-size: clamp(14px, 3vw, 18px);
  font-weight: 600; color: #f8fafc; text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.loading-orbit {
  position: absolute; inset: 0;
  animation: loadingOrbitSpin 6s linear infinite;
}
@keyframes loadingOrbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.loading-orbit-item {
  position: absolute; top: 50%; left: 50%;
  width: 0; height: 0;
}
/* Position each icon on the orbit ring (static placement, no animation on this element) */
.item-sun { transform: rotate(0deg) translateY(calc(-1 * clamp(75px, 16vw, 100px))); }
.item-moon { transform: rotate(120deg) translateY(calc(-1 * clamp(75px, 16vw, 100px))); }
.item-wave { transform: rotate(240deg) translateY(calc(-1 * clamp(75px, 16vw, 100px))); }
/* Counter-rotate the icon itself so it stays upright while the orbit spins */
.loading-orbit-item > svg {
  position: absolute; top: 0; left: 0; transform: translate(-50%, -50%);
  animation: loadingOrbitCounterSpin 6s linear infinite;
  filter: drop-shadow(0 1px 4px rgba(0,0,0,.5));
}
@keyframes loadingOrbitCounterSpin {
  from { transform: translate(-50%, -50%) rotate(0deg); }
  to { transform: translate(-50%, -50%) rotate(-360deg); }
}

.loading-overlay-label {
  color: var(--text-dim); font-size: 13px; text-align: center; max-width: 320px; padding: 0 16px;
}
@media (prefers-reduced-motion: reduce) {
  .loading-pulse-ring, .loading-core, .loading-orbit, .loading-orbit-item > svg { animation: none; }
}

main { max-width: 1400px; margin: 0 auto; padding: 24px; overflow-x: hidden; }

/* Buttons */
button.primary {
  background: var(--accent); color: #06121f; border: none;
  padding: 0 22px; height: 44px; font-weight: 600; font-size: 14px;
  border-radius: var(--radius-sm); transition: transform .1s, background .15s;
  white-space: nowrap;
}
button.primary:hover { background: #7dd3fc; }
button.primary:active { transform: scale(.98); }

/* "Best Tide" search button: a hand-drawn / sketch aesthetic rather than a
   flat, generic pill. The visible fill is an SVG rounded-rect run through an
   feTurbulence + feDisplacementMap filter so its outline reads as a slightly
   irregular, rough-inked shape (redrawn on every render via the SVG filter,
   so it never looks machine-perfect). A wobbly two-line wave icon (drawn with
   uneven control points, not a perfect sine repeat) reinforces the wave
   concept without relying on a razor-straight scalloped edge. Content sits in
   a normal flex layer ABOVE the rough-fill layer so it is never cut off. */
.wave-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  gap: clamp(6px, 1.2vw, 10px); overflow: visible;
  padding-inline: clamp(18px, 3vw, 26px);
  height: 44px;
  margin-bottom: 8px;
  background: none;
  border-radius: var(--radius-sm);
  isolation: isolate;
}
.wave-btn-rough-fill {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 0; overflow: visible;
}
.wave-btn-rough-shape {
  fill: var(--accent);
}
.wave-btn:hover .wave-btn-rough-shape { fill: #7dd3fc; }
.wave-btn:active .wave-btn-rough-shape { fill: #38bdf8; }
.wave-btn-content {
  position: relative; z-index: 1; display: inline-flex; align-items: center;
  gap: clamp(6px, 1.2vw, 10px);
}
.wave-btn-icon { flex-shrink: 0; overflow: visible; }
.wave-btn-path { transform-origin: center; }
.wave-btn-path-1 { animation: waveBtnIdle 3.2s ease-in-out infinite; }
.wave-btn-path-2 { animation: waveBtnIdle 3.2s ease-in-out infinite .5s; }
@keyframes waveBtnIdle {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(3px); }
}
.wave-btn-label { white-space: nowrap; color: #06121f; }
.wave-btn-ring {
  position: absolute; inset: -3px; pointer-events: none;
  border: 2px solid var(--accent); opacity: 0; box-sizing: border-box;
  border-radius: var(--radius-sm);
}
.wave-btn.is-pulsing .wave-btn-ring { animation: waveBtnPulse 1s ease-out 5; }
@keyframes waveBtnPulse {
  0% { transform: scale(1); opacity: .8; }
  100% { transform: scale(1.35); opacity: 0; }
}
.wave-btn:hover { background: linear-gradient(180deg, #a5e5ff 0%, #7dd3fc 55%, var(--accent) 100%); }
.wave-btn:active { transform: scale(.98); }
@media (max-width: 380px) {
  .wave-btn-label { font-size: 13px; }
}
button.ghost-btn, a.ghost-btn {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 14px; height: 38px; font-size: 13px; border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
  text-decoration: none; cursor: pointer; box-sizing: border-box;
}
button.ghost-btn:hover, a.ghost-btn:hover { border-color: var(--accent); background: var(--surface-2); }
button.ghost-btn.danger, a.ghost-btn.danger { color: var(--bad); border-color: rgba(248,113,113,.3); }
button.ghost-btn.danger:hover, a.ghost-btn.danger:hover { background: rgba(248,113,113,.1); border-color: var(--bad); }

/* Controls */
.controls {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.controls-grid {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(150px, 190px) auto;
  gap: 14px; align-items: start;
}
/* align-items:start (rather than the old "end") keeps every column
   top-anchored, so the 88px-tall action-stack no longer pushes the
   shorter Search-location/Date columns down and leaves an empty gap
   above their labels. All three columns now start flush at the top of
   the row regardless of height. */
.controls-grid label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.input-group { display: flex; gap: 8px; flex-wrap: wrap; }
.input-group input, input#datePicker {
  flex: 1; padding: 12px 14px; font-size: 14px; height: 44px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); outline: none; transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}
input#datePicker { width: 100%; color-scheme: dark; }
.input-group input:focus, input#datePicker:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }

/* Square action button stack: Best Tide on top, This Spot underneath.
   Fixed width so it never gets squeezed by the grid at tablet widths —
   this is a dedicated column, not a flex item competing for space.
   Width MUST equal the button height (88px) below or the buttons render
   as short rectangles instead of true squares. */
.action-stack {
  display: flex; flex-direction: column; gap: 8px;
  width: 88px; flex-shrink: 0;
}
.secondary-actions-row { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Paste-GPS row: sits right under Search location / Best Tide / This Spot so
   a visitor with coordinates copied from another app can jump straight to
   the "This Spot" map + tide estimate without hunting for a form. */
.gps-paste-row {
  margin-top: 10px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.gps-paste-icon { font-size: 14px; opacity: .75; flex-shrink: 0; }
.gps-paste-row input {
  flex: 1 1 260px; min-width: 0; background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 8px 12px; font-size: 13px; outline: none; font-family: inherit;
}
.gps-paste-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }
.gps-paste-go-btn { flex: 0 0 auto; padding: 8px 18px; font-weight: 600; }
.gps-paste-status { flex-basis: 100%; font-size: 12px; min-height: 14px; }
.gps-paste-status.error { color: #ff8a8a; }
.gps-paste-status.success { color: #7be6a3; }
@media (max-width: 480px) {
  .gps-paste-row input { flex-basis: 100%; }
  .gps-paste-go-btn { flex: 1 1 auto; }
}
.gps-paste-row-modal { margin-top: 10px; margin-bottom: 4px; }

.examples { margin-top: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-dim); }
.chip {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px; font-size: 12px;
  transition: border-color .15s, background .15s; font-family: inherit;
}
.chip:hover { border-color: var(--accent); background: var(--surface-2); }

/* Tablet range (covers iPad portrait/landscape ~768-1024px CSS width) —
   stack Search location, Date, and the action buttons on separate rows
   so nothing is forced to squeeze onto one line. Widened from the old
   800px cutoff specifically because that left a gap through iPad widths
   where the date field and buttons still got cramped. */
@media (max-width: 1080px) {
  .controls-grid { grid-template-columns: 1fr; }
  /* Keep the two buttons as genuine squares - do NOT stretch them to fill
     the row (flex:1 on a 100%-wide row was turning each button into a
     short wide rectangle with dead space around the icon/label). Instead
     center a fixed-size square pair; the matching width:64px lives with
     the height:64px override below so width always equals height. */
  .action-stack {
    flex-direction: row; width: 100%; justify-content: center; gap: 12px;
  }
  .action-stack .wave-btn-square, .action-stack .spot-btn-square {
    flex: 0 0 auto;
  }
}

/* Summary cards */
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.card.highlight { border-color: rgba(251,191,36,.4); background: linear-gradient(135deg, var(--surface), rgba(251,191,36,.06)); }
.card .label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--text-dimmer); }
.card .value { font-size: 22px; font-weight: 700; margin-top: 4px; letter-spacing: -0.01em; }
.card.highlight .value { color: var(--gold); }
.card .meta { font-size: 12px; color: var(--text-dim); margin-top: 4px; font-family: 'JetBrains Mono', monospace; }

@media (max-width: 1000px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }

/* Sun/moon section */
.sun-moon-section { margin-bottom: 20px; }
.sun-moon-grid { display: grid; grid-template-columns: 1fr 280px; gap: 24px; padding: 20px; }
.sun-moon-grid h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .06em; }
.phase-timeline {
  position: relative; height: 56px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--border); margin-bottom: 12px;
}
.phase-timeline .marker {
  position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.6);
  z-index: 2;
}
.phase-timeline .marker.sunrise { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.phase-timeline .marker.sunset { background: #f97316; box-shadow: 0 0 10px #f97316; }
.phase-timeline .marker .lbl {
  position: absolute; top: -16px; left: -10px; font-size: 9px; color: var(--text-dim);
  white-space: nowrap; font-family: 'JetBrains Mono', monospace;
}
.phase-list {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 18px;
}
.phase-list li {
  font-size: 12px; color: var(--text-dim);
  display: flex; justify-content: space-between; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid var(--border);
}
.phase-list li.hl { color: var(--gold); font-weight: 600; }
.phase-list li .v { font-family: 'JetBrains Mono', monospace; color: var(--text); }
.phase-list li.hl .v { color: var(--gold); }

.phase-legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 11px; color: var(--text-dim); margin-bottom: 14px; }
.phase-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

.moon-wrap { display: flex; flex-direction: column; align-items: center; }
#moonCanvas { display: block; margin-bottom: 12px; }
.moon-info { text-align: center; }
.moon-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.moon-illum { font-size: 13px; color: var(--gold); font-family: 'JetBrains Mono', monospace; margin-bottom: 6px; }
.moon-meta { font-size: 11px; color: var(--text-dim); max-width: 200px; }

@media (max-width: 900px) {
  .sun-moon-grid { grid-template-columns: 1fr; }
  .phase-list { grid-template-columns: 1fr; }
}

/* Layout */
.layout { display: grid; grid-template-columns: 380px 1fr; gap: 18px; min-width: 0; }
.layout > * { min-width: 0; }
@media (max-width: 1000px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.panel-head .hint { font-size: 11px; color: var(--text-dim); }
.count {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  background: var(--bg-2); color: var(--text-dim); padding: 4px 10px; border-radius: 999px;
}

.map { height: 280px; width: 100%; background: var(--bg-2); position: relative; z-index: 0; isolation: isolate; }

.station-list { list-style: none; margin: 0; padding: 0; max-height: 380px; overflow-y: auto; }
.station-list li {
  padding: 12px 18px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.station-list li:hover { background: var(--surface-2); }
.station-list li.active { background: rgba(56,189,248,.08); border-left: 3px solid var(--accent); padding-left: 15px; }
.station-list li.aligned { background: rgba(251,191,36,.05); }
.station-list li.aligned .s-name { color: var(--gold); }
.station-list .s-name { font-size: 13px; font-weight: 500; }
.station-list .s-meta { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.station-list .s-dist { color: var(--text-dim); font-size: 12px; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }

.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.check { font-size: 12px; color: var(--text-dim); display: flex; gap: 6px; align-items: center; cursor: pointer; }
.check input { accent-color: var(--accent); }
select {
  background: var(--bg-2); color: var(--text); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: 12px;
  font-family: inherit; cursor: pointer;
}

.table-wrap { overflow-x: auto; max-height: 580px; overflow-y: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
thead { position: sticky; top: 0; background: var(--surface); z-index: 1; }
th { text-align: left; padding: 10px 12px; font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); border-bottom: 1px solid var(--border); }
td { padding: 12px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.prime { background: rgba(251,191,36,.10); }
tbody tr.prime:hover { background: rgba(251,191,36,.16); }
tbody tr.excellent { background: rgba(251,191,36,.05); }
tbody tr.excellent:hover { background: rgba(251,191,36,.10); }
.mono { font-family: 'JetBrains Mono', monospace; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; font-family: 'JetBrains Mono', monospace; }
.tag.low { background: rgba(56,189,248,.15); color: var(--accent); }
.tag.high { background: rgba(248,113,113,.15); color: var(--bad); }
.tag.prime { background: rgba(251,191,36,.20); color: var(--gold); }
.tag.excellent { background: rgba(251,191,36,.12); color: var(--gold-soft); }
.tag.workable { background: rgba(148,163,184,.15); color: var(--text-dim); }
.tier-tag { font-size: 9px; text-transform: uppercase; letter-spacing: .06em; margin-left: 6px; padding: 1px 6px; border-radius: 4px; vertical-align: middle; }
.score-bar { display: flex; align-items: center; gap: 8px; }
.score-bar .bar { flex: 1; height: 5px; background: var(--bg-2); border-radius: 3px; overflow: hidden; min-width: 40px; }
.score-bar .fill { height: 100%; background: linear-gradient(90deg, var(--bad), var(--warn), var(--good)); transition: width .3s; }
.score-bar .num { font-family: 'JetBrains Mono', monospace; font-size: 12px; min-width: 24px; text-align: right; }
.wx { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; line-height: 1.3; }
.wx .good { color: var(--good); }
.wx .warn { color: var(--warn); }
.wx .bad { color: var(--bad); }
.trend-arrow { font-size: 16px; }

/* Inline sky-quality badge + sun azimuth cells (async, per-row /api/predict) */
.sky-cell { font-size: 11px; font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.sky-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 7px; border-radius: 999px; font-size: 11px; font-weight: 500; }
.sky-badge.band-excellent { background: rgba(251,191,36,.20); color: var(--gold); }
.sky-badge.band-good { background: rgba(74,222,128,.15); color: var(--good); }
.sky-badge.band-fair { background: rgba(148,163,184,.15); color: var(--text-dim); }
.sky-badge.band-poor { background: rgba(248,113,113,.15); color: var(--bad); }
.sky-badge.band-loading { background: var(--bg-2); color: var(--text-dim); opacity: .6; }
.sky-badge.band-error, .sky-badge.band-na { background: var(--bg-2); color: var(--text-dim); }
.sky-skel { display: inline-block; width: 46px; height: 14px; border-radius: 4px; background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3, var(--bg-2)) 50%, var(--bg-2) 75%); background-size: 200% 100%; animation: sky-skel-pulse 1.3s ease-in-out infinite; }
@keyframes sky-skel-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.az-cell { font-size: 11px; font-family: 'JetBrains Mono', monospace; color: var(--text-dim); white-space: nowrap; }
.az-cell .az-deg { color: var(--text); }
.trend-arrow.rising { color: var(--bad); }
.trend-arrow.falling { color: var(--good); }
.go-btn { padding: 4px 10px; font-size: 11px; height: 28px; }

.empty { padding: 40px; text-align: center; color: var(--text-dim); font-size: 14px; }

.methodology { margin-top: 24px; }
.methodology details {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 18px;
}
.methodology summary { cursor: pointer; font-weight: 500; font-size: 13px; color: var(--text-dim); }
.methodology summary:hover { color: var(--text); }
.methodology ul { margin: 12px 0 0; padding-left: 22px; font-size: 13px; color: var(--text-dim); line-height: 1.7; }
.methodology code { background: var(--bg-2); padding: 1px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text); }
.methodology a { color: var(--accent); text-decoration: none; }
.methodology a:hover { text-decoration: underline; }

/* Modal */
.modal[hidden] { display: none !important; }
/* The modal itself scrolls (not just the card) so tall content on short
   viewports (mobile, landscape, small windows) is always reachable —
   fixes cards that overflowed the viewport with no way to scroll to the
   rest of the content or to the action buttons at the bottom. */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 20px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(4px); }
.modal-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; max-width: 460px; width: 100%; box-shadow: var(--shadow);
  margin: auto 0;
  max-height: calc(100vh - 40px); overflow-y: auto; -webkit-overflow-scrolling: touch;
}
.modal-card h2 { margin: 0 0 8px; font-size: 18px; }
.modal-card p { margin: 0 0 16px; font-size: 13px; color: var(--text-dim); line-height: 1.5; }
.modal-card label { display: block; font-size: 12px; color: var(--text-dim); margin-bottom: 6px; }
.modal-card input {
  width: 100%; padding: 12px 14px; font-size: 14px; height: 44px;
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); outline: none; font-family: inherit; margin-bottom: 14px;
}
.modal-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(56,189,248,.15); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-status { margin-top: 10px; font-size: 12px; color: var(--text-dim); text-align: right; }
.modal-status.err { color: var(--bad); }

/* Popup vs new-tab choice prompt */
.detail-choice-card { max-width: 380px; text-align: center; }
.detail-choice-sub { text-align: left; }
.detail-choice-actions { display: flex; flex-direction: column; gap: 10px; margin-bottom: 10px; }
.detail-choice-actions button { width: 100%; height: 44px; }
.detail-choice-cancel { width: 100%; }

/* Station detail modal (map + full info on one page) */
.station-detail-card {
  max-width: 980px; width: 100%; max-height: 88vh; overflow-y: auto;
  padding: 0; display: flex; flex-direction: column;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 2;
}
.modal-header h2 { font-size: 16px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-header-actions { display: flex; gap: 8px; flex-shrink: 0; }
.detail-body { padding: 0 22px 22px; }
.detail-map-wrap {
  position: relative; width: 100%; height: 340px; border-radius: var(--radius-sm);
  overflow: hidden; margin: 18px 0; border: 1px solid var(--border);
  z-index: 0; isolation: isolate;
}
.detail-map-wrap .leaflet-container { width: 100%; height: 100%; background: var(--bg-2); }
.detail-map-actions {
  position: absolute; bottom: 34px; right: 10px; z-index: 1200;
  display: flex; gap: 8px;
}
.detail-map-actions .ghost-btn { background: rgba(15, 23, 42, .88); }
.detail-info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px; margin-bottom: 18px;
}
.detail-info-card {
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.detail-info-card h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim);
  margin: 0 0 10px;
}
.detail-info-row { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; padding: 3px 0; }
.detail-info-row span:first-child { color: var(--text-dim); flex-shrink: 0; }
.detail-info-row span:last-child { font-family: 'JetBrains Mono', monospace; text-align: right; white-space: nowrap; margin-left: auto; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
@media (max-width: 640px) {
  .modal-header { flex-wrap: wrap; }
  .modal-header h2 { white-space: normal; }
  .detail-map-wrap { height: 240px; }
}
.go-cell { display: flex; flex-direction: column; gap: 6px; }
.go-cell .go-btn { width: 100%; justify-content: center; font-size: 12px; height: 30px; padding: 0 10px; }

/* Standalone full-page station detail view (opened via ?station=ID in a new tab) */
.standalone-detail-page { max-width: 980px; margin: 0 auto; padding: 8px 0 40px; }
.standalone-detail-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-bottom: 6px;
}
.standalone-detail-header h1 { font-size: 20px; margin: 0; }
.standalone-detail-page .detail-map-wrap { margin-top: 18px; }

/* Leaflet dark + gold pin */
.leaflet-container { background: #0f1a2e; }
.leaflet-popup-content-wrapper { background: var(--surface); color: var(--text); border-radius: 8px; }
.leaflet-popup-content { font-size: 13px; }
.leaflet-popup-content a { color: var(--accent); }
.leaflet-popup-tip { background: var(--surface); }
.leaflet-control-attribution { background: rgba(11,18,32,.7) !important; color: var(--text-dim) !important; font-size: 10px; }
.leaflet-control-attribution a { color: var(--accent) !important; }
.gold-pin {
  width: 22px; height: 22px; border-radius: 50% 50% 50% 0;
  background: var(--gold); transform: rotate(-45deg);
  border: 2px solid #fff; box-shadow: 0 0 12px rgba(251,191,36,.8);
  position: relative;
}
.gold-pin::after {
  content: ''; position: absolute; top: 6px; left: 6px; width: 6px; height: 6px;
  background: #06121f; border-radius: 50%;
}
.directions-link {
  display: inline-block; margin-top: 6px; padding: 4px 10px; font-size: 11px;
  background: var(--accent); color: #06121f; border-radius: 4px; text-decoration: none; font-weight: 500;
}

/* ---------- Window Search ---------- */
.window-search { padding: 0 24px; margin-top: 16px; }
.window-controls {
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px 18px;
}
.window-input-row {
  display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end;
}
.window-input-label {
  display: flex; flex-direction: column; gap: 4px;
  font-size: 11px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em;
  font-weight: 500;
}
.window-input-label span { white-space: nowrap; }
.window-min, .window-threshold {
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 10px; font-family: 'JetBrains Mono', monospace; font-size: 12px;
  min-width: 110px;
}
.window-min:focus, .window-threshold:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.15);
}
.window-threshold { width: 110px; }

.window-chips { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.window-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  font-size: 13px; font-weight: 500;
  transition: all .15s ease;
}
.window-chip:hover { border-color: var(--accent); }
.window-chip[aria-pressed="true"] {
  background: var(--gold); color: #1a1300; border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(251,191,36,.18);
}
.window-chip[aria-pressed="true"] .chip-count {
  background: rgba(0,0,0,.18); color: #1a1300;
}
.chip-icon { font-size: 14px; line-height: 1; }
.chip-count {
  background: var(--border); color: var(--text-dim);
  padding: 1px 7px; border-radius: 999px;
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  min-width: 18px; text-align: center;
}
.window-chip-clear {
  padding: 6px 12px; border-radius: 999px;
  background: transparent; color: var(--text-dim);
  border: 1px dashed var(--border);
  font-size: 11px;
}
.window-chip-clear:hover { color: var(--text); border-color: var(--text-dim); }

.window-detail { display: flex; flex-direction: column; gap: 12px; padding: 0 18px 18px; }
.window-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.window-card.empty { opacity: .55; }
.window-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px; gap: 10px;
}
.window-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.window-card-title .window-icon { font-size: 16px; }
.window-card-meta {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--text-dim);
}
.window-matches { display: flex; flex-direction: column; gap: 6px; }
.window-match-row {
  display: grid; grid-template-columns: 1fr auto auto; gap: 10px;
  align-items: center;
  padding: 6px 8px; border-radius: 6px;
  background: rgba(255,255,255,.02);
  font-size: 12px;
}
.window-match-row:hover { background: rgba(56,189,248,.06); cursor: pointer; }
.window-match-name { font-weight: 500; color: var(--text); }
.window-match-meta { color: var(--text-dim); font-size: 11px; }
.window-match-time {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  color: var(--gold);
}
.match-extreme { color: var(--gold); }
.match-span { color: var(--accent); }
.tag.gh-bonus {
  background: rgba(251,191,36,.18); color: var(--gold);
  border: 1px solid rgba(251,191,36,.4);
  font-size: 10px; padding: 2px 6px; margin-left: 4px;
  border-radius: 4px; font-weight: 600;
}
.tag.win-sunrise {
  background: rgba(251,113,133,.15); color: #fda4af;
  border: 1px solid rgba(251,113,133,.35);
  font-size: 10px; padding: 2px 6px; margin-left: 4px;
  border-radius: 4px;
}
.tag.win-midday {
  background: rgba(250,204,21,.15); color: #fde68a;
  border: 1px solid rgba(250,204,21,.35);
  font-size: 10px; padding: 2px 6px; margin-left: 4px;
  border-radius: 4px;
}
.tag.win-sunset {
  background: rgba(244,114,182,.15); color: #f9a8d4;
  border: 1px solid rgba(244,114,182,.35);
  font-size: 10px; padding: 2px 6px; margin-left: 4px;
  border-radius: 4px;
}
.window-empty {
  font-size: 11px; color: var(--text-dimmer); font-style: italic;
}

@media (max-width: 720px) {
  .window-input-row { gap: 10px; }
  .window-min, .window-threshold { min-width: 90px; font-size: 11px; }
  .window-match-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ---------- Best Dates Button & Modal ---------- */

.best-dates-btn {
  height: 44px; padding: 0 16px; font-size: 13px; font-weight: 600;
  border-color: rgba(251,191,36,.35); color: var(--gold-soft);
  white-space: nowrap;
}
.best-dates-btn:hover { border-color: var(--gold); background: rgba(251,191,36,.08); color: var(--gold); }
.best-dates-icon { font-size: 15px; line-height: 1; }

.best-dates-card {
  max-width: 580px; width: 100%;
}
.best-dates-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.best-dates-header h2 { margin: 0; font-size: 18px; }
.best-dates-sub { margin: 0 0 18px; font-size: 13px; color: var(--text-dim); line-height: 1.5; }

.best-dates-loading {
  display: flex; align-items: center; gap: 12px;
  padding: 28px 0; justify-content: center;
  font-size: 13px; color: var(--text-dim);
}
.bd-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--gold);
  animation: bd-spin .8s linear infinite;
}
@keyframes bd-spin { to { transform: rotate(360deg); } }

.best-dates-results { display: flex; flex-direction: column; gap: 18px; }
.bd-section {}
.bd-section-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--text-dim); margin-bottom: 4px;
}
.bd-hint { font-size: 11px; color: var(--text-dimmer); margin-bottom: 8px; line-height: 1.4; }

.bd-result-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
}
.bd-result-card.bd-found { border-color: rgba(251,191,36,.35); background: rgba(251,191,36,.05); }
.bd-result-card.bd-none { color: var(--text-dimmer); font-size: 13px; font-style: italic; text-align: center; padding: 18px; }

.bd-date {
  font-size: 18px; font-weight: 700; color: var(--gold); margin-bottom: 4px; letter-spacing: -0.01em;
}
.bd-sun-row {
  font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace;
  margin-bottom: 10px;
}
.bd-stations { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.bd-station-row {
  background: rgba(255,255,255,.03); border-radius: 6px;
  padding: 8px 10px; font-size: 12px;
}
.bd-station-name { font-weight: 600; color: var(--text); margin-bottom: 3px; }
.bd-station-meta { color: var(--text-dim); font-size: 11px; margin-bottom: 4px; font-family: 'JetBrains Mono', monospace; }
.bd-events { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.bd-event-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px; font-size: 10px; font-family: 'JetBrains Mono', monospace;
  font-weight: 600; white-space: nowrap;
}
.bd-event-tag.sunrise { background: rgba(251,191,36,.18); color: var(--gold); border: 1px solid rgba(251,191,36,.3); }
.bd-event-tag.sunset { background: rgba(249,115,22,.18); color: #fb923c; border: 1px solid rgba(249,115,22,.3); }

.bd-station-row-clickable {
  cursor: pointer; border: 1px solid transparent; transition: background .15s, border-color .15s, transform .1s;
}
.bd-station-row-clickable:hover, .bd-station-row-clickable:focus-visible {
  background: rgba(255,255,255,.07); border-color: rgba(125,211,252,.35); outline: none;
}
.bd-station-row-clickable:active { transform: scale(.99); }
.bd-station-tap-hint {
  font-size: 10px; color: var(--accent); margin-top: 6px; font-weight: 600;
  letter-spacing: .02em;
}

/* Calendar reminder section (Best Dates + station detail popups) */
.reminder-card { margin-top: 4px; }
.reminder-card .ghost-btn { margin-bottom: 12px; }
.reminder-email-row {
  display: flex; gap: 8px; flex-wrap: wrap;
}
.reminder-email-input {
  flex: 1 1 180px; min-width: 0; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 0 12px; height: 38px; font-size: 13px;
}
.reminder-email-input:focus { outline: none; border-color: var(--accent); }
.reminder-card button.primary { height: 38px; padding: 0 16px; font-size: 13px; }
.reminder-status { font-size: 12px; margin-top: 8px; min-height: 16px; }
.reminder-status.success { color: var(--good, #4ade80); }
.reminder-status.error { color: var(--bad); }

.best-dates-error {
  color: var(--bad); font-size: 13px; padding: 16px; text-align: center;
  background: rgba(248,113,113,.06); border-radius: var(--radius-sm); border: 1px solid rgba(248,113,113,.2);
}

@media (max-width: 600px) {
  .best-dates-btn { width: 100%; justify-content: center; }
  .best-dates-card { max-width: 100%; }
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .topbar-right { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .status { white-space: normal; }
  .input-group { flex-wrap: wrap; }
  .city-field { min-width: 100%; }
  #useDefaultBtn { flex: 1; justify-content: center; }
}

/* ---------- Square action buttons: Best Tide + This Spot ----------
   Specificity note: these MUST beat button.primary (0,1,1) and
   button.ghost-btn (0,1,1) for height/padding/margin, otherwise the
   base button rules win the cascade and the buttons stay at their
   pill height (44px / 38px) instead of becoming 88px squares - that
   mismatch is what caused the two buttons to render at different
   heights and visually collide with the Date field. Qualifying with
   button.wave-btn-square / button.spot-btn-square raises specificity
   to (0,2,1), safely above button.primary and button.ghost-btn. */
button.wave-btn-square, button.spot-btn-square {
  width: 100% !important; height: 88px !important; padding: 6px 4px !important; margin-bottom: 0 !important;
  flex-direction: column; gap: 6px !important;
}
.wave-btn-content-stacked { flex-direction: column; gap: 6px; }
.wave-btn-label-stacked { line-height: 1.25; text-align: center; font-size: 12px; font-weight: 700; letter-spacing: 0.01em; white-space: normal; }
button.spot-btn-square {
  flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; text-align: center; white-space: normal;
}
.spot-btn-icon { font-size: 17px; line-height: 1; }
.spot-btn-label { line-height: 1.25; font-size: 12px; font-weight: 700; letter-spacing: 0.01em; white-space: normal; }
@media (max-width: 1080px) {
  button.wave-btn-square, button.spot-btn-square { height: 64px !important; width: 64px !important; }
}

/* ---------- Predict Sunrise/Sunset ---------- */
.predict-sun-controls { padding: 0 22px 14px; display: flex; flex-direction: column; gap: 10px; }
.predict-sun-toggle-row { display: flex; gap: 6px; }
.predict-sun-toggle-btn {
  flex: 1; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-dim); font-size: 12px; font-weight: 700;
  letter-spacing: 0.01em; cursor: pointer; transition: background .15s, color .15s, border-color .15s;
}
.predict-sun-toggle-btn:hover { border-color: var(--accent); }
.predict-sun-toggle-btn.active { background: var(--accent); color: #05202e; border-color: var(--accent); }
.predict-sun-llm-toggle {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim);
  opacity: .6; cursor: not-allowed;
}
.predict-sun-llm-toggle input[type="checkbox"] { cursor: not-allowed; width: 16px !important; height: 16px !important; flex: 0 0 auto; margin: 0; accent-color: var(--accent); }
.predict-sun-consensus {
  text-align: center; padding: 16px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 14px;
}
.predict-sun-consensus .ps-band-emoji { font-size: 34px; display: block; margin-bottom: 6px; }
.predict-sun-consensus .ps-band-label { font-size: 16px; font-weight: 800; }
.predict-sun-consensus .ps-band-label.band-excellent { color: var(--good); }
.predict-sun-consensus .ps-band-label.band-good { color: var(--good); }
.predict-sun-consensus .ps-band-label.band-fair { color: var(--warn); }
.predict-sun-consensus .ps-band-label.band-poor { color: var(--bad); }
.predict-sun-consensus .ps-score-pct { font-size: 12px; color: var(--text-dim); margin-top: 4px; }
.predict-sun-consensus .ps-azimuth { font-size: 12px; color: var(--text-dim); margin-top: 8px; }
.predict-sun-model-grid { display: flex; flex-direction: column; gap: 10px; }
.predict-sun-model-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2);
}
.predict-sun-model-card .ps-model-head {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px;
}
.predict-sun-model-card .ps-model-name { font-size: 12px; font-weight: 700; letter-spacing: 0.02em; }
.predict-sun-model-card .ps-model-band { font-size: 12px; font-weight: 700; }
.predict-sun-model-card .ps-model-band.band-excellent, .predict-sun-model-card .ps-model-band.band-good { color: var(--good); }
.predict-sun-model-card .ps-model-band.band-fair { color: var(--warn); }
.predict-sun-model-card .ps-model-band.band-poor { color: var(--bad); }
.predict-sun-model-card .ps-model-unavailable { font-size: 12px; color: var(--text-dim); font-style: italic; }
.predict-sun-model-card .ps-model-inputs {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px; font-size: 11px; color: var(--text-dim);
}
.predict-sun-status { font-size: 13px; color: var(--text-dim); text-align: center; padding: 20px 10px; }
.predict-sun-status.err { color: var(--bad); }

/* ---------- Upcoming 3-Day Forecast (v1.65) ---------- */
.tdf-current-loc { font-weight: 400; color: var(--text-dim); font-size: 11px; }
#threeDayLocationRow { margin-bottom: 0; }
#threeDayLocationRow .input-group { gap: 6px; }
#threeDayGpsBtn { white-space: nowrap; font-size: 12px; padding: 0 12px; }
.tdf-day-grid { gap: 12px; }
.tdf-day-card { position: relative; }
.tdf-day-meta {
  grid-template-columns: 1fr !important; gap: 4px !important; margin-top: 4px;
}
.tdf-confidence {
  display: inline-block; font-weight: 700; font-size: 11px; border-radius: 4px;
  padding: 2px 8px; margin: 2px 0; width: fit-content;
}
.tdf-conf-high { color: var(--good); background: rgba(52, 211, 153, .12); }
.tdf-conf-medium { color: var(--warn); background: rgba(251, 191, 36, .12); }
.tdf-conf-low { color: var(--bad); background: rgba(248, 113, 113, .12); }
.tdf-conf-na { color: var(--text-dim); background: var(--surface-2); font-style: italic; }
.tdf-regime-flag {
  font-size: 11px; color: var(--warn); background: rgba(251, 191, 36, .08);
  border: 1px solid rgba(251, 191, 36, .25); border-radius: var(--radius-sm);
  padding: 6px 10px; margin-top: 8px; line-height: 1.4;
}
.tdf-note { font-size: 12px; color: var(--text-dim); margin-top: 8px; font-style: italic; line-height: 1.4; }

/* ---------- Saved Locations & Autocomplete ---------- */
.city-field { position: relative; flex: 1; min-width: 180px; }
.city-field input#city { width: 100%; }

.suggest-list {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60;
  list-style: none; margin: 0; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  max-height: 280px; overflow-y: auto;
}
.suggest-list[hidden] { display: none; }
.suggest-item {
  padding: 10px 12px; border-radius: 6px; cursor: pointer;
  font-size: 13px; color: var(--text); display: flex; flex-direction: column; gap: 2px;
}
.suggest-item .s-main { font-weight: 500; }
.suggest-item .s-sub { font-size: 11px; color: var(--text-dim); }
.suggest-item:hover, .suggest-item.active { background: rgba(56,189,248,.12); }
.suggest-empty, .suggest-loading, .suggest-error {
  padding: 10px 12px; font-size: 12px; color: var(--text-dim); text-align: center;
}
.suggest-error { color: var(--bad); }

.saved-chips { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.chip.saved-chip { display: inline-flex; align-items: center; gap: 6px; }
.chip.saved-chip .star { color: var(--gold); font-size: 11px; }
.chip.saved-chip.active-chip { border-color: var(--accent); background: rgba(56,189,248,.10); color: var(--accent); }
.chip.chip-manage { border-style: dashed; color: var(--text-dim); }
.chip.chip-manage:hover { color: var(--text); border-color: var(--text-dim); }

.locations-card { max-width: 560px; width: 100%; }
.locations-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.locations-header h2 { margin: 0; }
.add-location-row { position: relative; margin-bottom: 16px; }

.locations-list {
  list-style: none; margin: 0 0 4px; padding: 0;
  max-height: 320px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.location-row {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.location-row:last-child { border-bottom: none; }
.location-row:hover { background: var(--surface-2); }
.location-row .loc-star {
  background: none; border: none; color: var(--text-dimmer); font-size: 16px;
  cursor: pointer; padding: 2px; line-height: 1; flex-shrink: 0;
}
.location-row .loc-star.is-default { color: var(--gold); }
.location-row .loc-star:hover { color: var(--gold); }
.location-row .loc-info { flex: 1; min-width: 0; cursor: pointer; }
.location-row .loc-label { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.location-row .loc-coords { font-size: 11px; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }
.location-row .loc-badge {
  font-size: 9px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-dimmer); background: var(--bg-2); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.location-row .loc-remove {
  background: none; border: none; color: var(--text-dimmer); font-size: 15px;
  cursor: pointer; padding: 4px 6px; line-height: 1; flex-shrink: 0; border-radius: 4px;
}
.location-row .loc-remove:hover { color: var(--bad); background: rgba(248,113,113,.1); }
.locations-empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px; }

@media (max-width: 600px) {
  .locations-card { max-width: 100%; }
}

/* ---------- This Spot: full-screen map picker modal ---------- */
.this-spot-card {
  max-width: 1100px; width: 100%; height: 100%; max-height: calc(100vh - 40px);
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.this-spot-sub { margin: 12px 22px 0; font-size: 13px; color: var(--text-dim); }
.this-spot-map-wrap {
  position: relative; flex: 1; min-height: 320px; margin: 14px 22px;
  border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border);
  isolation: isolate; cursor: crosshair;
}
#thisSpotMap { position: absolute; inset: 0; background: var(--bg-2); }
.this-spot-pin-hint {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(15,23,42,.88); color: var(--text); font-size: 12px;
  padding: 6px 14px; border-radius: 999px; border: 1px solid var(--border);
  z-index: 1200; pointer-events: none; transition: opacity .2s;
}
.this-spot-pin-hint.is-hidden { opacity: 0; }
.this-spot-stations-info {
  margin: 0 22px 8px; font-size: 12px; color: var(--text-dim);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; line-height: 1.6;
}
.this-spot-stations-info .ts-warn { color: var(--bad); }
.this-spot-stations-info .ts-ok { color: var(--good); }
#thisSpotStatus { margin: 0 22px 16px; text-align: left; }
.this-spot-card .modal-header { padding: 16px 22px; }
.this-spot-card .modal-header h2 { font-size: 16px; }
#thisSpotFindBtn:disabled { opacity: .5; cursor: not-allowed; }

/* Drop-pin marker used on the This Spot picker map */
.this-spot-pin {
  width: 26px; height: 26px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: #fbbf24; border: 2px solid #fff; box-shadow: 0 0 10px rgba(251,191,36,.7);
}

@media (max-width: 640px) {
  .this-spot-card { max-height: 100vh; border-radius: 0; }
  .this-spot-map-wrap { margin: 10px 14px; min-height: 260px; }
  .this-spot-sub { margin: 10px 14px 0; }
  .this-spot-stations-info { margin: 0 14px 8px; }
  #thisSpotStatus { margin: 0 14px 12px; }
}

/* This Spot results popup */
.this-spot-result-card { max-width: 640px; width: 100%; }
.this-spot-joke-error {
  text-align: center; padding: 20px 10px;
}
.this-spot-joke-error .ts-emoji { font-size: 40px; display: block; margin-bottom: 12px; }
.this-spot-joke-error p { font-size: 15px; line-height: 1.6; color: var(--text); }
.ts-result-badge {
  display: inline-block; font-size: 11px; padding: 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); margin-bottom: 10px;
}
.ts-result-badge.low-conf { color: var(--bad); border-color: var(--bad); }
.ts-result-badge.good-conf { color: var(--good); border-color: var(--good); }

/* ---------- Picked Spots (custom map-picked pins, separate from Saved:) ---------- */
.picked-spots-section {
  margin-top: 16px; padding-top: 16px; border-top: 1px dashed var(--border);
}
.picked-spots-header {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); margin-bottom: 10px;
}
.picked-spots-header .ps-title-icon { font-size: 14px; }
.picked-spots-add-gps-btn {
  margin-left: auto; background: transparent; border: 1px solid var(--forest-soft); color: var(--forest-soft);
  border-radius: var(--radius-sm); padding: 5px 12px; font-size: 12px; font-weight: 600; transition: background .15s, color .15s;
}
.picked-spots-add-gps-btn:hover { background: var(--forest-soft); color: #eafff2; }
.add-by-gps-form {
  display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; padding: 14px;
  border: 1px solid var(--forest-soft); border-radius: var(--radius); background: var(--bg-2);
}
.add-by-gps-form[hidden] { display: none; }
.add-by-gps-coords-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-by-gps-coords-row input { flex: 1 1 160px; min-width: 0; }
.add-by-gps-form input, .add-by-gps-form textarea {
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; outline: none; font-family: inherit;
  resize: vertical;
}
.add-by-gps-form input:focus, .add-by-gps-form textarea:focus { border-color: var(--forest-soft); }
.add-by-gps-paste { font-style: italic; }
.add-by-gps-paste::placeholder { font-style: italic; }
.add-by-gps-counter { font-size: 11px; color: var(--text-dimmer); text-align: right; margin-top: -4px; }
.add-by-gps-actions { display: flex; gap: 8px; align-items: center; }
.add-by-gps-status { font-size: 12px; min-height: 16px; }
.add-by-gps-status.success { color: var(--good); }
.add-by-gps-status.error { color: var(--bad); }
@media (max-width: 640px) {
  .add-by-gps-coords-row { flex-direction: column; }
}
.picked-spots-empty {
  font-size: 12px; color: var(--text-dimmer); font-style: italic;
}
.picked-spots-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.picked-spot-card {
  background: linear-gradient(180deg, rgba(46,125,79,.14), rgba(30,95,62,.06)), var(--surface);
  border: 1px solid var(--forest-soft);
  border-radius: var(--radius); padding: 14px; box-shadow: 0 0 0 1px var(--forest-glow) inset;
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.picked-spot-title-row {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.picked-spot-title {
  font-weight: 700; font-size: 14px; color: var(--forest-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.picked-spot-delete-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: var(--radius-sm); width: 26px; height: 26px; flex-shrink: 0;
  font-size: 13px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: border-color .15s, color .15s;
}
.picked-spot-delete-btn:hover { border-color: var(--bad); color: var(--bad); }
.picked-spot-desc {
  font-size: 12px; color: var(--text-dim); line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
.picked-spot-gps-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.picked-spot-gps-box {
  font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 5px 9px; flex: 1 1 auto; min-width: 0; overflow-x: auto; white-space: nowrap;
}
.picked-spot-copy-btn, .picked-spot-maps-btn {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 5px 10px; font-size: 12px; white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.picked-spot-copy-btn:hover, .picked-spot-maps-btn:hover { border-color: var(--forest-soft); background: var(--surface-2); }
.picked-spot-copy-btn.copied { color: var(--good); border-color: var(--good); }
.picked-spot-actions-row {
  display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px;
}
.picked-spot-invite-btn {
  background: var(--forest-soft); border: none; color: #eafff2;
  border-radius: var(--radius-sm); padding: 6px 12px; font-size: 12px; font-weight: 600;
  transition: filter .15s;
}
.picked-spot-invite-btn:hover { filter: brightness(1.12); }
.picked-spot-invite-panel {
  display: flex; flex-direction: column; gap: 6px; margin-top: 4px;
  border-top: 1px solid var(--border); padding-top: 8px;
}
.picked-spot-invite-panel input[type="email"] {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: 12px; outline: none;
}
.picked-spot-invite-panel input[type="email"]:focus { border-color: var(--forest-soft); }
.picked-spot-invite-status { font-size: 11px; min-height: 14px; }
.picked-spot-invite-status.success { color: var(--good); }
.picked-spot-invite-status.error { color: var(--bad); }

/* Save-as-Picked-Spot flow inside the This Spot result popup */
.this-spot-gps-card {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-top: 14px;
}
.this-spot-gps-card h3 { margin: 0 0 8px; font-size: 13px; color: var(--text-dim); }
.this-spot-gps-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 10px;
}
.save-picked-spot-btn {
  background: var(--forest-soft); border: none; color: #eafff2;
  border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13px; font-weight: 600;
  transition: filter .15s;
}
.save-picked-spot-btn:hover { filter: brightness(1.12); }
.save-picked-spot-form {
  display: flex; flex-direction: column; gap: 8px; margin-top: 10px;
}
.save-picked-spot-form input, .save-picked-spot-form textarea {
  background: var(--bg-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 7px 10px; font-size: 13px; outline: none; font-family: inherit;
  resize: vertical;
}
.save-picked-spot-form input:focus, .save-picked-spot-form textarea:focus { border-color: var(--forest-soft); }
.save-picked-spot-form .char-count { font-size: 11px; color: var(--text-dimmer); text-align: right; margin-top: -4px; }
.save-picked-spot-form-actions { display: flex; gap: 8px; align-items: center; }
.save-picked-spot-status { font-size: 12px; min-height: 16px; }
.save-picked-spot-status.success { color: var(--good); }
.save-picked-spot-status.error { color: var(--bad); }

@media (max-width: 640px) {
  .picked-spots-grid { grid-template-columns: 1fr; }
}
