:root {
  --blue-950: #06244a;
  --blue-850: #063f7a;
  --blue-700: #1238c8;
  --aqua-600: #00a7c2;
  --aqua-100: #dff9fb;
  --sun-500: #ffd447;
  --sun-650: #f2a900;
  --coral-500: #ff5f57;
  --coral-650: #d9373f;
  --green-650: #0c7f5a;
  --green-100: #ddf7ec;
  --ink: #09243b;
  --muted: #5b6e7c;
  --line: rgba(9, 36, 59, 0.14);
  --surface: #ffffff;
  --surface-2: #f4fbfd;
  --shadow: 0 18px 48px rgba(6, 36, 74, 0.16);
  --radius: 8px;
  --topbar-height: 74px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-width: 320px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(0, 167, 194, 0.14) 0 25%, transparent 25% 50%, rgba(255, 212, 71, 0.12) 50% 75%, transparent 75%),
    linear-gradient(180deg, #f8feff 0%, #dff9fb 100%);
  background-size: 28px 28px, auto;
}

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

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

svg {
  width: 1.15em;
  height: 1.15em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

[hidden] {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-rows: var(--topbar-height) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 16px 12px 14px;
  background: linear-gradient(90deg, #ffffff 0%, #e6fbff 52%, #fff3b0 100%);
  border-bottom: 1px solid rgba(6, 36, 74, 0.14);
  box-shadow: 0 8px 26px rgba(6, 36, 74, 0.12);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  place-items: center;
  color: var(--blue-950);
  background: var(--sun-500);
  border: 2px solid var(--blue-950);
  border-radius: var(--radius);
  box-shadow: 5px 5px 0 var(--aqua-600);
}

.brand-mark svg {
  width: 29px;
  height: 29px;
  stroke-width: 2.2;
}

.brand strong {
  display: block;
  color: var(--blue-950);
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1.05;
}

.brand small {
  display: block;
  margin-top: 4px;
  color: var(--blue-850);
  font-size: 0.78rem;
  font-weight: 750;
  line-height: 1.2;
}

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

.button,
.icon-button,
.small-link,
.section-collapse {
  border: 0;
  cursor: pointer;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 15px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 850;
  text-decoration: none;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

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

.button:active,
.icon-button:active,
.small-link:active,
.section-collapse:active {
  transform: translateY(0);
}

.button-primary {
  color: var(--blue-950);
  background: var(--sun-500);
  border: 2px solid var(--blue-950);
  box-shadow: 4px 4px 0 var(--blue-950);
}

.button-secondary {
  color: var(--blue-950);
  background: #ffffff;
  border: 2px solid rgba(6, 36, 74, 0.2);
}

.button-danger {
  color: #ffffff;
  background: var(--coral-650);
  border: 2px solid var(--blue-950);
  box-shadow: 4px 4px 0 var(--blue-950);
}

.icon-button {
  position: relative;
  display: inline-grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--blue-950);
  background: #ffffff;
  border: 2px solid rgba(6, 36, 74, 0.18);
  border-radius: var(--radius);
}

.icon-button[data-tooltip]::after {
  position: absolute;
  right: 0;
  bottom: -34px;
  z-index: 10;
  width: max-content;
  max-width: 220px;
  padding: 6px 8px;
  color: #ffffff;
  pointer-events: none;
  content: attr(data-tooltip);
  background: var(--blue-950);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(-3px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.icon-button[data-tooltip]:hover::after,
.icon-button[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(286px, 340px) minmax(0, 1fr) minmax(310px, 390px);
  min-height: 0;
}

.planner-panel,
.detail-panel {
  position: relative;
  z-index: 20;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.94);
  border-color: var(--line);
  border-style: solid;
}

.planner-panel {
  display: flex;
  flex-direction: column;
  border-width: 0 1px 0 0;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  border-width: 0 0 0 1px;
}

.trip-status {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 14px;
  background: linear-gradient(135deg, #ffffff 0%, #edfbf6 100%);
  border-bottom: 1px solid var(--line);
}

.label {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1;
  text-transform: uppercase;
}

.trip-status strong {
  font-size: 0.96rem;
}

.status-light,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--blue-950);
  font-size: 0.74rem;
  font-weight: 850;
  background: var(--aqua-100);
  border: 1px solid rgba(0, 167, 194, 0.28);
  border-radius: 999px;
}

.status-light.is-edit {
  background: var(--sun-500);
  border-color: rgba(242, 169, 0, 0.45);
}

.panel-section {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panel-section-grow {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  border-bottom: 0;
}

.panel-section-grow.is-collapsed {
  flex: 0 0 auto;
  min-height: auto;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin: 0;
  color: var(--blue-950);
  font-size: 0.95rem;
  font-weight: 950;
}

.section-collapse {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0;
  color: inherit;
  font: inherit;
  background: transparent;
  border-radius: 6px;
}

.section-collapse:hover,
.section-collapse:focus-visible {
  color: var(--aqua-600);
}

.section-collapse svg {
  width: 17px;
  height: 17px;
  transition: transform 150ms ease;
}

.collapsible-section.is-collapsed .section-collapse svg {
  transform: rotate(-90deg);
}

.section-content {
  min-width: 0;
}

.collapsible-section.is-collapsed .section-content {
  display: none;
}

.panel-section-grow .section-content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.small-link {
  min-height: 30px;
  padding: 0 9px;
  color: var(--blue-850);
  font-size: 0.76rem;
  font-weight: 900;
  background: transparent;
  border-radius: 6px;
}

.route-toggles {
  display: grid;
  gap: 7px;
}

.route-toggle {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 36px;
  padding: 8px;
  color: var(--ink);
  text-align: left;
  background: var(--surface-2);
  border: 1px solid rgba(9, 36, 59, 0.12);
  border-radius: var(--radius);
  cursor: pointer;
}

.route-swatch {
  width: 14px;
  height: 14px;
  border: 2px solid var(--blue-950);
  border-radius: 3px;
}

.route-toggle strong {
  display: block;
  overflow: hidden;
  font-size: 0.76rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-toggle span:last-child {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.route-toggle.is-muted {
  opacity: 0.52;
}

.timeline {
  display: grid;
  gap: 10px;
  max-height: 230px;
  padding: 0;
  margin: 0;
  overflow: auto;
  list-style: none;
}

.timeline li {
  position: relative;
  padding-left: 24px;
}

.timeline li::before {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 8px;
  height: 8px;
  content: "";
  background: var(--sun-500);
  border: 2px solid var(--blue-950);
  border-radius: 50%;
}

.timeline li::after {
  position: absolute;
  top: 17px;
  bottom: -14px;
  left: 9px;
  width: 2px;
  content: "";
  background: rgba(6, 36, 74, 0.18);
}

.timeline li:last-child::after {
  content: none;
}

.timeline time {
  display: block;
  color: var(--green-650);
  font-size: 0.72rem;
  font-weight: 900;
}

.timeline strong {
  display: block;
  margin-top: 2px;
  font-size: 0.82rem;
  line-height: 1.22;
}

.timeline p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.35;
}

.place-list {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding-right: 3px;
}

.place-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 9px;
  color: inherit;
  text-align: left;
  background: #ffffff;
  border: 1px solid rgba(9, 36, 59, 0.12);
  border-radius: var(--radius);
  cursor: pointer;
}

.place-row:hover,
.place-row.is-selected {
  border-color: rgba(0, 167, 194, 0.52);
  box-shadow: 0 8px 20px rgba(0, 167, 194, 0.12);
}

.place-row.is-hidden {
  opacity: 0.48;
}

.pin-symbol {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--blue-950);
  font-size: 0.78rem;
  font-weight: 950;
  background: var(--pin-color, var(--sun-500));
  border: 2px solid var(--blue-950);
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  box-shadow: 3px 3px 0 rgba(6, 36, 74, 0.2);
}

.pin-symbol span {
  transform: rotate(45deg);
}

.place-row h3 {
  margin: 0;
  overflow: hidden;
  color: var(--blue-950);
  font-size: 0.82rem;
  font-weight: 950;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.place-row p {
  display: -webkit-box;
  margin: 4px 0 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.32;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.meta-line {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 7px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 7px;
  color: var(--blue-850);
  font-size: 0.68rem;
  font-weight: 850;
  background: var(--aqua-100);
  border-radius: 999px;
}

.map-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.map-canvas {
  width: 100%;
  height: 100%;
  background: #b9ecf4;
}

.map-filterbar {
  position: absolute;
  top: 14px;
  left: 50%;
  z-index: 1000;
  display: flex;
  max-width: calc(100% - 28px);
  gap: 7px;
  padding: 7px;
  overflow-x: auto;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(6, 36, 74, 0.15);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  backdrop-filter: blur(14px);
}

.filter-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  color: var(--blue-850);
  font-size: 0.75rem;
  font-weight: 900;
  background: #ffffff;
  border: 1px solid rgba(9, 36, 59, 0.16);
  border-radius: 999px;
  cursor: pointer;
}

.filter-chip.is-active {
  color: var(--blue-950);
  background: var(--sun-500);
  border-color: var(--blue-950);
}

.map-note {
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 1000;
  max-width: 280px;
  padding: 9px 11px;
  color: var(--blue-950);
  font-size: 0.75rem;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(6, 36, 74, 0.14);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(6, 36, 74, 0.12);
}

.leaflet-control-zoom a {
  color: var(--blue-950) !important;
  font-weight: 900;
}

.leaflet-div-icon {
  background: transparent;
  border: 0;
}

.map-marker {
  position: relative;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: var(--blue-950);
  font-size: 0.72rem;
  font-weight: 950;
  background: var(--pin-color);
  border: 2px solid var(--blue-950);
  border-radius: 50% 50% 50% 8px;
  box-shadow: 3px 3px 0 rgba(6, 36, 74, 0.25);
  transform: rotate(-45deg);
}

.map-marker span {
  transform: rotate(45deg);
}

.map-marker.is-selected {
  width: 42px;
  height: 42px;
  box-shadow: 0 0 0 5px rgba(255, 212, 71, 0.45), 4px 4px 0 rgba(6, 36, 74, 0.28);
}

.empty-detail {
  display: grid;
  flex: 1;
  place-content: center;
  padding: 24px;
  text-align: center;
}

.empty-detail svg {
  width: 62px;
  height: 62px;
  margin: 0 auto 14px;
  color: var(--aqua-600);
  fill: rgba(0, 167, 194, 0.1);
}

.empty-detail h2 {
  margin: 0;
  color: var(--blue-950);
  font-size: 1.08rem;
}

.empty-detail p {
  max-width: 280px;
  margin: 8px auto 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}

.detail-content {
  min-height: 0;
  overflow: auto;
}

.detail-hero {
  padding: 18px 18px 16px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(6, 36, 74, 0.92), rgba(0, 167, 194, 0.78)),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 10px);
}

.detail-category {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  color: var(--blue-950);
  font-size: 0.72rem;
  font-weight: 950;
  background: var(--sun-500);
  border-radius: 999px;
}

.detail-hero h2 {
  margin: 11px 0 0;
  font-size: 1.45rem;
  line-height: 1.06;
}

.detail-hero p {
  margin: 9px 0 0;
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.9rem;
  line-height: 1.42;
}

.detail-body {
  display: grid;
  gap: 14px;
  padding: 16px 18px 20px;
}

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.fact {
  min-height: 58px;
  padding: 9px;
  background: var(--surface-2);
  border: 1px solid rgba(9, 36, 59, 0.12);
  border-radius: var(--radius);
}

.fact span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 850;
  text-transform: uppercase;
}

.fact strong {
  display: block;
  margin-top: 4px;
  color: var(--blue-950);
  font-size: 0.82rem;
  line-height: 1.25;
}

.detail-description {
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.52;
}

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

.detail-actions .button {
  min-height: 44px;
  padding: 0 10px;
}

.detail-actions .wide {
  grid-column: 1 / -1;
}

.edit-actions {
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding-top: 4px;
}

.is-editing .edit-actions {
  display: grid;
}

.mobile-sheet {
  display: none;
}

.mobile-sheet.is-empty {
  display: none;
}

.modal {
  width: min(92vw, 480px);
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
}

.modal-wide {
  width: min(94vw, 780px);
}

.modal::backdrop {
  background: rgba(6, 36, 74, 0.52);
  backdrop-filter: blur(5px);
}

.modal-card {
  display: grid;
  gap: 15px;
  padding: 18px;
  background: #ffffff;
  border: 2px solid var(--blue-950);
  border-radius: var(--radius);
  box-shadow: 8px 8px 0 var(--blue-950), var(--shadow);
}

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

.modal-head h2 {
  margin: 0;
  color: var(--blue-950);
  font-size: 1.2rem;
  font-weight: 950;
}

.modal-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.modal-close {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
}

.place-form {
  max-height: min(86vh, 840px);
  overflow: auto;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--blue-950);
  font-size: 0.76rem;
  font-weight: 900;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid rgba(6, 36, 74, 0.22);
  border-radius: var(--radius);
  outline: 0;
}

.field textarea {
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--aqua-600);
  box-shadow: 0 0 0 3px rgba(0, 167, 194, 0.18);
}

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

.search-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.geocode-results {
  display: grid;
  gap: 6px;
}

.geocode-result,
.geocode-message {
  min-height: 38px;
  padding: 8px 10px;
  color: var(--blue-950);
  text-align: left;
  background: var(--aqua-100);
  border: 1px solid rgba(0, 167, 194, 0.28);
  border-radius: var(--radius);
}

.geocode-result {
  cursor: pointer;
}

.geocode-message {
  font-weight: 850;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  padding-top: 2px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(380px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 850;
  background: var(--blue-950);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: minmax(270px, 320px) minmax(0, 1fr);
  }

  .detail-panel {
    display: none;
  }

  .mobile-sheet {
    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 1200;
    display: block;
    width: min(390px, calc(100vw - 28px));
    max-height: 52vh;
    overflow: auto;
    background: rgba(255, 255, 255, 0.97);
    border: 2px solid var(--blue-950);
    border-radius: var(--radius);
    box-shadow: 7px 7px 0 rgba(6, 36, 74, 0.95), var(--shadow);
  }

  .sheet-handle {
    display: block;
    width: 46px;
    height: 5px;
    padding: 0;
    margin: 9px auto 0;
    background: rgba(6, 36, 74, 0.24);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
  }

  .mobile-sheet .detail-hero {
    padding-top: 12px;
  }
}

@media (max-width: 820px) {
  :root {
    --topbar-height: auto;
  }

  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .topbar {
    align-items: flex-start;
    padding: 10px;
  }

  .brand-mark {
    flex-basis: 42px;
    width: 42px;
    height: 42px;
    box-shadow: 4px 4px 0 var(--aqua-600);
  }

  .brand strong {
    font-size: 1rem;
  }

  .brand small {
    max-width: 190px;
    font-size: 0.7rem;
  }

  .topbar-actions {
    gap: 6px;
  }

  .topbar-actions .button {
    width: 42px;
    min-width: 42px;
    padding: 0;
  }

  .topbar-actions .button span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

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

  .planner-panel {
    display: none;
  }

  .map-filterbar {
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    transform: none;
  }

  .map-note {
    display: none;
  }

  .mobile-sheet {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 55vh;
    border-width: 2px 0 0;
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -18px 36px rgba(6, 36, 74, 0.22);
  }

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

  .form-grid,
  .search-line {
    grid-template-columns: 1fr;
  }

  .modal-card {
    padding: 14px;
    box-shadow: 5px 5px 0 var(--blue-950), var(--shadow);
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .button {
    width: 100%;
  }
}

.map-load-error {
  display: grid;
  height: 100%;
  place-items: center;
  padding: 24px;
  color: var(--blue-950);
  font-weight: 900;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
