:root {
  --bg: #ffffff;
  --bg-2: #f1f3f4;
  --fg: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --red: #ea4335;
  --green: #188038;
  --shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 2px 6px 2px rgba(60, 64, 67, 0.15);
  --shadow-s: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);
  --side: 408px;
}
:root[data-theme="dark"] {
  --bg: #202124;
  --bg-2: #303134;
  --fg: #e8eaed;
  --muted: #9aa0a6;
  --line: #3c4043;
  --blue: #8ab4f8;
  --blue-soft: #28354a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.6), 0 2px 6px 2px rgba(0, 0, 0, 0.4);
  --shadow-s: 0 1px 2px rgba(0, 0, 0, 0.6), 0 1px 3px 1px rgba(0, 0, 0, 0.35);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.4 "Google Sans", Roboto, system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--fg); background: var(--bg); overflow: hidden;
}
#map { position: fixed; inset: 0; }
button { font: inherit; color: inherit; }
svg { display: block; }

/* ---------- left column ---------- */
#side {
  position: fixed; z-index: 6; top: 0; left: 0; bottom: 0; width: var(--side); max-width: 100vw;
  background: var(--bg); box-shadow: var(--shadow); display: flex; flex-direction: column;
}
#searchCard {
  position: relative; display: flex; align-items: center; gap: 2px; height: 48px; margin: 10px 10px 8px;
  background: var(--bg); border-radius: 8px; box-shadow: var(--shadow-s); padding: 0 4px;
}
#searchCard input {
  flex: 1; min-width: 0; height: 46px; border: 0; outline: 0; background: transparent; color: var(--fg);
  font-size: 15px; padding: 0 6px;
}
#searchCard input::-webkit-search-cancel-button { display: none; }
.vsep { width: 1px; height: 28px; background: var(--line); margin: 0 4px; }
.icon-btn {
  flex: none; width: 40px; height: 40px; border: 0; border-radius: 50%; background: transparent; color: var(--muted);
  cursor: pointer; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg-2); }
.icon-btn.blue { color: var(--blue); }

body.dir-mode #searchCard { display: none; }

#panel { flex: 1; min-height: 0; overflow: auto; }
.view { padding: 4px 16px 24px; }
.view h2 { margin: 12px 0 6px; font-size: 22px; font-weight: 400; }
.view h3 { margin: 18px 0 4px; font-size: 12px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); margin: 0; }
.muted.small { font-size: 12px; margin-top: 22px; }
.view-head { display: flex; align-items: center; justify-content: space-between; }

.list { list-style: none; margin: 0 -16px; padding: 0; }
.list li { display: flex; gap: 14px; align-items: center; padding: 10px 16px; cursor: pointer; }
.list li:hover { background: var(--bg-2); }
.list .ico { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--bg-2); color: var(--muted); display: grid; place-items: center; }
.list .ico.red { background: var(--red); color: #fff; }
.list .txt { flex: 1; min-width: 0; }
.list .t { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .d { flex: none; font-size: 12.5px; color: var(--muted); }

/* search suggestions */
.suggest {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 6px 0; list-style: none;
  background: var(--bg); border-radius: 8px; box-shadow: var(--shadow); max-height: 60vh; overflow: auto;
}
.suggest li { display: flex; gap: 12px; align-items: center; padding: 8px 14px; cursor: pointer; }
.suggest li:hover, .suggest li.sel { background: var(--bg-2); }
.suggest .ico { color: var(--muted); flex: none; }
.suggest .t { font-size: 14.5px; }
.suggest .s { font-size: 12px; color: var(--muted); }
.suggest .none { color: var(--muted); cursor: default; }

/* place card */
.place h1 { margin: 14px 0 2px; font-size: 24px; font-weight: 400; line-height: 1.2; }
.place .sub { color: var(--muted); }
.actions { display: flex; gap: 10px; margin: 16px 0 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: 18px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); color: var(--blue); font-weight: 500;
}
.pill:hover { background: var(--blue-soft); }
.pill.fill { background: var(--blue); border-color: var(--blue); color: #fff; }
:root[data-theme="dark"] .pill.fill { color: #202124; }
.pill.fill:hover { filter: brightness(1.08); }
.info { margin: 10px -16px 0; border-top: 1px solid var(--line); }
.info div { display: flex; gap: 18px; align-items: center; padding: 12px 16px; cursor: default; }
.info .copy { cursor: pointer; }
.info div:hover.copy { background: var(--bg-2); }
.info svg { color: var(--blue); flex: none; }
.close-x { position: absolute; right: 8px; top: 8px; }
#viewPlace { position: relative; }

/* directions */
.dir-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 4px; }
.modes { display: flex; gap: 4px; }
.mode { width: 44px; height: 40px; border: 0; background: transparent; border-radius: 20px; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.mode:hover { background: var(--bg-2); }
.mode.on { background: var(--blue-soft); color: var(--blue); }
.dir-fields { display: flex; align-items: stretch; gap: 8px; margin-top: 4px; }
.dir-rail { flex: none; width: 20px; display: flex; flex-direction: column; align-items: center; padding: 18px 0; }
.rail-dot { width: 12px; height: 12px; border: 2.5px solid var(--muted); border-radius: 50%; }
.rail-line { flex: 1; width: 0; border-left: 3px dotted var(--muted); margin: 3px 0; min-height: 12px; }
.rail-pin { width: 12px; height: 12px; background: var(--red); border-radius: 50% 50% 50% 0; transform: rotate(-45deg); }
.dir-inputs { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.field { position: relative; }
.field input {
  width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg);
  font: inherit; font-size: 14.5px; padding: 0 12px; outline: none;
}
.field input:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
#swap { align-self: center; }
.dir-links { display: flex; gap: 16px; padding: 4px 0 2px 28px; }
.link { border: 0; background: transparent; color: var(--blue); cursor: pointer; padding: 4px 0; }
.link:hover { text-decoration: underline; }
#summary { margin: 14px -16px 0; padding: 14px 16px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#summary .big { font-size: 22px; color: var(--green); }
#summary .sm { color: var(--muted); margin-left: 8px; font-size: 15px; }
#summary .via { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
#err { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: #fce8e6; color: #c5221f; }
:root[data-theme="dark"] #err { background: #4a2523; color: #f28b82; }
#steps { list-style: none; margin: 0 -16px; padding: 0; }
#steps li { display: flex; align-items: center; gap: 16px; padding: 12px 16px; cursor: pointer; border-bottom: 1px solid var(--line); }
#steps li:hover { background: var(--bg-2); }
#steps .ic { flex: none; width: 28px; display: grid; place-items: center; color: var(--muted); }
#steps .tx { flex: 1; }
#steps .ds { flex: none; color: var(--muted); font-size: 12.5px; }

/* ---------- floating bits ---------- */
#chips {
  position: fixed; z-index: 5; top: 12px; left: calc(var(--side) + 14px); right: 80px; display: flex; gap: 8px;
  overflow-x: auto; scrollbar-width: none; padding: 2px 2px 6px;
}
#chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 14px 0 12px; border: 0; cursor: pointer;
  background: var(--bg); color: var(--fg); border-radius: 18px; box-shadow: var(--shadow-s); white-space: nowrap;
}
.chip svg { color: var(--blue); }
.chip:hover { background: var(--bg-2); }
.chip.on { background: var(--blue-soft); color: var(--blue); }
body.dir-mode #chips { display: none; }

#ctl { position: fixed; z-index: 5; right: 10px; bottom: 56px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
.fab, .zoom button, #layerBtn {
  border: 0; cursor: pointer; background: var(--bg); color: var(--muted); box-shadow: var(--shadow-s);
}
.fab { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; }
.zoom { display: flex; flex-direction: column; background: var(--bg); border-radius: 8px; box-shadow: var(--shadow-s); overflow: hidden; }
.zoom button { width: 40px; height: 40px; display: grid; place-items: center; box-shadow: none; }
.zoom button + button { border-top: 1px solid var(--line); }
.fab:hover, .zoom button:hover { background: var(--bg-2); }

#layerBtn {
  position: fixed; z-index: 5; left: calc(var(--side) + 14px); bottom: 26px; width: 72px; height: 72px; border-radius: 8px;
  padding: 0; overflow: hidden; display: flex; flex-direction: column; align-items: stretch; color: #fff;
}
#layerBtn .thumb { flex: 1; background: #242f3e; }
:root[data-theme="dark"] #layerBtn .thumb { background: #e8e6df; }
#layerBtn span:last-child { background: var(--bg); color: var(--fg); font-size: 12px; text-align: center; padding: 3px 0 4px; }

#ctx {
  position: fixed; z-index: 30; min-width: 220px; padding: 6px 0; background: var(--bg); border-radius: 8px; box-shadow: var(--shadow);
}
#ctx button { display: block; width: 100%; text-align: left; padding: 9px 16px; border: 0; background: transparent; cursor: pointer; }
#ctx button:hover { background: var(--bg-2); }
#ctx .hd { padding: 6px 16px 8px; color: var(--muted); font-size: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

#toast {
  position: fixed; z-index: 40; left: 50%; bottom: 28px; transform: translateX(-50%); background: #323232; color: #fff;
  padding: 10px 18px; border-radius: 4px; box-shadow: var(--shadow);
}

/* markers */
.pin { width: 28px; height: 38px; cursor: pointer; filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35)); }
.dot-pin { width: 16px; height: 16px; border-radius: 50%; background: var(--red); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45); cursor: pointer; }
.dot-pin.on { transform: scale(1.35); }
.origin-pin { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid #5f6368; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.me-pin { width: 18px; height: 18px; border-radius: 50%; background: #4285f4; border: 3px solid #fff; box-shadow: 0 0 0 6px rgba(66, 133, 244, 0.25); }

.maplibregl-ctrl-bottom-right { bottom: 0; }

/* ---------- small screens ---------- */
@media (max-width: 720px) {
  :root { --side: 100vw; }
  #side { bottom: auto; max-height: 62vh; border-radius: 0 0 16px 16px; }
  body.v-home #panel { display: none; }
  #chips { top: 68px; left: 8px; right: 8px; }
  body:not(.v-home) #chips { display: none; }
  #layerBtn { left: 10px; bottom: 26px; width: 56px; height: 56px; }
  #layerBtn span:last-child { font-size: 11px; }
  #ctl { bottom: 40px; }
}

/* add a place form */
#addForm label { display: block; margin-top: 12px; font-size: 12px; color: var(--muted); }
#addForm input, #addForm select, #addForm textarea {
  display: block; width: 100%; margin-top: 4px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--fg); font: inherit; font-size: 14.5px; outline: none;
}
#addForm textarea { resize: vertical; }
#addForm input:focus, #addForm select:focus, #addForm textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
#addErr { margin-top: 12px; padding: 10px 12px; border-radius: 8px; background: #fce8e6; color: #c5221f; }
:root[data-theme="dark"] #addErr { background: #4a2523; color: #f28b82; }
.info a { color: var(--blue); text-decoration: none; }
.info a:hover { text-decoration: underline; }

/* brand */
.brand-row { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; }
.brand-row img { border-radius: 11px; box-shadow: var(--shadow-s); }
.brand-row .b1 { font-size: 20px; font-weight: 650; letter-spacing: -0.2px; }
.brand-row .b2 { color: var(--muted); font-size: 13px; }

a.pill { text-decoration: none; }
