:root {
  color-scheme: light;
  --ink: #15211c;
  --muted: #66736f;
  --line: rgba(32, 48, 43, 0.14);
  --surface: rgba(255, 255, 255, 0.88);
  --solid: #ffffff;
  --soft: #eef5f1;
  --accent: #087f6f;
  --accent-strong: #056451;
  --sun: #f18f3b;
  --berry: #8b4acb;
  --rose: #d94f70;
  --shadow: 0 20px 55px rgba(31, 44, 38, 0.18);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans Thai", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  color: var(--ink);
  background: #dae8e2;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  width: 100vw;
  height: 100dvh;
  min-height: 620px;
  background:
    radial-gradient(circle at 16% 8%, rgba(241, 143, 59, 0.18), transparent 31%),
    linear-gradient(135deg, #edf6f1 0%, #d8e6e0 42%, #f7f1e7 100%);
}

.sidebar {
  position: relative;
  z-index: 900;
  min-width: 0;
  overflow: hidden;
  border-right: 1px solid var(--line);
  background: rgba(249, 252, 249, 0.92);
  backdrop-filter: blur(20px);
  transition:
    transform 180ms ease,
    border-color 180ms ease;
}

.sidebar-inner {
  display: flex;
  height: 100%;
  min-width: 320px;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
}

.sheet-handle {
  display: none;
}

.brand-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  gap: 14px;
  align-items: start;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 4vw, 2.65rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.subtitle {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.96rem;
  line-height: 1.55;
}

.icon-button,
.map-button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 10px 24px rgba(31, 44, 38, 0.1);
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

.icon-button:hover,
.map-button:hover {
  transform: translateY(-1px);
  border-color: rgba(8, 127, 111, 0.3);
  background: #ffffff;
}

.icon-button svg,
.map-button svg,
.source-note svg {
  width: 19px;
  height: 19px;
  stroke-width: 2.2;
}

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-grid > div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--solid);
}

.stat-grid span {
  display: block;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
}

.stat-grid small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-chip {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
  font-size: 0.86rem;
  font-weight: 700;
}

.filter-chip:hover,
.filter-chip.is-active {
  border-color: rgba(8, 127, 111, 0.32);
  color: #ffffff;
  background: var(--accent);
}

.place-list-wrap {
  min-height: 0;
  flex: 1;
  overflow: auto;
  padding-right: 4px;
}

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

.place-card {
  min-width: 0;
}

.place-card button {
  display: grid;
  width: 100%;
  grid-template-columns: 12px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 14px;
  color: inherit;
  text-align: left;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 10px 28px rgba(31, 44, 38, 0.08);
}

.place-card button:hover,
.place-card button:focus-visible,
.place-card.is-selected button {
  outline: none;
  border-color: rgba(8, 127, 111, 0.34);
  background: #ffffff;
}

.place-dot {
  width: 12px;
  height: 12px;
  margin-top: 5px;
  border: 2px solid #ffffff;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 111, 0.18);
}

.place-dot.park {
  background: #2e9b5f;
}

.place-dot.shopping {
  background: var(--sun);
  box-shadow: 0 0 0 3px rgba(241, 143, 59, 0.2);
}

.place-dot.culture {
  background: var(--berry);
  box-shadow: 0 0 0 3px rgba(139, 74, 203, 0.18);
}

.place-dot.landmark {
  background: var(--rose);
  box-shadow: 0 0 0 3px rgba(217, 79, 112, 0.18);
}

.place-name {
  display: block;
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.25;
}

.place-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.78rem;
}

.place-desc {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.source-note {
  display: flex;
  gap: 9px;
  align-items: center;
  border: 1px solid rgba(8, 127, 111, 0.16);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(232, 246, 240, 0.75);
  font-size: 0.8rem;
  line-height: 1.4;
}

.map-stage {
  position: relative;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

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

.search-panel {
  position: absolute;
  z-index: 800;
  top: 18px;
  left: 50%;
  width: min(620px, calc(100% - 32px));
  transform: translateX(-50%);
}

.search-box {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  border: 1px solid rgba(25, 36, 31, 0.14);
  border-radius: var(--radius);
  padding: 6px 7px 6px 16px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.search-box svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.search-box input {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 1rem;
}

.search-submit {
  min-height: 40px;
  border: 0;
  border-radius: var(--radius);
  padding: 0 16px;
  color: #ffffff;
  background: var(--accent);
  font-weight: 800;
}

.search-submit:hover {
  background: var(--accent-strong);
}

.search-results {
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.search-result {
  display: grid;
  width: 100%;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
  color: inherit;
  text-align: left;
  background: transparent;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover,
.search-result:focus-visible {
  outline: none;
  background: var(--soft);
}

.search-result strong {
  display: block;
  overflow-wrap: anywhere;
}

.search-result span {
  color: var(--muted);
  font-size: 0.8rem;
}

.map-actions {
  position: absolute;
  z-index: 760;
  right: 16px;
  bottom: 28px;
  display: grid;
  gap: 10px;
}

.sidebar-open {
  display: none;
}

.toast {
  position: absolute;
  z-index: 850;
  left: 50%;
  bottom: 24px;
  max-width: min(520px, calc(100% - 32px));
  transform: translate(-50%, 18px);
  border: 1px solid rgba(25, 36, 31, 0.12);
  border-radius: var(--radius);
  padding: 11px 14px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 170ms ease,
    transform 170ms ease;
}

.toast.is-visible {
  transform: translate(-50%, 0);
  opacity: 1;
}

.custom-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 3px solid #ffffff;
  border-radius: 50% 50% 50% 8px;
  color: #ffffff;
  background: var(--accent);
  box-shadow: 0 12px 22px rgba(21, 33, 28, 0.28);
  transform: rotate(-45deg);
}

.custom-marker span {
  display: block;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #ffffff;
}

.custom-marker.park {
  background: #2e9b5f;
}

.custom-marker.shopping {
  background: var(--sun);
}

.custom-marker.culture {
  background: var(--berry);
}

.custom-marker.landmark {
  background: var(--rose);
}

.user-marker {
  width: 18px;
  height: 18px;
  border: 4px solid #ffffff;
  border-radius: 999px;
  background: #267cff;
  box-shadow:
    0 0 0 7px rgba(38, 124, 255, 0.18),
    0 12px 24px rgba(21, 33, 28, 0.28);
}

.popup-card {
  min-width: 220px;
}

.popup-card h2 {
  margin: 0 0 6px;
  font-size: 1rem;
  line-height: 1.25;
}

.popup-card p {
  margin: 0 0 10px;
  color: var(--muted);
  line-height: 1.45;
}

.popup-meta {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.popup-card a {
  color: var(--accent);
  font-weight: 800;
  text-decoration: none;
}

.leaflet-control-zoom a,
.leaflet-control-layers {
  border: 0 !important;
  border-radius: var(--radius) !important;
  color: var(--ink) !important;
  box-shadow: 0 12px 28px rgba(31, 44, 38, 0.14) !important;
}

.leaflet-touch .leaflet-control-zoom a {
  width: 40px;
  height: 40px;
  line-height: 40px;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  border-radius: var(--radius);
  box-shadow: 0 16px 34px rgba(31, 44, 38, 0.18);
}

.leaflet-control-attribution {
  font-size: 0.68rem;
}

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

.app-shell.sidebar-collapsed .sidebar {
  border-color: transparent;
}

.app-shell.sidebar-collapsed .sidebar-inner {
  opacity: 0;
  pointer-events: none;
}

.app-shell.sidebar-collapsed .sidebar-open {
  display: inline-grid;
}

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

  .sidebar-inner {
    padding: 18px;
  }

  h1 {
    font-size: 2rem;
  }
}

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

  .app-shell,
  .app-shell.sidebar-collapsed {
    display: block;
    min-height: 100dvh;
  }

  .map-stage {
    height: 100dvh;
  }

  .sidebar {
    position: fixed;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    height: min(54dvh, 460px);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
  }

  .sidebar-inner {
    min-width: 0;
    padding: 16px;
    padding-top: 20px;
  }

  .sheet-handle {
    position: absolute;
    top: 8px;
    left: 50%;
    display: block;
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: rgba(21, 33, 28, 0.25);
    transform: translateX(-50%);
  }

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

  .subtitle,
  .source-note,
  .stat-grid {
    display: none;
  }

  h1 {
    font-size: 1.34rem;
    line-height: 1.1;
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 0.68rem;
  }

  .filter-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .filter-chip {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 11px;
    font-size: 0.82rem;
  }

  .place-list-wrap {
    overflow: auto;
  }

  .search-panel {
    top: 12px;
    width: calc(100% - 24px);
  }

  .search-box {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    min-height: 50px;
    padding-left: 13px;
  }

  .search-submit {
    min-height: 38px;
    padding: 0 12px;
  }

  .map-actions {
    right: 12px;
    bottom: calc(min(54dvh, 460px) + 24px);
  }

  .app-shell.sidebar-collapsed .sidebar {
    transform: translateY(calc(100% - 74px));
  }

  .app-shell.sidebar-collapsed .sidebar-inner {
    opacity: 1;
    pointer-events: auto;
  }

  .app-shell.sidebar-collapsed .filter-row,
  .app-shell.sidebar-collapsed .place-list-wrap {
    visibility: hidden;
  }

  .app-shell.sidebar-collapsed .sidebar-open {
    display: inline-grid;
  }

  .toast {
    bottom: 18px;
  }
}

@media (max-width: 430px) {
  .search-box {
    grid-template-columns: 20px minmax(0, 1fr) 42px;
    gap: 8px;
  }

  .search-submit {
    width: 42px;
    padding: 0;
    overflow: hidden;
    color: transparent;
  }

  .search-submit::before {
    content: "ไป";
    color: #ffffff;
  }

  .map-actions {
    bottom: calc(min(54dvh, 460px) + 18px);
  }
}
