:root {
  --bg: #ffffff;
  --bg-soft: #f1f3f4;
  --fg: #1f2328;
  --muted: #5f6368;
  --line: #dadce0;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --walk-only: #e37400;
  --danger: #d93025;
  --start: #188038;
  --end: #d93025;
  --poi: #7b1fa2;
  --shadow: 0 2px 12px rgba(0, 0, 0, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--fg);
  background: #e8eaed;
}
h1 { font-size: 17px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h2 { font-size: 13px; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
button, select, input { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--bg-soft); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #1765cc; }
button.danger { color: var(--danger); border-color: #f4c7c3; }
button.link { border: 0; background: none; color: var(--accent); padding: 4px 0; }
.muted { color: var(--muted); font-size: 12px; }
.badge { font-size: 11px; font-weight: 600; background: #fef7e0; color: #b06000; border-radius: 4px; padding: 1px 6px; }
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; user-select: none; }
.check[hidden] { display: none; }

/* 分段按钮 */
.seg { display: flex; background: var(--bg-soft); border-radius: 10px; padding: 3px; gap: 3px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 8px; padding: 6px 0; }
.seg button.active { background: var(--bg); color: var(--accent); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }

/* 地图 */
#map { position: fixed; inset: 0; background: #e8eaed; }
.amap-info-content { font: inherit; }

/* ---------- 导航页 ---------- */
.nav-page .panel {
  position: fixed; top: 16px; left: 16px; z-index: 1000; width: 320px;
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow); padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
}
.nav-page .panel h1 { margin: 0; }
.od { display: flex; align-items: center; gap: 8px; }
.od-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field { display: flex; align-items: center; gap: 8px; background: var(--bg-soft); border-radius: 8px; padding: 0 10px; }
.field select { flex: 1; min-width: 0; border: 0; background: none; padding: 8px 0; outline: none; cursor: pointer; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot-start { background: var(--start); }
.dot-end { background: var(--end); }
.od-btns { display: flex; flex-direction: column; gap: 6px; }
.icon-btn { width: 36px; height: 36px; padding: 0; font-size: 18px; border-radius: 50%; flex: none; }
.icon-btn:disabled { opacity: .5; cursor: progress; }
.result { background: var(--bg-soft); border-radius: 10px; padding: 12px; color: var(--muted); }
.result.error { background: #fce8e6; color: var(--danger); }
.r-main { display: flex; align-items: baseline; gap: 10px; color: var(--fg); }
.r-main b { font-size: 22px; }
.r-sub { font-size: 12px; margin-top: 2px; }
.seg-sub { padding: 2px; }
.seg-sub button { font-size: 13px; padding: 4px 0; }
.seg[hidden] { display: none; }
.r-steps {
  list-style: none; margin: 8px 0 0; padding: 0; max-height: 28vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px; color: var(--fg); font-size: 13px;
}
.r-steps li { display: flex; align-items: center; gap: 8px; }
.k-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.k-dot.k-walk { background: #0f9d58; }
.k-dot.k-ride { background: var(--accent); }
.k-dot.k-push { background: var(--walk-only); }
.k-dot.k-pickup { background: #fff; border: 2px solid var(--accent); }
.k-name { flex: none; min-width: 5.5em; }
.k-val { margin-left: auto; color: var(--muted); white-space: nowrap; }
.r-sum { font-size: 12px; margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line); }
.r-note { font-size: 12px; margin-top: 6px; color: #b06000; }
.leg-label {
  white-space: nowrap; font-size: 12px; line-height: 20px; padding: 0 6px; border-radius: 10px;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); color: var(--fg); pointer-events: none;
}
.leg-label.k-walk { color: #0b7a43; }
.leg-label.k-ride { color: #1765cc; }
.leg-label.k-push { color: #b06000; }
.ev-icon {
  width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 2px solid var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .35);
}
.ev-park { border-color: #5f6368; color: #5f6368; }
.row { display: flex; justify-content: space-between; align-items: center; }

.nav-poi {
  width: 14px; height: 14px;
  background: var(--poi); border: 2px solid #fff; border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4); cursor: pointer;
}
.pin {
  width: 26px; height: 26px;
  border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .45);
}
.pin-start { background: var(--start); }
.pin-end { background: var(--end); }
.picker-title { font-weight: 600; margin-bottom: 8px; }
.picker-btns { display: flex; gap: 6px; }
.picker-btns button { padding: 4px 10px; }

@media (max-width: 640px) {
  .nav-page .panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto;
    border-radius: 16px 16px 0 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    gap: 10px;
  }
  .nav-page .panel h1 { font-size: 15px; }
}

/* ---------- 404 ---------- */
.notfound-page { background: var(--bg); }
.notfound { max-width: 420px; margin: 20vh auto 0; padding: 0 16px; text-align: center; }
.notfound h1 { justify-content: center; font-size: 22px; }
.btn-link { display: inline-block; margin-top: 12px; color: var(--accent); }

/* ---------- 编辑器 ---------- */
.editor-page #map { left: 320px; }
.sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; width: 320px; overflow-y: auto;
  background: var(--bg); border-right: 1px solid var(--line); padding: 16px;
  display: flex; flex-direction: column; gap: 16px;
}
.sidebar section { display: flex; flex-direction: column; gap: 8px; }
.tools { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tools button { padding: 8px 4px; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tools button.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
kbd { font: 11px/1 ui-monospace, Consolas, monospace; color: var(--muted); }
.hint { background: var(--accent-soft); color: #174ea6; border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.props { display: flex; flex-direction: column; gap: 8px; }
.props label:not(.check) { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.props input[type=text], .props input[type=number], .inline input {
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; color: var(--fg); background: var(--bg);
}
.prop-title { font-weight: 600; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; }
.btns a.btn {
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: inherit; text-decoration: none;
}
.btns a.btn:hover { background: var(--bg-soft); }
.inline { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.inline input { width: 90px; }
.status { margin-top: auto; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.status.error { color: var(--danger); }

.node-icon {
  width: 12px; height: 12px;
  background: #fff; border: 2px solid var(--accent); border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .8);
}
.node-icon.sel { background: var(--danger); border-color: #fff; box-shadow: 0 0 0 2px var(--danger); }
.node-icon.iso { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 0 4px rgba(217, 48, 37, .35); }
.node-icon.pick { border-color: var(--poi); box-shadow: 0 0 0 3px rgba(123, 31, 162, .35); }
.node-icon, .poi-icon, .vertex-handle, .mid-handle { touch-action: none; }
.vertex-handle {
  width: 11px; height: 11px; background: #fff; border: 2px solid var(--danger);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35); cursor: move;
}
.mid-handle {
  width: 10px; height: 10px; border-radius: 50%; background: rgba(217, 48, 37, .45);
  border: 1.5px solid #fff; cursor: copy;
}
.mid-handle:hover { background: var(--danger); }
.prop-sub { font-weight: 600; font-size: 13px; margin-top: 4px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.poi-icon {
  position: relative; width: 12px; height: 12px;
  background: var(--poi); border: 2px solid #fff; border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.poi-icon.sel { box-shadow: 0 0 0 3px var(--danger); }
.poi-label {
  position: absolute; left: 16px; top: -5px; white-space: nowrap; font-size: 12px; line-height: 18px;
  background: rgba(255, 255, 255, .9); color: var(--poi); padding: 0 4px; border-radius: 4px;
}

@media (max-width: 760px) {
  .sidebar { position: fixed; top: auto; bottom: 0; right: 0; width: auto; height: 45vh; border-right: 0; border-top: 1px solid var(--line); }
  .editor-page #map { left: 0; bottom: 45vh; }
}
