  :root {
    --blue: #1a73e8;
    --blue-dark: #1765cc;
    --text: #202124;
    --text-secondary: #5f6368;
    --border: #dadce0;
    --surface: #ffffff;
    --hover: #f1f3f4;
    --green: #0f9d58;
    --red: #ea4335;
  }
  * { box-sizing: border-box; }
  html, body {
    margin: 0; height: 100%;
    font-family: Gudea, Roboto, Arial, -apple-system, "Segoe UI", sans-serif;
    color: var(--text);
  }
  #map { position: absolute; inset: 0; }
  button, input, textarea, select { font-family: inherit; }

  /* ---------- Search pill ---------- */
  #search-card {
    position: absolute;
    top: 12px; left: 12px;
    width: 380px;
    max-width: calc(100% - 24px);
    z-index: 10;
  }
  .surface-row {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    display: flex;
    align-items: center;
    padding: 0 8px;
    height: 48px;
  }
  #search-card .surface-row { border-radius: 24px; }
  .icon-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border: none; background: transparent; border-radius: 50%;
    cursor: pointer; color: var(--text-secondary); flex-shrink: 0;
  }
  .icon-btn:hover { background: var(--hover); }
  .icon-btn svg { width: 20px; height: 20px; }

  #search-input, .directions-input input {
    border: none; outline: none; font-size: 15px; flex: 1;
    background: transparent; color: var(--text); min-width: 0;
    padding: 0 4px;
  }
  #search-input::placeholder, .directions-input input::placeholder { color: var(--text-secondary); }

  /* ---------- Dropdown / autocomplete ---------- */
  .dropdown {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    margin-top: 8px;
    overflow: hidden;
    max-height: 320px;
    overflow-y: auto;
  }
  .dropdown:empty { display: none; }
  .dropdown-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    font-size: 14px;
    border-bottom: 1px solid #f1f3f4;
  }
  .dropdown-item:last-child { border-bottom: none; }
  .dropdown-item:hover { background: var(--hover); }
  .dropdown-item .pin { color: var(--text-secondary); flex-shrink: 0; }
  .dropdown-item .label { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dropdown-item.muted { color: var(--text-secondary); cursor: default; }
  .dropdown-item.muted:hover { background: none; }
  .dropdown-item.add-new { color: var(--blue); font-weight: 500; }
  .dropdown-item.add-new .pin { color: var(--blue); }

  /* ---------- Add-place banner + form ---------- */
  #add-place-banner {
    position: absolute;
    top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 20;
    background: var(--text);
    color: #fff;
    border-radius: 20px;
    padding: 10px 10px 10px 18px;
    font-size: 14px;
    display: none;
    align-items: center;
    gap: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,.3);
  }
  #add-place-banner.visible { display: flex; }
  #add-place-banner button {
    background: rgba(255,255,255,.15);
    border: none; color: #fff; border-radius: 50%;
    width: 26px; height: 26px; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
  }
  #add-place-banner button svg { width: 14px; height: 14px; }

  #new-place-card {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    margin-top: 8px;
    padding: 14px;
    display: none;
  }
  #new-place-card.visible { display: block; }
  #new-place-card .label { font-size: 12px; color: var(--text-secondary); margin-bottom: 8px; }
  #new-place-card input {
    width: 100%; padding: 8px 10px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 6px; outline: none;
  }
  #new-place-card input:focus { border-color: var(--blue); }
  #new-place-card .actions { display: flex; gap: 8px; margin-top: 10px; justify-content: flex-end; }
  #new-place-card .actions button {
    border: none; border-radius: 20px; padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
  }
  #new-place-card .save-btn { background: var(--blue); color: #fff; }
  #new-place-card .save-btn:hover { background: var(--blue-dark); }
  #new-place-card .save-btn:disabled { background: #9aa0a6; cursor: default; }
  #new-place-card .cancel-btn { background: transparent; color: var(--text-secondary); }
  #new-place-card .cancel-btn:hover { background: var(--hover); }
  #new-place-category-picker {
    display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0;
  }
  .category-chip {
    border: 1px solid var(--border); border-radius: 14px;
    padding: 5px 10px; font-size: 12px; font-weight: 500;
    background: transparent; color: var(--text-secondary); cursor: pointer;
  }
  .category-chip:hover { background: var(--hover); }
  .category-chip.active { background: #e8f0fe; color: var(--blue); border-color: #e8f0fe; }

  /* ---------- Place card ---------- */
  #place-card {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    margin-top: 8px;
    padding: 14px;
    display: none;
  }
  #place-card.visible { display: block; }
  #place-card .row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
  #place-card .name { font-size: 15px; font-weight: 500; line-height: 1.3; }
  #place-card .directions-btn {
    margin-top: 12px;
    display: flex; align-items: center; gap: 8px;
    background: var(--blue); color: #fff; border: none;
    border-radius: 20px; padding: 8px 16px; font-size: 14px; font-weight: 500;
    cursor: pointer;
  }
  #place-card .directions-btn:hover { background: var(--blue-dark); }
  #place-card .directions-btn svg { width: 16px; height: 16px; fill: #fff; }

  /* ---------- Directions panel ---------- */
  #directions-card {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    display: none;
    overflow: visible;
  }
  #directions-card.visible { display: block; }

  .directions-header {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 8px 4px 12px;
  }
  .directions-header .title { font-size: 16px; font-weight: 500; flex: 1; }

  .directions-inputs { padding: 4px 12px 8px; position: relative; }
  .directions-input {
    display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--border);
    padding: 8px 4px;
  }
  .directions-input .dot {
    width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  }
  .directions-input .dot.start { background: var(--green); }
  .directions-input .dot.end { background: var(--red); border-radius: 2px; transform: rotate(45deg); }

  .swap-btn {
    position: absolute;
    right: 14px; top: 44px;
    width: 32px; height: 32px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-secondary);
    z-index: 2;
  }
  .swap-btn:hover { background: var(--hover); }
  .swap-btn svg { width: 16px; height: 16px; }

  /* ---------- trips history ---------- */
  #trips-toggle {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 11;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border: none; border-radius: 8px;
    background: var(--surface); color: var(--text-secondary);
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 1px 3px 1px rgba(60,64,67,.15);
    cursor: pointer;
  }
  #trips-toggle:hover { background: var(--hover); }
  #trips-toggle svg { width: 20px; height: 20px; }

  #trips-panel {
    display: none;
    position: absolute;
    top: 12px; right: 12px;
    z-index: 13;
    width: 340px; max-width: calc(100% - 24px);
    max-height: calc(100% - 24px);
    background: var(--surface);
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(60,64,67,.3), 0 2px 6px 2px rgba(60,64,67,.15);
    overflow: hidden;
    flex-direction: column;
  }
  #trips-panel.visible { display: flex; }
  .trips-header {
    display: flex; align-items: center;
    padding: 10px 8px 10px 16px;
    border-bottom: 1px solid var(--border);
  }
  .trips-title { flex: 1; font-size: 16px; font-weight: 500; }
  #trips-list { overflow-y: auto; }

  .trip-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
  }
  .trip-row:hover { background: var(--hover); }
  .trip-row:last-child { border-bottom: none; }
  .trip-mode { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
  .trip-body { flex: 1; min-width: 0; }
  .trip-ends {
    font-size: 14px; font-weight: 500;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .trip-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
  .trip-meta .abandoned { color: #c5221f; }
  .trip-delete {
    border: none; background: transparent; cursor: pointer;
    color: var(--text-secondary); padding: 4px; border-radius: 50%;
    flex-shrink: 0;
  }
  .trip-delete:hover { background: var(--border); }
  .trip-delete svg { width: 16px; height: 16px; display: block; }
  .trips-empty { padding: 24px 16px; text-align: center; font-size: 13px; color: var(--text-secondary); }

  /* ---------- dev-only simulation panel (?dev=1) ---------- */
  #sim-panel {
    position: absolute;
    top: 12px; right: 12px;
    z-index: 20;
    width: 210px;
    background: rgba(32,33,36,.92); color: #e8eaed;
    border-radius: 8px; padding: 10px 12px;
    font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  }
  .sim-title { font-size: 11px; text-transform: uppercase; opacity: .65; margin-bottom: 8px; }
  .sim-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
  .sim-row button {
    flex: 1; padding: 5px 8px; cursor: pointer;
    border: 1px solid #5f6368; border-radius: 4px;
    background: #3c4043; color: #e8eaed; font: inherit;
  }
  .sim-row button:hover { background: #494c50; }
  .sim-row input[type="range"] { flex: 1; min-width: 0; }

  /* ---------- live journey HUD ---------- */
  #start-journey {
    display: none;
    width: 100%;
    margin-top: 10px;
    padding: 10px;
    border: none; border-radius: 24px;
    background: var(--blue); color: #fff;
    font-size: 15px; font-weight: 500; cursor: pointer;
  }
  #start-journey:hover { background: var(--blue-dark); }
  #start-journey.visible { display: block; }

  #maneuver-banner {
    display: none;
    position: absolute;
    top: 12px; left: 50%; transform: translateX(-50%);
    z-index: 12;
    min-width: 280px; max-width: calc(100% - 24px);
    background: var(--blue); color: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 6px rgba(60,64,67,.4);
    padding: 12px 16px;
    align-items: center; gap: 14px;
  }
  #maneuver-banner.visible { display: flex; }
  #maneuver-banner.off-route { background: var(--red); }
  .maneuver-icon { font-size: 26px; line-height: 1; flex-shrink: 0; }
  .maneuver-distance { font-size: 19px; font-weight: 500; }
  .maneuver-road { font-size: 13px; opacity: .9; }

  #journey-sheet {
    display: none;
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 12;
    background: var(--surface);
    border-radius: 12px 12px 0 0;
    box-shadow: 0 -1px 3px rgba(60,64,67,.3);
    padding: 14px 16px 16px;
  }
  #journey-sheet.visible { display: block; }
  .journey-main { display: flex; align-items: baseline; gap: 10px; }
  .journey-eta { font-size: 24px; font-weight: 500; color: var(--green); }
  .journey-sub { font-size: 14px; color: var(--text-secondary); }
  .journey-progress {
    height: 4px; margin: 10px 0 12px;
    background: var(--border); border-radius: 2px; overflow: hidden;
  }
  .journey-progress-fill {
    height: 100%; width: 0%;
    background: var(--blue); transition: width .4s ease;
  }
  .journey-actions { display: flex; align-items: center; gap: 12px; }
  .journey-flag { flex: 1; font-size: 12px; color: var(--text-secondary); }
  #journey-stop {
    padding: 8px 20px;
    border: 1px solid var(--border); border-radius: 20px;
    background: var(--surface); color: var(--red);
    font-size: 14px; font-weight: 500; cursor: pointer;
  }
  #journey-stop:hover { background: var(--hover); }

  #resume-prompt {
    display: none;
    position: absolute;
    bottom: 16px; left: 50%; transform: translateX(-50%);
    z-index: 14;
    width: 360px; max-width: calc(100% - 24px);
    background: var(--surface);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(60,64,67,.4);
    padding: 14px 16px;
  }
  #resume-prompt.visible { display: block; }
  .resume-text { font-size: 14px; margin-bottom: 12px; }
  .resume-actions { display: flex; gap: 8px; justify-content: flex-end; }
  .resume-actions button {
    padding: 8px 18px; border-radius: 20px; cursor: pointer;
    font-size: 14px; font-weight: 500;
    border: none; background: var(--blue); color: #fff;
  }
  .resume-actions button.ghost {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
  }

  /* ---------- use-my-location + geo status ---------- */
  #use-my-location {
    display: flex; align-items: center; gap: 10px;
    width: calc(100% - 24px);
    margin: 0 12px 4px;
    padding: 8px 4px;
    border: none; background: transparent;
    color: var(--blue); font-size: 14px; font-weight: 500;
    cursor: pointer; border-radius: 6px; text-align: left;
  }
  #use-my-location:hover { background: var(--hover); }
  #use-my-location:disabled { color: var(--text-secondary); cursor: default; }
  #use-my-location svg { width: 18px; height: 18px; flex-shrink: 0; }

  #geo-status {
    display: none;
    margin: 0 12px 8px;
    padding: 8px 10px;
    font-size: 12px; line-height: 1.4;
    border-radius: 6px;
    background: var(--hover); color: var(--text-secondary);
  }
  #geo-status.error { background: #fce8e6; color: #c5221f; }

  .mode-tabs { display: flex; gap: 4px; padding: 4px 12px 10px; }
  .mode-tab {
    flex: 1;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 6px;
    border: none; border-radius: 20px;
    background: transparent; color: var(--text-secondary);
    cursor: pointer; font-size: 13px; font-weight: 500;
  }
  .mode-tab:hover { background: var(--hover); }
  .mode-tab.active { background: #e8f0fe; color: var(--blue); }
  .mode-tab svg { width: 18px; height: 18px; }

  #route-summary {
    margin: 0 12px 12px;
    padding: 12px;
    background: var(--hover);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
  }
  #route-summary .big { font-size: 20px; font-weight: 500; color: var(--text); }
  #route-summary .distance { font-size: 13px; }

  /* ---------- Map type control ---------- */
  #maptype-toggle {
    position: absolute;
    bottom: 24px; left: 12px;
    z-index: 10;
    background: var(--surface);
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.3);
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    color: var(--text);
  }
  #maptype-toggle:hover { background: var(--hover); }

