:root {
  --bg: #efe8dc;
  --ink: #1b1914;
  --muted: #655e52;
  --line: #e4d8c6;
  --paper: #fffcf7;
  --navy: #12263f;
  --navy-2: #1c3d66;
  --gold: #a8843d;
  --gold-2: #e8d7ae;
  --shadow: 0 12px 32px rgba(18, 38, 63, 0.16);
  --header-h: 64px;
  --dining: #b5522a;
  --hotel: #1e4f86;
  --leisure: #1d7a4d;
  --shopping: #8a6420;
  --panel-width: 320px;
  --map-size: 64dvh;
  --safe-b: env(safe-area-inset-bottom);
  color-scheme: light;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow: hidden;
}

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

button { cursor: pointer; }

header {
  height: var(--header-h);
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  padding-left: max(14px, env(safe-area-inset-left));
  padding-right: max(14px, env(safe-area-inset-right));
  background: var(--navy);
  color: #fff;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #0c1b2e;
  color: var(--gold-2);
  border: 1px solid rgba(232, 215, 174, 0.45);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.eyebrow {
  margin: 0;
  color: var(--gold-2);
  font-size: 11px;
  letter-spacing: 0.16em;
}

h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

#locate {
  flex: none;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(232, 215, 174, 0.7);
  background: transparent;
  color: var(--gold-2);
}

#locate:hover, #locate:focus-visible { background: rgba(255, 255, 255, 0.08); }

.layout {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  background: var(--paper);
  order: 1;
}

.map-wrap {
  position: relative;
  z-index: 1;
  order: -1;
  flex: 0 0 var(--map-size);
  min-height: 140px;
  overflow: hidden;
  background: #d7dee6;
}

.splitter {
  order: 0;
  flex: none;
  height: 18px;
  border: 0;
  padding: 0;
  background: #f3ecdf;
  cursor: row-resize;
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splitter::before {
  content: "";
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: #c9bba6;
}

.splitter:hover::before,
.splitter:focus-visible::before { background: var(--gold); }

body.is-dragging { user-select: none; }
body.is-dragging #map { pointer-events: none; }
body.is-dragging.is-row { cursor: row-resize; }
body.is-dragging.is-col { cursor: col-resize; }

.filters {
  position: relative;
  z-index: 5;
  flex: none;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--line);
  background: #fbf7f0;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1 1 132px;
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
}

.field select,
.menu-btn,
.check,
.menu-actions button,
.view-toggle button {
  min-height: 40px;
}

.field select,
.menu-btn {
  width: 100%;
  border: 1px solid var(--line);
  background-color: #fff;
  border-radius: 10px;
  padding: 0 28px 0 10px;
  color: var(--navy);
}

.menu { position: relative; }

.menu-btn {
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1.2 L6 6.2 L11 1.2' fill='none' stroke='%23655e52' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.menu-btn[aria-expanded="true"] {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(168, 132, 61, 0.18);
}

.menu-panel {
  position: absolute;
  z-index: 6;
  top: calc(100% + 6px);
  left: 0;
  width: max(240px, 100%);
  max-height: min(340px, 56vh);
  overflow: auto;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.menu-panel-end { left: auto; right: 0; }

.check-list { display: grid; gap: 2px; }

.check-list label {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-height: 36px;
  padding: 4px 2px;
  border-radius: 8px;
}

.check-list label:hover { background: #fbf7f0; }

.check-list .swatch { margin-top: 5px; flex: none; }

.check-list small { display: block; color: var(--muted); }

.menu-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 8px;
  background: #fff;
}

.menu-actions button,
.back,
.action,
.text-btn {
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  min-height: 40px;
  padding: 0 12px;
}

.menu-actions button:last-child,
.action.primary {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.check {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 140px;
  padding: 0 4px 8px;
  font-size: 14px;
  color: var(--ink);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  min-height: 36px;
  padding: 0 12px;
}

.chip[aria-pressed="true"] { color: #fff; border-color: transparent; }
.chip[data-category="dining"][aria-pressed="true"] { background: var(--dining); }
.chip[data-category="hotel"][aria-pressed="true"] { background: var(--hotel); }
.chip[data-category="leisure"][aria-pressed="true"] { background: var(--leisure); }
.chip[data-category="shopping"][aria-pressed="true"] { background: var(--shopping); }

.search { display: block; margin-top: 10px; }

.search input {
  width: 100%;
  min-height: 42px;
  border-radius: 12px;
  border: 1px solid var(--line);
  padding: 0 12px;
  background: #fff;
}

.origin-line { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.results { flex: 1; overflow: auto; min-height: 0; -webkit-overflow-scrolling: touch; }

.item, .list-card {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 12px 14px;
}

.item.active,
.list-card.active {
  background: #f6edd9;
  box-shadow: inset 4px 0 0 var(--gold);
}

.item.active h2 { color: var(--navy); }

.item-top, .detail-kicker {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.cat {
  display: inline-block;
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 12px;
  color: #fff;
  background: var(--navy);
}

.cat.dining { background: var(--dining); }
.cat.hotel { background: var(--hotel); }
.cat.leisure { background: var(--leisure); }
.cat.shopping { background: var(--shopping); }

.distance, .muted { color: var(--muted); font-size: 13px; }

.item h2, .detail h2, .list-card h2, .place-card h2 {
  margin: 4px 0 0;
  font-size: 16px;
  font-weight: 600;
}

.desc {
  margin: 4px 0 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.upcoming {
  display: inline-block;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: #7a5b1e;
  font-size: 12px;
}

.empty, .loading { padding: 22px 16px; color: var(--muted); }

.empty button { margin-top: 8px; }

.detail { padding: 12px 14px 24px; }

.back { margin-bottom: 10px; }

.detail h2 { font-size: 22px; line-height: 1.3; }

.address { margin: 8px 0; white-space: pre-wrap; }

.cards { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }

.cards span {
  background: #f3ecdf;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }

.action { text-decoration: none; display: inline-flex; align-items: center; }

.place-card .action { margin-top: 10px; }

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

.block h3 { margin: 0 0 6px; font-size: 16px; }

.terms {
  white-space: pre-wrap;
  color: var(--muted);
  font-size: 13px;
  margin-top: 8px;
}

.disclaimer {
  margin: 0;
  padding: 10px 14px calc(10px + var(--safe-b));
  color: var(--muted);
  font-size: 12px;
  border-top: 1px solid var(--line);
  background: #fbf7f0;
}

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

#search-here {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 2;
  min-height: 36px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--navy);
  color: #fff;
  box-shadow: var(--shadow);
}

.map-error {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 56px;
  z-index: 2;
  margin: 0;
  padding: 12px;
  border-radius: 12px;
  background: #fff8ee;
  color: #6b3a12;
  box-shadow: var(--shadow);
}

.legend {
  position: absolute;
  z-index: 2;
  left: 12px;
  bottom: 12px;
  display: flex;
  gap: 8px;
  margin: 0;
  padding: 6px 10px;
  list-style: none;
  background: rgba(255, 252, 247, 0.96);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(18, 38, 63, 0.14);
  font-size: 12px;
  color: var(--navy);
}

.legend li { display: flex; align-items: center; gap: 4px; }

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.7);
}

.swatch.dining { background: var(--dining); }
.swatch.hotel { background: var(--hotel); }
.swatch.leisure { background: var(--leisure); }
.swatch.shopping { background: var(--shopping); }

.place-card {
  position: absolute;
  z-index: 3;
  left: 12px;
  right: 12px;
  bottom: 72px;
  max-width: 380px;
  max-height: min(220px, 46%);
  overflow: auto;
  padding: 12px 36px 12px 14px;
  border-radius: 16px;
  background: rgba(255, 252, 247, 0.98);
  box-shadow: var(--shadow);
  border-top: 4px solid var(--pin, var(--navy));
}

.place-card h2 { margin-right: 0; }

.icon-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
}

.view-toggle {
  position: fixed;
  z-index: 6;
  right: max(12px, env(safe-area-inset-right));
  bottom: calc(12px + var(--safe-b));
  display: flex;
  padding: 4px;
  gap: 2px;
  background: #fff;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

body[data-view="split"] .view-toggle {
  top: calc(var(--header-h) + var(--map-size) - 56px);
  bottom: auto;
}

.view-toggle button {
  border: 0;
  background: transparent;
  border-radius: 999px;
  padding: 0 10px;
  color: var(--muted);
}

.view-toggle button[aria-pressed="true"] { background: var(--navy); color: #fff; }

.pin-html { width: 28px; height: 36px; line-height: 0; transform: translateY(2px); }
.pin-html.selected { width: 44px; height: 56px; }
.pin-html svg { width: 100%; height: 100%; display: block; }

.cluster-bubble {
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #f7f1e6;
  color: var(--navy);
  border: 2px solid var(--navy-2);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(18, 38, 63, 0.18);
}

.user-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #1a73e8;
  border: 2px solid #fff;
  box-shadow: 0 0 0 6px rgba(26, 115, 232, 0.28);
}

.noscript { padding: 16px; }

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

body[data-view="map"] .panel,
body[data-view="map"] .splitter { display: none; }
body[data-view="map"] .map-wrap { flex: 1 1 auto; order: 0; }
body[data-view="list"] .map-wrap,
body[data-view="list"] .splitter { display: none; }
body[data-view="list"] .panel { flex: 1; }

@media (max-width: 420px) {
  .legend { left: 8px; gap: 6px; padding: 5px 8px; font-size: 11px; }
  .view-toggle { right: 8px; }
  .view-toggle button { padding: 0 8px; }
}

@media (min-width: 960px) {
  .layout { flex-direction: row; }
  .panel {
    order: 0;
    flex: 0 0 var(--panel-width);
    width: var(--panel-width);
    border-right: 0;
  }
  .splitter {
    order: 0;
    width: 12px;
    height: auto;
    cursor: col-resize;
    background: #e7dfd2;
    border-left: 1px solid var(--line);
    border-right: 1px solid var(--line);
  }
  .splitter::before { width: 4px; height: 48px; }
  .map-wrap {
    order: 0;
    flex: 1 1 auto;
    min-width: 280px;
    width: auto;
  }
  .view-toggle { display: none; }
  .place-card {
    left: auto;
    right: 12px;
    bottom: 16px;
    width: min(360px, calc(100% - 240px));
    max-height: 240px;
  }
  .legend { bottom: 16px; }
  body[data-view="map"] .panel,
  body[data-view="map"] .splitter,
  body[data-view="list"] .map-wrap,
  body[data-view="list"] .splitter { display: flex; }
  body[data-view="list"] .map-wrap { display: block; }
}

button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
