:root {
  --paper: #f3eee4;
  --card: #fffaf2;
  --ink: #2a2420;
  --muted: #6b5e54;
  --erhai: #2a6b7c;
  --cangshan: #3f5c48;
  --dusk: #b86b3c;
  --line: #e0d4c4;
  --shadow: 0 10px 28px rgba(42, 36, 32, 0.06);
  --radius: 18px;
  --pad: clamp(16px, 4vw, 28px);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 480px at 10% -10%, rgba(42, 107, 124, 0.12), transparent 60%),
    radial-gradient(900px 420px at 100% 0%, rgba(63, 92, 72, 0.10), transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.page {
  width: min(720px, 100%);
  margin: 0 auto;
  padding: calc(20px + env(safe-area-inset-top)) var(--pad) calc(120px + env(safe-area-inset-bottom));
}

.top {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 22px;
}
.eyebrow {
  margin: 0 0 6px;
  color: var(--erhai);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  line-height: 1.25;
}
.sub { margin: 8px 0 0; color: var(--muted); }
.meta-line { margin: 10px 0 0; color: var(--cangshan); font-size: 0.95rem; }

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.travelers {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 44px;
}
.travelers input {
  width: 3.2rem;
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--ink);
  text-align: center;
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  min-height: 44px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  touch-action: manipulation;
}
.btn.primary { background: var(--erhai); color: #fff; }
.btn.ghost { background: var(--card); border-color: var(--line); color: var(--ink); }
.btn.soft { background: rgba(42, 107, 124, 0.08); color: var(--erhai); width: 100%; margin-top: 12px; }
.btn.danger { background: transparent; color: #9b3b2e; border-color: #e4c4bc; }
.btn:focus-visible { outline: 3px solid rgba(42, 107, 124, 0.35); outline-offset: 2px; }

.callout {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--erhai);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.callout[contenteditable="true"] { outline: 2px dashed rgba(42, 107, 124, 0.35); }

.toc {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 22px;
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 8px 0;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
}
.toc a {
  text-decoration: none;
  color: var(--cangshan);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
}

.block { margin-bottom: 34px; }
.block h2 {
  font-family: var(--serif);
  font-size: 1.35rem;
  margin: 0 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.day-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.day-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}
.day-title {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0;
}
.pill-row { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font-size: 0.85rem;
  color: var(--erhai);
  background: rgba(42, 107, 124, 0.08);
  border-radius: 999px;
  padding: 4px 10px;
}
.props {
  display: grid;
  gap: 8px;
  margin: 10px 0 14px;
  font-size: 0.95rem;
}
.props div { display: grid; grid-template-columns: 4.5rem 1fr; gap: 8px; }
.props dt, .props .lab { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 10px;
  padding: 12px 0;
  border-top: 1px dashed var(--line);
}
.timeline .t { color: var(--dusk); font-weight: 500; font-size: 0.92rem; }
.timeline .body strong { display: block; margin-bottom: 2px; }
.timeline .body p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.edit-tools { display: none; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
body.is-edit .edit-tools { display: flex; }
body.is-edit .edit-only { display: inline-flex; }
.edit-only { display: none; }
body.is-edit .edit-bar { display: flex; }

.field-edit, .prose-edit, [contenteditable="true"] {
  border-radius: 10px;
}
body.is-edit .day-title,
body.is-edit .props span.val,
body.is-edit .timeline .t,
body.is-edit .timeline .body strong,
body.is-edit .timeline .body p,
body.is-edit .prose-edit,
body.is-edit .budget-row input,
body.is-edit .budget-row textarea {
  outline: 1px dashed transparent;
}
body.is-edit .day-title:focus,
body.is-edit .props span.val:focus,
body.is-edit .timeline .t:focus,
body.is-edit .timeline .body strong:focus,
body.is-edit .timeline .body p:focus,
body.is-edit .prose-edit:focus {
  outline: 2px solid rgba(42, 107, 124, 0.35);
  background: #fff;
}

.budget-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.metric {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.metric .n {
  font-family: var(--serif);
  font-size: 1.35rem;
  color: var(--erhai);
}
.metric .l { color: var(--muted); font-size: 0.85rem; }

.budget-list { display: grid; gap: 10px; }
.budget-row {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  display: grid;
  gap: 8px;
}
.budget-row .row1 {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
}
.budget-row .cat { color: var(--cangshan); font-size: 0.85rem; }
.budget-row .amt { font-weight: 700; white-space: nowrap; }
.budget-row .note { color: var(--muted); font-size: 0.9rem; margin: 0; }
.budget-row.optional { opacity: 0.78; border-style: dashed; }

.fine { color: var(--muted); font-size: 0.9rem; margin: 0 0 12px; }
#tipsList { margin: 0; padding-left: 1.2rem; }
#tipsList li { margin-bottom: 8px; }

.foot {
  color: var(--muted);
  font-size: 0.88rem;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.edit-bar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 250, 242, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.save-msg { color: var(--cangshan); font-size: 0.9rem; min-width: 6rem; }

dialog {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 22px;
  width: min(92vw, 380px);
  background: var(--card);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(42, 36, 32, 0.35); }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field input {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
}
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.err { color: #9b3b2e; margin: 0; }

body.is-edit input.inline, body.is-edit textarea.inline {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
  min-height: 44px;
}
body.is-edit textarea.inline { min-height: 72px; resize: vertical; }

@media (max-width: 520px) {
  .timeline li { grid-template-columns: 1fr; gap: 4px; }
  .budget-summary { grid-template-columns: 1fr; }
  .props div { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
