@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  --sv-bg-deep: #0a0e17;
  --sv-bg-surface: #111827;
  --sv-bg-glass: rgba(17, 24, 39, 0.7);
  --sv-edge: rgba(255,255,255,0.08);
  --sv-mint: #00d4aa;
  --sv-mint-glow: rgba(0,212,170,0.25);
  --sv-amber: #ff9f43;
  --sv-sky: #54a0ff;
  --sv-slate: #636e72;
  --sv-ink: #f1f5f9;
  --sv-dim: #94a3b8;
  --sv-ghost: #64748b;
  --sv-alert: #ff6b6b;
  --sv-curve: 16px;
  --sv-curve-sm: 10px;
  --sv-ease: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--sv-bg-deep);
  color: var(--sv-ink);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ===== TOPBAR ===== */
.sv-topbar {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 2000;
  padding: 12px 20px;
  background: rgba(10,14,23,0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--sv-edge);
  display: flex; align-items: center; justify-content: space-between;
  transition: var(--sv-ease);
}
.sv-brand {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 700;
  background: linear-gradient(135deg, var(--sv-mint), #00f5d4);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sv-brand em {
  font-style: normal;
  -webkit-text-fill-color: var(--sv-ink);
}
.sv-subtitle {
  font-size: 0.75rem; color: var(--sv-ghost);
  display: none;
}
@media (min-width: 600px) { .sv-subtitle { display: block; } }

/* ===== VIEWPORT MAP ===== */
.sv-viewport {
  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 500px;
  padding-top: 52px;
}
#sv-map {
  width: 100%; height: 100%;
  background: var(--sv-bg-surface);
}
.leaflet-container { height: 100%; width: 100%; }

/* ===== CONTROL DOCK ===== */
.sv-dock {
  position: fixed;
  z-index: 1500;
  background: rgba(10,14,23,0.92);
  backdrop-filter: blur(24px);
  border: 1px solid var(--sv-edge);
  overflow-y: auto;
  transition: var(--sv-ease);
}
@media (min-width: 769px) {
  .sv-dock {
    top: 68px; left: 16px;
    width: 370px;
    max-height: calc(100vh - 84px);
    border-radius: var(--sv-curve);
    padding: 24px;
  }
}
@media (max-width: 768px) {
  .sv-dock {
    bottom: 0; left: 0; right: 0;
    max-height: 75vh;
    border-radius: 20px 20px 0 0;
    padding: 16px 16px 24px;
    box-shadow: 0 -8px 40px rgba(0,0,0,0.5);
  }
  .sv-dock.sv-folded {
    max-height: 60px; overflow: hidden;
  }
}

.sv-drag-bar {
  display: none;
  width: 40px; height: 4px;
  background: var(--sv-ghost);
  border-radius: 4px;
  margin: 0 auto 12px;
  cursor: pointer;
}
@media (max-width: 768px) { .sv-drag-bar { display: block; } }

.sv-dock-heading {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 600;
  margin-bottom: 16px;
  color: var(--sv-ink);
}

/* ===== FORM FIELDS ===== */
.sv-field { margin-bottom: 12px; position: relative; }
.sv-field label {
  display: block;
  font-size: 0.7rem; font-weight: 500;
  color: var(--sv-ghost);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}
.sv-textbox {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve-sm);
  color: var(--sv-ink);
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: var(--sv-ease);
}
.sv-textbox::placeholder { color: var(--sv-ghost); }
.sv-textbox:focus {
  border-color: var(--sv-mint);
  box-shadow: 0 0 0 3px var(--sv-mint-glow);
}

.sv-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Duration switch */
.sv-switch-row {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px;
}
.sv-switch-label { font-size: 0.8rem; color: var(--sv-dim); }
.sv-switch {
  position: relative;
  width: 42px; height: 22px;
  background: #333;
  border-radius: 20px;
  cursor: pointer;
  transition: var(--sv-ease);
  flex-shrink: 0;
}
.sv-switch.on { background: var(--sv-mint); }
.sv-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 18px; height: 18px;
  background: white;
  border-radius: 50%;
  transition: var(--sv-ease);
}
.sv-switch.on::after { left: 22px; }
#sv-est-toggle { display: none; }

/* Action chips */
.sv-chip-row {
  display: flex; gap: 8px;
  margin-bottom: 14px;
}
.sv-chip {
  flex: 1;
  padding: 8px 6px;
  font-size: 0.72rem; font-weight: 500;
  color: var(--sv-mint);
  background: rgba(0,212,170,0.08);
  border: 1px solid rgba(0,212,170,0.2);
  border-radius: var(--sv-curve-sm);
  cursor: pointer;
  transition: var(--sv-ease);
  font-family: 'Inter', sans-serif;
  text-align: center;
}
.sv-chip:hover {
  background: rgba(0,212,170,0.18);
  transform: translateY(-1px);
}

/* Dropdown */
.sv-dropdown {
  width: 100%;
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve-sm);
  color: var(--sv-ink);
  font-size: 0.9rem;
  font-family: 'Inter', sans-serif;
  outline: none;
  appearance: none;
  cursor: pointer;
  transition: var(--sv-ease);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}
.sv-dropdown:focus {
  border-color: var(--sv-mint);
  box-shadow: 0 0 0 3px var(--sv-mint-glow);
}
.sv-dropdown option { background: var(--sv-bg-surface); color: var(--sv-ink); }

/* Primary action */
.sv-cta {
  width: 100%;
  padding: 12px;
  font-size: 1rem; font-weight: 600;
  color: var(--sv-bg-deep);
  background: linear-gradient(135deg, var(--sv-mint), #00f5d4);
  border: none;
  border-radius: var(--sv-curve-sm);
  cursor: pointer;
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: 0.5px;
  transition: var(--sv-ease);
  margin-top: 6px;
  position: relative;
  overflow: hidden;
}
.sv-cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--sv-mint-glow);
}
.sv-cta:active { transform: translateY(0); }

/* ===== OUTCOME DISPLAY ===== */
.sv-outcome {
  background: rgba(10,14,23,0.92);
  backdrop-filter: blur(24px);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve);
  padding: 24px;
  animation: svReveal 0.4s ease;
}
.sv-seat-pick {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem; font-weight: 700;
  margin-bottom: 6px;
}
.sv-seat-pick em { font-style: normal; color: var(--sv-mint); }
.sv-trip-info {
  font-size: 0.85rem; color: var(--sv-dim);
  margin-bottom: 16px;
}
.sv-gauge-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.sv-gauge label {
  display: flex; justify-content: space-between;
  font-size: 0.8rem; margin-bottom: 4px; color: var(--sv-dim);
}
.sv-gauge label em { font-style: normal; font-weight: 600; }
.sv-gauge-track {
  height: 8px; border-radius: 8px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.sv-gauge-bar {
  height: 100%; border-radius: 8px;
  transition: width 1s ease;
}
.sv-gauge-bar.port { background: var(--sv-amber); }
.sv-gauge-bar.star { background: var(--sv-sky); }
.sv-gauge-bar.shade { background: var(--sv-slate); }

.sv-outcome-btns { display: flex; gap: 10px; }
.sv-action {
  flex: 1; padding: 10px;
  font-size: 0.85rem; font-weight: 500;
  border-radius: var(--sv-curve-sm);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: var(--sv-ease);
  border: 1px solid var(--sv-edge);
  background: rgba(255,255,255,0.04);
  color: var(--sv-ink);
  text-align: center;
}
.sv-action:hover { background: rgba(255,255,255,0.1); }
.sv-action.highlight {
  background: linear-gradient(135deg, var(--sv-mint), #00f5d4);
  color: var(--sv-bg-deep);
  border: none; font-weight: 600;
}

/* ===== LOADER ===== */
.sv-loader-box {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.sv-loader {
  width: 48px; height: 48px;
  border: 3px solid var(--sv-edge);
  border-top-color: var(--sv-mint);
  border-radius: 50%;
  animation: svRotate 0.8s linear infinite;
}
@keyframes svRotate { to { transform: rotate(360deg); } }
@keyframes svReveal { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ===== CONTENT BLOCKS ===== */
.sv-content {
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 20px 40px;
}
.sv-content-intro {
  text-align: center;
  margin-bottom: 48px;
}
.sv-content-intro h2 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  margin-bottom: 10px;
  background: linear-gradient(135deg, var(--sv-ink), var(--sv-mint));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sv-content-intro p {
  color: var(--sv-dim);
  font-size: clamp(0.9rem, 2vw, 1.05rem);
  max-width: 600px; margin: 0 auto;
}

.sv-tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
  margin-bottom: 48px;
}
.sv-tile {
  background: var(--sv-bg-glass);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve);
  padding: 28px 24px;
  transition: var(--sv-ease);
  backdrop-filter: blur(10px);
}
.sv-tile:hover {
  border-color: rgba(0,212,170,0.3);
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
}
.sv-tile-emoji { font-size: 2rem; margin-bottom: 14px; display: block; }
.sv-tile h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.1rem; font-weight: 600;
  margin-bottom: 8px;
  color: var(--sv-ink);
}
.sv-tile p { font-size: 0.88rem; color: var(--sv-dim); line-height: 1.65; }

/* Guide steps */
.sv-guide { margin-bottom: 48px; }
.sv-guide h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.3rem; font-weight: 600;
  margin-bottom: 24px;
  text-align: center;
}
.sv-guide-item {
  display: flex; gap: 16px;
  margin-bottom: 20px;
  padding: 18px;
  background: var(--sv-bg-glass);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve-sm);
  transition: var(--sv-ease);
}
.sv-guide-item:hover { border-color: rgba(0,212,170,0.2); }
.sv-guide-badge {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--sv-mint), #00f5d4);
  color: var(--sv-bg-deep);
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700; font-size: 1rem;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sv-guide-text h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 4px; }
.sv-guide-text p { font-size: 0.85rem; color: var(--sv-dim); }

/* Advice box */
.sv-advice {
  background: var(--sv-bg-glass);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve);
  padding: 28px 24px;
  margin-bottom: 48px;
}
.sv-advice h3 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.15rem; font-weight: 600;
  margin-bottom: 16px;
}
.sv-advice-row {
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 12px;
  font-size: 0.88rem;
  color: var(--sv-dim);
}
.sv-advice-ico { font-size: 1.1rem; flex-shrink: 0; }

/* ===== BOTTOM BAR ===== */
.sv-bottom {
  text-align: center;
  padding: 24px 20px;
  border-top: 1px solid var(--sv-edge);
  color: var(--sv-ghost);
  font-size: 0.8rem;
}
.sv-bottom a { color: var(--sv-mint); text-decoration: none; }
.sv-bottom a:hover { text-decoration: underline; }

/* ===== AUTOCOMPLETE OVERRIDES ===== */
.auto-search-wrapper { display: block; position: relative; width: 100%; }
.auto-search-wrapper input {
  width: 100%; padding: 10px 40px 10px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--sv-edge);
  border-radius: var(--sv-curve-sm);
  color: var(--sv-ink);
  font-size: 0.95rem; font-family: 'Inter', sans-serif;
  outline: none; box-shadow: none;
  transition: var(--sv-ease);
}
.auto-search-wrapper input::placeholder { color: var(--sv-ghost); }
.auto-search-wrapper input:focus {
  border-color: var(--sv-mint);
  box-shadow: 0 0 0 3px var(--sv-mint-glow);
}
.auto-results-wrapper {
  display: none;
  background: var(--sv-bg-surface);
  border: 1px solid var(--sv-edge);
  border-top: none;
  border-radius: 0 0 var(--sv-curve-sm) var(--sv-curve-sm);
  overflow: hidden;
  box-sizing: border-box;
}
.auto-results-wrapper.auto-is-active { display: block; position: absolute; width: 100%; z-index: 99999; margin-top: -1px; }
.auto-results-wrapper ul { list-style: none; margin: 0; padding: 0; overflow: auto; }
.auto-results-wrapper ul li {
  padding: 10px 14px; cursor: pointer;
  color: var(--sv-dim);
  font-size: 0.85rem; border-bottom: 1px solid var(--sv-edge);
  transition: var(--sv-ease);
}
.auto-results-wrapper ul li:hover, .auto-selected { background: rgba(0,212,170,0.1) !important; color: var(--sv-ink) !important; }
.auto-clear {
  align-items: center;
  background-color: transparent;
  border: none;
  cursor: pointer;
  display: none;
  justify-content: center;
  position: absolute;
  right: 4px;
  bottom: 4px;
  height: calc(100% - 26px);
  width: 36px;
  z-index: 1;
  padding: 0;
}
.auto-search-wrapper input:not([value=""]) ~ .auto-clear,
.auto-search-wrapper .auto-clear {
  display: flex;
}
.auto-clear:before {
  content: '';
  display: block;
  width: 16px; height: 16px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%2394a3b8' d='M18.984 6.422 13.406 12l5.578 5.578-1.406 1.406L12 13.406l-5.578 5.578-1.406-1.406L10.594 12 5.016 6.422l1.406-1.406L12 10.594l5.578-5.578z'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.auto-clear:hover:before { opacity: 1; }
.auto-clear span { display: none; }
.auto-is-loading:after {
  border-color: var(--sv-edge) var(--sv-mint) var(--sv-mint) var(--sv-edge);
}

/* Route line animation */
path.leaflet-interactive.routeline {
  stroke-dasharray: 1920;
  stroke-dashoffset: 1920;
  animation: svDash 20s linear 3s forwards;
}
@keyframes svDash { to { stroke-dashoffset: 0; } }

/* PWA install */
.sv-pwa-btn {
  position: fixed; bottom: 16px; right: 16px;
  padding: 10px 20px;
  background: var(--sv-mint);
  color: var(--sv-bg-deep);
  font-weight: 600;
  border: none;
  border-radius: var(--sv-curve-sm);
  cursor: pointer;
  z-index: 2000;
  font-family: 'Inter', sans-serif;
  display: none;
  box-shadow: 0 4px 20px var(--sv-mint-glow);
  transition: var(--sv-ease);
}
.sv-pwa-btn:hover { transform: translateY(-2px); }

/* Leaflet overrides */
.leaflet-control-attribution { font-size: 10px !important; }
.leaflet-control-attribution a { color: var(--sv-mint) !important; }
.leaflet-control-zoom {
  margin-top: 60px !important;
  border: 1px solid var(--sv-edge) !important;
  border-radius: var(--sv-curve-sm) !important;
  overflow: hidden;
}
.leaflet-control-zoom a {
  background: rgba(10, 14, 23, 0.85) !important;
  color: var(--sv-ink) !important;
  border-color: var(--sv-edge) !important;
  backdrop-filter: blur(10px);
}
.leaflet-control-zoom a:hover {
  background: rgba(0, 212, 170, 0.15) !important;
  color: var(--sv-mint) !important;
}

/* Error state */
.sv-alert-msg {
  color: var(--sv-alert);
  text-align: center;
  padding: 20px;
  font-size: 0.95rem;
}
