:root {
  --ink: #1f2727;
  --muted: #6a7471;
  --paper: #f7f3ea;
  --surface: #fffaf1;
  --line: #ded6c8;
  --accent: #0f766e;
  --accent-strong: #0b534d;
  --bus: #2563eb;
  --boat: #0891b2;
  --walk: #d97706;
  --bolt: #27272a;
  --shadow: 0 24px 80px rgba(28, 38, 37, 0.14);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 32%),
    linear-gradient(215deg, rgba(217, 119, 6, 0.09), transparent 28%),
    var(--paper);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100svh;
  min-height: 100svh;
  overflow: hidden;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.45rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.icon-button,
.primary-link,
.secondary-link,
.inspector-link {
  min-height: 42px;
  border: 1px solid rgba(31, 39, 39, 0.12);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease;
}

.icon-button {
  padding: 0 14px;
  color: var(--ink);
  background: rgba(255, 250, 241, 0.72);
  backdrop-filter: blur(18px);
}

.icon-button:hover,
.primary-link:hover,
.secondary-link:hover,
.inspector-link:hover {
  transform: translateY(-1px);
}

.icon-button svg,
.primary-link svg,
.secondary-link svg,
.inspector-link svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.day-rail {
  display: flex;
  align-items: stretch;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.day-chip {
  min-width: 116px;
  border: 1px solid rgba(31, 39, 39, 0.13);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 250, 241, 0.78);
  color: var(--ink);
  text-align: left;
  transition:
    transform 180ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.day-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.day-chip strong {
  display: block;
  margin-top: 4px;
  line-height: 1.05;
  font-size: 0.95rem;
}

.day-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.35);
}

.day-chip.is-active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.22);
}

.day-chip.is-active span {
  color: rgba(255, 255, 255, 0.78);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 430px) minmax(0, 1fr);
  gap: 14px;
}

.itinerary-panel {
  min-height: 0;
  overflow: auto;
  border: 1px solid rgba(31, 39, 39, 0.12);
  border-radius: 8px;
  background: rgba(255, 250, 241, 0.84);
  box-shadow: var(--shadow);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.summary-strip div {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.summary-strip div:last-child {
  border-right: 0;
}

.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-strip .metric {
  color: var(--ink);
  font-size: 1.65rem;
  line-height: 1;
}

.day-detail {
  padding: 22px;
}

.detail-head p:first-child {
  margin-bottom: 6px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.detail-head h2 {
  margin-bottom: 8px;
  font-size: clamp(1.55rem, 3vw, 2.2rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.detail-head p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 18px 0;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(31, 39, 39, 0.12);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 760;
}

.tag::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
}

.tag.bus::before {
  background: var(--bus);
}

.tag.boat::before {
  background: var(--boat);
}

.tag.walk::before {
  background: var(--walk);
}

.tag.bolt::before {
  background: var(--bolt);
}

.detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 22px;
}

.primary-link {
  padding: 0 12px;
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

.secondary-link {
  padding: 0 12px;
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.08);
  font-weight: 800;
}

h3 {
  margin: 22px 0 12px;
  font-size: 0.82rem;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 10px;
}

.timeline li {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: start;
}

.time {
  color: var(--accent-strong);
  font-weight: 850;
  font-size: 0.87rem;
}

.stop-body {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(31, 39, 39, 0.1);
}

.stop-body strong {
  display: block;
  line-height: 1.2;
}

.stop-body span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.42;
}

.segment-list {
  display: grid;
  gap: 8px;
}

.segment-item {
  width: 100%;
  border: 1px solid rgba(31, 39, 39, 0.11);
  border-radius: 8px;
  padding: 10px;
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.42);
  text-align: left;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
}

.segment-item:hover,
.segment-item.is-active {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.38);
  background: rgba(255, 255, 255, 0.72);
}

.segment-mode {
  min-height: 28px;
  width: fit-content;
  max-width: 78px;
  border-radius: 999px;
  padding: 5px 9px;
  color: white;
  background: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.05;
}

.segment-mode.bus {
  background: var(--bus);
}

.segment-mode.boat {
  background: var(--boat);
}

.segment-mode.walk {
  background: var(--walk);
}

.segment-mode.bolt {
  background: var(--bolt);
}

.segment-copy strong,
.segment-copy span {
  display: block;
}

.segment-copy strong {
  line-height: 1.2;
}

.segment-copy span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.36;
}

.transport-list {
  display: grid;
  gap: 8px;
}

.transport-item {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 12px;
  align-items: start;
  padding: 10px 0;
  border-bottom: 1px solid rgba(31, 39, 39, 0.1);
}

.transport-item b {
  width: fit-content;
  min-width: 50px;
  border-radius: 999px;
  padding: 4px 9px;
  color: white;
  text-align: center;
  font-size: 0.78rem;
  background: var(--accent);
}

.transport-item b.bus {
  background: var(--bus);
}

.transport-item b.boat {
  background: var(--boat);
}

.transport-item b.walk {
  background: var(--walk);
}

.transport-item b.bolt {
  background: var(--bolt);
}

.transport-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.42;
}

.transport-item strong {
  display: block;
  color: var(--ink);
}

.notes-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.48;
}

.notes-list li + li {
  margin-top: 8px;
}

.map-stage {
  position: relative;
  min-height: 560px;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid rgba(31, 39, 39, 0.14);
  background: #cfe6dd;
  box-shadow: var(--shadow);
}

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

.map-inspector {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 650;
  width: min(380px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  border: 1px solid rgba(31, 39, 39, 0.14);
  border-radius: 8px;
  padding: 16px;
  color: var(--ink);
  background: rgba(255, 250, 241, 0.94);
  box-shadow: 0 24px 70px rgba(31, 39, 39, 0.22);
  backdrop-filter: blur(18px);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px) scale(0.98);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.map-inspector.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.inspector-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(31, 39, 39, 0.12);
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
}

.inspector-close svg {
  width: 17px;
  height: 17px;
}

.inspector-kicker {
  margin: 0 38px 6px 0;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.map-inspector h2 {
  margin: 0 38px 7px 0;
  font-size: 1.28rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.map-inspector p {
  color: var(--muted);
  line-height: 1.42;
}

.preview-media {
  position: relative;
  min-height: 158px;
  margin: 12px 0 10px;
  overflow: hidden;
  border: 1px solid rgba(31, 39, 39, 0.12);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.18), rgba(217, 119, 6, 0.16)),
    #d9e7e5;
}

.preview-media img {
  width: 100%;
  height: 172px;
  display: block;
  object-fit: cover;
}

.preview-media figcaption {
  position: absolute;
  left: 10px;
  bottom: 10px;
  max-width: calc(100% - 20px);
  border-radius: 999px;
  padding: 5px 9px;
  color: #fff;
  background: rgba(31, 39, 39, 0.74);
  font-size: 0.72rem;
  font-weight: 850;
  backdrop-filter: blur(12px);
}

#googleFrame {
  width: 100%;
  height: 230px;
  border: 1px solid rgba(31, 39, 39, 0.12);
  border-radius: 8px;
  background: #d9e7e5;
}

.inspector-link {
  margin-top: 10px;
  min-height: 40px;
  width: 100%;
  padding: 0 12px;
  color: white;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 850;
}

.map-overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 500;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.route-status,
.legend {
  min-height: 42px;
  border: 1px solid rgba(31, 39, 39, 0.12);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  background: rgba(255, 250, 241, 0.9);
  box-shadow: 0 12px 40px rgba(31, 39, 39, 0.13);
  backdrop-filter: blur(18px);
  font-size: 0.88rem;
  font-weight: 760;
}

.legend {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend b {
  display: inline-block;
  width: 18px;
  height: 4px;
  border-radius: 999px;
}

.legend-bus {
  background: var(--bus);
}

.legend-boat {
  background: var(--boat);
}

.legend-walk {
  background: var(--walk);
}

.legend-bolt {
  background: var(--bolt);
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.45);
  animation: pulse 1.9s infinite;
}

.source-dock {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.source-dock a {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  padding: 0 11px;
  color: var(--accent-strong);
  background: rgba(255, 250, 241, 0.68);
  border: 1px solid rgba(31, 39, 39, 0.12);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 780;
}

.pin-marker {
  appearance: none;
  min-width: 30px;
  height: 30px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(31, 39, 39, 0.25);
  font-size: 0.8rem;
  font-weight: 900;
  cursor: pointer;
  white-space: nowrap;
  transform-origin: left center;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.pin-marker.active {
  min-width: 32px;
  max-width: 32px;
  height: 32px;
}

.pin-marker:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(31, 39, 39, 0.32);
}

.pin-number {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  flex: 0 0 auto;
}

.pin-label {
  display: none;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
  line-height: 1.05;
}

.pin-marker.bus {
  background: var(--bus);
}

.pin-marker.boat {
  background: var(--boat);
}

.pin-marker.walk {
  background: var(--walk);
}

.pin-marker.bolt {
  background: var(--bolt);
}

.pin-marker.base {
  min-width: 32px;
  height: 32px;
  color: var(--ink);
  background: #facc15;
}

.pin-marker.base .pin-label,
.pin-marker.base .pin-number {
  color: var(--ink);
}

.pin-marker.overview {
  min-width: 18px;
  width: 18px;
  height: 18px;
  font-size: 0;
}

.pin-marker.overview::after {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #fff;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  color: var(--ink);
  background: var(--surface);
}

.popup-title {
  margin: 0 0 4px;
  font-weight: 900;
}

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

.popup-action {
  margin-top: 9px;
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 11px rgba(15, 118, 110, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(15, 118, 110, 0);
  }
}

@media (max-width: 980px) {
  .app-shell {
    height: auto;
    overflow: visible;
    padding: 12px;
  }

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

  .map-stage {
    min-height: 460px;
    order: -1;
  }

  .map-inspector {
    position: fixed;
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    max-height: 72%;
  }

  .itinerary-panel {
    max-height: none;
  }
}

@media (max-width: 640px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
  }

  .icon-button {
    flex: 1;
  }

  .day-chip {
    min-width: 98px;
  }

  .summary-strip div {
    padding: 13px 12px;
  }

  .day-detail {
    padding: 18px;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }

  .timeline li,
  .transport-item,
  .segment-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .map-stage {
    min-height: 420px;
  }

  #googleFrame {
    height: 168px;
  }

  .preview-media {
    min-height: 126px;
  }

  .preview-media img {
    height: 136px;
  }

  .map-overlay {
    left: 10px;
    right: 10px;
    bottom: 10px;
    flex-direction: column;
  }

  .legend {
    justify-content: flex-start;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    min-height: auto;
    padding: 0;
  }

  .topbar-actions,
  .map-stage,
  .source-dock {
    display: none;
  }

  .day-rail {
    flex-wrap: wrap;
    overflow: visible;
  }

  .workspace {
    display: block;
  }

  .itinerary-panel {
    box-shadow: none;
    border: 0;
  }
}
