:root {
  --bg: #0f1115;
  --panel: #1a1d24;
  --panel-raised: #20242d;
  --text: #e8e9ec;
  --muted: #9aa0ab;
  --accent: #4fa3ff;
  --live: #4fd1a5;
  --border: #2a2e37;
  --skeleton: #262a33;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0 0 0.25rem;
}

.subtitle {
  color: var(--muted);
  margin: 0;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1rem 1.5rem 3rem;
}

.controls {
  max-width: 900px;
  margin: 0 auto 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
}

legend {
  padding: 0 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  white-space: nowrap;
}

input[type="number"] {
  width: 4rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
}

button#generate {
  align-self: flex-start;
  background: var(--accent);
  color: #06131f;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
}

button#generate:hover {
  filter: brightness(1.1);
}

#status {
  color: var(--muted);
  margin: 0;
  min-height: 1.2em;
}

#results-panel {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
}

#results-column {
  flex: 1 1 420px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#results-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

#confirm-bar {
  position: sticky;
  top: 1rem;
  z-index: 10;
  background: var(--panel-raised);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

#confirm-count {
  color: var(--muted);
  font-size: 0.9rem;
}

button#build-route,
button#back-to-browsing {
  background: var(--accent);
  color: #06131f;
  border: none;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  cursor: pointer;
}

button#back-to-browsing {
  background: transparent;
  color: var(--accent);
  padding: 0.5rem 0;
}

.confirm-toggle {
  flex: none;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.confirm-toggle.confirmed {
  background: var(--accent);
  color: #06131f;
}

#final-itinerary {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.final-itinerary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.start-time-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.start-time-label input[type="time"] {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.4rem;
}

#route-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.route-step {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
}

.route-step-controls {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.route-step-controls button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  width: 1.6rem;
  height: 1.6rem;
  cursor: pointer;
}

.route-step-controls button:disabled {
  opacity: 0.35;
  cursor: default;
}

.route-leg {
  color: var(--live);
  font-size: 0.8rem;
  margin: 0 0 0.35rem;
}

.route-arrival {
  color: var(--muted);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
}

.route-status {
  color: var(--muted);
  font-size: 0.8rem;
  font-style: italic;
  margin: 0 0 0.5rem;
}

#map {
  flex: 1 1 500px;
  min-width: 0;
  height: 70vh;
  min-height: 420px;
  position: sticky;
  top: 1rem;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--panel);
}

/* Leaflet renders its own control/attribution styling; only override what
   needs to match the site's dark/light theme rather than fight Leaflet's
   own CSS everywhere. */
.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--panel);
  color: var(--text);
}

.leaflet-popup-content a {
  color: var(--accent);
}

.marker-highlight {
  filter: drop-shadow(0 0 6px var(--accent));
  transform: scale(1.25);
  transform-origin: bottom center;
}

.route-marker-inner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #06131f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  border: 2px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

@media (max-width: 860px) {
  #results-panel {
    flex-direction: column;
  }

  #map {
    position: static;
    width: 100%;
    height: 50vh;
    order: -1;
  }
}

.category-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.category-section + .category-section {
  margin-top: 0.75rem;
}

.category-section > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 1.02rem;
  list-style: none;
}

.category-section > summary::-webkit-details-marker {
  display: none;
}

.category-section > summary::before {
  content: "▾ ";
  color: var(--accent);
}

.category-section:not([open]) > summary::before {
  content: "▸ ";
}

.category-cards {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.venue-card {
  background: var(--panel-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  gap: 0.9rem;
}

.venue-index {
  flex: none;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--accent);
  color: #06131f;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.venue-body h3 {
  margin: 0 0 0.35rem;
}

.venue-meta {
  margin: 0 0 0.35rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
}

.venue-address {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.review-links {
  margin: 0.6rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.review-links a {
  color: var(--accent);
  text-decoration: none;
}

.review-links a:hover {
  text-decoration: underline;
}

.live-section {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.live-heading {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 0.55rem;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--live);
  flex: none;
}

.live-dot.pulsing {
  animation: pulse 1.4s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .live-dot.pulsing {
    animation: none;
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(79, 209, 165, 0.45); }
  50% { opacity: 0.55; box-shadow: 0 0 0 4px rgba(79, 209, 165, 0); }
}

.provider-rows {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.provider-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.provider-name {
  width: 6.4rem;
  flex: none;
  color: var(--text);
}

.provider-stars { color: var(--live); flex: none; }
.provider-count { color: var(--muted); flex: none; }

.provider-row a {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
  text-decoration: none;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.55rem;
}

.provider-row a:hover { color: var(--live); border-color: var(--live); }

.skeleton-row {
  height: 1.1rem;
  border-radius: 5px;
  background: linear-gradient(90deg, var(--skeleton) 25%, var(--panel-raised) 50%, var(--skeleton) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-row { animation: none; }
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.live-caveat {
  margin: 0.5rem 0 0;
  font-size: 0.76rem;
  color: var(--muted);
}

.field-note {
  flex-basis: 100%;
  font-size: 0.78rem;
  color: var(--muted);
}

.provider-price {
  color: var(--muted);
  flex: none;
}

.venue-card.price-filtered {
  display: none;
}

footer {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

footer a {
  color: var(--accent);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f6f8;
    --panel: #ffffff;
    --panel-raised: #fbfbfc;
    --text: #1a1d24;
    --muted: #5b6270;
    --border: #dde1e7;
    --skeleton: #e9ebef;
  }
}
