:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #0d1118;
  --panel-2: #121821;
  --panel-3: #18202b;
  --panel-soft: #121821;
  --panel-strong: #18202b;
  --line: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --muted: #95a0ad;
  --text: #f5f7fb;
  --soft: #d7dde5;
  --accent: #35d4a4;
  --accent-2: #77a7ff;
  --warn: #ffd166;
  --danger: #ff6b6b;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.38);
  --app-bg:
    radial-gradient(circle at 12% 0%, rgba(53, 212, 164, 0.16), transparent 30%),
    linear-gradient(180deg, var(--panel) 0%, var(--bg) 54%, var(--bg) 100%);
  --body-bg: var(--bg);
  --card-bg: rgba(5, 7, 11, 0.92);
  --surface-bg: rgba(18, 24, 33, 0.86);
  --soft-surface-bg: rgba(255, 255, 255, 0.055);
  --soft-surface-bg-2: rgba(255, 255, 255, 0.045);
  --map-bg: #0b1018;
  --popup-bg: #0e141d;
  --thumb-overlay: linear-gradient(180deg, transparent 36%, rgba(7, 9, 13, 0.72));
  --toggle-bg: rgba(7, 9, 13, 0.88);
  --toggle-active-bg: #f5f7fb;
  --toggle-active-text: #07090d;
  --marker-text: #06101a;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f7f2;
  --panel: #ffffff;
  --panel-2: #e9f1ec;
  --panel-3: #dce8e1;
  --panel-soft: #e9f1ec;
  --panel-strong: #dce8e1;
  --line: rgba(5, 30, 20, 0.12);
  --border: rgba(5, 30, 20, 0.12);
  --muted: #66736d;
  --text: #07110d;
  --soft: #24352e;
  --accent: #148f6a;
  --accent-2: #2c6fd6;
  --warn: #a66b00;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(14, 36, 28, 0.14);
  --app-bg:
    radial-gradient(circle at 12% 0%, rgba(20, 143, 106, 0.14), transparent 30%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 58%, #edf5ef 100%);
  --body-bg:
    radial-gradient(circle at 50% 0%, rgba(20, 143, 106, 0.13), transparent 35%),
    #edf5ef;
  --card-bg: rgba(255, 255, 255, 0.92);
  --surface-bg: rgba(255, 255, 255, 0.9);
  --soft-surface-bg: rgba(5, 30, 20, 0.055);
  --soft-surface-bg-2: rgba(5, 30, 20, 0.045);
  --map-bg: #e9f1ec;
  --popup-bg: #ffffff;
  --thumb-overlay: linear-gradient(180deg, transparent 42%, rgba(5, 30, 20, 0.42));
  --toggle-bg: rgba(255, 255, 255, 0.88);
  --toggle-active-bg: #07110d;
  --toggle-active-text: #f3f7f2;
  --marker-text: #ffffff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
}

body {
  overflow: hidden;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", sans-serif;
}

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

button {
  font: inherit;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 430px;
  height: 100dvh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
  padding: calc(10px + env(safe-area-inset-top)) 12px calc(76px + env(safe-area-inset-bottom));
  background: var(--app-bg);
  color: var(--text);
}

.weather-card {
  flex: 0 0 auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.weather-main {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.weather-actions {
  display: grid;
  gap: 7px;
  justify-items: end;
}

.theme-toggle {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--soft-surface-bg);
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.weather-temp-wrap {
  display: flex;
  align-items: center;
  min-height: 42px;
}

.weather-icon {
  display: none;
  width: 42px;
  height: 42px;
  margin-right: 2px;
}

.weather-icon[src] {
  display: block;
}

.weather-temp {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}

.weather-condition {
  margin-top: 3px;
  color: var(--soft);
  font-size: 0.9rem;
}

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

.weather-grid div {
  min-width: 0;
  padding: 9px 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: var(--soft-surface-bg-2);
}

.weather-grid span,
.meta-label {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.weather-grid strong {
  display: block;
  overflow: hidden;
  margin-top: 3px;
  font-size: 0.88rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.map-panel {
  position: relative;
  flex: 0 0 auto;
  height: clamp(300px, 50dvh, 470px);
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--map-bg);
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
  background: var(--map-bg);
}

.leaflet-container {
  font: inherit;
  background: var(--map-bg);
}

.leaflet-control-attribution {
  background: var(--toggle-bg) !important;
  color: var(--muted) !important;
}

.leaflet-control-attribution a {
  color: var(--soft) !important;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--popup-bg);
  color: var(--text);
  border: 1px solid var(--line);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
}

.leaflet-popup-content {
  margin: 10px 12px;
  font-size: 0.88rem;
}

.place-marker,
.current-marker {
  display: grid;
  place-items: center;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.place-marker {
  width: 30px;
  height: 30px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  background: var(--accent-2);
  color: var(--marker-text);
  font-size: 0.8rem;
  font-weight: 900;
  opacity: 0.72;
  transition: opacity 160ms ease, transform 160ms ease, background 160ms ease;
}

.place-marker.selected {
  background: var(--accent);
  opacity: 1;
  transform: scale(1.28);
}

.place-marker.dimmed {
  opacity: 0.36;
}

.current-marker {
  width: 24px;
  height: 24px;
  border: 3px solid #ffffff;
  background: #1e8cff;
}

.current-marker::after {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ffffff;
  content: "";
}

.location-button {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 500;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: var(--toggle-bg);
  color: var(--text);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36);
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  flex: 0 0 auto;
  margin-top: 10px;
}

.control-stack {
  display: grid;
  grid-template-columns: auto auto;
  gap: 7px;
  justify-items: end;
}

.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

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

.chip {
  flex: 0 0 auto;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: var(--soft-surface-bg);
  color: var(--soft);
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
}

.chip.active {
  border-color: rgba(53, 212, 164, 0.64);
  background: rgba(53, 212, 164, 0.16);
  color: #effff9;
}

.sort-control {
  display: grid;
  grid-template-columns: auto auto;
  gap: 7px;
  align-items: center;
  min-height: 38px;
  padding: 0 8px 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: var(--soft-surface-bg);
  color: var(--soft);
  font-size: 0.78rem;
  font-weight: 800;
}

.sort-control span {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
}

.sort-control select {
  min-height: 28px;
  max-width: 104px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: 0;
}

.sort-control option {
  background: var(--panel-2);
  color: var(--text);
}

.content {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  overflow: hidden;
}

.tiles {
  display: flex;
  height: 100%;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 2px 10px;
  scroll-padding: 2px;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

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

.list {
  display: none;
  height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0 1px 12px;
}

.list-mode .tiles {
  display: none;
}

.list-mode .list {
  display: block;
}

.place-card,
.itinerary-card,
.list-item {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background: var(--surface-bg);
  color: var(--text);
}

.place-card,
.itinerary-card {
  display: flex;
  flex: 0 0 min(82vw, 348px);
  flex-direction: column;
  min-height: 100%;
  overflow: hidden;
  text-align: left;
  scroll-snap-align: start;
}

.place-card {
  padding: 0;
  cursor: pointer;
}

.place-card.selected,
.list-item.selected {
  border-color: rgba(53, 212, 164, 0.86);
  box-shadow: inset 0 0 0 1px rgba(53, 212, 164, 0.46), 0 18px 46px rgba(0, 0, 0, 0.35);
}

.thumb {
  position: relative;
  min-height: 112px;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(119, 167, 255, 0.18), rgba(53, 212, 164, 0.12)),
    var(--panel-2);
}

.thumb img {
  width: 100%;
  height: 100%;
  min-height: 112px;
  object-fit: cover;
  opacity: 0.9;
}

.thumb::after {
  position: absolute;
  inset: 0;
  background: var(--thumb-overlay);
  content: "";
}

.card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 13px;
}

.place-topline,
.list-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.category {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.distance {
  flex: 0 0 auto;
  color: var(--soft);
  font-size: 0.82rem;
  font-weight: 800;
}

.subtle-line {
  overflow: hidden;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hours-block {
  display: grid;
  gap: 3px;
  margin-top: 9px;
  color: var(--soft);
  font-size: 0.8rem;
  line-height: 1.25;
}

.hours-block span {
  font-weight: 800;
}

.hours-block small {
  color: var(--muted);
  font-size: 0.7rem;
}

.detail-grid {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.detail-grid div {
  padding: 8px 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: var(--soft-surface-bg-2);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid strong {
  display: block;
  margin-top: 3px;
  color: var(--soft);
  font-size: 0.8rem;
  line-height: 1.25;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 9px;
}

.badge {
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.place-card h2,
.itinerary-card h2 {
  margin: 8px 0 0;
  font-size: 1.15rem;
  line-height: 1.16;
  letter-spacing: 0;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
  color: var(--soft);
  font-size: 0.86rem;
}

.status {
  margin-top: 10px;
  font-size: 0.9rem;
  font-weight: 800;
}

.status.open {
  color: var(--accent);
}

.status.soon {
  color: var(--warn);
}

.status.closed {
  color: var(--danger);
}

.status.unknown {
  color: var(--muted);
}

.notes {
  display: -webkit-box;
  overflow: hidden;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.list-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  width: 100%;
  min-height: 96px;
  margin-bottom: 10px;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.list-thumb {
  width: 72px;
  height: 76px;
  overflow: hidden;
  border-radius: 16px;
  background:
    linear-gradient(135deg, rgba(119, 167, 255, 0.18), rgba(53, 212, 164, 0.12)),
    var(--panel-2);
}

.list-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.list-copy {
  min-width: 0;
}

.list-copy h2 {
  overflow: hidden;
  margin: 4px 0 0;
  font-size: 1rem;
  line-height: 1.16;
  letter-spacing: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.list-copy .meta-row,
.list-copy .status {
  margin-top: 6px;
  font-size: 0.82rem;
}

.list-copy .subtle-line {
  margin-top: 5px;
  font-size: 0.78rem;
}

.list-copy .hours-block,
.list-copy .detail-grid {
  margin-top: 7px;
}

.list-copy .detail-grid div {
  padding: 7px 8px;
}

.list-notes {
  display: -webkit-box;
  overflow: hidden;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.3;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.itinerary-card {
  padding: 15px;
  background:
    linear-gradient(135deg, rgba(119, 167, 255, 0.28), rgba(53, 212, 164, 0.1)),
    rgba(12, 17, 26, 0.94);
}

.itinerary-type {
  width: fit-content;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  color: #e9f1ff;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.itinerary-card .subtitle {
  margin: 8px 0 0;
  color: var(--soft);
  font-weight: 800;
}

.itinerary-card .details {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.35;
}

.itinerary-list .subtitle,
.itinerary-list .details {
  color: var(--soft);
}

.route-options {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.route-options li {
  padding: 8px 9px;
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--soft);
  font-size: 0.84rem;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 14px;
}

.action-row a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 800;
  text-decoration: none;
}

.list-item.itinerary-list {
  display: block;
  padding: 13px;
  background:
    linear-gradient(135deg, rgba(119, 167, 255, 0.25), rgba(53, 212, 164, 0.09)),
    rgba(12, 17, 26, 0.94);
}

.list-item.itinerary-list h2 {
  margin: 8px 0 0;
  font-size: 1rem;
}

.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.view-toggle {
  position: fixed;
  right: max(12px, calc((100vw - 430px) / 2 + 12px));
  bottom: calc(10px + env(safe-area-inset-bottom));
  left: max(12px, calc((100vw - 430px) / 2 + 12px));
  z-index: 900;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  max-width: 406px;
  min-height: 54px;
  padding: 5px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: var(--toggle-bg);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(18px);
}

.view-toggle button {
  min-width: 0;
  min-height: 44px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0;
  cursor: pointer;
}

.view-toggle button.active {
  background: var(--toggle-active-bg);
  color: var(--toggle-active-text);
}

@media (max-height: 720px) {
  .app {
    padding-top: calc(8px + env(safe-area-inset-top));
  }

  .weather-card {
    padding: 11px;
  }

  .weather-grid {
    gap: 5px;
    margin-top: 9px;
  }

  .weather-grid div {
    padding: 7px 6px;
  }

  .map-panel {
    height: clamp(260px, 47dvh, 390px);
    margin-top: 8px;
  }

  .controls,
  .content {
    margin-top: 8px;
  }

  .thumb {
    min-height: 92px;
  }

  .thumb img {
    min-height: 92px;
  }
}

@media (min-width: 760px) {
  body {
    background: var(--body-bg);
  }

  .app {
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    border-left: 1px solid rgba(255, 255, 255, 0.08);
  }
}
