* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif; color: #1c2530; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { overflow: hidden; }
#map { position: absolute; inset: 0; }

#ui { position: absolute; inset: 0; display: flex; flex-direction: column; pointer-events: none; }
#ui > * { pointer-events: auto; }

#topCard {
  margin: 10px; padding: 10px 12px; background: #fff; border-radius: 16px;
  box-shadow: 0 6px 24px rgba(0,0,0,.12);
}
#editRoute { display:none; border:0; border-radius:10px; padding:8px 12px; color:#087d43; background:#ecf8f1; font-size:13px; font-weight:800; }
.compactBrand { display:none; align-items:center; gap:9px; color:#0a9d54; }
.compactBrand i { display:grid; place-items:center; width:28px; height:28px; border-radius:9px; background:#0a9d54; color:#fff; font-style:normal; font-size:16px; font-weight:800; box-shadow:0 3px 8px rgba(10,157,84,.2); }
.compactBrand div { display:flex; align-items:baseline; gap:7px; }
.compactBrand b { font-size:17px; letter-spacing:-.5px; }
.compactBrand span { font-size:12px; color:#7f8e87; font-weight:600; }
.routeFields { display:flex; align-items:center; gap:7px; }

.field {
  position: relative; display: flex; align-items: center; gap: 8px;
  flex:1 1 0; background: #f4f6f9; border-radius: 11px; padding: 0 9px; height: 42px;
}
.field .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.field.origin .dot { background: #0a9d54; }
.field.dest .dot { background: #ff4d4f; }
.field input { flex: 1; border: 0; background: transparent; font-size:14px; outline: none; height: 100%; min-width: 0; }
#locateBtn { display:grid; place-items:center; border:0; background:transparent; color:#0a9d54; width:25px; height:25px; border-radius:7px; flex:0 0 auto; }
#locateBtn svg { width:17px; height:17px; fill:currentColor; transform:rotate(-14deg); }
#swapBtn { width:30px; height:30px; border:0; border-radius:9px; background:#0a9d54; color:#fff; font-size:16px; line-height:1; flex:0 0 auto; }

.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.plates { display: flex; background: #f4f6f9; border-radius: 10px; padding: 3px; }
.plates button { border: 0; background: transparent; padding: 7px 10px; font-size: 13px; border-radius: 8px; color: #5b6573; }
.plates button.on { background: #0a9d54; color: #fff; font-weight: 700; }
#planBtn { flex: 1; border: 0; background: #0a9d54; color: #fff; font-size: 16px; font-weight: 700; height: 44px; border-radius: 12px; }
#planBtn:active { opacity: .85; }

.dd { position: absolute; top: 46px; left: 0; right: 0; background: #fff; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); z-index: 20; max-height: 240px; overflow: auto; display: none; }
.dd.show { display: block; }
.dd div { padding: 11px 12px; font-size: 14px; border-bottom: 1px solid #f0f2f5; }
.dd div:last-child { border-bottom: 0; }
.dd div small { color: #9aa3b2; margin-left: 6px; font-size: 12px; }
.dd div:active { background: #f4f6f9; }

#sheet {
  margin-top: auto; max-height: 62%; background: #fff; border-radius: 20px 20px 0 0;
  box-shadow: 0 -6px 24px rgba(0,0,0,.12); padding: 14px 14px 22px; overflow: auto;
}
.viewToggle { display:flex; gap:6px; margin:0 0 10px; padding:4px; border-radius:10px; background:#f2f5f2; }
.viewToggle[hidden] { display:none; }
.viewToggle button { flex:1; border:0; background:transparent; color:#718078; border-radius:8px; padding:9px 8px; font-size:13px; font-weight:700; }
.viewToggle button.on { background:#fff; color:#0a9d54; box-shadow:0 1px 5px rgba(0,0,0,.08); }
#sheet.mapMode { max-height:74px; min-height:74px; overflow:visible; padding-bottom:12px; }
#sheet.mapMode #baseline, #sheet.mapMode #cards, #sheet.mapMode #detail { display:none !important; }
#topCard.compact { margin:8px 10px; min-height:56px; padding:8px 12px; border-radius:15px; display:flex; align-items:center; justify-content:space-between; box-shadow:0 7px 20px rgba(27,50,39,.14); }
#topCard.compact .routeFields, #topCard.compact .row { display:none; }
#topCard.compact .compactBrand { display:flex; }
#topCard.compact #editRoute { display:block; }

@media (max-width: 380px) {
  .routeFields { gap:5px; }
  .field { padding:0 7px; }
  .field input { font-size:13px; }
  #swapBtn { width:28px; }
}

/* 手机输入框字体低于 16px 会触发 Safari 自动放大，导致横向溢出和错位。 */
@media (max-width: 600px) {
  #topCard { margin: max(10px, env(safe-area-inset-top)) 10px 10px; padding:10px; }
  .routeFields { gap:6px; min-width:0; }
  .field { min-width:0; padding:0 8px; }
  .field input { font-size:16px; }
  #swapBtn { width:34px; height:34px; border-radius:10px; }
  .row { gap:7px; }
  .plates { min-width:0; }
  .plates button { padding:7px 9px; font-size:14px; }
  #planBtn { min-width:0; font-size:16px; }
  .dd { max-height: min(38vh, 260px); position:fixed; left:10px; right:10px; top:auto; z-index:100; }
  .field:focus-within .dd { top:calc(env(safe-area-inset-top) + 126px); }
  #sheet { padding-bottom:calc(22px + env(safe-area-inset-bottom)); }
}
#baseline { display:none; }
#baseline b { color: #ff4d4f; }

#cards { display: flex; flex-direction: column; gap: 10px; }
.card { border: 2px solid #eef1f5; border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px; transition: .15s; }
.card.recommended { position:relative; min-height:108px; padding:35px 18px 16px; border:2px solid #e9edf2; border-radius:16px; background:#fff; gap:10px; }
.recommendLabel { position:absolute; top:0; left:0; padding:5px 9px; border-radius:11px 0 9px 0; background:#0a9d54; color:#fff; font-size:11px; font-weight:700; }
.card.on { border-color: #e9edf2; background: #fff; }
.card .meta { flex: 1; min-width:0; }
.card .meta .route { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:18px; color:#1c2530; font-weight:800; line-height:1.28; margin-bottom:4px; }
.freeNote { color:#667386; font-size:13px; line-height:1.35; }
.card .save { color:#ff4d4f; font-weight:800; font-size:19px; white-space:nowrap; margin-left:8px; }

@media (max-width: 380px) {
  .card.recommended { padding:33px 14px 14px; }
  .card .meta .route { font-size:16px; }
  .freeNote { font-size:12px; }
  .card .save { font-size:18px; }
}
.card .tag { font-size: 11px; padding: 2px 7px; border-radius: 6px; background: #fff4e5; color: #d9881a; margin-left: 6px; }

#detail { margin-top: 14px; display: none; }
#detail.show { display: block; }
.stepTitle { margin:0 0 7px; font-size:13px; color:#728078; font-weight:700; }
.steps { list-style: none; margin: 0 0 12px; padding: 0; }
.steps li { position: relative; padding: 9px 0 9px 34px; font-size: 15px; font-weight:600; border-left: 2px solid #e3e7ee; margin-left: 13px; line-height:1.35; }
.steps li:last-child { border-left-color: transparent; }
.steps li span { position:absolute; left:-14px; top:8px; display:grid; place-items:center; width:25px; height:25px; border-radius:50%; background:#c7ced9; color:#fff; font-size:12px; font-weight:800; }
.steps li.enter span,.steps li.exit span { background:#0a9d54; }.steps li.uturn span { background:#ff9f1a; }

.wp { background: #f4f6f9; border-radius: 10px; padding: 9px 10px; font-size: 13px; color: #5b6573; margin-bottom: 12px; }
.wp b { color: #0a9d54; }

.navBtns { display: flex; gap: 10px; }
.navBtns button { flex: 1; border: 0; border-radius: 12px; height: 48px; font-size: 15px; font-weight: 700; color: #fff; }
.navBtns .amap { background: #0a9d54; }
.navBtns .baidu { background: #2e58ff; }
.navBtns .copy { background: #6b7480; flex: 0 0 64px; }

#toast { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); background: rgba(0,0,0,.82); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px; max-width: 80%; display: none; z-index: 50; text-align: center; }
#loading { position: fixed; left: 50%; top: 50%; transform: translate(-50%,-50%); background: rgba(10,157,84,.95); color: #fff; padding: 14px 22px; border-radius: 14px; font-size: 15px; font-weight: 700; display: none; z-index: 40; }
