:root {
  --bg: #eef2f7;
  --bg-grad: linear-gradient(135deg, #e0f2fe 0%, #eef2f7 40%, #f0fdfa 100%);
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6eaf0;
  --brand: #0ea5a4;          /* teal */
  --brand-2: #0284c7;        /* blue */
  --brand-grad: linear-gradient(135deg, #0ea5a4 0%, #0284c7 100%);
  --accent: #f97316;         /* coral/orange */
  --green: #059669;
  --red: #e11d48;
  --amber: #d97706;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow: 0 6px 24px -8px rgba(15,23,42,.15), 0 2px 6px rgba(15,23,42,.05);
  --shadow-lg: 0 20px 50px -20px rgba(2,132,199,.35);
  --r: 18px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg-grad); min-height: 100vh;
  color: var(--ink); line-height: 1.65; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--red); font-size: 14px; min-height: 20px; }
a { color: var(--brand-2); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: rgba(255,255,255,.75); backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,.6);
  padding: 12px 20px; box-shadow: var(--shadow-sm);
}
.brand { font-weight: 800; font-size: 19px; letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 11px;
  background: var(--brand-grad); box-shadow: var(--shadow-sm); font-size: 18px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.steps { display: flex; gap: 6px; flex-wrap: wrap; }
.step {
  font-size: 13px; color: var(--muted); padding: 5px 12px; border-radius: 20px;
  background: #f1f5f9; transition: .2s; white-space: nowrap;
}
.step.active { color: #fff; background: var(--brand-grad); box-shadow: var(--shadow-sm); }
.gear {
  border: none; background: #fff; width: 40px; height: 40px; border-radius: 12px; cursor: pointer;
  font-size: 19px; box-shadow: var(--shadow-sm); transition: .2s;
}
.gear:hover { transform: rotate(30deg); box-shadow: var(--shadow); }

/* 顶部提示条 */
.key-banner {
  background: #fff7ed; border-bottom: 1px solid #fed7aa; color: #9a3412;
  padding: 10px 20px; font-size: 14px; text-align: center;
}
.link-btn { background: none; border: none; color: var(--brand-2); font-weight: 700; cursor: pointer; font-size: 14px; }

.container { max-width: 940px; margin: 0 auto; padding: 22px 16px 70px; }

/* ---------- 面板 ---------- */
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 26px; box-shadow: var(--shadow); animation: rise .35s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.panel-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: linear-gradient(135deg, rgba(14,165,164,.10), rgba(2,132,199,.10));
  border: 1px solid rgba(2,132,199,.14); border-radius: 16px; padding: 18px 22px; margin-bottom: 18px;
}
.panel-hero h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.02em; }
.panel-hero p { margin: 0; color: var(--muted); font-size: 14px; }
.hero-emoji { font-size: 46px; line-height: 1; filter: drop-shadow(0 6px 10px rgba(0,0,0,.12)); }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 10px 18px; border-radius: 12px; cursor: pointer; font-size: 15px; font-weight: 600;
  transition: .18s; box-shadow: var(--shadow-sm);
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--brand-grad); border: none; color: #fff; }
.btn.ghost { background: transparent; color: var(--muted); box-shadow: none; border-color: transparent; }
.btn.ghost:hover { background: #f1f5f9; box-shadow: none; }
.btn.big { padding: 13px 26px; font-size: 16px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 16px 0; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }

/* ---------- 隐私提示 ---------- */
.privacy-note {
  background: linear-gradient(135deg, #ecfdf5, #f0fdfa); border: 1px solid #a7f3d0; color: #065f46;
  padding: 13px 16px; border-radius: 14px; font-size: 14px; margin: 16px 0;
}

/* ---------- 粘贴框 ---------- */
.paste {
  width: 100%; min-height: 130px; padding: 15px; font-size: 15px;
  border: 2px dashed var(--brand); border-radius: 14px; resize: vertical; font-family: inherit;
  background: #f8fffe; transition: .2s;
}
.paste:focus { outline: none; border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 4px rgba(2,132,199,.1); }

/* ---------- 顶栏「出行人」按钮 ---------- */
.peoplebtn {
  border: 1px solid var(--line); background: #fff; padding: 7px 13px; border-radius: 12px; cursor: pointer;
  font-size: 14px; font-weight: 600; box-shadow: var(--shadow-sm); display: flex; align-items: center; gap: 6px; transition: .18s;
}
.peoplebtn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.count-badge { background: var(--brand-grad); color: #fff; border-radius: 20px; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; font-size: 12px; }

/* ---------- 出行人整页 ---------- */
.fullpage { position: fixed; inset: 0; z-index: 90; background: var(--bg-grad); overflow-y: auto; animation: fade .2s; }
.fullpage-bar {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; background: rgba(255,255,255,.85); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.fp-title { font-weight: 800; font-size: 18px; }
.fullpage-body { max-width: 860px; margin: 0 auto; padding: 18px 16px 60px; }
.paste-fold { border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: #fff; margin: 14px 0; box-shadow: var(--shadow-sm); }
.paste-fold summary { font-weight: 700; cursor: pointer; }
.people-toolbar { display: flex; align-items: center; gap: 12px; margin: 16px 0 8px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 180px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; font-family: inherit; }
.search-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,164,.12); }
.empty-hint { color: var(--muted); text-align: center; padding: 30px 12px; border: 1px dashed var(--line); border-radius: 14px; }

/* ---------- 出行人紧凑列表 ---------- */
.people-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.person-row { border: 1px solid var(--line); border-radius: 12px; background: #fff; box-shadow: var(--shadow-sm); overflow: hidden; transition: .15s; }
.person-row.invalid { border-color: var(--red); }
.person-summary {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer; user-select: none;
}
.person-summary:hover { background: #f8fafc; }
.pr-name { font-weight: 700; font-size: 15px; }
.pr-arrow { margin-left: auto; color: var(--muted); transition: transform .2s; font-size: 13px; }
.person-row.open .pr-arrow { transform: rotate(90deg); }
.person-detail { padding: 4px 14px 16px; border-top: 1px dashed var(--line); }

/* ---------- 出行人卡片（详情内字段） ---------- */
.person-card { border: none; padding: 0; background: transparent; box-shadow: none; }
.person-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; }
.person-head b { font-size: 16px; }
.tag { font-size: 12px; padding: 3px 10px; border-radius: 12px; background: #e0f2fe; color: var(--brand-2); font-weight: 600; }
.tag.old { background: #fef3c7; color: #92400e; }
.tag.child { background: #dcfce7; color: #166534; }
.tag.warn { background: #ffe4e6; color: var(--red); }
.pc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.pc-grid label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.pc-grid input, .pc-grid select {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit;
  font-weight: 400; transition: .15s;
}
.pc-grid input:focus, .pc-grid select:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,164,.12); }
.pc-grid .full { grid-column: 1 / -1; }
.copybtn { font-size: 12px; padding: 4px 11px; border-radius: 9px; border: 1px solid var(--brand); color: var(--brand); background: #fff; cursor: pointer; font-weight: 600; }
.copybtn:hover { background: #ecfeff; }
.field-inline { display: flex; align-items: center; gap: 6px; }
.field-inline input { flex: 1; }
.del-btn { margin-left: auto; color: var(--red); background: none; border: none; cursor: pointer; font-size: 13px; font-weight: 600; }
.parsed-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---------- 汇总 ---------- */
.summary-box {
  background: linear-gradient(135deg, #f0f9ff, #f8fafc); border: 1px solid #dbeafe; border-radius: 14px;
  padding: 15px 17px; margin: 18px 0;
}
.summary-box.small { font-size: 14px; }
.summary-box h3 { margin: 0 0 8px; font-size: 15px; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 16px 0; }
.form-grid label, .field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 700; }
.form-grid input, .form-grid select, .field input, .field textarea, #refineInput {
  padding: 11px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; font-weight: 400; font-family: inherit; transition: .15s;
}
.form-grid input:focus, .form-grid select:focus, .field input:focus, .field textarea:focus, #refineInput:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,164,.12);
}
.field { margin: 16px 0; }
.field-label { font-weight: 700; font-size: 14px; }
.chips { display: flex; gap: 9px; flex-wrap: wrap; }
.chips label {
  font-weight: 500; border: 1px solid var(--line); padding: 8px 16px; border-radius: 22px; cursor: pointer;
  display: flex; align-items: center; gap: 7px; transition: .15s; background: #fff;
}
.chips label:hover { border-color: var(--brand); }
.chips input:checked + span, .chips label:has(input:checked) { color: var(--brand); }
.status { color: var(--brand-2); font-size: 14px; min-height: 22px; font-weight: 600; }

/* ---------- 微调栏 ---------- */
.refine { display: flex; gap: 10px; margin: 14px 0; }
.refine input { flex: 1; }

/* ---------- 方案展示 ---------- */
.plan-output h2 { font-size: 20px; margin-top: 30px; display: flex; align-items: center; gap: 8px; }
.plan-title { font-size: 26px; margin-bottom: 4px; letter-spacing: -.02em; background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.day-card {
  border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 14px;
  padding: 16px 18px; margin: 14px 0; background: #fff; box-shadow: var(--shadow-sm);
}
.day-card h3 { margin: 0 0 6px; color: var(--brand-2); }
.day-item { padding: 9px 0; border-bottom: 1px dashed var(--line); }
.day-item:last-child { border-bottom: none; }
.day-item .it-head { font-weight: 700; }
.it-type { font-size: 12px; padding: 2px 9px; border-radius: 10px; background: #e0f2fe; color: var(--brand-2); margin-left: 6px; font-weight: 600; }
.it-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.it-note { font-size: 13px; color: var(--amber); margin-top: 2px; }
.section-block {
  border: 1px solid var(--line); border-radius: 16px; padding: 18px 20px; margin: 16px 0; background: #fff; box-shadow: var(--shadow-sm);
}
.section-block h3 { margin-top: 0; display: flex; align-items: center; gap: 8px; }
.allergy { color: var(--red); font-weight: 800; }
.route-summary { background: linear-gradient(135deg,#f0f9ff,#ecfeff); border:1px solid #bae6fd; border-radius:12px; padding:10px 14px; font-size:14px; margin-bottom:10px; }
#map { height: 380px; border-radius: 14px; margin: 12px 0; border: 1px solid var(--line); z-index: 1; }
.feature-warn {
  background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; padding: 11px 15px; border-radius: 12px; font-size: 14px; margin: 14px 0;
}
.weather-grid { display: flex; gap: 9px; flex-wrap: wrap; }
.weather-day {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 13px; text-align: center; min-width: 96px; font-size: 13px;
  background: linear-gradient(135deg, #f0f9ff, #fff);
}
.weather-day .wd-date { font-weight: 700; }
.weather-day .wd-temp { font-size: 16px; color: var(--brand-2); font-weight: 700; }
.sources { font-size: 13px; }
.sources a { word-break: break-all; }
.markdown p { margin: 6px 0; }
.markdown ul { margin: 6px 0; padding-left: 22px; }

/* ---------- 遮罩 & 弹窗 ---------- */
.mask {
  position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.glass { background: rgba(255,255,255,.96); }
.login-box {
  border-radius: 22px; padding: 32px 28px; width: 100%; max-width: 360px; text-align: center; box-shadow: var(--shadow-lg);
}
.login-emoji { font-size: 40px; margin-bottom: 6px; }
.login-box h2 { margin: 4px 0; }
.login-box input { width: 100%; padding: 13px; margin: 14px 0; border: 1px solid var(--line); border-radius: 12px; font-size: 16px; }

.settings-box {
  background: #fff; border-radius: 22px; padding: 24px; width: 100%; max-width: 480px;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
}
.settings-head { display: flex; align-items: center; justify-content: space-between; }
.settings-head h2 { margin: 0; font-size: 20px; }
.icon-close { border: none; background: #f1f5f9; width: 32px; height: 32px; border-radius: 10px; cursor: pointer; font-size: 15px; }
.key-field { margin: 16px 0; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdff; }
.key-label { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.key-label .need { font-weight: 500; font-size: 12px; color: var(--muted); background: #eef2f7; padding: 2px 8px; border-radius: 10px; }
.key-field input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; }
.key-field input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,164,.12); }
.key-help { display: inline-block; margin-top: 7px; font-size: 12px; font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #cbd5e1; display: inline-block; flex: none; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(5,150,105,.18); }
.adv { margin-top: 8px; }
.adv summary { font-size: 12px; color: var(--muted); cursor: pointer; }
.adv input { margin-top: 8px; }
.settings-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* ---------- 聊天式就地调整 ---------- */
.chat-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 80;
  border: none; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: 15px;
  padding: 13px 20px; border-radius: 30px; cursor: pointer; box-shadow: var(--shadow-lg);
}
.chat-fab:active { transform: scale(.97); }
.chat-drawer {
  position: fixed; right: 18px; bottom: 18px; z-index: 85; width: 380px; max-width: calc(100vw - 24px);
  height: 70vh; max-height: 620px; background: #fff; border-radius: 20px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--line); animation: rise .25s ease;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: linear-gradient(135deg, rgba(14,165,164,.10), rgba(2,132,199,.10)); border-bottom: 1px solid var(--line); }
.chat-head-title { font-weight: 700; }
.chat-quick { display: flex; gap: 7px; overflow-x: auto; padding: 10px 14px; border-bottom: 1px solid var(--line); flex: none; }
.chat-quick button {
  flex: none; border: 1px solid var(--line); background: #f8fafc; color: var(--ink); border-radius: 18px;
  padding: 6px 13px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.chat-quick button:hover { border-color: var(--brand); color: var(--brand); }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #f8fafc; }
.bubble { max-width: 85%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: var(--brand-grad); color: #fff; border-bottom-right-radius: 4px; }
.bubble.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.pending { color: var(--muted); font-style: italic; }
.chat-hint { text-align: center; color: var(--muted); font-size: 13px; padding: 8px 12px; }
.chat-input-row { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); flex: none; }
.chat-input-row input { flex: 1; padding: 11px 13px; border: 1px solid var(--line); border-radius: 12px; font-size: 15px; font-family: inherit; }
.chat-input-row input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(14,165,164,.12); }

@media (max-width: 640px) {
  .chat-drawer { right: 0; left: 0; bottom: 0; width: 100%; max-width: 100%; height: 82vh; border-radius: 20px 20px 0 0; }
  .chat-fab { right: 14px; bottom: 14px; }
}

.foot { text-align: center; color: var(--muted); font-size: 13px; padding: 22px; }

/* ---------- toast（在 JS 里创建） ---------- */

/* ---------- 手机适配 ---------- */
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .pc-grid { grid-template-columns: 1fr; }
  .steps { font-size: 12px; }
  .step { padding: 4px 9px; }
  .container { padding: 16px 11px 56px; }
  .panel { padding: 18px; border-radius: 16px; }
  .panel-hero { padding: 15px 16px; }
  .panel-hero h1 { font-size: 19px; }
  .hero-emoji { font-size: 36px; }
  .plan-title { font-size: 22px; }
}

/* ---------- 打印 ---------- */
@media print {
  .no-print, .topbar, .foot, .key-banner { display: none !important; }
  body { background: #fff; }
  .panel { box-shadow: none; border: none; padding: 0; }
  #map, .section-block, .day-card { page-break-inside: avoid; }
}
