:root {
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --route: #e11d48;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #ffffff;
  --map-bg: #f3f4f6;
  --road: #ffffff;
  --block: #e5e7eb;
  --block-line: #d1d5db;
  --store: #0f766e;
  --food: #f59e0b;
  --ent: #1d4ed8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f3f4f6; --muted: #9ca3af; --line: #374151; --bg: #111827;
    --map-bg: #1f2937; --road: #374151; --block: #2b3646; --block-line: #3b475a;
    --accent: #14b8a6; --accent-ink: #06201d;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column; height: 100dvh;
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

.bar { padding: 8px 12px 6px; padding-top: max(8px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); background: var(--bg); position: relative; z-index: 20; }
.fields { display: flex; align-items: flex-end; gap: 6px; }
.field { position: relative; flex: 1; min-width: 0; }
.field label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 2px; }
.field input {
  width: 100%; padding: 9px 10px; font-size: 16px; /* 16px stops iOS zoom-on-focus */
  border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
#swapBtn { flex: none; width: 36px; height: 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font-size: 18px; cursor: pointer; }

.suggest { position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 50vh; overflow-y: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.suggest li { padding: 9px 10px; border-radius: 8px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.suggest li:hover, .suggest li.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.suggest .tag { color: var(--muted); font-size: 12px; white-space: nowrap; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.chips button { border: 1px solid var(--line); background: var(--bg); color: var(--ink); border-radius: 999px; padding: 5px 11px; font-size: 13px; cursor: pointer; }
.chips button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips .ghost { border-style: dashed; color: var(--muted); }

main { position: relative; flex: 1; min-height: 0; background: var(--map-bg); }
#map { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
#map:active { cursor: grabbing; }
.map-bg { fill: var(--map-bg); }
.block { fill: var(--block); stroke: var(--block-line); stroke-width: .25; }
.road { stroke: var(--road); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.pin .dot { stroke: #fff; }
.pin.store .dot { fill: var(--store); }
.pin.food .dot { fill: var(--food); }
.pin.ent .bubble { fill: var(--ent); stroke: #fff; }
.pin.ent text { fill: #fff; font-weight: 700; text-anchor: middle; pointer-events: none; }
.pin .hit { fill: transparent; }
.lbl { fill: var(--ink); paint-order: stroke; stroke: var(--bg); stroke-linejoin: round; pointer-events: none; font-weight: 600; }
.route-case { fill: none; stroke: #fff; stroke-linecap: round; stroke-linejoin: round; opacity: .9; }
.route-line { fill: none; stroke: var(--route); stroke-linecap: round; stroke-linejoin: round; }
.mark circle { stroke: #fff; }
.mark.a circle { fill: #2563eb; }
.mark.b circle { fill: var(--route); }
.mark text { fill: #fff; font-weight: 800; text-anchor: middle; pointer-events: none; }
.sel-ring { fill: none; stroke: var(--route); }

.zoom { position: absolute; right: 10px; bottom: 10px; display: flex; flex-direction: column; gap: 6px; z-index: 5; }
.zoom button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 20px; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.15); }
#toast { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); background: #111827; color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 13px; z-index: 6; }

#sheet { flex: none; max-height: 40vh; overflow-y: auto; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
#sheet h2 { margin: 0 0 2px; font-size: 16px; }
#sheet p { margin: 4px 0; }
.big { font-size: 17px; font-weight: 700; }
.big b { color: var(--accent); }
.muted { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 10px; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--accent); color: var(--accent-ink); }
.btn.alt { background: transparent; color: var(--ink); border: 1px solid var(--line); }
#pickCard { padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px dashed var(--line); }
.legend { font-size: 12px; color: var(--muted); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 10px !important; }
.legend .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: -1px; }
.legend .dot.store { background: var(--store); } .legend .dot.food { background: var(--food); } .legend .dot.ent { background: var(--ent); }
.note { font-size: 12px; color: var(--muted); }
.chips .free { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-size: 13px; cursor: pointer; }
.chips .free input { width: 16px; height: 16px; accent-color: var(--accent); }
.tagp { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; vertical-align: 1px; }
.tagp.free { background: color-mix(in srgb, #16a34a 18%, transparent); color: #15803d; }
.tagp.paid { background: color-mix(in srgb, #f59e0b 22%, transparent); color: #b45309; }
