:root {
  color-scheme: light;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #15171c;
  --muted: #555b66;
  --faint: #8a8f99;
  --line: #e4e4df;
  --accent: #e4572e;
  --accent-soft: #fdeee9;
  --star: #f5a524;
  --star-soft: #fff4dc;
  --google: #1a73e8;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 18, 24, .05), 0 4px 16px rgba(16, 18, 24, .05);
}
/* Dark theme only via the map's theme switch (default is light, regardless of the OS setting) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1013;
  --surface: #181a1f;
  --text: #eef0f4;
  --muted: #a7acb6;
  --faint: #7d828d;
  --line: #2a2d34;
  --accent: #ff7a50;
  --accent-soft: #2c1b15;
  --star-soft: #2e2512;
  --google: #6ea8ff;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Layout: list panel on the left, map fills the rest. Phones: map on top, list below. Only the panel scrolls. */
html, body { height: 100%; }
body { overflow: hidden; }
.app { display: grid; grid-template-columns: minmax(400px, 500px) 1fr; height: 100vh; height: 100dvh; }
.panel { overflow-y: auto; overscroll-behavior: contain; border-right: 1px solid var(--line); background: var(--bg); }
.content { padding: 0 18px; }
.map { height: 100%; min-height: 0; background: var(--line); z-index: 0; }
@media (max-width: 860px) {
  /* Rows: map / grip / list. Scrolling the list down collapses the map (.collapsed) and slides the header up (.hide-top);
     only the grip brings the map back (set in app.js) */
  .app { grid-template-columns: 1fr; grid-template-rows: 38dvh auto 1fr; transition: grid-template-rows .3s ease; }
  .app.collapsed { grid-template-rows: 0dvh auto 1fr; }
  .app.dragging { transition: none; }
  .map { grid-row: 1; }
  .grip {
    grid-row: 2; display: flex; align-items: center; justify-content: center; gap: 10px; height: 26px;
    background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.08);
    cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; position: relative; z-index: 1;
  }
  .app.dragging .grip { cursor: grabbing; }
  .grip-bar { width: 44px; height: 5px; border-radius: 3px; background: var(--faint); }
  .grip-txt { display: none; font-size: 13px; font-weight: 600; color: var(--muted); }
  .app.collapsed .grip { height: 34px; }
  .app.collapsed .grip-txt { display: inline; }
  .panel { grid-row: 3; border-right: 0; }
  .content { padding: 0 14px; }
  .top { transition: transform .3s ease; }
  .app.hide-top .top { transform: translateY(-100%); }
}
.grip { display: none; }
@media (max-width: 860px) { .grip { display: flex; } }
@media (max-width: 860px) and (prefers-reduced-motion: reduce) {
  .app, .top { transition: none; }
}

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 18px 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
.logo {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 19px;
}
.brand small { display: block; font-size: 13px; font-weight: 400; color: var(--muted); letter-spacing: 0; }

.search { position: relative; }
.search input {
  width: 100%; height: 54px;
  padding: 0 48px 0 50px;
  border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 17px;
  box-shadow: var(--shadow);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.search input::placeholder { color: var(--faint); }
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon {
  position: absolute; left: 16px; top: 50%; width: 22px; height: 22px; transform: translateY(-50%);
  fill: none; stroke: var(--muted); stroke-width: 2.2; stroke-linecap: round;
}
.clear {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: var(--line); color: var(--muted); font-size: 14px; cursor: pointer;
}
.clear:hover { color: var(--text); }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions:has(button:not([hidden])) { margin-top: 10px; }
.ask, .gbtn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 0 16px; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 15px;
}
.ask { border: 0; background: linear-gradient(135deg, #6d5dfc, #e4572e); color: #fff; }
.ask:hover { filter: brightness(1.08); }
.gbtn { border: 1.5px solid var(--line); background: var(--surface); }
.gbtn:hover { border-color: var(--google); color: var(--google); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 15px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--surface);
  font-size: 15px; font-weight: 500; cursor: pointer; transition: border-color .15s;
}
.chip:hover { border-color: var(--muted); }
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.fav-chip { color: #a86a00; }
[data-theme="dark"] .fav-chip { color: var(--star); }
.chip.fav-chip.on { background: var(--star); border-color: var(--star); color: #1a1300; }

/* Toolbar: result count on its own line, controls below */
.bar { display: grid; gap: 10px; margin: 18px 0 12px; }
.count { margin: 0; font-size: 15px; color: var(--muted); }
.count b { color: var(--text); font-size: 20px; font-weight: 700; letter-spacing: -.01em; margin-right: 4px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.district, .locate {
  height: 40px; border: 1.5px solid var(--line); border-radius: 11px; background-color: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer;
}
.district {
  min-width: 140px; max-width: 180px; padding: 0 32px 0 12px;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: right 15px center, right 10px center; background-size: 5px 5px; background-repeat: no-repeat;
}
.locate { padding: 0 13px; white-space: nowrap; }
.locate:hover, .district:hover { border-color: var(--muted); }
.locate.on { border-color: var(--accent); color: var(--accent); }
.locate:disabled { opacity: .7; cursor: default; }
.sort { display: flex; margin-left: auto; background: var(--line); border-radius: 11px; padding: 3px; }
.sort button { border: 0; background: none; height: 34px; padding: 0 13px; border-radius: 9px; font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; }
.sort button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }

/* List */
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.item {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; transition: border-color .15s;
}
.item:hover { border-color: color-mix(in srgb, var(--muted) 45%, var(--line)); }
.item.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.head {
  display: flex; gap: 14px; width: 100%; padding: 14px; text-align: left;
  background: none; border: 0; cursor: pointer; align-items: flex-start;
}
.head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: var(--radius); }
.thumb {
  flex: none; width: 84px; height: 84px; border-radius: 12px; overflow: hidden;
  background: var(--accent-soft); display: grid; place-items: center; font-size: 38px;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.info { flex: 1; min-width: 0; }
.name { display: block; margin: 0; font-size: 17px; font-weight: 700; line-height: 1.3; letter-spacing: -.01em; }
.fav-mark { color: var(--star); }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 6px 0; font-size: 14px; color: var(--muted); }
.meta > span + span::before { content: "·"; margin-right: 8px; color: var(--faint); }
.meta > .rating + span::before { content: none; }
.rating {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px 1px 6px; border-radius: 7px;
  background: var(--star-soft); color: var(--text); font-weight: 700; font-size: 14px;
}
.rating svg { width: 15px; height: 15px; fill: var(--star); }
.summary {
  margin: 0; font-size: 14.5px; line-height: 1.5; color: var(--muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item.open .summary { -webkit-line-clamp: unset; color: var(--text); }
.chev { flex: none; align-self: center; width: 24px; height: 24px; stroke: var(--muted); fill: none; stroke-width: 2.2; transition: transform .25s; }
.item.open .chev { transform: rotate(180deg); }

/* Expandable details */
.more { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s ease; }
.item.open .more { grid-template-rows: 1fr; }
.more > div { overflow: hidden; }
.details { margin: 0 14px; padding: 14px 2px 16px; border-top: 1px solid var(--line); display: grid; gap: 12px; font-size: 15px; }
.row { display: flex; gap: 12px; align-items: flex-start; }
.row svg { flex: none; width: 20px; height: 20px; margin-top: 1px; stroke: var(--muted); fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.row a { text-decoration: none; color: var(--accent); font-weight: 500; }
.row a:hover { text-decoration: underline; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); }
.acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 4px; }
.cta, .fav {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 12px;
  font-weight: 600; font-size: 15px; text-decoration: none; cursor: pointer;
}
.cta { background: var(--accent); color: #fff; border: 0; }
.cta:hover { filter: brightness(1.06); }
.fav { border: 1.5px solid var(--line); background: var(--surface); }
.fav:hover, .fav.on { border-color: var(--star); color: #a86a00; background: var(--star-soft); }
[data-theme="dark"] .fav:hover, [data-theme="dark"] .fav.on { color: var(--star); }
.verified { font-size: 13px; color: var(--faint); }

/* AI + Google sections */
.ai, .google {
  margin: 16px 0 6px; padding: 16px; border-radius: var(--radius);
  border: 1.5px solid color-mix(in srgb, #6d5dfc 35%, var(--line));
  background: color-mix(in srgb, #6d5dfc 6%, var(--surface));
}
.google { border-color: color-mix(in srgb, var(--google) 35%, var(--line)); background: color-mix(in srgb, var(--google) 5%, var(--surface)); }
.ai-head, .g-head { display: flex; justify-content: space-between; align-items: center; }
.ai-title, .g-title { font-weight: 700; font-size: 16px; }
.ai-close { width: 34px; height: 34px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 15px; }
.ai-close:hover { background: var(--line); color: var(--text); }
.ai-answer { margin: 8px 0 14px; font-size: 15px; }
.reason { display: block; margin: 2px 0 6px; font-size: 14px; color: #5a49e8; }
[data-theme="dark"] .reason { color: #a99cff; }
.g-attr { margin: 10px 2px 0; font-size: 12px; color: var(--muted); font-family: Roboto, Arial, sans-serif; }
.g-note { margin: 4px 2px 12px; font-size: 14px; color: var(--muted); }
.divider { list-style: none; margin: 16px 2px 2px; font-size: 14px; font-weight: 700; color: var(--muted); }
.sentinel { text-align: center; color: var(--muted); font-size: 14px; padding: 22px 0; }
.empty { text-align: center; color: var(--muted); font-size: 15px; padding: 48px 12px; }
.foot { color: var(--faint); font-size: 13px; padding: 28px 0 32px; text-align: center; }

/* Map */
.leaflet-container { font: 14px/1.4 Inter, system-ui, sans-serif; background: var(--line); }
.leaflet-touch .leaflet-bar a, .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; font-size: 22px; }
.leaflet-tooltip.pin-tip { font-size: 14px; font-weight: 600; border-radius: 9px; padding: 5px 10px; }
/* Pins: white bubble with the place's food emoji; Google = blue ring, favourite = star, active = enlarged + filled */
.pin {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: #fff; border: 3px solid var(--accent); font-size: 18px; line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); transition: transform .15s;
}
.pin.g { border-color: var(--google); }
.pin:hover { transform: scale(1.12); }
.on > .pin { transform: scale(1.35); background: var(--accent); }
.on > .pin.g { background: var(--google); }
.fav-pin svg { display: block; width: 100%; height: 100%; fill: var(--star); stroke: #fff; stroke-width: 1.5; stroke-linejoin: round; filter: drop-shadow(0 2px 3px rgba(0,0,0,.45)); transition: transform .15s; }
.fav-pin:hover svg { transform: scale(1.12); }
.fav-pin.on svg { transform: scale(1.4); }
.me-dot { width: 20px; height: 20px; border-radius: 50%; background: #1a73e8; border: 3px solid #fff; box-shadow: 0 0 0 3px rgba(26,115,232,.35), 0 1px 4px rgba(0,0,0,.4); }
.theme-btn, .legend {
  border: 0; border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 1px 6px rgba(0,0,0,.3);
}
.theme-btn { min-height: 40px; padding: 0 14px; cursor: pointer; font-size: 14px; font-weight: 600; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; font-size: 13px; font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--accent); }
.legend i.g { border-color: var(--google); }
.legend i.me { background: #1a73e8; border: 2px solid #fff; box-shadow: 0 0 0 2px rgba(26,115,232,.4); }
.legend b { color: var(--star); font-size: 17px; line-height: 1; }
.fav-pop a { color: var(--accent); font-weight: 600; }
[data-theme="dark"] .leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(.95) contrast(.85) saturate(.6); }
[data-theme="dark"] .leaflet-bar a, [data-theme="dark"] .leaflet-control-attribution, [data-theme="dark"] .leaflet-popup-content-wrapper, [data-theme="dark"] .leaflet-popup-tip { background: var(--surface) !important; color: var(--muted) !important; border-color: var(--line) !important; }
[data-theme="dark"] .leaflet-control-attribution a { color: var(--text) !important; }
[data-theme="dark"] .leaflet-tooltip.pin-tip { background: var(--surface); color: var(--text); border-color: var(--line); }
[data-theme="dark"] .pin { background: #22252c; }

@media (max-width: 560px) {
  .thumb { width: 72px; height: 72px; font-size: 32px; }
  .head { padding: 12px; gap: 12px; }
  .name { font-size: 17px; }
  .summary { font-size: 15px; -webkit-line-clamp: 3; }
  .details { margin: 0 12px; font-size: 15.5px; }
  .chev { width: 22px; height: 22px; }
  .legend { font-size: 12px; gap: 4px 10px; padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .more, .chev, .pin, .fav-pin svg { transition: none; }
}
/* Phones: compact header (after the base rules so it wins) */
@media (max-width: 860px) {
  .top { padding: 12px 14px 10px; }
  .brand { margin-bottom: 10px; font-size: 16px; }
  .brand small { display: none; }
  .logo { width: 30px; height: 30px; font-size: 16px; border-radius: 9px; }
  .search input { height: 50px; }
  .chips { padding-top: 10px; }
  .bar { margin-top: 14px; }
}
