:root {
  --blue: #1a73e8;
  --text: #202124;
  --text-2: #5f6368;
  --text-3: #70757a;
  --line: #e8eaed;
  --hover: #f1f3f4;
  --green: #188038;
  --shadow: 0 2px 4px rgba(0, 0, 0, .2), 0 -1px 0 rgba(0, 0, 0, .02);
  --panel-w: 408px;
  font-family: Roboto, "Segoe UI", Arial, sans-serif;
  color: var(--text);
}
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; }
#map { position: absolute; inset: 0; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
.ic { width: 24px; height: 24px; fill: currentColor; display: block; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); }
.icon-btn.blue { color: var(--blue); }

/* ---------- search bar ---------- */
.searchbox {
  position: absolute; top: 12px; left: 12px; z-index: 3; width: calc(var(--panel-w) - 24px);
  background: #fff; border-radius: 24px; box-shadow: var(--shadow); overflow: hidden;
}
.searchbox.open { border-radius: 24px 24px 12px 12px; }
.search-bar { display: flex; align-items: center; height: 48px; padding: 0 4px 0 20px; }
.search-bar input { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 15px; background: transparent; }
.search-bar input::placeholder { color: var(--text-3); }
.divider { width: 1px; height: 24px; background: #dadce0; margin: 0 4px; }

.suggestions { list-style: none; margin: 0; padding: 8px 0; border-top: 1px solid var(--line); background: #fff; max-height: 60vh; overflow-y: auto; }
.sugg { display: flex; align-items: center; gap: 14px; padding: 8px 20px; cursor: pointer; }
.sugg.active { background: var(--hover); }
.sugg-ic { width: 32px; height: 32px; border-radius: 50%; background: var(--hover); color: var(--text-2); display: flex; align-items: center; justify-content: center; flex: none; }
.sugg-ic .ic { width: 18px; height: 18px; }
.sugg-text { min-width: 0; }
.sugg-name { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sugg-addr { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.sugg-msg { padding: 10px 20px; color: var(--text-2); font-size: 13px; }

/* ---------- side panel ---------- */
.sidebar {
  position: absolute; top: 0; left: 0; bottom: 0; width: var(--panel-w); z-index: 2;
  background: #fff; box-shadow: 0 0 20px rgba(0, 0, 0, .25); overflow-y: auto;
}
.place-view { padding: 76px 0 24px; }
.place-head { padding: 8px 24px 16px; }
.place-name { font-size: 22px; font-weight: 400; line-height: 28px; margin: 0; }
.place-type { color: var(--text-2); font-size: 14px; margin-top: 4px; }
.place-loading { color: var(--text-3); font-size: 13px; padding: 0 24px 12px; }

.actions { display: flex; justify-content: space-around; padding: 4px 12px 16px; border-bottom: 1px solid var(--line); }
.action { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 72px; color: var(--blue); font-size: 12px; font-weight: 500; }
.action-ic { width: 40px; height: 40px; border-radius: 50%; border: 1px solid #dadce0; display: flex; align-items: center; justify-content: center; }
.action-ic .ic { width: 20px; height: 20px; }
.action:hover .action-ic { background: #e8f0fe; }
.action.primary .action-ic { background: var(--blue); border-color: var(--blue); color: #fff; }
.action.primary:hover .action-ic { background: #1765cc; }

.info { list-style: none; margin: 0; padding: 8px 0; }
.info-row { display: flex; align-items: center; gap: 24px; padding: 12px 24px; font-size: 14px; line-height: 20px; }
.info-row.clickable { cursor: pointer; }
.info-row.clickable:hover { background: var(--hover); }
.info-ic { color: var(--blue); flex: none; }
.info-text { min-width: 0; overflow-wrap: anywhere; }
.info-text a { color: inherit; text-decoration: none; }
.info-text a:hover { text-decoration: underline; }

/* ---------- directions ---------- */
.dir-head { padding: 8px 12px 12px; border-bottom: 1px solid var(--line); box-shadow: 0 2px 4px rgba(0, 0, 0, .06); position: sticky; top: 0; background: #fff; z-index: 1; }
.dir-toprow { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.modes { display: flex; gap: 4px; margin: 0 auto; }
.mode { width: 56px; height: 32px; border-radius: 16px; display: flex; align-items: center; justify-content: center; color: var(--text-2); }
.mode.active { background: #e8f0fe; color: var(--blue); }
.mode .ic { width: 20px; height: 20px; }
.dir-inputs { display: flex; align-items: center; gap: 8px; }
.dir-rail { display: flex; flex-direction: column; align-items: center; width: 24px; padding-left: 8px; }
.rail-origin { width: 10px; height: 10px; border: 2px solid var(--text-2); border-radius: 50%; }
.rail-dots { width: 2px; height: 22px; margin: 4px 0; background: radial-gradient(circle, var(--text-3) 1px, transparent 1.5px) 0 0 / 2px 6px repeat-y; }
.rail-dest { color: #ea4335; }
.rail-dest .ic { width: 18px; height: 18px; }
.dir-fields { flex: 1; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.dir-fields input { height: 40px; box-sizing: border-box; padding: 0 12px; border: 1px solid #dadce0; border-radius: 8px; outline: 0; font-size: 14px; }
.dir-fields input:focus { border: 2px solid var(--blue); padding: 0 11px; }
.dir-sugg { margin: 8px -12px -12px; }

.routes { padding-bottom: 24px; }
.dir-msg { padding: 20px 24px; color: var(--text-2); font-size: 14px; }
.dir-msg.error { color: #d93025; }
.route-opt { display: flex; gap: 16px; padding: 16px 24px 16px 20px; border-left: 4px solid transparent; border-bottom: 1px solid var(--line); cursor: pointer; }
.route-opt:hover { background: #f8f9fa; }
.route-opt.selected { border-left-color: var(--blue); }
.ro-ic { color: var(--text-2); }
.ro-main { flex: 1; min-width: 0; }
.ro-via { font-size: 15px; font-weight: 500; }
.ro-note { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.ro-meta { text-align: right; flex: none; }
.ro-time { font-size: 15px; font-weight: 500; }
.ro-time.best { color: var(--green); }
.ro-dist { font-size: 13px; color: var(--text-3); margin-top: 4px; }
.steps-title { padding: 16px 24px 4px; font-size: 13px; font-weight: 500; color: var(--text-2); text-transform: uppercase; letter-spacing: .5px; }
.steps { list-style: none; margin: 0; padding: 0; }
.step { display: flex; gap: 20px; padding: 0 24px; cursor: pointer; }
.step:hover { background: #f8f9fa; }
.step-ic { color: var(--text-2); padding-top: 12px; flex: none; }
.step-body { flex: 1; padding: 12px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.step-text { font-size: 14px; line-height: 20px; }
.step-text b { font-weight: 500; }
.step-dist { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- map overlays ---------- */
.pin-card {
  position: absolute; left: 50%; bottom: 32px; transform: translateX(-50%); z-index: 2;
  display: flex; align-items: center; gap: 4px; padding: 6px 6px 6px 8px;
  background: #fff; border-radius: 12px; box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
  max-width: min(420px, calc(100% - 32px)); box-sizing: border-box;
}
.pin-open { display: flex; flex-direction: column; align-items: flex-start; text-align: left; min-width: 0; flex: 1; padding: 6px 10px; border-radius: 8px; }
.pin-open:hover { background: var(--hover); }
.pc-title { font-size: 14px; font-weight: 500; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pc-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.lang-chip {
  position: absolute; left: 12px; bottom: 24px; z-index: 1;
  display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 10px;
  background: #fff; border-radius: 18px; box-shadow: var(--shadow); font-size: 14px; color: var(--text);
}
.lang-chip .ic { width: 20px; height: 20px; color: var(--text-2); }
.lang-chip:hover { background: #f8f9fa; }

.ctx { position: absolute; z-index: 5; min-width: 220px; padding: 6px 0; background: #fff; border-radius: 8px; box-shadow: 0 2px 12px rgba(0, 0, 0, .3); }
.ctx button { display: block; width: 100%; text-align: left; padding: 9px 16px; font-size: 14px; }
.ctx button:hover { background: var(--hover); }
.ctx button.mono { font-variant-numeric: tabular-nums; color: var(--text-2); }
.ctx hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

.toast {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 6;
  background: #323232; color: #fff; padding: 12px 20px; border-radius: 6px; font-size: 14px; box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
}

/* markers */
.pin { width: 27px; height: 43px; cursor: pointer; }
.pin.small { transform-origin: bottom center; }
.pin.small svg { width: 22px; height: 35px; }
.origin-dot { width: 14px; height: 14px; border-radius: 50%; background: #fff; border: 3px solid var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); cursor: grab; }

/* MapLibre controls, Google-ish */
.maplibregl-ctrl-group { border-radius: 8px !important; box-shadow: 0 1px 4px rgba(0, 0, 0, .3) !important; }
.maplibregl-ctrl-group button { width: 40px; height: 40px; }
.maplibregl-ctrl-bottom-right { margin-bottom: 8px; }

/* wide screens: keep overlays clear of the side panel */
@media (min-width: 641px) {
  body:not([data-mode="browse"]) .lang-chip { left: calc(var(--panel-w) + 12px); }
  body:not([data-mode="browse"]) .maplibregl-ctrl-bottom-left { left: var(--panel-w); }
}

/* phones: side panel becomes a bottom sheet */
@media (max-width: 640px) {
  .searchbox { left: 8px; right: 8px; top: 8px; width: auto; }
  .sidebar {
    top: auto; right: 0; width: auto; height: 50vh; border-radius: 16px 16px 0 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, .2);
  }
  .sidebar::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: #dadce0; margin: 8px auto 0; }
  body[data-mode="directions"] .sidebar { height: 70vh; }
  .place-view { padding-top: 4px; }
  body:not([data-mode="browse"]) .lang-chip { display: none; }
  body:not([data-mode="browse"]) .maplibregl-ctrl-bottom-right { bottom: 50vh; }
  body[data-mode="directions"] .maplibregl-ctrl-bottom-right { bottom: 70vh; }
  .pin-card { bottom: 20px; }
}
