:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #667085;
  --line: #d8dde6;
  --accent: #1264a3;
  --accent-strong: #0b4f82;
  --priced: #15803d;
  --partial: #b45309;
  --plain: #64748b;
}

* {
  box-sizing: border-box;
}

html,
body,
.app-shell {
  height: 100%;
  margin: 0;
}

html,
body {
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family:
    "Aptos", "Inter", "SF Pro Text", ui-sans-serif, system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-variant-ligatures: contextual common-ligatures;
  text-rendering: optimizeLegibility;
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 420px;
  grid-template-rows: 100dvh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.panel-toggle {
  background: var(--text);
  border: 1px solid rgb(255 255 255 / 0.7);
  border-radius: 999px;
  box-shadow: 0 4px 14px rgb(15 23 42 / 0.22);
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
  min-height: 32px;
  padding: 0 12px;
  position: fixed;
  right: calc(420px + 12px);
  top: 12px;
  z-index: 1200;
}

.panel-collapsed {
  grid-template-columns: 0 minmax(0, 1fr) 420px;
}

.panel-collapsed .panel-toggle {
  right: calc(420px + 12px);
}

.panel-collapsed .sidebar {
  border-right: 0;
  overflow: hidden;
  padding: 0;
}

.panel-collapsed .sidebar > * {
  display: none;
}

.sidebar,
.details {
  background: var(--panel);
  border-color: var(--line);
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 16px 18px;
  padding-top: 54px;
}

.details {
  border-left: 1px solid var(--line);
}

.details-toggle {
  display: none;
}

.brand h1 {
  font-size: 22px;
  line-height: 1.2;
  margin: 0 0 4px;
}

.brand p,
.details-empty p,
.summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.brand p {
  margin: 0 0 18px;
}

.control-group {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.control-group label {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

.segmented {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: #fff;
  color: var(--muted);
  min-height: 40px;
  cursor: pointer;
}

.segmented button + button {
  border-left: 1px solid var(--line);
}

.segmented button.active {
  background: var(--accent);
  color: white;
}

.summary {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 12px;
}

.summary strong {
  color: var(--text);
}

.filter-toggle {
  display: none;
}

.map-panel {
  height: 100dvh;
  min-width: 0;
  position: relative;
}

#map {
  height: 100%;
  width: 100%;
}

.leaflet-container {
  font: inherit;
}

/* Local Leaflet layout fallback. Without these rules, map tiles and markers
   render in normal document flow if the CDN stylesheet is blocked. */
.leaflet-pane,
.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow,
.leaflet-tile-container,
.leaflet-pane > svg,
.leaflet-pane > canvas,
.leaflet-zoom-box,
.leaflet-image-layer,
.leaflet-layer {
  left: 0;
  position: absolute;
  top: 0;
}

.leaflet-container {
  overflow: hidden;
  position: relative;
}

.leaflet-tile,
.leaflet-marker-icon,
.leaflet-marker-shadow {
  user-select: none;
  -webkit-user-drag: none;
}

.leaflet-tile {
  border: 0;
  filter: inherit;
  max-height: none;
  max-width: none;
  padding: 0;
}

.leaflet-marker-icon,
.leaflet-marker-shadow {
  display: block;
}

.leaflet-container img.leaflet-tile {
  mix-blend-mode: normal;
}

.leaflet-control {
  position: relative;
  z-index: 800;
}

.leaflet-top,
.leaflet-bottom {
  pointer-events: none;
  position: absolute;
  z-index: 1000;
}

.leaflet-top {
  top: 0;
}

.leaflet-right {
  right: 0;
}

.leaflet-bottom {
  bottom: 0;
}

.leaflet-left {
  left: 0;
}

.leaflet-control {
  clear: both;
  float: left;
  pointer-events: auto;
}

.leaflet-right .leaflet-control {
  float: right;
}

.leaflet-top .leaflet-control {
  margin-top: 10px;
}

.leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.leaflet-left .leaflet-control {
  margin-left: 10px;
}

.leaflet-right .leaflet-control {
  margin-right: 10px;
}

.leaflet-control-zoom a {
  background: #fff;
  border-bottom: 1px solid #ccc;
  color: #111827;
  display: block;
  height: 28px;
  line-height: 28px;
  text-align: center;
  text-decoration: none;
  width: 28px;
}

.leaflet-control-zoom {
  border: 1px solid #bbb;
  border-radius: 4px;
  box-shadow: 0 1px 5px rgb(0 0 0 / 0.25);
  overflow: hidden;
}

.leaflet-control-attribution {
  background: rgb(255 255 255 / 0.8);
  color: #334155;
  font-size: 11px;
  padding: 2px 6px;
}

.leaflet-control-attribution a {
  color: var(--accent);
}

.leaflet-pane {
  z-index: 400;
}

.leaflet-tile-pane {
  z-index: 200;
}

.leaflet-overlay-pane {
  z-index: 400;
}

.leaflet-shadow-pane {
  z-index: 500;
}

.leaflet-marker-pane {
  z-index: 600;
}

.leaflet-tooltip-pane {
  z-index: 650;
}

.leaflet-popup-pane {
  z-index: 700;
}

.leaflet-map-pane canvas {
  z-index: 100;
}

.leaflet-map-pane svg {
  z-index: 200;
}

.leaflet-tooltip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.18);
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
  position: absolute;
  white-space: nowrap;
}

.marker-dot {
  appearance: none;
  align-items: center;
  border: 2px solid white;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.25);
  color: white;
  display: flex;
  font-size: 10px;
  font-weight: 800;
  height: var(--size);
  justify-content: center;
  min-height: var(--size);
  min-width: var(--size);
  pointer-events: auto;
  touch-action: manipulation;
  transform: translateZ(0);
  width: var(--size);
}

.marker-dot:active {
  transform: scale(0.94) translateZ(0);
}

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

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

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

.details-empty {
  padding: 28px;
}

.details-empty h2,
.destination-header h2 {
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 8px;
}

.destination-header {
  border-bottom: 1px solid var(--line);
  padding: 20px 22px;
}

.destination-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
}

.route-list {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.route-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.route-card header {
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.route-path {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 800;
  gap: 6px;
}

.route-arrow {
  color: var(--muted);
  font-family: "SF Pro Text", "Segoe UI Symbol", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.airport-chip,
.entity-chip,
.axis-badge {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  line-height: 1;
  white-space: nowrap;
}

.airport-chip {
  background: #eef6ff;
  border: 1px solid #c7def7;
  color: #0b4f82;
  font-size: 12px;
  font-weight: 900;
  gap: 5px;
  padding: 5px 7px;
}

.entity-chip {
  background: #f8fafc;
  border: 1px solid #d8dde6;
  color: #243041;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
  padding: 4px 7px 4px 4px;
}

.chip-icon {
  align-items: center;
  background: #fff;
  border: 1px solid #d8dde6;
  border-radius: 999px;
  color: var(--accent);
  display: inline-flex;
  font-size: 9px;
  font-weight: 900;
  height: 18px;
  justify-content: center;
  min-width: 18px;
  padding: 0 4px;
}

.program-chip .chip-icon {
  color: #7c2d12;
}

.axis-badge {
  background: #ecfdf3;
  border: 1px solid #b7e4c7;
  color: #166534;
  font-size: 11px;
  font-weight: 900;
  padding: 5px 7px;
}

.route-score {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
}

.leg {
  padding: 12px 14px;
}

.leg + .leg {
  border-top: 1px solid var(--line);
}

.leg-title {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 800;
  gap: 8px;
  margin-bottom: 8px;
}

.leg-path {
  align-items: center;
  display: inline-flex;
  gap: 5px;
}

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

.option {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  display: grid;
  gap: 2px;
  padding: 8px;
}

.option-main {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  font-weight: 800;
  gap: 6px;
}

.option-program {
  align-items: center;
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}

.booking-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  margin-left: auto;
  text-decoration: none;
}

.booking-link:hover {
  color: var(--accent-strong);
  text-decoration: underline;
}

.option-sub {
  color: var(--muted);
  font-size: 12px;
}

.empty-options {
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1100px) {
  .app-shell {
    grid-template-columns: 290px minmax(0, 1fr);
  }

  .panel-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
  }

  .panel-toggle {
    left: auto;
    right: 12px;
  }

  .panel-collapsed .panel-toggle {
    left: auto;
    right: 12px;
  }

  .details {
    border-left: 0;
    border-top: 1px solid var(--line);
    bottom: 0;
    box-shadow: 0 -10px 20px rgb(15 23 42 / 0.16);
    max-height: 45dvh;
    position: fixed;
    right: 0;
    width: calc(100% - 290px);
    z-index: 500;
  }

  .details.details-hidden {
    display: none;
  }

  .panel-collapsed .details {
    width: 100%;
  }
}

@media (max-width: 760px) {
  html,
  body {
    height: auto;
    overflow: hidden;
  }

  .app-shell {
    display: block;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
    position: relative;
  }

  .panel-toggle {
    left: auto;
    right: 16px;
    top: 10px;
  }

  .panel-collapsed .panel-toggle {
    left: auto;
    right: 16px;
  }

  .details-expanded .panel-toggle {
    display: none;
  }

  .sidebar {
    background: rgb(255 255 255 / 0.96);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 20px rgb(15 23 42 / 0.12);
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    left: 8px;
    max-height: 40dvh;
    overflow: auto;
    padding: 8px;
    position: absolute;
    right: 8px;
    top: 8px;
    z-index: 700;
  }

  .panel-collapsed .sidebar {
    display: none;
  }

  .panel-collapsed .map-panel {
    height: 100dvh;
  }

  .brand {
    display: none;
  }

  .brand h1 {
    font-size: 18px;
  }

  .brand p {
    display: none;
  }

  .control-group {
    gap: 5px;
    margin-bottom: 0;
  }

  .control-group label {
    font-size: 10px;
  }

  select {
    min-height: 36px;
    padding: 7px 8px;
  }

  .segmented button {
    font-size: 12px;
    min-height: 36px;
    padding: 0 6px;
  }

  .filter-toggle {
    background: var(--text);
    border: 0;
    border-radius: 6px;
    color: #fff;
    display: block;
    font-weight: 800;
    min-height: 36px;
  }

  .filter-toggle.active {
    background: var(--accent);
  }

  .secondary-filters {
    display: none;
    gap: 8px;
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
  }

  .secondary-filters.open {
    display: grid;
  }

  .summary {
    display: none;
  }

  .map-panel {
    height: 100dvh;
  }

  #map {
    height: 100%;
    min-height: 0;
  }

  .details {
    border-left: 0;
    border-top: 1px solid var(--line);
    bottom: 0;
    box-shadow: 0 -10px 22px rgb(15 23 42 / 0.18);
    box-sizing: border-box;
    left: 0;
    max-height: 42dvh;
    min-height: 0;
    overflow: auto;
    position: fixed;
    right: 0;
    width: 100%;
    z-index: 800;
  }

  .leaflet-control-attribution {
    display: none;
  }

  .leaflet-control-zoom {
    display: none;
  }

  .details-toggle {
    align-items: center;
    background: var(--text);
    border: 0;
    border-radius: 999px;
    box-shadow: 0 4px 14px rgb(15 23 42 / 0.22);
    color: #fff;
    cursor: pointer;
    display: flex;
    font-size: 18px;
    font-weight: 900;
    height: 34px;
    justify-content: center;
    line-height: 1;
    padding: 0;
    position: absolute;
    right: 16px;
    top: 10px;
    width: 34px;
    z-index: 4;
  }

  .details.expanded {
    height: 100dvh;
    max-height: 100dvh;
  }

  .details:has(.details-empty) {
    max-height: 72px;
  }

  .details.expanded:has(.details-empty) {
    height: 112px;
    max-height: 112px;
  }

  .details-empty {
    padding: 12px 16px;
  }

  .details-empty h2 {
    font-size: 14px;
    margin: 0 0 2px;
  }

  .details-empty p {
    font-size: 12px;
    margin: 0;
  }

  .destination-header {
    background: #fff;
    padding: 14px 16px;
    padding-right: 62px;
    position: sticky;
    top: 0;
    z-index: 1;
  }

  .destination-header h2 {
    font-size: 16px;
  }

  .route-list {
    gap: 10px;
    padding: 10px;
  }

  .route-card header,
  .leg {
    padding: 10px;
  }

  .route-path {
    font-size: 13px;
  }
}

@media (max-width: 430px) {
  .sidebar {
    grid-template-columns: 1fr;
    max-height: 40dvh;
  }

  .summary {
    font-size: 12px;
  }

  .details {
    max-height: none;
    height: 40dvh;
    width: 100%;
  }

  .details:has(.details-empty) {
    height: 72px;
  }

  .details.expanded {
    height: 100dvh;
  }

  .details.expanded:has(.details-empty) {
    height: 112px;
  }
}
