:root {
  color-scheme: light;
  --ink: #18211f;
  --muted: #66706d;
  --panel: rgba(255, 255, 255, 0.94);
  --line: rgba(24, 33, 31, 0.12);
  --bib: #d23f31;
  --selected: #246c64;
  --accent: #1f6f5b;
  --shadow: 0 18px 48px rgba(23, 32, 30, 0.2);
}

* { box-sizing: border-box; }
html, body, .app-shell, .map-stage, #map { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #eef3ef;
}

.map-stage { position: relative; overflow: hidden; }
#map { width: 100%; min-height: 100dvh; background: #dbe7df; }

.topbar {
  position: absolute;
  top: calc(14px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.eyebrow { margin: 0 0 2px; color: var(--muted); font-size: 11px; letter-spacing: 0; }
h1 { margin: 0; font-size: 18px; line-height: 1.2; letter-spacing: 0; }

.icon-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.locate-icon {
  display: block;
  width: 18px;
  height: 18px;
  margin: 0 auto;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
}
.locate-icon::before, .locate-icon::after {
  content: "";
  position: absolute;
  background: currentColor;
}
.locate-icon::before { left: 7px; top: -7px; width: 2px; height: 30px; }
.locate-icon::after { left: -7px; top: 7px; width: 30px; height: 2px; }

.controls {
  position: absolute;
  top: calc(86px + env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  z-index: 500;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}
.chip {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  padding: 9px 13px;
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(23, 32, 30, 0.12);
}
.chip.active { background: #17201e; color: #fff; }

.list-panel {
  position: absolute;
  left: 14px;
  bottom: calc(154px + env(safe-area-inset-bottom));
  z-index: 450;
  width: min(380px, calc(100vw - 28px));
  max-height: 33dvh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.search-row { padding: 10px; border-bottom: 1px solid var(--line); }
#searchInput {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.restaurant-list { overflow: auto; }
.restaurant-item {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  text-align: left;
  padding: 11px 12px;
  display: grid;
  gap: 5px;
}
.restaurant-item strong { font-size: 15px; line-height: 1.2; }
.restaurant-item span { color: var(--muted); font-size: 12px; line-height: 1.25; }

.detail-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 520;
  min-height: 132px;
  padding: 10px 16px calc(16px + env(safe-area-inset-bottom));
  background: #fff;
  border-radius: 8px 8px 0 0;
  box-shadow: 0 -16px 42px rgba(23, 32, 30, 0.18);
}
.sheet-handle {
  width: 44px;
  height: 4px;
  border-radius: 99px;
  background: #d4ddda;
  margin: 0 auto 10px;
}
.empty-state { margin: 26px 0; text-align: center; color: var(--muted); font-size: 14px; }
.detail-title { margin: 0 0 4px; font-size: 19px; letter-spacing: 0; }
.detail-meta { margin: 0 0 9px; color: var(--muted); font-size: 13px; line-height: 1.35; }
.detail-address { margin: 0 0 12px; color: var(--ink); font-size: 13px; line-height: 1.45; }
.actions { display: flex; gap: 10px; }
.action {
  flex: 1;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}
.action.primary { background: var(--accent); color: #fff; }
.action.secondary { background: #edf4f1; color: var(--ink); }

.marker-dot {
  width: 30px;
  height: 30px;
  border-radius: 50% 50% 50% 8px;
  transform: rotate(-45deg);
  border: 2px solid #fff;
  box-shadow: 0 6px 14px rgba(0,0,0,.24);
  display: grid;
  place-items: center;
}
.marker-dot span {
  transform: rotate(45deg);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}
.marker-dot.bib { background: var(--bib); }
.marker-dot.selected { background: var(--selected); }
.user-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #1b79ff;
  border: 3px solid #fff;
  box-shadow: 0 0 0 8px rgba(27, 121, 255, .18);
}
.toast {
  position: absolute;
  left: 50%;
  bottom: calc(158px + env(safe-area-inset-bottom));
  z-index: 700;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 10px 13px;
  background: rgba(24, 33, 31, .9);
  color: #fff;
  border-radius: 8px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.toast.show { opacity: 1; }

@media (min-width: 760px) {
  .topbar { left: 24px; right: auto; width: 440px; }
  .controls { top: calc(92px + env(safe-area-inset-top)); left: 24px; right: auto; }
  .list-panel { left: 24px; bottom: 24px; width: 390px; max-height: 48dvh; }
  .detail-sheet {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: 420px;
    border-radius: 8px;
  }
}
