:root {
  --ink: #102037;
  --muted: #66758a;
  --line: #e6eaf0;
  --paper: #ffffff;
  --canvas: #f4f7fb;
  --accent: #f15b43;
  --accent-deep: #d94631;
  --green: #1ca675;
  --navy: #0c1727;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); }
button, input { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { display: block; width: 20px; height: 20px; flex: none; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 22px; height: 22px; }

.app-shell, #mainScreen { width: 100%; height: 100dvh; overflow: hidden; position: relative; }
#map { position: absolute; inset: 0; background: #dce6dd; }
#map .amap-logo, #map .amap-copyright { display: none !important; }

.is-locked #mainScreen { filter: blur(7px) saturate(.92); }

.setup-dialog { width: min(380px, calc(100% - 40px)); padding: 26px 24px 24px; border-radius: 16px; color: var(--ink); background: var(--paper); text-align: left; }
.lock-brand { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 20px; padding: 0; background: none; box-shadow: none; }
.setup-dialog h2 { margin-bottom: 10px; font-size: 23px; letter-spacing: -.2px; }
.setup-copy-text { margin-bottom: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }
.eyebrow { margin: 0 0 7px; font-size: 10px; font-weight: 750; letter-spacing: 1.6px; color: var(--accent); }
h2, p { margin-top: 0; }
h2 { margin-bottom: 0; font-size: 22px; letter-spacing: 0; }
.setup-form { margin-top: 20px; display: grid; gap: 9px; }
.setup-form label { font-size: 12px; font-weight: 600; color: var(--muted); }
.passcode-field { position: relative; }
.passcode-field input { width: 100%; padding: 14px 46px 14px 15px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink); background: #f6f8fb; font-size: 19px; font-weight: 650; letter-spacing: 4px; text-transform: uppercase; font-variant-numeric: tabular-nums; }
.passcode-field input::placeholder { font-size: 13px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.passcode-field input:focus { outline: 2px solid rgba(28,166,117,.32); border-color: var(--green); background: #fff; }
.toggle-passcode { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; color: #97a3b3; background: transparent; }
.toggle-passcode:hover, .toggle-passcode.is-revealed { color: var(--green); background: #eef7f2; }
.field-hint { margin: 0; color: #97a3b3; font-size: 11px; }

.topbar { position: absolute; z-index: 2; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; display: flex; align-items: center; justify-content: space-between; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.brand-lockup { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px 8px 10px; border-radius: 999px; color: var(--ink); background: rgba(255,255,255,.86); backdrop-filter: blur(10px); box-shadow: 0 3px 14px rgba(12,23,39,.14); }
.brand-glyph { display: block; width: 22px; height: 22px; border-radius: 7px; }
.brand-name { font-size: 14px; font-weight: 620; letter-spacing: -.1px; }
.icon-button { width: 42px; height: 42px; display: grid; place-items: center; border: 0; border-radius: 50%; padding: 0; }
.icon-button.light { color: var(--ink); background: white; box-shadow: 0 4px 18px rgba(4,12,22,.15); }
.icon-button.light:hover .icon { color: var(--green); }

.sheet { position: absolute; z-index: 3; left: 0; right: 0; bottom: 68px; background: var(--paper); border-radius: 15px 15px 0 0; box-shadow: 0 -5px 25px rgba(16,32,55,.12); }
.plan-sheet { min-height: 298px; padding: 11px 20px 18px; }
.sheet-handle { width: 34px; height: 4px; margin: 0 auto 14px; border-radius: 3px; background: #dfe5ed; }
.sheet-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 17px; }
.status-chip, .count-label { color: var(--muted); font-size: 11px; }
.status-chip { padding: 5px 9px; color: #0f8a5c; background: #eaf7f1; border-radius: 999px; }
.route-fields { position: relative; padding: 1px 0; }
.route-field { position: relative; height: 45px; display: flex; align-items: center; gap: 11px; padding: 0 6px 0 4px; border-bottom: 1px solid var(--line); }
.route-field input { flex: 1; min-width: 0; height: 100%; border: 0; outline: 0; color: var(--ink); font-size: 14px; background: transparent; }
.route-field input::placeholder { color: #a4aeba; }
.route-point { z-index: 1; width: 11px; height: 11px; flex: 0 0 auto; border: 2px solid white; border-radius: 50%; box-shadow: 0 0 0 1px #9eabb9; }
.route-point.start { background: var(--green); box-shadow: 0 0 0 1px var(--green); }
.route-point.end { background: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.route-line { position: absolute; left: 9px; top: 34px; height: 23px; border-left: 1px dashed #afbac6; }
.clear-input { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 6px; color: #9aa6b6; background: transparent; }
.clear-input:hover { color: var(--ink); background: #f2f5f9; }
.pick-button { width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 7px; color: #6b7c92; background: #f2f5f9; }
.pick-button:hover { color: var(--green); background: #eaf7f1; }
.suggestions { position: absolute; z-index: 8; top: 91px; left: 0; right: 0; max-height: 218px; overflow: auto; padding: 5px 12px; border-radius: 6px; background: white; box-shadow: 0 9px 25px rgba(16,32,55,.2); }
.suggestion { width: 100%; padding: 11px 2px; text-align: left; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; }
.suggestion:last-child { border: 0; }
.suggestion strong, .suggestion small { display: block; }
.suggestion strong { font-size: 13px; font-weight: 650; }
.suggestion small { margin-top: 3px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.travel-modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 16px; }
.mode-button { height: 38px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: #fff; font-size: 12px; }
.mode-button.active { border-color: var(--green); color: var(--green); font-weight: 700; background: #eef7f2; }
.route-preview { display: grid; grid-template-columns: 1fr 1fr 1.46fr; align-items: center; gap: 10px; margin-top: 16px; padding-top: 15px; border-top: 1px solid var(--line); }
.route-preview > div { display: grid; gap: 3px; }
.route-preview span { font-size: 15px; font-weight: 750; }
.route-preview small, .trip-metrics span { color: var(--muted); font-size: 10px; }
.primary-button { min-height: 48px; padding: 0 17px; border: 0; border-radius: 5px; color: white; background: var(--accent); font-weight: 750; box-shadow: 0 5px 13px rgba(241,91,67,.24); }
.primary-button:hover { background: var(--accent-deep); }
.primary-button span { margin-left: 7px; font-size: 18px; }
.primary-button.compact { min-height: 40px; font-size: 12px; }

.picker-sheet { padding: 11px 20px 16px; max-height: min(44dvh, 380px); display: flex; flex-direction: column; }
.picker-targets { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-bottom: 14px; }
.picker-target { height: 34px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; font-size: 12px; }
.picker-target.active { border-color: var(--ink); color: var(--ink); font-weight: 700; background: #f8fafc; }
.picker-summary { display: flex; align-items: center; gap: 11px; padding: 12px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.picker-summary > div { min-width: 0; flex: 1; }
.picker-summary strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.picker-summary small { display: block; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.picker-hint { margin: 8px 0 0; color: #8c98a8; font-size: 11px; }
.picker-nearby { margin-top: 8px; overflow: auto; flex: 1; min-height: 0; }
.picker-nearby-title { margin: 0 0 2px; color: var(--muted); font-size: 10px; letter-spacing: 1px; }
.picker-nearby-item { display: block; width: 100%; padding: 7px 2px; text-align: left; border: 0; border-bottom: 1px solid var(--line); color: var(--ink); background: transparent; }
.picker-nearby-item:last-child { border: 0; }
.picker-nearby-item strong { display: block; font-size: 12px; font-weight: 650; }
.picker-nearby-item small { display: block; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 10px; }
.picker-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 9px; margin-top: 12px; }
.ghost-button { min-height: 40px; border: 1px solid var(--line); border-radius: 5px; color: var(--muted); background: #fff; font-size: 12px; }
.ghost-button:hover { color: var(--ink); }

.trip-panel { position: absolute; z-index: 3; left: 14px; right: 14px; bottom: 77px; }
.trip-card { padding: 16px; border-radius: 8px; color: white; background: var(--navy); box-shadow: 0 7px 26px rgba(12,23,39,.3); }
.trip-card-head { display: flex; justify-content: space-between; align-items: center; }
.live-indicator { display: flex; align-items: center; gap: 6px; color: #8ee3c3; font-size: 11px; font-weight: 700; }
.live-indicator::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #34cc93; box-shadow: 0 0 0 3px rgba(52,204,147,.16); }
.text-button { padding: 3px; border: 0; background: transparent; font-size: 12px; }
.danger { color: #ff967f; }
.next-instruction { display: flex; align-items: center; gap: 12px; margin: 16px 0 17px; }
.maneuver-icon { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 50%; color: #8ff0c4; background: rgba(28,166,117,.18); }
.next-instruction p { margin-bottom: 3px; font-size: 15px; font-weight: 650; }
.next-instruction small { color: #99aabd; font-size: 11px; }
.trip-metrics { display: grid; grid-template-columns: repeat(3, 1fr); padding: 13px 0; border-top: 1px solid #273952; border-bottom: 1px solid #273952; }
.trip-metrics div { display: grid; gap: 4px; padding-left: 11px; border-left: 1px solid #273952; }
.trip-metrics div:first-child { padding-left: 0; border-left: 0; }
.trip-metrics strong { font-size: 17px; }
.share-button { width: 100%; margin-top: 13px; padding: 9px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid #3b506e; border-radius: 8px; color: #cbd8e7; background: transparent; font-size: 12px; }
.share-button .icon { color: #78d8b3; }
.share-button:hover { border-color: #4e6a90; color: #fff; }

.sheet-toggle-row { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; padding-top: 13px; border-top: 1px solid var(--line); }
.toggle-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.toggle-label .icon { color: #97a3b3; }
.switch { position: relative; width: 46px; height: 27px; padding: 0; border: 0; border-radius: 999px; background: #dfe5ed; transition: background .18s ease; }
.switch .switch-knob { position: absolute; top: 3px; left: 3px; width: 21px; height: 21px; border-radius: 50%; background: #fff; box-shadow: 0 1px 4px rgba(12,23,39,.24); transition: transform .18s ease; }
.switch[aria-checked="true"] { background: var(--green); }
.switch[aria-checked="true"] .switch-knob { transform: translateX(19px); }
.switch.is-unsupported { opacity: .5; }
.trip-card-actions { display: inline-flex; align-items: center; gap: 4px; }
.wake-button { width: 28px; height: 28px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; color: #8ff0c4; background: rgba(255,255,255,.07); }
.wake-button[aria-pressed="false"] { color: #7d8ca1; }
.wake-button:hover { background: rgba(255,255,255,.14); }

.content-sheet { top: 93px; bottom: 68px; overflow: auto; padding: 11px 20px 22px; }
.history-list, .place-list { display: grid; gap: 10px; }
.history-item, .place-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.history-symbol, .place-symbol { width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 12px; color: #6b7c92; background: #f1f4f8; }
.history-symbol[data-mode="walking"] { color: #0f9d68; background: #eaf7f1; }
.history-symbol[data-mode="riding"] { color: #b8791a; background: #fdf3e3; }
.history-symbol[data-mode="driving"] { color: #3962a0; background: #e9f1ff; }
.place-symbol { color: #0f9d68; background: #eaf7f1; }
.history-main, .place-main { min-width: 0; flex: 1; }
.history-main strong, .place-main strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.history-main small, .place-main small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.item-action { display: grid; place-items: center; padding: 6px; border: 0; color: #456d99; background: transparent; font-size: 13px; }
.item-action.delete { color: #c08b83; }
.item-action.delete:hover { color: var(--accent); }
.empty-state { padding: 48px 15px; color: var(--muted); text-align: center; font-size: 13px; }

.bottom-nav { position: absolute; z-index: 5; left: 0; right: 0; bottom: 0; height: calc(65px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: rgba(255,255,255,.97); }
.nav-item { display: grid; place-content: center; justify-items: center; gap: 4px; border: 0; color: #94a0af; background: transparent; }
.nav-item small { font-size: 10px; }
.nav-item.active { color: var(--green); }

.toast { position: fixed; z-index: 20; left: 50%; bottom: 90px; transform: translate(-50%, 18px); max-width: calc(100% - 40px); padding: 10px 14px; border-radius: 4px; color: white; background: rgba(12,23,39,.94); opacity: 0; pointer-events: none; transition: .22s ease; font-size: 12px; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog { border: 0; box-shadow: 0 18px 50px rgba(10,22,38,.28); }
dialog::backdrop { background: rgba(9,19,33,.45); backdrop-filter: blur(3px); }
.share-dialog, .replay-dialog { width: min(420px, calc(100% - 32px)); padding: 27px; border-radius: 8px; color: var(--ink); }
.share-dialog h2, .replay-dialog h2 { margin-bottom: 9px; }
.share-dialog > p:not(.eyebrow) { color: var(--muted); font-size: 13px; line-height: 1.55; }
.dialog-close { position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 0; border-radius: 8px; color: #97a3b3; background: transparent; }
.dialog-close:hover { color: var(--ink); background: #f1f4f8; }
.share-url { display: flex; margin-top: 18px; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.share-url input { min-width: 0; flex: 1; padding: 10px; border: 0; outline: 0; color: var(--muted); font-size: 11px; }
.share-url button { width: 44px; display: grid; place-items: center; border: 0; color: var(--green); background: #eef7f2; }
.replay-stat-row { display: flex; gap: 14px; margin: 19px 0; color: var(--muted); font-size: 12px; }
.replay-stat-row span { padding-right: 14px; border-right: 1px solid var(--line); }
.replay-stat-row span:last-child { border: 0; }
#replayRange { width: 100%; accent-color: var(--accent); }
.replay-controls { display: flex; align-items: center; justify-content: space-between; margin-top: 15px; }
.replay-controls .primary-button { min-width: 76px; }
#replayTime { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

.map-location-dot { width: 22px; height: 22px; border: 5px solid white; border-radius: 50%; background: #2479e8; box-shadow: 0 1px 7px rgba(18,66,127,.36); }
.map-location-dot.replay-dot { background: #3962a0; }
.map-destination-pin { width: 25px; height: 25px; border: 4px solid white; border-radius: 50% 50% 50% 0; background: var(--accent); box-shadow: 0 2px 8px rgba(92,31,21,.35); transform: rotate(-45deg); }
.map-picker-pin { width: 26px; height: 26px; border: 4px solid white; border-radius: 50% 50% 50% 0; background: var(--green); box-shadow: 0 3px 10px rgba(12,60,44,.4); transform: rotate(-45deg); cursor: move; }

@media (min-width: 700px) {
  .plan-sheet { left: 24px; right: auto; bottom: 24px; width: 405px; border-radius: 10px; }
  .picker-sheet { left: 24px; right: auto; bottom: 24px; width: 405px; max-height: calc(100dvh - 48px); border-radius: 10px; }
  .content-sheet { left: 24px; right: auto; top: 85px; bottom: 24px; width: 405px; border-radius: 10px; }
  .trip-panel { left: 24px; right: auto; bottom: 24px; width: 405px; }
  .bottom-nav { left: auto; right: 22px; bottom: 22px; width: 190px; height: 55px; padding: 0; border: 0; border-radius: 7px; box-shadow: 0 6px 24px rgba(12,23,39,.15); }
}
