* {
  box-sizing: border-box;
}

:root {
  --ink: #132033;
  --muted: #657084;
  --subtle: #7b8798;
  --line: #d8e0df;
  --line-strong: #b9c8c5;
  --surface: #ffffff;
  --surface-soft: #f3f7f5;
  --surface-tint: #edf6f5;
  --teal: #106a7a;
  --teal-dark: #0b5360;
  --blue: #2563d9;
  --green: #1f8a5b;
  --yellow: #d2961b;
  --red: #d64b3c;
  --shadow: 0 20px 60px rgba(19, 32, 51, 0.22);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: #dbe9e7;
}

body {
  min-height: 100dvh;
  overflow: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden],
.hidden {
  display: none !important;
}

.app-hidden {
  visibility: hidden;
  pointer-events: none;
}

#app.map-pick-only {
  display: block;
  grid-template-columns: none;
  grid-template-rows: none;
}

#app.map-pick-only #panel {
  display: none !important;
}

#app.map-pick-only .map-stage {
  position: absolute;
  inset: 0;
  grid-column: auto;
  grid-row: auto;
  min-height: 100dvh;
}

#app.map-pick-only .map-legend {
  bottom: 18px;
}

#addressField.locrow.locaddr {
  margin-top: 10px;
  padding-left: 0;
  gap: 8px;
}

#addressField .addrinput {
  min-height: 44px;
  padding: 10px 12px;
  font-size: 14px;
}

#addressField .locbtn {
  min-height: 44px;
  padding: 10px 14px;
}

#addressField .addrsug {
  left: 0;
  right: 0;
}

.welcome-flow {
  position: fixed;
  inset: 0;
  z-index: 20;
  min-height: 100dvh;
  background: #0b1f23;
  color: #fff;
}

.welcome-flow.flow-hidden {
  display: none;
}

.flow-screen {
  display: none;
  min-height: 100dvh;
}

.flow-screen.active {
  display: grid;
}

.intro-screen {
  position: relative;
  place-items: end start;
  overflow: hidden;
  padding: max(24px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

.intro-video,
.intro-scrim {
  position: absolute;
  inset: 0;
}

.intro-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  object-fit: cover;
  object-position: center center;
  filter: brightness(1.18) saturate(1.08);
}

.intro-scrim {
  background:
    linear-gradient(180deg, rgba(4, 18, 22, 0.04) 0%, rgba(4, 18, 22, 0.12) 36%, rgba(4, 18, 22, 0.74) 100%),
    linear-gradient(90deg, rgba(4, 18, 22, 0.72) 0%, rgba(4, 18, 22, 0.12) 68%);
}

.intro-content {
  position: relative;
  width: min(100%, 620px);
  padding-bottom: 10px;
}

.intro-brand,
.flow-step {
  color: #9fe2d8;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.intro-content h1,
.onboard-card h1 {
  margin: 8px 0 0;
  letter-spacing: 0;
}

.intro-content h1 {
  max-width: 10ch;
  font-size: clamp(44px, 13vw, 78px);
  line-height: 0.96;
}

.intro-content p,
.flow-copy {
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.45;
}

.intro-content p {
  max-width: 420px;
  margin-top: 14px;
  font-size: 16px;
}

.flow-primary,
.flow-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 52px;
  border-radius: 8px;
  font-weight: 900;
  cursor: pointer;
}

.flow-primary {
  width: 100%;
  margin-top: 24px;
  padding: 14px 18px;
  border: 0;
  background: #ffffff;
  color: #0e5f6d;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.25);
}

.onboard-card .flow-primary {
  background: var(--teal);
  color: #fff;
}

.flow-secondary {
  padding: 13px 16px;
  border: 1px solid rgba(16, 106, 122, 0.26);
  background: #eef7f4;
  color: var(--teal-dark);
}

.onboard-screen {
  place-items: stretch;
  height: 100dvh;
  max-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  padding: max(18px, env(safe-area-inset-top)) 14px calc(34px + env(safe-area-inset-bottom));
  background:
    linear-gradient(180deg, rgba(235, 247, 244, 0.94), rgba(251, 253, 251, 0.98)),
    #eef7f4;
  color: var(--ink);
}

.onboard-card {
  align-self: start;
  width: min(100%, 620px);
  margin: 0 auto;
  padding: 6px 0;
}

.onboard-card h1 {
  color: var(--ink);
  font-size: clamp(30px, 8vw, 44px);
  line-height: 1.02;
}

.flow-copy {
  max-width: 560px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 15px;
}

.choice-grid,
.pref-grid {
  display: grid;
  gap: 9px;
  margin: 18px 0 0;
  padding: 0;
  border: 0;
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.pref-grid {
  grid-template-columns: 1fr;
}

.choice-card,
.pref-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.choice-card input,
.pref-card input {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  accent-color: var(--teal);
}

.choice-card strong,
.choice-card small,
.pref-card strong,
.pref-card small {
  display: block;
}

.choice-card strong,
.pref-card strong {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.15;
}

.choice-card small,
.pref-card small {
  margin-top: 4px;
  color: var(--subtle);
  font-size: 12px;
  line-height: 1.2;
}

.choice-card:has(input:checked),
.choice-card.selected,
.pref-card:has(input:checked) {
  border-color: rgba(16, 106, 122, 0.46);
  background: #eaf7f3;
  box-shadow: 0 0 0 3px rgba(16, 106, 122, 0.1);
}

button.choice-card {
  width: 100%;
  text-align: left;
  font: inherit;
}

.startloc-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.startloc-row .loclabel {
  font-weight: 700;
  color: var(--ink);
}

.startloc-row .locval {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.flow-controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin-top: 14px;
}

.flow-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.flow-controls .flow-field {
  margin-top: 0;
  min-width: 0;
  width: 100%;
}

.flow-controls input[type="time"] {
  -webkit-appearance: none;
  appearance: none;
}

.flow-field input,
.flow-field select {
  width: 100%;
  min-width: 0;
  min-height: 50px;
  padding: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
  outline: none;
}

.flow-field input[type="time"]::-webkit-calendar-picker-indicator {
  display: none;
}

.flow-field input:focus,
.flow-field select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16, 106, 122, 0.14);
}

.location-status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.flow-actions {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 10px;
  margin-top: 24px;
}

.flow-actions .flow-primary,
.flow-actions .flow-secondary {
  width: 100%;
  margin-top: 0;
}

.trip-summary {
  position: relative;
  margin-bottom: 12px;
  padding: 10px 60px 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.trip-summary-edit {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  padding: 5px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
}

.trip-summary-edit:hover {
  border-color: var(--teal);
  background: var(--surface-tint);
}

.trip-summary strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 13px;
}

#app {
  position: relative;
  min-height: 100dvh;
  overflow: hidden;
  background: #dbe9e7;
}

.map-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

.map-legend {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(184, 202, 199, 0.82);
  box-shadow: 0 10px 32px rgba(19, 32, 51, 0.14);
  backdrop-filter: blur(14px);
}

h2,
h3,
p {
  margin: 0;
}

.map-legend {
  position: absolute;
  z-index: 3;
  top: calc(12px + env(safe-area-inset-top));
  left: 12px;
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.legend-dot,
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.green {
  background: var(--green);
}

.yellow {
  background: var(--yellow);
}

.red {
  background: var(--red);
}

#panel {
  position: absolute;
  z-index: 4;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 68dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
  background: #fbfdfb;
  border-top: 1px solid var(--line);
  border-radius: 8px 8px 0 0;
  box-shadow: var(--shadow);
  overscroll-behavior: contain;
  transition: max-height 240ms ease, border-radius 240ms ease;
}

#panel.panel-fullscreen {
  max-height: 100dvh;
  border-radius: 0;
}

.panel-scroll {
  min-height: 0;
  overflow-y: auto;
}

.panel-content {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 240ms ease;
}

.panel-inner {
  min-height: 0;
  overflow: hidden;
}

#panel.panel-collapsed .panel-content {
  grid-template-rows: 0fr;
}

.prompt-row {
  position: relative;
  margin-top: 10px;
}

.prompt-row textarea {
  width: 100%;
  min-height: 84px;
  padding: 14px 64px 14px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  line-height: 1.4;
  resize: none;
  outline: none;
}

.prompt-row textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16, 106, 122, 0.14);
}

.prompt-send {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(16, 106, 122, 0.32);
}

.prompt-send > span {
  display: block;
  line-height: 1;
  transform: translateY(-1px);
}

.prompt-send:hover {
  background: var(--teal-dark);
}

.prompt-send:disabled {
  cursor: wait;
  opacity: 0.7;
}

.regenerate-btn {
  display: none;
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(214, 75, 60, 0.32);
}

.regenerate-btn:hover {
  background: #b03a2e;
}

#panel.has-results .prompt-row {
  display: none;
}

#panel.has-results .regenerate-btn {
  display: block;
}

#panel.panel-collapsed .regenerate-btn {
  display: none;
}

.plan-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  background: rgba(11, 31, 35, 0.62);
  backdrop-filter: blur(8px);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
  animation: fade-in 180ms ease;
}

.plan-overlay .spinner-big {
  width: 72px;
  height: 72px;
  border: 5px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.sheet-handle {
  position: sticky;
  top: 0;
  z-index: 1;
  display: block;
  width: 100%;
  margin: 0 0 8px;
  padding: 6px 0;
  background: transparent;
  border: 0;
  cursor: grab;
  touch-action: none;
}

.sheet-handle::before {
  content: "";
  display: block;
  width: 44px;
  height: 4px;
  margin: 0 auto;
  border-radius: 999px;
  background: #bac9c6;
}

.sheet-handle:active {
  cursor: grabbing;
}

.panel-head {
  display: block;
  margin-bottom: 12px;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--teal);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h2 {
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.controls label,
.prompt-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.controls input,
.controls select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

.controls input:focus,
.controls select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16, 106, 122, 0.14);
}

.toggle-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 0;
  margin: 10px 0;
  border: 0;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  cursor: pointer;
}

.toggle input {
  position: relative;
  width: 36px;
  height: 22px;
  flex: 0 0 36px;
  margin: 0;
  appearance: none;
  border-radius: 999px;
  background: #c7d2d0;
  transition: background 160ms ease;
}

.toggle input::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(19, 32, 51, 0.22);
  transition: transform 160ms ease;
}

.toggle input:checked {
  background: var(--teal);
}

.toggle input:checked::before {
  transform: translateX(14px);
}

.toggle strong,
.toggle small {
  display: block;
  min-width: 0;
}

.toggle strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.15;
}

.toggle small {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
  line-height: 1.15;
}

textarea {
  min-height: 92px;
  line-height: 1.35;
  resize: vertical;
}

.chips {
  display: flex;
  gap: 7px;
  margin: 10px -14px 0;
  padding: 0 14px 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.chips::-webkit-scrollbar {
  display: none;
}

.chips button {
  flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid #c8d9d5;
  border-radius: 999px;
  background: #eef7f4;
  color: #254f53;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.chips button:hover,
.chips button.used {
  border-color: rgba(16, 106, 122, 0.42);
  background: #dff0ed;
}

.primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  padding: 12px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  font-size: 15px;
  font-weight: 850;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(16, 106, 122, 0.25);
}

.primary:hover {
  background: var(--teal-dark);
}

.primary:disabled {
  cursor: wait;
  opacity: 0.72;
}

.btn-icon {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.data-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 10px;
}

.status-item {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.status-item span:last-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-dot.neutral {
  background: #9aa7b6;
}

.status-dot.warn {
  background: var(--yellow);
}

.status-dot.ok {
  background: var(--green);
}

.status-dot.bad {
  background: var(--red);
}

.results {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.empty-state,
.loading-card,
.route-overview,
.context-card,
.recommendation-card,
.stop,
.alts {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.empty-state {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.loading-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px;
}

.loading-card strong {
  display: block;
  font-size: 14px;
}

.loading-card p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border: 3px solid #cddbd8;
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 850ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.route-overview {
  padding: 13px;
  background: linear-gradient(180deg, #ffffff 0%, #f5faf8 100%);
}

.overview-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.overview-kicker {
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.route-overview h3 {
  margin-top: 3px;
  font-size: 18px;
  line-height: 1.12;
}

.variant-pill,
.crowd-badge,
.source-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border-radius: 999px;
  font-weight: 850;
}

.variant-pill {
  padding: 6px 9px;
  background: #e8f3f1;
  color: var(--teal-dark);
  font-size: 11px;
}

.overview-copy {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 12px;
}

.metric {
  min-width: 0;
  padding: 9px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.metric-label {
  color: var(--subtle);
  font-size: 11px;
  font-weight: 800;
}

.metric-value {
  margin-top: 3px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 850;
  line-height: 1.05;
}

.metric-hint {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.context-card,
.recommendation-card {
  padding: 12px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.context-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.context-stat {
  min-width: 0;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.context-stat strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.context-stat span {
  display: block;
  margin-top: 2px;
  color: var(--subtle);
  font-size: 11px;
}

.recommendation-card p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.source-pill {
  padding: 4px 7px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 10px;
}

.timeline {
  display: grid;
  gap: 8px;
}

.stop {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  cursor: pointer;
}

.stop:hover,
.stop:focus-visible {
  border-color: var(--teal);
  outline: none;
}

.stop-index {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 4px 10px rgba(19, 32, 51, 0.17);
}

.stop-index.port {
  background: var(--teal);
}

.stop-main {
  min-width: 0;
}

.stop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.time {
  color: var(--subtle);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.name {
  margin-top: 3px;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
  line-height: 1.25;
}

.crowd-badge {
  flex: 0 0 auto;
  padding: 5px 7px;
  color: #fff;
  font-size: 10px;
  text-transform: uppercase;
}

.crowd-badge.green {
  background: var(--green);
}

.crowd-badge.yellow {
  background: var(--yellow);
}

.crowd-badge.red {
  background: var(--red);
}

.why {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.stop-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.meta-chip {
  max-width: 100%;
  padding: 4px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.alts {
  padding: 11px;
}

.alts-title {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 850;
}

.alt-list {
  display: grid;
  gap: 6px;
}

.alt-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

.alt-row strong {
  color: var(--ink);
}

.error-card {
  padding: 13px;
  border: 1px solid #efc7bf;
  border-radius: 8px;
  background: #fff4f1;
  color: #8d3227;
  font-size: 13px;
  line-height: 1.4;
}

.map-marker {
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border: 2px solid #fff;
  border-radius: 50%;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  box-shadow: 0 8px 18px rgba(19, 32, 51, 0.24);
}

.marker-green {
  background: var(--green);
}

.marker-yellow {
  background: var(--yellow);
}

.marker-red {
  background: var(--red);
}

.marker-port {
  background: var(--teal);
}

.stop-popup .maplibregl-popup-tip {
  display: none;
}

.stop-popup .maplibregl-popup-content {
  padding: 0;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
}

.stop-popup .maplibregl-popup-close-button {
  top: -9px;
  right: -9px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 4px 10px rgba(19, 32, 51, 0.2);
}

.popup-card {
  width: min(286px, calc(100vw - 36px));
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(19, 32, 51, 0.18);
}

.popup-title {
  color: var(--ink);
  font-size: 17px;
  font-weight: 900;
  line-height: 1.18;
}

.popup-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.popup-text {
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.42;
}

.popup-info {
  display: grid;
  gap: 6px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 12px;
}

.popup-info div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.maplibregl-ctrl-top-right {
  top: 12px;
  right: 12px;
}

.maplibregl-ctrl-bottom-right {
  bottom: calc(68dvh + 50px);
}

@media (max-width: 420px) {
  .intro-screen.active {
    display: grid;
  }

  .intro-screen {
    place-items: end start;
    padding: max(24px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
    background: #061416;
  }

  .intro-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
  }

  .intro-content {
    padding-bottom: 0;
  }

  .intro-content h1 {
    font-size: clamp(40px, 12vw, 48px);
  }

  .intro-content p {
    font-size: 15px;
  }

  .pref-grid {
    padding-bottom: 88px;
  }

  [data-flow-screen="trip"] .onboard-card {
    padding-bottom: 88px;
  }

  #tripNext {
    position: fixed;
    z-index: 25;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: 14px;
    width: auto;
    margin-top: 0;
  }

  .flow-actions {
    position: fixed;
    z-index: 25;
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    left: 14px;
    padding-top: 10px;
    background: linear-gradient(180deg, rgba(251, 253, 251, 0), #fbfdfb 28%);
  }

  .map-legend {
    gap: 7px;
    font-size: 11px;
  }

  #panel {
    padding-inline: 12px;
  }

  .chips {
    margin-inline: -12px;
    padding-inline: 12px;
  }
}

@media (max-width: 360px) {
  .choice-grid,
  .flow-actions {
    grid-template-columns: 1fr;
  }

  .intro-content h1 {
    font-size: 40px;
  }
}

@media (max-width: 859px) {
  #panel {
    max-height: 55dvh;
  }

  .maplibregl-ctrl-top-right {
    display: none;
  }

  .map-legend {
    top: calc(12px + env(safe-area-inset-top));
    bottom: auto;
  }

  .popup-card {
    width: min(230px, calc(100vw - 28px));
    padding: 10px;
  }

  .popup-title {
    font-size: 14px;
  }

  .popup-text {
    margin-top: 7px;
    font-size: 12px;
  }

  .popup-info {
    margin-top: 8px;
    gap: 4px;
    font-size: 11px;
  }

  .popup-info div {
    padding: 5px 7px;
  }

  .popup-badges {
    margin-top: 7px;
    gap: 4px;
  }

  .crowd-badge,
  .source-pill {
    font-size: 9px;
    padding: 4px 6px;
  }

  .stop-popup .maplibregl-popup-close-button {
    width: 24px;
    height: 24px;
    font-size: 16px;
  }

  .panel-scroll {
    display: flex;
    flex-direction: column;
  }

  .panel-scroll .panel-content {
    order: 0;
  }

  .panel-scroll .prompt-row {
    order: 1;
    margin-top: 12px;
    margin-bottom: 0;
  }

  .panel-scroll .regenerate-btn {
    order: 2;
    margin-top: 12px;
  }
}

@media (min-width: 500px) {
  .flow-controls {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 700px) {
  .intro-screen {
    padding: 42px;
  }

  .flow-primary {
    width: auto;
    min-width: 220px;
  }

  .onboard-screen {
    place-items: center;
    padding: 32px;
  }

  .onboard-card {
    align-self: center;
  }

  .pref-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 860px) {
  body {
    overflow: hidden;
  }

  #app {
    display: grid;
    grid-template-columns: 430px minmax(0, 1fr);
    min-height: 100vh;
  }

  .map-stage {
    position: relative;
    grid-column: 2;
    min-height: 100vh;
  }

  #panel {
    position: relative;
    grid-column: 1;
    grid-row: 1;
    right: auto;
    bottom: auto;
    max-height: none;
    height: 100vh;
    padding: 18px;
    border-top: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    box-shadow: none;
  }

  .sheet-handle {
    display: none;
  }

  .prompt-row textarea {
    min-height: 140px;
    padding: 18px 68px 18px 16px;
    font-size: 14px;
  }

  .prompt-send {
    width: 44px;
    height: 44px;
    right: 12px;
  }

  .panel-head {
    margin-bottom: 16px;
  }

  h2 {
    font-size: 25px;
  }

  .chips {
    flex-wrap: wrap;
    overflow: visible;
    margin-inline: 0;
    padding-inline: 0;
  }

  .map-legend {
    top: auto;
    left: auto;
    right: 18px;
    bottom: 18px;
  }

  .maplibregl-ctrl-top-right {
    top: 18px;
    right: 18px;
  }

  .maplibregl-ctrl-bottom-right {
    bottom: 18px;
  }
}

.locctl {
  margin: 4px 0 10px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.locrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 4px 0;
  font-size: 13px;
}

.locrow .loclabel {
  flex: 0 0 38px;
  width: 38px;
  color: var(--ink);
  font-weight: 700;
}

.locrow .locval {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.locbtn {
  padding: 5px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--teal-dark);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.locbtn:hover {
  background: var(--surface-tint);
}

.locbtn.active {
  border-color: var(--teal);
  background: var(--teal);
  color: #fff;
}

.locrow.locaddr {
  position: relative;
  margin-top: 1px;
  padding-left: 44px;
}

.addrsug {
  position: absolute;
  left: 44px;
  right: 0;
  top: 100%;
  z-index: 30;
  margin: 3px 0 0;
  padding: 0;
  list-style: none;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 6px 16px rgba(19, 32, 51, 0.18);
}

.addrsug li {
  padding: 7px 9px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.addrsug li:last-child {
  border-bottom: none;
}

.addrsug li:hover,
.addrsug li.active {
  background: var(--surface-tint);
}

.addrinput {
  flex: 1;
  min-width: 0;
  padding: 6px 9px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
}

.addrinput:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(16, 106, 122, 0.14);
}

.loccheck {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 7px 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.locfoot {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
}

.pickhint {
  color: #7c2d12;
  font-size: 12px;
}
