* { box-sizing: border-box; }

:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #1f2328;
  --text-soft: #59636e;
  --text-faint: #9aa0a6;
  --border: #ece6df;
  --accent: #d97757;
  --accent-strong: #c05f3c;
  --accent-soft: #f7ece6;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { font-size: 18px; font-weight: 700; }
nav { display: flex; gap: 6px; }
.tab {
  border: none;
  background: transparent;
  color: var(--text-soft);
  font-size: 14px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.tab.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }

main {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}

.card {
  background: var(--surface);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* 表单 */
.field { margin-bottom: 20px; }
.row { display: flex; gap: 16px; }
.row .field { flex: 1; }
label {
  display: block;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 600;
  margin-bottom: 8px;
}
input[type="text"], input[type="number"], select {
  width: 100%;
  padding: 11px 14px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--accent); background: #fff; }

.tags { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-soft);
  font-size: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}
.chip.active {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:disabled { background: #e2a58f; cursor: not-allowed; }
.btn-primary:not(:disabled):hover { background: var(--accent-strong); }

.error { margin: 12px 0 0; color: #c0392b; font-size: 14px; min-height: 20px; }

/* 结果头部 */
.head .title { margin: 0 0 8px; font-size: 22px; }
.head .overview { margin: 0 0 14px; color: var(--text-soft); }
.head .meta { display: flex; flex-wrap: wrap; gap: 8px; }
.meta-item {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  padding: 3px 12px;
  border-radius: 999px;
}
.budget-summary { margin-top: 14px; font-size: 15px; color: var(--text-soft); }
.budget-summary b { color: var(--accent-strong); }
.budget-summary .sep { margin: 0 10px; color: var(--text-faint); }
.over-budget {
  margin-left: 10px;
  background: #fdecea;
  color: #c0392b;
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 999px;
  font-weight: 600;
}
.progress { margin-top: 10px; font-size: 13px; color: var(--text-faint); }

/* 按天切换 */
.day-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
  position: sticky;
  top: 62px;
  z-index: 5;
  background: var(--bg);
  padding: 8px 0;
}
.day-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  font-size: 14px;
  padding: 7px 16px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.day-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.day-tab.pending { color: var(--text-faint); border-style: dashed; }

/* 当天行程 */
.day-header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.day-badge {
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  padding: 4px 14px;
  border-radius: 999px;
}
.day-theme { font-size: 16px; font-weight: 600; }
.day-cost { margin-left: auto; font-size: 14px; color: var(--accent-strong); font-weight: 600; }
.btn-map {
  background: var(--accent-soft);
  color: var(--accent-strong);
  border: 1px solid transparent;
  font-size: 13px;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.btn-map:hover { border-color: var(--accent); }

.timeline { margin-top: 8px; }
.activity {
  display: flex;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.activity:first-of-type { border-top: none; padding-top: 8px; }
.act-time {
  flex-shrink: 0;
  width: 108px;
  font-size: 13px;
  color: var(--accent-strong);
  font-weight: 600;
  padding-top: 3px;
}
.act-body { flex: 1; min-width: 0; }
.act-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.act-type { font-size: 11px; padding: 2px 8px; border-radius: 4px; font-weight: 600; white-space: nowrap; }
.act-type.spot { background: #e8f0fe; color: #1a56db; }
.act-type.food { background: #fdf0e6; color: #c2571b; }
.act-type.transit { background: #eef0f2; color: #59636e; }
.act-type.other { background: #f0f0f0; color: #59636e; }
.act-title { font-weight: 600; }
.act-desc { margin-top: 4px; color: var(--text-soft); font-size: 14px; }
.act-sub { margin-top: 6px; display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.act-cost { color: var(--accent-strong); font-weight: 600; }
.act-addr { color: var(--text-faint); }
.act-dist { margin-top: 6px; color: #4a7d4f; font-size: 13px; }
.act-tip { margin-top: 6px; color: #9a7b3f; font-size: 13px; }
.act-side { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.act-photo {
  border: none;
  background: none;
  padding: 0;
  cursor: zoom-in;
  border-radius: 10px;
}
.act-photo img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  border: 1px solid var(--border);
}

/* 展示图放大 */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  cursor: zoom-out;
}
.lightbox img {
  max-width: 92vw;
  max-height: 78vh;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}
.lightbox p {
  color: #fff;
  font-size: 14px;
  margin: 0;
}
.btn-replace {
  flex-shrink: 0;
  align-self: flex-start;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-soft);
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
}
.btn-replace:hover { border-color: var(--accent); color: var(--accent-strong); }

h2 { font-size: 17px; margin: 0 0 12px; }
.tip-item { color: var(--text-soft); font-size: 14px; margin: 6px 0; }
.budget-total { font-weight: 700; color: var(--accent-strong); margin-bottom: 6px; }
.btn-copy {
  padding: 11px 22px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

/* 地图 */
.map-box {
  margin-top: 14px;
  height: 320px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
.map-box[hidden] { display: none; }
.map-toolbar {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.map-mode {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-soft);
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
}
.map-mode.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.map-canvas { flex: 1; min-height: 0; }
.map-loading, .map-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-faint);
  font-size: 14px;
}
.map-num {
  width: 24px;
  height: 24px;
  line-height: 24px;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

/* 生成中 */
.generating { text-align: center; color: var(--text-soft); padding: 40px 20px; }
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 历史 */
.history-item {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
}
.history-item:first-of-type { border-top: none; padding-top: 0; }
.hi-main { flex: 1; min-width: 0; }
.hi-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hi-meta { color: var(--text-faint); font-size: 13px; margin-top: 4px; }
.hi-actions { flex-shrink: 0; display: flex; gap: 12px; }
.link {
  background: none;
  border: none;
  color: var(--accent-strong);
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  padding: 4px;
}
.link.danger { color: #c0392b; }
.btn-clear {
  margin-top: 16px;
  width: 100%;
  padding: 11px;
  background: var(--bg);
  color: var(--text-faint);
  border: none;
  border-radius: 12px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}
.empty { text-align: center; color: var(--text-faint); padding: 40px 0; }

/* toast */
#toast {
  position: fixed;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(31, 35, 40, 0.92);
  color: #fff;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 640px) {
  .row { flex-direction: column; gap: 0; }
  main { padding: 20px 14px 80px; }
  .act-time { width: 84px; }
}
