/* ============================================================
   行程规划 · 地图版 — Apple 风响应式样式（浅/深色主题）
   ============================================================ */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #1c1c1e;
  --text-2: #8e8e93;
  --line: rgba(0, 0, 0, .08);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --purple: #af52de;
  --red: #ff3b30;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
[data-theme="dark"] {
  --bg: #000000;
  --card: #1c1c1e;
  --text: #f2f2f7;
  --text-2: #8e8e93;
  --line: rgba(255, 255, 255, .1);
  --shadow: 0 1px 3px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro SC", "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.5; min-height: 100vh;
}

/* ---------- 顶栏 ---------- */
#topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; height: 52px; padding: 0 12px;
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.brand { flex: 1; text-align: center; font-size: 17px; font-weight: 600; letter-spacing: .5px; }
.icon-btn {
  width: 36px; height: 36px; border: none; border-radius: 50%;
  background: transparent; color: var(--blue); font-size: 22px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: none;
  transition: background .12s, transform .1s;
}
.icon-btn:active { background: var(--line); transform: scale(.92); }

/* ---------- 通用 ---------- */
#app { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page { max-width: 720px; margin: 0 auto; animation: fadein .25s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.card {
  background: var(--card); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow); margin-bottom: 12px;
}
.sec-title { font-size: 13px; font-weight: 600; color: var(--text-2); margin: 18px 4px 8px; text-transform: uppercase; letter-spacing: .5px; }
.muted { color: var(--text-2); font-size: 12px; font-weight: 400; }
.empty { text-align: center; color: var(--text-2); padding: 48px 0; font-size: 14px; }

.btn-primary {
  width: 100%; padding: 14px; border: none; border-radius: 16px;
  background: var(--blue); color: #fff; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s; letter-spacing: .3px;
}
.btn-primary:disabled { opacity: .35; cursor: default; }
.btn-primary:not(:disabled):active { transform: scale(.98); opacity: .85; }
.btn-ghost {
  padding: 14px; border-radius: 16px; border: 1.5px solid var(--line);
  background: transparent; color: var(--blue); font-size: 16px; font-weight: 600;
  cursor: pointer; transition: opacity .15s, transform .1s;
}
.btn-ghost:active { transform: scale(.98); opacity: .7; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 12px; margin-top: 20px; }
.btn-row .btn-primary, .btn-row .btn-ghost { flex: 1; }

/* ---------- 按钮 ---------- */
.mini-btn {
  height: 30px; padding: 0 14px; border: none; border-radius: 15px; flex: none;
  background: var(--line); color: var(--text); cursor: pointer;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  transition: opacity .12s, transform .1s;
}
.mini-btn:active { transform: scale(.95); opacity: .7; }
.mini-btn.icon { width: 30px; height: 30px; padding: 0; border-radius: 8px; font-size: 15px; }
.mini-btn.sm { height: 26px; padding: 0 10px; font-size: 12px; border-radius: 13px; }
.mini-btn.sm.icon { width: 26px; height: 26px; padding: 0; }
.mini-btn.primary { background: var(--blue); color: #fff; font-weight: 600; }
.mini-btn.danger { color: var(--red); background: color-mix(in srgb, var(--red) 8%, transparent); }
.mini-btn.danger:active { background: color-mix(in srgb, var(--red) 15%, transparent); }

/* ---------- 提示 ---------- */
#toast {
  position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 20px; border-radius: 20px;
  font-size: 14px; z-index: 300; max-width: 80vw; text-align: center;
  animation: fadein .2s ease;
}
#overlay {
  position: fixed; inset: 0; z-index: 200;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px;
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text); font-size: 15px;
}
#overlay[hidden] { display: none; }
.spin {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--blue);
  animation: rot .8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

.demo-banner {
  background: color-mix(in srgb, var(--orange) 12%, var(--card));
  color: var(--orange); font-size: 12.5px; padding: 10px 14px;
  border-radius: 12px; margin-bottom: 12px; line-height: 1.6;
}

/* ---------- 首页布局 ---------- */
.home-layout { display: grid; grid-template-columns: 400px 1fr; gap: 16px; align-items: start; }
.panel { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.map-wrap {
  position: relative; border-radius: var(--radius); overflow: hidden;
  min-height: 560px; box-shadow: var(--shadow); background: var(--card);
}
.map-hint {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 500;
  background: color-mix(in srgb, var(--card) 90%, transparent);
  backdrop-filter: blur(10px); color: var(--text-2); font-size: 12px;
  padding: 6px 14px; border-radius: 20px; white-space: nowrap;
}
.map-fallback { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--text-2); }

/* 搜索 */
.search-box { position: relative; }
#searchInput {
  width: 100%; padding: 13px 16px; border: none; border-radius: 14px;
  background: var(--card); box-shadow: var(--shadow); font-size: 15px;
  color: var(--text); outline: none;
}
#searchInput:focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); }
.tip-list {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 150;
  background: var(--card); border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.15);
  overflow: hidden; max-height: 320px; overflow-y: auto;
}
.tip-item { padding: 11px 16px; cursor: pointer; border-bottom: 1px solid var(--line); }
.tip-item:last-child { border-bottom: none; }
.tip-item:hover, .tip-item:active { background: var(--line); }
.tip-name { font-size: 14.5px; font-weight: 500; }
.tip-addr { font-size: 12px; color: var(--text-2); margin-top: 2px; }

/* 地点卡片 */
.stop-list { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding: 2px; }
.stop-card {
  background: var(--card); border-radius: 14px; padding: 12px 14px;
  box-shadow: var(--shadow); border: 1.5px solid transparent;
}
.stop-card.stop-start { border-color: color-mix(in srgb, var(--green) 50%, transparent); }
.stop-head { display: flex; align-items: center; gap: 10px; }
.stop-idx {
  width: 24px; height: 24px; border-radius: 50%; flex: none;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.stop-start .stop-idx { background: var(--green); }
.stop-info { flex: 1; min-width: 0; }
.stop-name { font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stop-addr { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-start {
  font-size: 10.5px; color: var(--green); border: 1px solid var(--green);
  padding: 1px 6px; border-radius: 8px; margin-left: 4px; vertical-align: 2px;
}
.stop-ctrl {
  display: flex; gap: 16px; align-items: center; margin-top: 10px;
  font-size: 13px; color: var(--text-2); flex-wrap: wrap;
}
.stop-ctrl span { display: flex; align-items: center; gap: 6px; }

/* 步进器 / 分段控件 / 输入 */
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--line); border-radius: 9px; padding: 2px; }
.stepper button {
  width: 26px; height: 26px; border: none; border-radius: 7px; background: var(--card);
  font-size: 15px; color: var(--blue); cursor: pointer;
}
.stepper b { min-width: 28px; text-align: center; font-size: 14px; color: var(--text); }
.stepper.sm button { width: 22px; height: 22px; font-size: 13px; }
.stepper.sm b { min-width: 22px; font-size: 13px; }

.cfg { display: flex; flex-direction: column; gap: 14px; margin: 18px 0; }
.cfg-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.cfg-row label { font-size: 15px; }
.date-input {
  border: none; border-radius: 10px; padding: 8px 10px; background: var(--line);
  color: var(--text); font-size: 14px; outline: none;
}
.segmented {
  display: flex; background: var(--line); border-radius: 10px; padding: 2px;
}
.segmented button {
  border: none; background: transparent; color: var(--text); font-size: 13.5px;
  padding: 7px 16px; border-radius: 8px; cursor: pointer; transition: all .15s;
}
.segmented button.seg-on { background: var(--card); box-shadow: var(--shadow); font-weight: 600; color: var(--blue); }
.num-input {
  width: 60px; border: none; border-radius: 8px; padding: 5px 8px;
  background: var(--line); color: var(--text); font-size: 13px; text-align: center; outline: none;
}
.num-input.sm { padding: 3px 6px; }

/* ---------- 地图 marker ---------- */
.leaflet-container { height: 100%; width: 100%; background: var(--card); }
.mk-dot {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2.5px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.mk-dot.mk-start { background: var(--green); }
.plan-map { height: 280px; border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow); }

/* ---------- 总览页 ---------- */
.hero-card {
  background: linear-gradient(135deg, var(--blue), #5856d6);
  border-radius: 20px; padding: 24px; color: #fff; margin-bottom: 16px;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--blue) 30%, transparent);
}
.hero-total { font-size: 40px; font-weight: 700; letter-spacing: -1px; }
.hero-sub { font-size: 13px; opacity: .85; margin: 4px 0 16px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.bar-name { width: 34px; opacity: .9; }
.bar-track { flex: 1; height: 8px; background: rgba(255,255,255,.25); border-radius: 4px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; transition: width .6s cubic-bezier(.16,1,.3,1); }
.bar-val { min-width: 52px; text-align: right; font-weight: 600; }
.stat-row { display: flex; gap: 10px; margin-top: 16px; }
.stat {
  flex: 1; background: rgba(255,255,255,.15); border-radius: 12px; padding: 10px;
  display: flex; flex-direction: column; align-items: center;
}
.stat b { font-size: 16px; }
.stat span { font-size: 11px; opacity: .8; }

.route-chain {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  background: var(--card); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); margin-bottom: 14px;
}
.chain-node { font-size: 13px; font-weight: 600; background: var(--line); padding: 5px 12px; border-radius: 14px; }
.chain-node:first-child { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.chain-node.origin { background: color-mix(in srgb, var(--green) 18%, transparent); color: var(--green); }
.chain-node.dest { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.chain-arrow { color: var(--text-2); font-size: 12px; }

.endpoint-row { display: flex; gap: 12px; margin-bottom: 14px; }
.endpoint { flex: 1; min-width: 0; }
.endpoint label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.ep-set { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 14px; font-weight: 500; }
.ep-set span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-box.sm input { padding: 8px 12px; font-size: 14px; }
.return-card { border: 1.5px solid var(--blue); }

.day-card { cursor: pointer; transition: transform .15s; }
.day-card:active { transform: scale(.985); }
.dc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.dc-date { font-size: 17px; font-weight: 700; }
.dc-date span { font-size: 12.5px; color: var(--text-2); font-weight: 400; margin-left: 8px; }
.dc-cost { font-size: 15px; font-weight: 600; color: var(--blue); }
.dc-row { font-size: 13.5px; color: var(--text); margin-top: 6px; line-height: 1.6; }
.dc-row.muted { color: var(--text-2); }
.dc-enter { font-size: 12px; color: var(--text-2); text-align: right; margin-top: 8px; }

/* ---------- 每日详情 ---------- */
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.ph-title { font-size: 22px; font-weight: 700; }
.ph-title span { display: block; font-size: 13px; color: var(--text-2); font-weight: 400; margin-top: 2px; }
.ph-cost { font-size: 18px; font-weight: 700; color: var(--blue); }

.time-bar { display: flex; gap: 16px; margin-bottom: 12px; }
.time-bar label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.time-input { font-size: 14px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: var(--card); font-variant-numeric: tabular-nums; }

.suggest-banner { display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--orange) 8%, var(--card)); border: 1px solid var(--orange); border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; }
.sb-text { flex: 1; min-width: 0; font-size: 13px; color: var(--text); line-height: 1.5; }

.timeline { position: relative; padding-left: 6px; }
.tl-item {
  display: flex; gap: 12px; background: var(--card); border-radius: 14px;
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .12s;
}
.tl-item:active { transform: scale(.985); }
.tl-item.transfer { cursor: default; }
.tl-item.transfer .tl-body { background: color-mix(in srgb, var(--blue) 5%, transparent); border-radius: 8px; }
.tl-item.transfer .tl-title { font-size: 13px; color: var(--text-2); }
.tl-item.transfer .tl-sub { font-size: 12px; }
.tl-transit { font-size: 12px; color: var(--text-2); margin-top: 6px; line-height: 1.6; padding: 6px 10px; background: color-mix(in srgb, var(--blue) 4%, transparent); border-radius: 8px; }
.tl-draggable { cursor: grab; }
.tl-draggable.dragging { opacity: 0.35; cursor: grabbing; }
.tl-draggable.drag-over { outline: 2px dashed var(--blue); outline-offset: -2px; }
.drag-handle { color: var(--text-2); font-size: 18px; padding: 0 2px; user-select: none; cursor: grab; line-height: 1; }
.tl-time { font-size: 12px; color: var(--text-2); min-width: 88px; padding-top: 3px; font-variant-numeric: tabular-nums; }
.tl-body { flex: 1; min-width: 0; }
.tl-title { font-size: 15px; font-weight: 600; }
.tl-sub { font-size: 12.5px; color: var(--text-2); margin-top: 4px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.tag-real { font-size: 10.5px; color: var(--green); border: 1px solid var(--green); padding: 0 5px; border-radius: 6px; }
.tag-mock { font-size: 10.5px; color: var(--orange); border: 1px solid var(--orange); padding: 0 5px; border-radius: 6px; }

/* ---------- 选项 / POI 列表 ---------- */
.opt-card { cursor: pointer; border: 1.5px solid transparent; }
.opt-card.opt-on { border-color: var(--blue); }
.oc-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.oc-title { font-size: 16px; font-weight: 700; }
.oc-time { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.oc-price { font-size: 17px; font-weight: 700; color: var(--blue); white-space: nowrap; }
.oc-sub { font-size: 12px; color: var(--text-2); margin-top: 8px; }
.seat-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.seat-chip {
  border: 1.5px solid var(--line); background: transparent; color: var(--text);
  font-size: 13px; padding: 7px 14px; border-radius: 18px; cursor: pointer;
  white-space: nowrap; flex-shrink: 0; transition: all .12s;
}
.seat-chip:active { transform: scale(.95); }
.seat-chip.seat-on { border-color: var(--blue); color: var(--blue); font-weight: 600; background: color-mix(in srgb, var(--blue) 8%, transparent); }

.poi-card { display: flex; align-items: center; gap: 12px; cursor: pointer; border: 1.5px solid transparent; }
.poi-card.opt-on { border-color: var(--blue); }
.poi-info { flex: 1; min-width: 0; }
.poi-name { font-size: 15px; font-weight: 600; }
.poi-addr { font-size: 12px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.poi-price { font-size: 14.5px; font-weight: 700; color: var(--blue); white-space: nowrap; }
.poi-add { font-size: 13px; color: var(--green); font-weight: 600; white-space: nowrap; }
.muted-card { color: var(--text-2); text-align: center; }

/* ---------- 总结页 ---------- */
.cost-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; }
.cost-row:last-child { border-bottom: none; }
.cost-row.total { font-weight: 700; font-size: 17px; }
.cost-row.total b { color: var(--blue); }
.mini-day { display: flex; justify-content: space-between; font-size: 14px; cursor: pointer; padding: 13px 16px; }
.mini-day b { color: var(--blue); }
.sug-row { font-size: 14px; padding: 8px 0; line-height: 1.65; border-bottom: 1px solid var(--line); }
.sug-row:last-child { border-bottom: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .home-layout { grid-template-columns: 1fr; }
  .map-wrap { order: -1; min-height: 42vh; max-height: 46vh; }
  #app { padding: 12px; }
  .hero-total { font-size: 32px; }
  .tl-time { min-width: 76px; }
  .stop-list { max-height: none; }
}
@media (max-width: 480px) {
  .hero-total { font-size: 28px; }
  .stat b { font-size: 14px; }
  .stat span { font-size: 10px; }
  .ph-title { font-size: 19px; }
  .tl-time { min-width: 64px; font-size: 11px; }
}
