:root {
  color-scheme: light;
  --paper: #f7f0e3;
  --paper-deep: #eadfc9;
  --ink: #302e29;
  --muted: #7c776d;
  --green: #2f6b4f;
  --green-soft: #d9e4d8;
  --wish-red: #c64b43;
  --wish-red-soft: #e5a39d;
  --terracotta: #b76542;
  --line: rgba(80, 70, 53, 0.16);
  --white: #fffdfa;
  --shadow: 0 18px 50px rgba(70, 58, 41, 0.12);
  --radius-lg: 24px;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 8%, rgba(183, 101, 66, 0.08), transparent 30%),
    radial-gradient(circle at 92% 72%, rgba(47, 107, 79, 0.08), transparent 34%),
    var(--paper);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image: radial-gradient(rgba(80, 70, 53, 0.18) 0.45px, transparent 0.65px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: 100%;
  /* 手机浏览器地址栏会伸缩：100vh 是"最大视口"高度，会把底部按钮推出可视区；
     100dvh 跟随当前可视高度。老浏览器忽略第二行，保留 100vh 兜底。 */
  height: 100vh;
  height: 100dvh;
  padding: 20px 24px 12px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(270px, 1fr) auto minmax(270px, 1fr);
  align-items: center;
  gap: 24px;
  padding-bottom: 16px;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 2px solid var(--terracotta);
  border-radius: 50% 46% 52% 48%;
  color: var(--terracotta);
  font: 700 1.35rem/1 "STKaiti", "KaiTi", serif;
  transform: rotate(-5deg);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font: 700 clamp(1.4rem, 2vw, 1.8rem)/1.2 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.08em;
}

.brand-block p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.journey-summary {
  display: grid;
  grid-template-columns: auto 1px auto;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-width: 280px;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 250, 0.66);
  box-shadow: 0 8px 24px rgba(70, 58, 41, 0.05);
}

.summary-number {
  display: flex;
  align-items: baseline;
  gap: 6px;
  white-space: nowrap;
}

.summary-number strong {
  color: var(--green);
  font: 700 1.35rem/1 "Georgia", serif;
}

.summary-number span {
  color: var(--muted);
  font-size: 0.78rem;
}

/* 「想去城市」用与地图一致的赭红，和「去过」区分开 */
.summary-number.wanted strong {
  color: var(--wish-red);
}

.summary-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
}

.top-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.quiet-button,
.round-button,
.filter-tab,
.panel-back,
.dialog-close {
  border: 0;
  cursor: pointer;
}

.quiet-button {
  min-height: 40px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #565249;
  background: rgba(255, 253, 250, 0.62);
  font-size: 0.85rem;
}

.quiet-button:hover,
.quiet-button:focus-visible {
  border-color: rgba(47, 107, 79, 0.4);
  color: var(--green);
  background: var(--white);
}

.workspace {
  position: relative;
  min-height: 0;
}

.map-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 460px;
  overflow: hidden;
  border: 1px solid rgba(95, 79, 54, 0.18);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(rgba(255, 253, 248, 0.84), rgba(252, 248, 239, 0.84)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(85, 75, 60, 0.05) 28px);
  box-shadow: var(--shadow);
}

#map {
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  overscroll-behavior: contain;
}

#map.dragging {
  cursor: grabbing;
  user-select: none;
}

.map-tools {
  position: absolute;
  z-index: 4;
  top: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 36px);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(240px, 34vw);
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: 0 8px 24px rgba(70, 58, 41, 0.08);
}

.search-box span {
  color: var(--green);
  font-size: 1.3rem;
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 0.9rem;
}

.filter-tabs {
  display: flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 253, 250, 0.94);
  box-shadow: 0 8px 24px rgba(70, 58, 41, 0.08);
}

.filter-tab {
  min-width: 54px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 0.82rem;
}

.filter-tab.active {
  color: var(--white);
  background: var(--green);
}

.round-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--green);
  background: rgba(255, 253, 250, 0.94);
  box-shadow: 0 8px 24px rgba(70, 58, 41, 0.08);
}

.legend {
  position: absolute;
  z-index: 3;
  bottom: 16px;
  left: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: #5f5a50;
  background: rgba(255, 253, 250, 0.88);
  box-shadow: 0 8px 24px rgba(70, 58, 41, 0.07);
  font-size: 0.78rem;
}

.legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-dot.visited {
  background: var(--green);
}

.legend-dot.wanted {
  background: var(--wish-red);
}

.legend-dot.unvisited {
  border: 1px solid #b8aa90;
  background: #e5d9c4;
}

.legend-tip {
  padding-left: 12px;
  border-left: 1px solid var(--line);
  color: #8d867a;
}

.map-empty {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: var(--muted);
  background: rgba(247, 240, 227, 0.86);
  transition: opacity 250ms ease, visibility 250ms ease;
}

.map-empty.hidden {
  visibility: hidden;
  opacity: 0;
}

.loader {
  width: 32px;
  height: 32px;
  border: 3px solid var(--paper-deep);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.city-panel {
  /* 保持原来的绝对定位铺满工作区高度：高度确定，内部滚动层才能正确算出剩余空间 */
  position: absolute;
  z-index: 7;
  top: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  width: min(430px, calc(100% - 24px));
  /* 面板本身不滚动，改由 .city-content 滚动，底部操作条才能钉住 */
  overflow: hidden;
  border: 1px solid rgba(95, 79, 54, 0.18);
  border-radius: 20px;
  background:
    linear-gradient(rgba(255, 253, 248, 0.94), rgba(250, 246, 236, 0.96)),
    repeating-linear-gradient(0deg, transparent, transparent 28px, rgba(77, 89, 75, 0.06) 29px);
  box-shadow: -12px 18px 55px rgba(59, 49, 36, 0.2);
  transform: translateX(calc(100% + 36px));
  transition: transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

/* 城市内容区：撑满剩余高度并自己滚动 */
.city-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 26px 30px;
}

.city-panel.open {
  transform: translateX(0);
}

/* 手机端的控件（呼出胶囊 / 抽屉把手 / 关闭按钮 / 缩放按钮）：桌面一律不显示 */
.panel-handle,
.panel-toggle,
.panel-close,
.map-zoom {
  display: none;
}

.panel-toggle {
  align-items: center;
  gap: 7px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(95, 79, 54, 0.2);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.94);
  color: #2f6b4f;
  box-shadow: 0 8px 22px rgba(59, 49, 36, 0.18);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.panel-toggle-caret {
  font-size: 0.9rem;
  line-height: 1;
}

/* 抽屉展开时把呼出胶囊藏起来 */
.panel-toggle.is-hidden {
  display: none;
}

/* ── 右侧常驻面板：菜单态（日历 + 清单）/ 城市态 ───────────────────── */
.city-panel.view-menu > .city-content,
.city-panel.view-menu > .panel-toolbar {
  display: none;
}

.city-panel.view-city .menu-view {
  display: none;
}

.menu-view {
  display: block;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 26px 30px;
}

/* 浏览器存储模式（公网版）的备份提醒；本地版保持隐藏 */
.backup-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px dashed rgba(191, 111, 73, 0.55);
  border-radius: 12px;
  background: rgba(255, 247, 235, 0.92);
}

.backup-notice.is-hidden {
  display: none;
}

.backup-notice p {
  flex: 1;
  margin: 0;
  color: #8a6a4f;
  font-size: 0.8rem;
  line-height: 1.55;
}

.backup-notice button {
  flex: none;
  padding: 5px 12px;
  border: 1px solid var(--terracotta);
  border-radius: 999px;
  color: var(--terracotta);
  background: rgba(255, 253, 248, 0.95);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.backup-notice button:hover,
.backup-notice button:focus-visible {
  border-color: var(--terracotta);
  color: #fff;
  background: var(--terracotta);
}

/* 从未备份或超过 7 天没备份：换成警示配色 */
.backup-notice.warn {
  border-color: rgba(198, 75, 67, 0.65);
  background: rgba(255, 240, 236, 0.95);
}

.backup-notice.warn p {
  color: #a5463f;
}

.menu-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding-right: 12px;
}

.menu-kicker {
  margin: 0;
  color: var(--terracotta);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}

.menu-heading h2 {
  margin: 4px 0 0;
  font-family: "STKaiti", "KaiTi", "Songti SC", "SimSun", serif;
  font-size: 1.3rem;
  font-weight: 700;
}

.menu-count {
  color: var(--muted);
  font-size: 0.78rem;
}

.menu-block {
  margin-bottom: 20px;
}

.menu-block:last-child {
  margin-bottom: 0;
}

/* ── 日历 ─────────────────────────────────────────────────────────── */
.calendar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
}

.calendar-button {
  display: grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: #5c574d;
  background: rgba(255, 253, 248, 0.86);
  font-size: 0.95rem;
  line-height: 1;
  transition: background 160ms ease, color 160ms ease;
}

.calendar-button:hover {
  color: var(--green);
  background: var(--green-soft);
}

.calendar-button.today-button {
  font-size: 0.76rem;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  gap: 3px;
  margin: 14px 0 6px;
}

.calendar-weekdays span {
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.calendar-weekdays .weekend {
  color: var(--wish-red);
}

.calendar-grid {
  gap: 3px;
}

/* 单元格按「日数字 / 节日名 / 标记点」三行排布，红圈绿圈叠在边框上 */
.calendar-day {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.05;
}

.calendar-day.outside {
  opacity: 0.32;
}

.calendar-day.rest {
  background: rgba(198, 75, 67, 0.08);
}

.calendar-day.makeup {
  background: rgba(80, 70, 53, 0.07);
}

.calendar-number {
  font-weight: 600;
}

.calendar-number.weekend {
  color: var(--wish-red);
}

.calendar-day.today .calendar-number {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  color: #fffdfa;
  background: var(--green);
}

.calendar-holiday {
  max-width: 100%;
  overflow: hidden;
  font-size: 0.6rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 补班日不写「补班」两个字，只留一个灰点，免得日历太吵 */
.calendar-holiday.makeup {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  color: transparent;
  background: var(--muted);
}

.calendar-holiday.rest {
  color: var(--wish-red);
}

.calendar-marks {
  display: flex;
  gap: 3px;
  height: 7px;
}

.calendar-mark {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.calendar-mark.plan {
  background: var(--wish-red);
}

.calendar-mark.visited {
  background: var(--green);
}

/* 未来的出行计划：红圈 */
.calendar-day.has-plan {
  border-color: var(--wish-red);
  box-shadow: 0 0 0 1px rgba(198, 75, 67, 0.25) inset;
}

/* 过去真的去过：绿圈 */
.calendar-day.has-visited {
  border-color: var(--green);
  box-shadow: 0 0 0 1px rgba(47, 107, 79, 0.22) inset;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.72rem;
}

.calendar-legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.mark-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.mark-dot.plan {
  border: 2px solid var(--wish-red);
}

.mark-dot.visited {
  border: 2px solid var(--green);
}

.mark-dot.rest {
  background: rgba(198, 75, 67, 0.28);
}

.mark-dot.makeup {
  background: rgba(80, 70, 53, 0.24);
}

/* 悬停标签：跟随光标，自己画所以没有原生提示的延迟 */
.calendar-tip {
  position: fixed;
  z-index: 30;
  top: 0;
  left: 0;
  display: none;
  flex-direction: column;
  gap: 2px;
  max-width: 230px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.98);
  box-shadow: 0 10px 28px rgba(70, 58, 41, 0.18);
  font-size: 0.78rem;
  line-height: 1.35;
  pointer-events: none;
}

.calendar-tip.show {
  display: flex;
}

.calendar-tip span:first-child {
  color: var(--muted);
  font-size: 0.72rem;
}

/* ── 即将出发 / 想去的城市 ────────────────────────────────────────── */
.plan-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.plan-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(198, 75, 67, 0.22);
  border-radius: 13px;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.9);
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease;
}

.plan-button:hover {
  border-color: rgba(198, 75, 67, 0.55);
  background: rgba(198, 75, 67, 0.08);
}

.plan-text {
  font-size: 0.92rem;
  font-weight: 700;
}

.plan-when {
  flex: none;
  color: var(--muted);
  font-size: 0.76rem;
}

/* 按钮宽度跟着城市名走：短名字小按钮、长名字长按钮 */
.want-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: 240px;
  margin-top: 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.want-chip {
  max-width: 100%;
  padding: 7px 14px;
  border: 1px solid rgba(47, 107, 79, 0.24);
  border-radius: 999px;
  overflow: hidden;
  color: var(--green);
  background: rgba(255, 253, 248, 0.92);
  font-size: 0.85rem;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.want-chip:hover {
  border-color: rgba(47, 107, 79, 0.6);
  color: #23503b;
  background: var(--green-soft);
}

.menu-empty {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.menu-empty.is-hidden {
  display: none;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #645f55;
  background: rgba(235, 226, 209, 0.72);
  font-size: 1.35rem;
}

.city-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding-right: 28px;
}

/* 城市页左上角的返回图标（纯图标，不放文字） */
.panel-back {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 4px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green);
  background: rgba(255, 253, 248, 0.9);
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.panel-back svg {
  width: 19px;
  height: 19px;
}

.panel-back:hover {
  border-color: rgba(47, 107, 79, 0.55);
  color: #23503b;
  background: var(--green-soft);
}

.panel-back:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.province-name {
  margin-bottom: 5px;
  color: var(--terracotta);
  font-size: 0.78rem;
  letter-spacing: 0.14em;
}

.city-heading h2 {
  font: 700 2rem/1.1 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.08em;
}

.city-statuses {
  display: grid;
  justify-items: end;
  gap: 2px;
}

/* 列宽固定 + 右对齐：文案长短或是否显示“√”都不会让开关移动，
   两行开关也始终上下对齐 */
.visited-switch {
  display: grid;
  grid-template-columns: 4.5em 42px 1em;
  align-items: center;
  justify-content: end;
  gap: 8px;
  min-height: 38px;
  color: var(--muted);
  cursor: pointer;
  font-size: 0.82rem;
  white-space: nowrap;
}

/* 勾选标记占独立的一格：未勾选时保留空位，勾选时只让文字出现，开关不会左右移动 */
.switch-tick {
  visibility: hidden;
  color: var(--green);
  font-weight: 700;
  text-align: center;
}

.switch-tick.on {
  visibility: visible;
}

.want-switch .switch-tick {
  color: var(--wish-red);
}

.visited-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #d8cdb9;
  transition: background 180ms ease;
}

.switch-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--white);
  box-shadow: 0 2px 6px rgba(50, 45, 37, 0.2);
  transition: transform 180ms ease;
}

.visited-switch input:checked + .switch-track {
  background: var(--green);
}

.visited-switch input:checked + .switch-track i {
  transform: translateX(18px);
}

.visited-switch input:focus-visible + .switch-track {
  outline: 3px solid rgba(47, 107, 79, 0.22);
}

.want-switch input:checked + .switch-track {
  background: var(--wish-red);
}

.want-switch input:focus-visible + .switch-track {
  outline-color: rgba(198, 75, 67, 0.24);
}

/* 城市面板的「记录 / 规划」页签 */
.panel-tabs {
  display: flex;
  gap: 6px;
  margin: 0 0 18px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(234, 223, 201, 0.42);
}

.panel-tab {
  position: relative;
  flex: 1;
  padding: 9px 12px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.86rem;
  transition: color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.panel-tab:hover {
  color: var(--ink);
}

.panel-tab.active {
  color: #fff;
  background: var(--green);
  box-shadow: 0 4px 12px rgba(47, 107, 79, 0.24);
}

.panel-tab[data-tab="plan"].active {
  background: var(--terracotta);
  box-shadow: 0 4px 12px rgba(183, 101, 66, 0.26);
}

.postcard-rule {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 22px 0;
  color: var(--terracotta);
  font-size: 0.7rem;
}

.postcard-rule::before,
.postcard-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--line) 0 7px, transparent 7px 12px);
}

.field-label {
  display: block;
  margin: 15px 0 8px;
  color: #4f4a42;
  font-weight: 700;
  font-size: 0.88rem;
}

.paper-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline: 0;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.52);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.paper-input:focus {
  border-color: rgba(47, 107, 79, 0.55);
  box-shadow: 0 0 0 3px rgba(47, 107, 79, 0.1);
}

.date-input {
  height: 44px;
  padding: 0 12px;
}

.note-input {
  min-height: 150px;
  padding: 12px 14px;
  line-height: 1.8;
  resize: vertical;
  background-image: repeating-linear-gradient(transparent, transparent 27px, rgba(72, 84, 72, 0.09) 28px);
  background-attachment: local;
}

.save-line {
  display: flex;
  justify-content: space-between;
  margin-top: 7px;
  color: #90897d;
  font-size: 0.74rem;
}

#saveState.saved {
  color: var(--green);
}

#saveState.error {
  color: #a43d32;
}

.photo-section {
  margin-top: 24px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

/* 钉在面板底部：城市内容再多也只滚动上面那块，这一条始终留在原处 */
.panel-toolbar {
  display: flex;
  flex: none;
  gap: 10px;
  padding: 16px 26px 20px;
  border-top: 1px solid var(--line);
  background: linear-gradient(rgba(252, 248, 239, 0.92), rgba(250, 246, 236, 0.98));
}

.toolbar-button {
  display: inline-flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 9px 14px;
  border: 1px solid rgba(47, 107, 79, 0.55);
  border-radius: 10px;
  color: var(--green);
  background: var(--green-soft);
  cursor: pointer;
  font-size: 0.86rem;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  transition: color 160ms ease, background 160ms ease, border-color 160ms ease;
}

.toolbar-button:hover,
.toolbar-button:focus-visible {
  border-color: var(--green);
  color: #fff;
  background: var(--green);
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-title-row .field-label {
  display: inline-block;
  margin-bottom: 3px;
}

.section-title-row small {
  margin-left: 8px;
  color: var(--muted);
}

.add-photo-button {
  padding: 9px 12px;
  border: 1px dashed rgba(47, 107, 79, 0.5);
  border-radius: 10px;
  color: var(--green);
  cursor: pointer;
  font-size: 0.82rem;
}

.add-photo-button:hover {
  background: var(--green-soft);
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

/* 拍立得样式：照片在上，说明栏固定在下方白边上，避免文字压在照片里 */
.photo-card {
  position: relative;
  display: grid;
  /* 必须显式写 minmax(0, 1fr)：否则这一列会按图片的原始宽度(可能几千像素)撑开，
     再由 overflow:hidden 裁掉，看起来就像缩略图没显示全 */
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto 26px;
  overflow: hidden;
  border: 6px solid var(--white);
  border-radius: 4px;
  background: var(--white);
  box-shadow: 0 7px 16px rgba(67, 56, 40, 0.13);
}

.photo-card:nth-child(odd) {
  transform: rotate(-0.8deg);
}

.photo-card:nth-child(even) {
  transform: rotate(0.7deg);
}

/* 缩略图统一 4:3 框，完整显示整张照片（contain 不裁切），
   比例不同的照片自动留浅色边，两列缩略图高度依然整齐 */
.photo-card img {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: contain;
  background: #ece3d5;
  cursor: zoom-in;
}

.photo-card .photo-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 0 2px;
}

.photo-actions button {
  flex: none;
  overflow: hidden;
  padding: 0;
  border: 0;
  color: #6d665a;
  background: transparent;
  cursor: pointer;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-actions .cover {
  color: var(--terracotta);
  font-weight: 700;
}

.photo-name {
  overflow: hidden;
  min-width: 0;
  color: #9a9284;
  font-size: 0.68rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.photo-empty {
  display: grid;
  justify-items: center;
  gap: 3px;
  margin-top: 12px;
  padding: 25px 10px;
  border: 1px dashed rgba(92, 81, 64, 0.25);
  border-radius: 14px;
  color: #a0988a;
}

/* 有照片时必须真正隐藏：display:grid 会覆盖 HTML 的 hidden 属性 */
.photo-empty.is-hidden {
  display: none !important;
}

/* 每张照片右上角的删除按钮 */
.photo-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  color: #fff;
  background: rgba(58, 48, 38, 0.62);
  cursor: pointer;
  font-size: 0.82rem;
  line-height: 1;
  transition: background 150ms ease, transform 150ms ease;
}

.photo-delete:hover {
  background: var(--wish-red);
  transform: scale(1.08);
}

.photo-delete:focus-visible {
  outline: 2px solid var(--wish-red);
  outline-offset: 1px;
}

.photo-empty span {
  font-size: 1.8rem;
}

.photo-empty p {
  font-size: 0.85rem;
}

.photo-empty small {
  font-size: 0.72rem;
}

footer {
  display: flex;
  justify-content: space-between;
  padding: 8px 4px 0;
  color: #8e877b;
  font-size: 0.72rem;
}

.toast-region {
  position: fixed;
  z-index: 20;
  right: 28px;
  bottom: 28px;
  display: grid;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  padding: 12px 15px;
  border: 1px solid rgba(47, 107, 79, 0.22);
  border-radius: 12px;
  color: #34473c;
  background: rgba(247, 252, 246, 0.96);
  box-shadow: var(--shadow);
  animation: toast-in 220ms ease both;
  font-size: 0.85rem;
}

.toast.error {
  border-color: rgba(164, 61, 50, 0.25);
  color: #8b352d;
  background: #fff7f4;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* 对话框本身不设尺寸，交给图片决定：
   图片按自身比例缩放到视口内，弹窗再贴合图片，所以能完整看到整张图 */
.photo-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: auto;
  max-width: 92vw;
  max-height: 92vh;
  padding: 14px;
  border: 0;
  border-radius: 16px;
  background: #24231f;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.4);
}

.photo-dialog::backdrop {
  background: rgba(32, 29, 25, 0.78);
  backdrop-filter: blur(4px);
}

.photo-dialog img {
  display: block;
  width: auto;
  height: auto;
  max-width: calc(92vw - 28px);
  max-height: calc(92vh - 74px);
  border-radius: 8px;
  opacity: 0;
  transition: opacity 160ms ease;
}

.photo-dialog.loaded img {
  opacity: 1;
}

.photo-dialog p {
  flex: none;
  max-width: min(92vw - 28px, 660px);
  margin-top: 10px;
  color: #f7f0e3;
  text-align: center;
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}

.photo-dialog .dialog-close {
  z-index: 2;
  color: white;
  background: rgba(0, 0, 0, 0.45);
}

.settings-dialog {
  position: relative;
  width: min(92vw, 480px);
  padding: 28px;
  border: 1px solid rgba(95, 79, 54, 0.2);
  border-radius: 22px;
  color: var(--ink);
  background:
    linear-gradient(rgba(255, 253, 248, 0.97), rgba(250, 246, 236, 0.98)),
    repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(77, 89, 75, 0.06) 28px);
  box-shadow: 0 28px 80px rgba(53, 45, 34, 0.3);
}

.settings-dialog::backdrop {
  background: rgba(55, 49, 40, 0.48);
  backdrop-filter: blur(3px);
}

.settings-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-right: 38px;
}

.settings-heading h2 {
  font: 700 1.55rem/1.2 "STKaiti", "KaiTi", serif;
  letter-spacing: 0.08em;
}

.settings-heading p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
}

.settings-stamp {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 2px solid var(--terracotta);
  border-radius: 48% 52% 45% 55%;
  color: var(--terracotta);
  font: 700 1.2rem/1 "STKaiti", "KaiTi", serif;
  transform: rotate(-4deg);
}

/* 说明当前分辨率的自动判断结果与可调范围 */
.settings-hint {
  margin-top: 16px;
  padding: 10px 12px;
  border: 1px solid rgba(47, 107, 79, 0.22);
  border-radius: 10px;
  color: #4f6b58;
  background: rgba(47, 107, 79, 0.06);
  font-size: 0.76rem;
  line-height: 1.6;
}

.settings-hint:empty {
  display: none;
}

.settings-controls {
  display: grid;
  gap: 12px;
  margin-top: 26px;
}

.size-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.size-setting span {
  display: grid;
  gap: 2px;
}

.size-setting strong {
  color: #4f4a42;
  font-size: 0.9rem;
}

.size-setting small {
  color: var(--muted);
  font-size: 0.73rem;
}

.size-setting output {
  min-width: 54px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--green);
  background: rgba(255, 255, 255, 0.58);
  font: 700 0.8rem/1.2 "Georgia", serif;
  text-align: center;
}

.settings-controls input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0 0 9px;
  accent-color: var(--green);
  cursor: pointer;
}

.settings-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed rgba(80, 70, 53, 0.2);
}

.settings-actions > div {
  display: flex;
  gap: 8px;
}

.settings-button {
  min-height: 39px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: #565249;
  background: rgba(255, 253, 250, 0.74);
  cursor: pointer;
  font-size: 0.84rem;
}

.settings-button:hover,
.settings-button:focus-visible {
  border-color: rgba(47, 107, 79, 0.45);
  color: var(--green);
  outline: 0;
}

.settings-button.primary {
  border-color: var(--green);
  color: var(--white);
  background: var(--green);
}

.settings-button.reset {
  color: var(--terracotta);
  background: transparent;
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr auto;
  }

  .journey-summary {
    grid-row: 2;
    grid-column: 1 / -1;
    width: 100%;
  }

  .top-actions {
    grid-column: 2;
  }

  .app-shell {
    padding: 14px 14px 10px;
  }

  .map-card {
    min-height: 420px;
  }
}

/* 手机布局：窄屏，或触屏设备（无悬停 + 粗指针）——有些手机浏览器上报的视口很宽，
   只按宽度判断会被误当成桌面，导致抽屉与呼出按钮都不出现 */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
  body {
    overflow: hidden;
  }

  .app-shell {
    padding: 10px 10px 7px;
  }

  .topbar {
    gap: 10px;
    padding-bottom: 10px;
  }

  .brand-mark {
    width: 40px;
    height: 40px;
  }

  .brand-block p,
  .quiet-button span,
  .legend-tip {
    display: none;
  }

  h1 {
    font-size: 1.25rem;
  }

  .quiet-button {
    min-height: 36px;
    padding: 0 9px;
    font-size: 0.76rem;
  }

  .settings-dialog {
    padding: 24px 20px 20px;
  }

  .settings-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .settings-actions > div,
  .settings-button {
    width: 100%;
  }

  .journey-summary {
    min-width: 0;
    padding: 8px 12px;
  }

  .workspace {
    min-height: 0;
  }

  .map-card {
    min-height: 0;
    border-radius: 18px;
  }

  .map-tools {
    top: 10px;
    left: 10px;
    flex-wrap: wrap;
    gap: 6px;
    max-width: calc(100% - 20px);
  }

  .search-box {
    width: calc(100vw - 90px);
    height: 39px;
  }

  .filter-tabs {
    order: 3;
  }

  .round-button {
    width: 39px;
    height: 39px;
  }

  .legend {
    bottom: 8px;
    left: 8px;
  }

  footer {
    display: none;
  }

  .city-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 80vh;
    /* iPhone 底部横条：留给抽屉底部操作条 */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    border-radius: 22px 22px 0 0;
    transform: translateY(calc(100% + 20px));
  }

  /* 窄屏内边距收窄；底部操作条同样钉住 */
  .city-content,
  .menu-view {
    padding: 30px 20px 24px;
  }

  .panel-toolbar {
    padding: 14px 20px 18px;
  }

  .city-panel.open {
    transform: translateY(0);
  }

  /* 菜单态比城市态矮：日历用不着占满 80vh，少挡地图 */
  .city-panel.view-menu {
    max-height: 62vh;
  }

  /* 收起时露出的呼出胶囊，钉在地图底部中央（含 iPhone 底部横条安全区） */
  .panel-toggle {
    position: absolute;
    z-index: 6;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    display: inline-flex;
    transform: translateX(-50%);
  }

  /* 抽屉顶部把手：一条可见的短横 + 整条可点/可拖的命中区 */
  .panel-handle {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 24px;
    padding: 0;
    border: 0;
    background: none;
    cursor: grab;
    touch-action: none;
  }

  .panel-handle-bar {
    position: absolute;
    top: 9px;
    left: 50%;
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: #d6cbb8;
    transform: translateX(-50%);
  }

  /* 抽屉右上角的收起按钮 */
  .panel-close {
    position: absolute;
    z-index: 2;
    top: 10px;
    right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: rgba(240, 233, 220, 0.92);
    color: #7a6a56;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
  }

  /* 单手缩放按钮：右下角竖排，双指不方便时用（避开底部胶囊） */
  .map-zoom {
    position: absolute;
    z-index: 6;
    right: 10px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .zoom-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(95, 79, 54, 0.2);
    border-radius: 50%;
    background: rgba(255, 253, 248, 0.94);
    color: #2f6b4f;
    box-shadow: 0 8px 22px rgba(59, 49, 36, 0.18);
    cursor: pointer;
    font-size: 1.05rem;
    font-weight: 700;
  }

  .zoom-button:active {
    background: rgba(244, 236, 220, 0.98);
  }

  /* 窄屏把日历压扁一点，好让下面的清单也能露出来 */
  .calendar-day {
    min-height: 40px;
    font-size: 0.78rem;
  }

  .calendar-holiday {
    font-size: 0.56rem;
  }

  .want-list {
    max-height: 180px;
  }

  .toast-region {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }

  .toast {
    min-width: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
