:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #24292f;
  --muted: #6a737d;
  --line: #e4e7eb;
  --primary: #185fa5;
  --primary-dark: #0c447c;
  --accent: #e6f1fb;
  --warn: #a32d2d;
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body { background: var(--bg); color: var(--text); line-height: 1.6; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-size: 17px; font-weight: 600; }
.ver { font-size: 11px; background: var(--accent); color: var(--primary); padding: 2px 8px; border-radius: 10px; vertical-align: middle; }

main { max-width: 760px; margin: 24px auto 60px; padding: 0 16px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 24px; margin-bottom: 16px;
}
h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 19px; }
h3 { font-size: 16px; margin-bottom: 10px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.grid label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
input, select {
  font-size: 14px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); outline: none;
}
input:focus, select:focus { border-color: var(--primary); }

  .prefs { border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 18px 0 6px; }
  .prefs legend { font-size: 13px; color: var(--muted); padding: 0 6px; }
/* 城市联想选择 */
.city-picker { position: relative; display: block; }
.city-picker input { width: 100%; }
.city-suggest {
  position: absolute; top: calc(100% + 5px); left: 0; right: 0; z-index: 60;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(24, 95, 165, .14); max-height: 264px; overflow-y: auto;
}
.city-suggest-item {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 13px; font-size: 14px; cursor: pointer;
}
.city-suggest-item:hover, .city-suggest-item.active { background: var(--accent); }
.city-suggest-item .cn { font-weight: 500; }
.city-suggest-item .prov { color: var(--muted); font-size: 12px; }
.city-suggest-empty { padding: 11px 13px; color: var(--muted); font-size: 13px; }
.field-note { font-size: 12px; color: var(--muted); margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; margin: 4px 14px 4px 0;
  font-size: 14px; color: var(--text); cursor: pointer;
}
.chip input { width: 15px; height: 15px; }

.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }
button {
  font-size: 14px; padding: 9px 20px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text);
}
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-dark); }
button.ghost:hover { border-color: var(--primary); color: var(--primary); }
button:disabled { opacity: .55; cursor: not-allowed; }

.tip { font-size: 13px; color: var(--warn); margin-top: 10px; min-height: 20px; }

/* 结果区 */
.result-title-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.result-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.history-select {
  border: 1px solid var(--line); border-radius: 10px; padding: 5px 10px;
  font-size: 13px; color: var(--text); background: #fff; cursor: pointer; max-width: 170px;
}

.tabs { display: flex; gap: 8px; margin-top: 14px; }
.tab { border-radius: 20px; padding: 7px 18px; }
.tab.active { background: var(--accent); border-color: var(--primary); color: var(--primary); font-weight: 600; }

/* 方案概览：行程总览 + 必打卡全览（两方案通用，不随出行方式切换） */
.overview-group {
  background: #fafbfc; border: 1px dashed var(--line); border-radius: 14px;
  padding: 16px 18px 2px; margin-bottom: 16px;
}
.group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.group-title { font-size: 15px; font-weight: 600; color: var(--primary); }
.group-note { font-size: 12px; color: var(--muted); }
.overview-group .card { background: transparent; border: none; padding: 0 0 14px; margin-bottom: 0; }
.overview-group .must-check-card { margin-top: 0; }

/* 分区标题：方案概览 → 出行方案详情 → 每日行程 */
.section-group { margin-bottom: 16px; }
.section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 22px 0 10px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--primary); }
.section-note { font-size: 12px; color: var(--muted); }

.budget-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.budget-table th, .budget-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 14px; }
.budget-table th { color: var(--muted); font-weight: 500; width: 90px; }
.budget-table tr.total td { font-weight: 600; color: var(--primary); }
.budget-table tr.per td { font-size: 12px; color: var(--muted); border-bottom: none; padding-top: 2px; text-align: right; }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 4px 12px; font-size: 14px; margin-top: 8px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 500; }

.station-line { font-size: 14px; margin: 6px 0; }
.station-line b { color: var(--primary); }

.day-card { margin-bottom: 14px; }
.day-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.day-no { background: var(--primary); color: #fff; border-radius: 8px; padding: 2px 12px; font-size: 14px; font-weight: 600; }
.day-theme { font-weight: 600; font-size: 15px; }
.day-date { color: var(--muted); font-size: 13px; }
.day-weather {
  background: #eaf4fd; color: #185fa5; border: 1px solid #cfe0f2;
  border-radius: 12px; padding: 1px 10px; font-size: 12px; white-space: nowrap;
}
.day-weather .rain { color: #2a6fb0; font-weight: 600; }

.sect { margin-top: 14px; }
.sect-title { font-size: 13px; font-weight: 600; color: var(--primary); margin-bottom: 6px; }

.spot, .meal {
  border-left: 3px solid var(--accent); background: #fafbfc;
  border-radius: 0 8px 8px 0; padding: 8px 12px; margin-bottom: 6px; font-size: 14px;
}
.spot .row1 { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.spot .name { font-weight: 600; }
.badge-must { background: #e64545; color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 9px; margin-left: 6px; font-weight: 600; vertical-align: 1px; white-space: nowrap; }
.sect-note { font-size: 11px; color: var(--muted); margin-left: 8px; font-weight: 400; }
.spot .meta { color: var(--muted); font-size: 12px; }
.spot .price { color: var(--warn); font-size: 12px; margin-top: 2px; }
.spot .hl { color: var(--muted); font-size: 13px; margin-top: 2px; }
.spot .leg { color: #2a6fb0; font-size: 12px; margin-top: 2px; }
.spot-ops { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.spot-ops button {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 8px; font-size: 12px; padding: 2px 10px; cursor: pointer;
}
.spot-ops button:hover { border-color: var(--primary); color: var(--primary); }
.spot-ops button.op-del:hover { border-color: #c0392b; color: #c0392b; }
.swap-input-row { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.swap-input-row input { flex: 1; min-width: 0; font-size: 13px; padding: 4px 8px; }
.swap-input-row button { font-size: 12px; padding: 3px 10px; }
.verified-badge {
  display: inline-block; font-size: 11px; font-weight: 600; color: #2e7d32;
  background: #e8f5e9; border: 1px solid #c8e6c9; border-radius: 10px;
  padding: 1px 8px; margin-left: 6px; vertical-align: middle;
}
.meal .slot { color: var(--primary); font-weight: 600; margin-right: 6px; font-size: 12px; }
.meal .cost { color: var(--muted); font-size: 12px; }

.hotel-line { font-size: 14px; }
.hotel-line .lab { color: var(--muted); margin-right: 6px; }

.tips li { margin: 6px 0 6px 20px; font-size: 14px; }
.disclaimer {
  margin-top: 14px; padding: 10px 12px; background: #fff8e6; border: 1px solid #f0e0b0;
  border-radius: 8px; font-size: 12px; color: #8a6d1a;
}

/* 遮罩与弹窗 */
.overlay, .modal {
  position: fixed; inset: 0; background: rgba(36, 41, 47, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
/* hidden 属性必须压过上面的 display:flex，否则弹窗/遮罩无法关闭 */
.modal[hidden], .overlay[hidden] { display: none !important; }
.loading-box, .modal-box { text-align: center; }
.loading-box { color: #fff; }
.loading-box .loading-sub { font-size: 12px; opacity: .75; margin-top: 8px; }
#loadingMsg { margin-top: 14px; font-size: 15px; }
.spinner {
  width: 38px; height: 38px; margin: 0 auto; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.3); border-top-color: #fff;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.modal-box { width: min(420px, 92vw); text-align: left; }
.modal-box label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.modal-box input { width: 100%; }

.share-row { display: flex; gap: 8px; align-items: stretch; }
.share-row input { flex: 1; min-width: 0; font-size: 13px; }

.error-box {
  margin-bottom: 16px; padding: 12px 14px; background: #fcebeb; border: 1px solid #f0c1c1;
  border-radius: 10px; color: var(--warn); font-size: 14px;
}

/* 刷新后恢复上次方案的提示条 */
.restore-tip {
  margin-bottom: 14px; padding: 10px 14px; background: #e8f3fd; border: 1px solid #c3ddf5;
  border-radius: 10px; color: #185fa5; font-size: 13px;
}

@media (max-width: 600px) {
  .card { padding: 16px; }
  .kv { grid-template-columns: 90px 1fr; }
  .day-weather { white-space: normal; }
  .result-btns button { padding: 7px 12px; font-size: 13px; }
  .history-select { max-width: 132px; padding: 4px 8px; }
  .section-head { margin-top: 18px; }
}

/* 行程总览时间轴 */
.timeline-card-head { display: flex; align-items: baseline; gap: 10px; }
.timeline-note { font-size: 12px; color: var(--muted); }
.timeline { margin-top: 12px; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-rail { position: relative; width: 14px; flex: none; }
.tl-item:not(:last-child) .tl-rail::before {
  content: ""; position: absolute; left: 6px; top: 15px; bottom: -2px;
  width: 2px; background: var(--line);
}
.tl-dot {
  position: absolute; top: 4px; left: 0; width: 14px; height: 14px;
  border-radius: 50%; background: #fff; border: 3px solid var(--primary);
}
.tl-dot.return { border-color: #c8ccd1; }
.tl-body {
  flex: 1; min-width: 0; padding: 0 8px; margin-left: -8px;
  border-radius: 8px; cursor: pointer; transition: background .25s;
}
.tl-body:hover { background: var(--accent); }
.tl-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tl-no { background: var(--primary); color: #fff; border-radius: 8px; padding: 1px 10px; font-size: 13px; font-weight: 600; }
.tl-date { color: var(--muted); font-size: 12px; }
.tl-theme { font-weight: 600; font-size: 14px; margin: 2px 0; }
.tl-spots { font-size: 13px; margin: 2px 0; }
.tl-spot { font-weight: 500; }
.tl-spot .badge-must { margin-left: 3px; }
.badge-must-mini { display: inline-block; min-width: 14px; height: 14px; line-height: 14px; text-align: center; background: #e64545; color: #fff; font-size: 11px; border-radius: 50%; margin-left: 4px; vertical-align: 1px; }
.tl-arrow { color: #b0b6bc; margin: 0 4px; }
.tl-more { color: var(--muted); }
.tl-hotel { font-size: 12px; color: var(--muted); margin-top: 2px; }
.tl-hotel .lab { color: var(--primary); font-weight: 600; margin-right: 4px; }
.tl-item.flash .tl-body { background: var(--accent); }
#daysPanel .day-card { scroll-margin-top: 70px; }
.day-card.flash { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 必打卡全览与天数建议 */
.must-check-card { margin-top: 12px; }
.mc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.mc-title { font-weight: 600; }
.mc-warn { font-size: 12px; color: #b45309; background: #fef3c7; border: 1px solid #fcd34d; border-radius: 999px; padding: 2px 10px; }
.mc-ok { font-size: 12px; color: #047857; background: #d1fae5; border: 1px solid #6ee7b7; border-radius: 999px; padding: 2px 10px; }
.mc-summary { font-size: 13px; color: var(--muted); margin: 0 0 10px; line-height: 1.6; }
.mc-list { display: grid; gap: 6px; }
.mc-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 10px; border-radius: 8px; background: var(--bg2); flex-wrap: wrap; }
.mc-item.mc-full { background: #fef9ec; border: 1px dashed #f59e0b; }
.mc-name { font-weight: 600; }
.mc-tag { font-size: 11px; color: #92400e; background: #fde68a; border-radius: 999px; padding: 1px 8px; }
.mc-day { font-size: 12px; color: var(--muted); }
.mc-suggest { font-size: 12px; color: var(--muted); margin-left: auto; }

/* 必打卡取舍弹窗 */
#mustPickModal .modal-box { width: min(540px, 94vw); }
.must-pick-days { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.must-pick-days label {
  flex-direction: row; align-items: center; gap: 8px; margin-bottom: 0;
  font-size: 13px; color: var(--muted);
}
.must-pick-days input { width: 76px; }
.fit-badge { font-size: 12px; border-radius: 999px; padding: 3px 12px; white-space: nowrap; }
.fit-badge.fit-ok { color: #047857; background: #d1fae5; border: 1px solid #6ee7b7; }
.fit-badge.fit-bad { color: #b45309; background: #fef3c7; border: 1px solid #fcd34d; }
.must-pick-list { display: grid; gap: 8px; max-height: 46vh; overflow-y: auto; padding-right: 4px; }
.must-pick-item {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 14px; color: var(--text); background: #fafbfc;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px;
  margin-bottom: 0; cursor: pointer;
}
.must-pick-item input { width: 16px; height: 16px; flex: none; }
.must-pick-item .name { font-weight: 600; }
.must-pick-item .meta { color: var(--muted); font-size: 12px; }
.must-pick-add { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin: 12px 0; }
.must-pick-add input { width: 100%; }
