:root {
  --bg: #ffffff; --fg: #1d1d1f; --muted: #6e6e73; --line: #e3e3e8; --btn: #f2f2f7; --accent: #6c3fc4; --ok: #2e7d32;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --bg: #1c1c1e; --fg: #f2f2f7; --muted: #a1a1a6; --line: #3a3a3c; --btn: #2c2c2e; }
}
:root[data-theme="dark"] { --bg: #1c1c1e; --fg: #f2f2f7; --muted: #a1a1a6; --line: #3a3a3c; --btn: #2c2c2e; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 14px/1.4 -apple-system, system-ui, "PingFang SC", sans-serif; overflow: hidden; }
body { display: flex; flex-direction: column; height: 100dvh; }
header { display: flex; gap: 8px; padding: calc(env(safe-area-inset-top) + 8px) 12px 6px; border-bottom: 1px solid var(--line); }
header select { flex: 1; min-width: 0; }
select, button { font: inherit; color: var(--fg); background: var(--btn); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
button:active { opacity: .7; }
button.done { color: var(--ok); }
#status { font-size: 12px; color: var(--muted); padding: 2px 12px 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#map { flex: 1; min-height: 0; }
#fab { position: fixed; right: 12px; top: calc(env(safe-area-inset-top) + 96px); display: flex; flex-direction: column; gap: 8px; z-index: 2; }
#fab button { width: 44px; height: 44px; padding: 0; font-size: 20px; border-radius: 22px; background: var(--bg); box-shadow: 0 1px 4px rgba(0,0,0,.25); }
#btn-3d { font-size: 14px !important; font-weight: 600; }
#fab button.on { background: #1a73e8; color: #fff; border-color: #1a73e8; }
#panel { padding: 8px 12px calc(env(safe-area-inset-bottom) + 8px); border-top: 1px solid var(--line); max-height: 45dvh; overflow-y: auto; }
#gps { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row button { flex: 1; }
#hint { color: var(--muted); margin-top: 6px; }
#result .big { display: flex; justify-content: space-between; align-items: baseline; margin-top: 8px; }
#r-time { font-size: 24px; font-weight: 600; }
#r-dist { font-size: 16px; color: var(--muted); }
#result .sub { display: flex; gap: 12px; color: var(--muted); font-size: 13px; flex-wrap: wrap; }
#r-names { flex-basis: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#profile { width: 100%; height: 90px; display: block; margin: 6px 0; }
.speed { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.speed input { flex: 1; }
#r-model, #storage { font-size: 11px; color: var(--muted); margin-top: 4px; }
#toast { position: fixed; left: 16px; right: 16px; top: calc(env(safe-area-inset-top) + 140px); background: rgba(0,0,0,.8); color: #fff; padding: 10px 14px; border-radius: 10px; z-index: 3; text-align: center; }
#exag { position: fixed; left: 12px; top: calc(env(safe-area-inset-top) + 96px); z-index: 2; display: flex; align-items: center; gap: 8px;
  background: var(--bg); padding: 6px 10px; border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.25); font-size: 13px; }
#exag[hidden] { display: none; }
#exag input { width: 140px; }
#exag-val { min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
#map { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.wp { width: 26px; height: 26px; border-radius: 13px; color: #fff; font: 600 12px/26px system-ui, sans-serif; text-align: center;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: grab; }
.wp.start { background: #2e7d32; } .wp.end { background: #c62828; } .wp.via { background: #6c3fc4; }
.wp-pop .row { display: flex; gap: 6px; margin-top: 6px; }
.wp-pop button { padding: 4px 8px; font-size: 12px; }
#r-legs { font-size: 12px; color: var(--muted); margin-top: 4px; }
#r-legs .leg { display: inline-block; min-width: 3.2em; margin-right: .6em; color: var(--fg); }
#tips { font-size: 11px; color: var(--muted); margin-top: 4px; }
button:disabled { opacity: .4; }
button.busy { color: var(--accent); }
button.danger { color: #c62828; }
#mgr { position: fixed; inset: 0; z-index: 10; background: var(--bg); display: flex; flex-direction: column; }
#mgr[hidden] { display: none; }
.mgr-top { display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 8px) 12px 8px; border-bottom: 1px solid var(--line); }
.mgr-top b { flex: 1; font-size: 16px; }
.mgr-top label { font-size: 13px; color: var(--muted); }
#mgr-map { flex: 1; min-height: 0; }
.mgr-legend { font-size: 11px; color: var(--muted); padding: 4px 12px; }
.mgr-legend .sw { display: inline-block; width: 12px; height: 10px; vertical-align: -1px; margin: 0 2px 0 8px; border: 1.5px solid #6b7078; }
.mgr-legend .sw.none { background: rgba(138,143,152,.45); border-style: dashed; }
.mgr-legend .sw.ok { border-color: #1a73e8; }
.mgr-legend .sw.stale { border-color: #ef6c00; background: rgba(138,143,152,.2); }
#mgr-sheet { padding: 10px 12px; border-top: 1px solid var(--line); }
#mgr-sheet[hidden] { display: none; }
#mgr-sheet .head { display: flex; justify-content: space-between; align-items: baseline; }
#mgr-sheet .head b { font-size: 16px; }
#mgr-sheet .st { font-size: 13px; } .st.ok { color: #1a73e8; } .st.stale { color: #ef6c00; } .st.none { color: var(--muted); }
#mgr-sheet .info { font-size: 12px; color: var(--muted); margin-top: 3px; }
#mgr-sheet .row { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
#mgr-sheet .row button { flex: 1; min-width: 72px; }
#mgr-sheet button.on { background: #fff4e0; border-color: #ef6c00; }
#mgr-usage { font-size: 11px; color: var(--muted); padding: 0 12px calc(env(safe-area-inset-bottom) + 8px); }
.mgr-label { background: var(--bg); border-radius: 8px; padding: 3px 7px; box-shadow: 0 1px 4px rgba(0,0,0,.3); font-size: 12px; line-height: 1.25; cursor: pointer; text-align: center; white-space: nowrap; }
.mgr-label span { display: block; font-size: 11px; color: var(--muted); }
.mgr-label.none { opacity: .85; } .mgr-label.ok { border: 1.5px solid #1a73e8; } .mgr-label.stale { border: 1.5px solid #ef6c00; }
.mgr-label.busy span { color: var(--accent); }
#modal { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; padding: 16px; }
#modal[hidden] { display: none; }
#modal .box { background: var(--bg); border-radius: 14px; padding: 16px; max-width: 360px; width: 100%; }
#modal-text { white-space: pre-line; margin-bottom: 14px; }
#modal .row { display: flex; gap: 8px; } #modal .row button { flex: 1; }
#toast button { margin-left: 8px; padding: 4px 10px; background: #fff; color: #000; }
#mgr-map.compact .mgr-label { padding: 1px 5px; font-size: 10px; }
#mgr-map.compact .mgr-label span { display: none; }
#mgr-map.compact .mgr-label b { font-weight: 500; }
#exag.off { opacity: .6; }
