/* ============================================================
   旅行規劃｜淺色日系繪本風
   ============================================================ */
:root {
  --paper: #FFFCF6;
  --card: #FFFFFF;
  --ink: #3E3A39;
  --yellow: #F6D27A;
  --coral: #F2A497;
  --water: #A8D3E6;
  --green: #B9DAA5;
  --gold: #8C5D00;
  --red: #A33C32;
  --lavender: #DED2ED;
  --apricot: #F4C7AA;
  --water-active: color-mix(in srgb, #A8D3E6 75%, #000 25%);
  --line: #E9E2D4;
  --muted: #6E6865;
  --bw: 3px;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 12px;
  --hour: 52px;
  --font: "Huninn", "jf-openhuninn", "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 110px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: normal; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 999px; z-index: 100; }
.skip:focus { left: 16px; }

.muted { color: var(--muted); }

/* ---------- 頁首 ---------- */
.site-header {
  max-width: 1440px; margin: 0 auto; padding: 18px 16px 8px;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.brand { flex: 0 0 auto; width: 251px; height: 66px; }
.brand svg { width: 100%; height: 100%; overflow: visible; }
.brand-train { animation: train-bob 4s ease-in-out infinite; }
@keyframes train-bob { 0%, 100% { transform: translateX(0); } 50% { transform: translateX(3px); } }

.trip-summary { flex: 1 1 320px; min-width: 0; }
.trip-summary h1 { font-size: 1.7rem; line-height: 1.25; }
.trip-meta { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.trip-meta li {
  border: 2px solid var(--ink); border-radius: 999px; background: var(--card);
  padding: 2px 12px; font-size: .9rem; display: inline-flex; align-items: center; gap: 6px;
}
.meta-cost #metaCost { font-variant-numeric: tabular-nums; }
.eye {
  border: 2px solid var(--ink); background: #fff; color: var(--ink);
  width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; padding: 0;
  margin-right: -8px;
}

/* ---------- 分頁導覽 ---------- */
.pagetabs {
  max-width: 1440px; margin: 0 auto; padding: 8px 16px 14px;
  display: flex; gap: 10px; flex-wrap: wrap;
}
.pagetabs button {
  border: var(--bw) solid var(--ink); background: var(--card); border-radius: 999px;
  padding: 6px 18px; font-size: 1rem;
}
.pagetabs button[aria-current="page"] { background: var(--green); }

main { max-width: 1440px; margin: 0 auto; padding: 0 16px; }

/* ---------- 共用容器與按鈕 ---------- */
.panel {
  background: var(--card); border: var(--bw) solid var(--ink); border-radius: var(--r-lg);
  overflow: hidden; min-width: 0;
}
.btn {
  border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 6px 16px;
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.3; text-decoration: none; color: var(--ink);
}
.btn.primary { background: var(--green); }
.btn.danger { background: var(--red); color: #fff; }
.btn:disabled, .tb-btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.small { padding: 3px 10px; font-size: .85rem; }
.icon-btn { border: 2px solid var(--ink); background: #fff; border-radius: 50%; width: 32px; height: 32px; display: inline-grid; place-items: center; padding: 0; }
.tag {
  display: inline-block; border: 1.5px solid var(--ink); border-radius: 999px; padding: 0 8px;
  font-size: .75rem; line-height: 1.5; background: #fff; white-space: nowrap;
}
.tag.est { background: #FFF4D6; border-style: dashed; }
.tag.pend { background: #FDE8E4; border-style: dashed; }
.tag.ok { background: #EEF7E8; }

.cat-sight { --cat: var(--yellow); }
.cat-food { --cat: var(--coral); }
.cat-stay { --cat: var(--water); }
.cat-transport, .cat-flight { --cat: var(--green); }

/* ============================================================
   規劃頁：左側地圖、右側行事曆
   ============================================================ */
#workspace {
  display: grid; gap: 16px;
  grid-template-columns: minmax(300px, 5fr) minmax(0, 7fr);
  grid-template-areas: "map cal" "route cal";
  grid-template-rows: auto 1fr;
  align-items: start;
}
#workspace.timelinepreview { grid-template-columns: minmax(300px, 4fr) minmax(0, 6fr); }
#mappanel { grid-area: map; }
#routepanel { grid-area: route; }
#calendarpanel { grid-area: cal; }

/* 地圖 */
.mapheading {
  background: var(--water); border-bottom: var(--bw) solid var(--ink);
  display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; flex-wrap: wrap;
}
.mapheading h2 { font-size: 1.15rem; }
.mapbuttons { display: flex; gap: 6px; }
.mapbuttons button {
  border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 3px 12px; font-size: .9rem;
}
.mapbuttons button[aria-pressed="true"] { background: var(--water-active); color: #fff; }
#map { height: 460px; background: #EEF0F1; position: relative; z-index: 0; }
#map .leaflet-tile-pane { filter: saturate(.28) contrast(.95) brightness(1.04); }
#map iframe { width: 100%; height: 100%; border: 0; }
.map-fallback { padding: 16px; }
.map-pin span {
  display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: #fff; border: 3px solid #555555; font-size: 13px; color: var(--ink); font-family: var(--font);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--cat) 70%, transparent);
}
.map-pin.is-selected span { background: var(--cat); border-color: var(--ink); transform: scale(1.15); }
.leaflet-tooltip { font-family: var(--font); border: 2px solid var(--ink); border-radius: 10px; }

/* 交通明細 */
#routepanel summary {
  background: var(--coral); padding: 10px 14px; cursor: pointer; list-style: none;
  display: flex; align-items: center; gap: 10px; font-size: 1.1rem;
}
#routepanel summary::-webkit-details-marker { display: none; }
#routepanel[open] summary { border-bottom: var(--bw) solid var(--ink); }
#routepanel .sum-meta { font-size: .85rem; margin-left: auto; }
#routepanel .chev { transition: transform 160ms ease-out; }
#routepanel:not([open]) .chev { transform: rotate(-90deg); }
#routelist { padding: 10px 12px 12px; max-height: 420px; overflow: auto; }
.route-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.route-list li {
  border: 2px solid var(--ink); border-radius: var(--r-sm); padding: 8px 10px; background: #fff;
  display: grid; gap: 4px;
}
.route-list li.is-selected { background: #FFF8E6; }
.route-list li.warn { border-color: var(--red); }
.route-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .9rem; }
.route-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.route-note { font-size: .8rem; color: var(--muted); margin: 8px 2px 0; }
.segs { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.seg {
  display: inline-flex; align-items: center; gap: 4px; font-size: .8rem;
  border-radius: 999px; padding: 1px 8px; background: color-mix(in srgb, var(--mc, #84909E) 16%, #fff);
  border: 1.5px solid var(--mc, #84909E);
}
.seg i { color: var(--ink); }
.segs .sep { font-size: .7rem; color: var(--muted); }

/* ---------- 行事曆工具列 ---------- */
.paneltoolbar {
  background: var(--yellow); border-bottom: var(--bw) solid var(--ink);
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; flex-wrap: wrap;
}
.pt-title { display: flex; align-items: baseline; gap: 10px; margin-right: auto; }
.pt-title h2 { font-size: 1.15rem; }
#yearmonth { font-size: .9rem; }
.calendar-viewtoggle { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #fff; }
.calendar-viewtoggle button { border: 0; background: transparent; padding: 3px 14px; }
.calendar-viewtoggle button + button { border-left: 2px solid var(--ink); }
.calendar-viewtoggle button[aria-pressed="true"] { background: var(--gold); color: #fff; }
.toolbarbuttons { display: flex; gap: 6px; }
.tb-btn { border: 2px solid var(--ink); background: #fff; border-radius: 999px; padding: 3px 12px; }
.tb-btn.add { width: 34px; padding: 3px 0; font-size: 1.05rem; line-height: 1.2; }

/* ---------- 日期列（週／單日共用） ---------- */
.timeline-dates { border-bottom: 2px dashed var(--line); background: var(--paper); }
.date-track {
  position: relative; display: flex; padding: 40px 10px 8px; overflow-x: auto; overflow-y: hidden;
  scrollbar-width: thin;
}
.date-track::before {
  content: ""; position: absolute; left: 30px; right: 30px; top: 57px; height: 3px; background: var(--ink);
  border-radius: 3px; z-index: 0;
}
.date-station {
  position: relative; z-index: 1; flex: 1 0 64px; border: 0; background: transparent; padding: 0 2px;
  display: grid; justify-items: center; gap: 2px;
}
.date-num {
  width: 36px; height: 36px; border-radius: 50%; border: var(--bw) solid var(--ink); background: var(--paper);
  display: grid; place-items: center; font-size: 1rem;
}
.date-station[aria-selected="true"] .date-num { background: var(--green); }
.date-station .date-lbl { font-size: .78rem; white-space: nowrap; }
.date-station[aria-selected="true"] .date-lbl { font-weight: bold; }
.date-num.bounce { animation: date-bounce 320ms ease-out; }
@keyframes date-bounce { 45% { transform: translateY(-3px) scale(1.12); } 100% { transform: none; } }
.date-station.has-issue .date-num::after {
  content: "!"; position: absolute; top: -4px; margin-left: 30px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); color: #fff; font-size: 11px; display: grid; place-items: center;
}
.date-illus {
  position: absolute; top: 3px; left: 0; width: 44px; height: 33px; z-index: 2;
  transform: translateX(-50%);
  transition: left 550ms cubic-bezier(.3, .1, .25, 1);
  pointer-events: none;
}
.date-illus svg { width: 100%; height: 100%; display: block; overflow: visible; }
.date-illus.hop svg { animation: illus-hop 550ms cubic-bezier(.3, .1, .25, 1); }
@keyframes illus-hop { 45% { transform: translateY(-4px); } 100% { transform: none; } }

/* ---------- 週視圖 ---------- */
#calendar { position: relative; }
.week-scroll { max-height: 72vh; overflow: auto; position: relative; }
.week-grid { display: grid; min-width: max-content; }
.wk-corner, .wk-head { position: sticky; top: 0; z-index: 3; background: var(--card); border-bottom: 2px solid var(--ink); }
.wk-corner { left: 0; z-index: 4; }
.wk-head {
  border: 0; border-bottom: 2px solid var(--ink); border-left: 1px solid var(--line);
  padding: 6px 4px; display: grid; justify-items: center; font-size: .88rem;
}
.wk-head small { font-size: .75rem; color: var(--muted); }
.wk-head.is-sel { background: #F3F9EE; box-shadow: inset 0 -4px 0 var(--green); }
.wk-gutter { position: sticky; left: 0; z-index: 2; background: var(--card); border-right: 1px solid var(--line); }
.wk-gutter span { position: absolute; right: 6px; font-size: .72rem; color: var(--muted); transform: translateY(-50%); }
.wk-col {
  position: relative; border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) - 1px), var(--line) calc(var(--hour) - 1px) var(--hour));
}
.wk-col.is-sel { background-color: #FBFDF8; }
.wk-off { position: absolute; left: 0; right: 0; background: repeating-linear-gradient(135deg, #F4EFE5 0 6px, transparent 6px 12px); pointer-events: none; }
.wk-now { position: absolute; left: 0; right: 0; border-top: 2px solid var(--red); z-index: 2; pointer-events: none; }

.cal-item {
  position: absolute; background: #fff; border: 2px solid var(--ink); border-left: 7px solid var(--cat);
  border-radius: 10px; padding: 3px 6px 8px; overflow: hidden; font-size: .78rem; line-height: 1.3;
  cursor: pointer; user-select: none; -webkit-user-select: none; z-index: 1;
  transition: box-shadow 160ms ease-out;
}
.cal-item:hover, .cal-item:focus-visible { z-index: 5; box-shadow: 0 3px 0 var(--ink); }
.cal-item.is-selected { box-shadow: 0 0 0 3px var(--gold); z-index: 4; }
.cal-item .ci-time { font-size: .72rem; display: flex; gap: 4px; align-items: center; }
.cal-item .ci-name { font-weight: bold; word-break: break-word; }
.cal-item .warn-dot { color: var(--red); }
.cal-item.has-issue { border-color: var(--red); border-left-color: var(--cat); }
.cal-item.is-locked { background-image: repeating-linear-gradient(135deg, transparent 0 8px, #F7F3EA 8px 10px); }
.cal-item .resize-handle {
  position: absolute; left: 0; right: 0; bottom: 0; height: 9px; cursor: ns-resize; touch-action: none;
}
.cal-item .resize-handle::after {
  content: ""; position: absolute; left: 50%; bottom: 3px; width: 22px; height: 3px; margin-left: -11px; border-radius: 3px; background: var(--ink); opacity: .35;
}
.cal-item:hover .resize-handle::after { opacity: .8; }
.cal-item.pressing::before {
  content: ""; position: absolute; left: 0; top: 0; height: 3px; background: var(--gold);
  animation: press-fill 3s linear forwards;
}
@keyframes press-fill { from { width: 0; } to { width: 100%; } }
.cal-item.drag-armed { opacity: .45; outline: 2px dashed var(--gold); }
.cal-item.resizing { z-index: 6; box-shadow: 0 0 0 3px var(--gold); }
.cal-ghost {
  position: absolute; left: 3px; right: 18px; border: 2px dashed var(--gold); background: #FFF6DE; border-radius: 10px;
  font-size: .75rem; padding: 3px 6px; pointer-events: none; z-index: 8;
}
.cal-leg {
  position: absolute; right: 2px; width: 13px; border-radius: 7px; border: 1.5px solid var(--ink);
  background: var(--mc, #84909E); cursor: pointer; z-index: 2; min-height: 10px;
}
.cal-leg.est { background-image: repeating-linear-gradient(180deg, transparent 0 4px, rgba(255,255,255,.6) 4px 7px); }
.cal-leg.warn { box-shadow: 0 0 0 2px var(--red); }
.cal-hint { font-size: .78rem; color: var(--muted); padding: 6px 12px 10px; margin: 0; border-top: 1px dashed var(--line); }

/* ---------- 單日時間軸 ---------- */
.timeline-intro {
  padding: 10px 14px; display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; font-size: .9rem;
  border-bottom: 2px dashed var(--line);
}
.timeline-intro strong { font-size: 1.05rem; }
.timeline-intro label { display: inline-flex; align-items: center; gap: 4px; }
.timeline-intro input[type="time"] { border: 2px solid var(--ink); border-radius: 10px; padding: 1px 6px; background: #fff; }
.timeline-intro .day-note { flex-basis: 100%; color: var(--muted); font-size: .85rem; }

.timeline-list {
  display: grid; grid-template-columns: 78px minmax(0, 1fr);
  height: clamp(460px, 74vh, 920px); position: relative;
}
.day-time-scale { position: relative; display: flex; align-items: center; justify-content: center; border-right: 1px solid var(--line); }
.scale-track { position: relative; width: 100%; height: min(60vh, calc(100% - 56px)); }
.scale-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--ink); border-radius: 3px; }
.scale-tick { position: absolute; left: 50%; width: 8px; height: 2px; margin-left: 2px; background: var(--ink); opacity: .35; }
.scale-tick span { position: absolute; left: 10px; top: -8px; font-size: .62rem; color: var(--muted); }
.scale-end {
  position: absolute; left: 50%; transform: translate(-50%, 0); font-size: .78rem; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 999px; padding: 0 6px; white-space: nowrap; z-index: 1;
}
.scale-end.top { top: -28px; }
.scale-end.bottom { bottom: -28px; }
.scale-dot {
  position: absolute; left: 50%; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--ink); background: #fff;
  transform: translate(-50%, -50%); transition: top 160ms ease-out; z-index: 3;
}
.now-line { position: absolute; left: 4px; right: 0; border-top: 2px solid var(--red); z-index: 2; }
.now-line span {
  position: absolute; left: -2px; top: -11px; background: var(--red); color: #fff; font-size: .68rem; border-radius: 6px; padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

.timeline-cards {
  position: relative; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  padding: 30vh 16px 30vh 14px; scroll-behavior: auto;
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.timeline-cards:focus-visible { outline-offset: -3px; }
.timeline-time-row { position: relative; padding: 7px 0; --fade: 0; }
.timeline-card {
  position: relative; width: 94%; background: #fff; border: 2px solid var(--ink); border-left: 8px solid var(--cat, var(--green));
  border-radius: var(--r-md); padding: 10px 14px 10px 12px; display: grid; gap: 4px;
  transform-origin: left center; transition: transform 160ms ease-out, filter 160ms ease-out;
  filter: blur(calc(0.15px + var(--fade) * 1.6px));
}
.timeline-card::after {
  content: ""; position: absolute; inset: -2px; border-radius: inherit; pointer-events: none;
  background: linear-gradient(to bottom, rgba(255,252,246, calc(var(--fade) * .15)), rgba(255,252,246, calc(var(--fade) * .82)));
  transition: opacity 160ms ease-out;
}
.timeline-time-row.above .timeline-card::after {
  background: linear-gradient(to top, rgba(255,252,246, calc(var(--fade) * .15)), rgba(255,252,246, calc(var(--fade) * .82)));
}
.timeline-time-row.timeline-current .timeline-card { transform: scale(1.05); filter: none; z-index: 1; }
.timeline-time-row.timeline-current .timeline-card::after { opacity: 0; }
.timeline-card:hover, .timeline-card:focus-within, .timeline-card:focus { filter: none; }
.timeline-card:hover::after, .timeline-card:focus-within::after, .timeline-card:focus::after { opacity: 0; }
.timeline-card.is-selected { box-shadow: 0 0 0 3px var(--gold); }
.timeline-card header { padding-right: 34px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: .85rem; }
.tc-time { font-variant-numeric: tabular-nums; font-weight: bold; }
.tc-dur { color: var(--muted); }
.timeline-card h3 { font-size: 1.08rem; line-height: 1.35; }
.tc-line { margin: 0; font-size: .86rem; display: flex; gap: 6px; align-items: baseline; }
.tc-line i { width: 14px; text-align: center; color: var(--muted); }
.tc-warn { margin: 0; padding: 0; list-style: none; color: var(--red); font-size: .84rem; }
.tc-edit { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; }
.timeline-card .tc-src { font-size: .8rem; color: var(--gold); }
.leg-card { --cat: var(--green); background: #FBFDF9; border-style: dashed; border-left-style: solid; }
.leg-card.walk-only { --cat: var(--yellow); background: #FFFDF6; }
.leg-card .leg-ft { font-size: .88rem; }
.timeline-empty { text-align: center; padding: 30px 10px; color: var(--muted); }

/* ---------- 預覽浮窗 ---------- */
#popover {
  position: fixed; z-index: 60; width: min(320px, calc(100vw - 32px)); background: #fff; border: var(--bw) solid var(--ink);
  border-radius: var(--r-md); padding: 14px 16px 12px; box-shadow: 0 6px 0 rgba(62,58,57,.18);
}
#popover h3 { font-size: 1.1rem; padding-right: 30px; }
#popover p { margin: 4px 0; font-size: .88rem; }
#popover .pop-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#popover .pop-close { position: absolute; top: 8px; right: 8px; }
#popover .pop-cat { height: 6px; border-radius: 6px; background: var(--cat); margin: -4px 0 8px; width: 48px; }

/* ============================================================
   費用總覽
   ============================================================ */
.exp-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.exp-col { display: grid; gap: 16px; min-width: 0; }
.exp-card { background: #fff; border: var(--bw) solid var(--ink); border-radius: var(--r-lg); padding: 16px 18px; }
.exp-card h2 { font-size: 1.2rem; margin-bottom: 10px; }
.tot-rows { display: grid; gap: 8px; }
.tot-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; border-bottom: 1px dashed var(--line); padding-bottom: 6px; flex-wrap: wrap; }
.tot-row .amt { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.tot-row.big .amt { font-size: 1.6rem; }
.tot-row.big { border-bottom: 0; background: #F3F9EE; border-radius: var(--r-sm); padding: 8px 10px; border: 2px solid var(--ink); }
.exp-hint { font-size: .85rem; margin: 10px 0 0; }
.exp-warn { color: var(--red); }
.budget-bar { height: 14px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: var(--paper); margin: 8px 0 4px; }
.budget-bar span { display: block; height: 100%; background: var(--green); }
.budget-bar.over span { background: var(--coral); }
.exp-table-wrap { overflow-x: auto; border: var(--bw) solid var(--ink); border-radius: var(--r-lg); background: #fff; }
.exp-table { width: 100%; border-collapse: collapse; font-size: .88rem; }
.exp-table th, .exp-table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.exp-table { min-width: 560px; }
.exp-table td:nth-child(2) { min-width: 11em; }
.exp-table td.num, .exp-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.exp-table thead th { background: var(--paper); border-bottom: 2px solid var(--ink); font-weight: normal; }
.exp-table tr.cat-row th { background: var(--c); border-top: 2px solid var(--ink); border-bottom: 2px solid var(--ink); }
.exp-table tr.cat-row th .num { float: right; }
.exp-table tr.row-food td { background: color-mix(in srgb, var(--coral) 12%, #fff); }
.exp-table tr.is-pending td { color: var(--muted); }
.linkbtn { border: 0; background: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; text-align: left; }
.pie-wrap { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: 18px; align-items: center; }
.pie { width: 100%; height: auto; display: block; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: grid; grid-template-columns: 18px 1fr auto; gap: 8px; align-items: center; font-size: .9rem; }
.legend .sw { width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--ink); background: var(--c); }
.legend .num { font-variant-numeric: tabular-nums; text-align: right; }
.legend small { display: block; color: var(--muted); }

/* ============================================================
   攜帶用品
   ============================================================ */
.pk-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; padding: 12px 14px; margin-bottom: 16px; overflow: visible; }
.pk-search { display: flex; align-items: center; gap: 8px; border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px; flex: 1 1 220px; background: #fff; }
.pk-search input { border: 0; outline: 0; width: 100%; background: transparent; }
.pk-search:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.pk-filter { display: inline-flex; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; }
.pk-filter button { border: 0; background: #fff; padding: 4px 12px; }
.pk-filter button + button { border-left: 2px solid var(--ink); }
.pk-filter button[aria-pressed="true"] { background: var(--green); }
.pk-progress { flex: 1 1 240px; display: grid; gap: 4px; font-size: .88rem; }
.pk-bar { height: 14px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper); overflow: hidden; }
.pk-bar span { display: block; height: 100%; background: var(--green); transition: width 200ms ease-out; }
#packgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; align-items: start; }
.pk-group { background: #fff; border: var(--bw) solid var(--ink); border-radius: var(--r-lg); overflow: hidden; }
.pk-group > header { background: var(--c); border-bottom: var(--bw) solid var(--ink); padding: 8px 14px; display: flex; justify-content: space-between; align-items: center; }
.pk-group h3 { font-size: 1.05rem; }
.pk-list { list-style: none; margin: 0; padding: 6px 10px; display: grid; gap: 2px; }
.pk-item { display: grid; grid-template-columns: 1fr 58px 32px; gap: 6px; align-items: center; padding: 5px 2px; border-bottom: 1px dashed var(--line); }
.pk-item label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pk-item input[type="checkbox"] { width: 20px; height: 20px; accent-color: #6FA35A; flex: none; }
.pk-item.done .pk-name { text-decoration: line-through; color: var(--muted); }
.pk-item input.pk-qty { width: 100%; border: 2px solid var(--ink); border-radius: 10px; padding: 1px 4px; text-align: center; }
.pk-item input.pk-note { grid-column: 1 / -1; border: 0; border-bottom: 1px solid var(--line); font-size: .82rem; padding: 2px 4px 2px 28px; background: transparent; color: var(--muted); }
.pk-item .icon-btn { width: 28px; height: 28px; font-size: .8rem; }
.pk-add { display: flex; gap: 6px; padding: 8px 10px 12px; }
.pk-add input { flex: 1; border: 2px solid var(--ink); border-radius: 999px; padding: 4px 12px; min-width: 0; }
.pk-empty { padding: 10px; color: var(--muted); font-size: .88rem; }

/* ============================================================
   底部工具籤、提示、對話框
   ============================================================ */
.toolfab { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 50; display: grid; justify-items: center; }
.fab {
  width: 60px; height: 60px; border-radius: 50%; border: var(--bw) solid var(--ink); background: var(--green); color: #fff;
  font-size: 1.35rem; display: grid; place-items: center; box-shadow: 0 4px 0 var(--ink);
}
.fab i { transition: transform 160ms ease-out; -webkit-text-stroke: 1px var(--ink); }
.fab[aria-expanded="true"] i { transform: rotate(180deg); }
.toolmenu {
  position: absolute; bottom: 74px; left: 50%; transform: translateX(-50%); width: max-content; min-width: 220px;
  background: #fff; border: var(--bw) solid var(--ink); border-radius: var(--r-lg); padding: 8px; display: grid; gap: 4px;
  box-shadow: 0 6px 0 rgba(62,58,57,.18);
}
.toolmenu button { border: 0; background: transparent; text-align: left; padding: 8px 12px; border-radius: 12px; display: flex; gap: 10px; align-items: center; }
.toolmenu button:hover, .toolmenu button:focus-visible { background: #F3F9EE; }
.toolmenu i { width: 18px; text-align: center; }

#toast {
  position: fixed; left: 50%; bottom: 92px; transform: translateX(-50%); z-index: 70; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 8px 16px; border-radius: 999px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity 200ms;
}
#toast.show { opacity: 1; }

dialog {
  border: var(--bw) solid var(--ink); border-radius: var(--r-lg); padding: 0; background: var(--paper); color: var(--ink);
  width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
}
dialog::backdrop { background: rgba(62,58,57,.35); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 38px); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--green); border-bottom: var(--bw) solid var(--ink); }
.dlg-head h2 { font-size: 1.15rem; }
.dlg-body { padding: 14px 16px; overflow: auto; }
.dlg-foot { display: flex; gap: 8px; padding: 12px 16px; border-top: 2px dashed var(--line); flex-wrap: wrap; }
.dlg-foot .grow { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.form-grid label, .cost-fs label { display: grid; gap: 3px; font-size: .86rem; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid input:not([type="checkbox"]), .form-grid select, .form-grid textarea, .seg-row input, .seg-row select {
  border: 2px solid var(--ink); border-radius: var(--r-sm); padding: 6px 10px; background: #fff; width: 100%; min-width: 0;
}
.form-grid input:disabled { background: #F3F0EA; opacity: .6; }
.form-grid label.check { display: flex; align-items: center; gap: 8px; align-self: end; padding-bottom: 6px; }
.form-grid label.check input { width: 18px; height: 18px; accent-color: #6FA35A; }
.cost-fs { border: 2px dashed var(--ink); border-radius: var(--r-md); display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; padding: 8px 12px 12px; margin: 0; }
.cost-fs legend { padding: 0 6px; }
.form-hint { font-size: .8rem; color: var(--muted); margin: 0; }
.form-error { color: var(--red); font-size: .85rem; margin: 8px 0 0; }
.seg-list { display: grid; gap: 8px; margin: 10px 0; }
.seg-row { display: grid; grid-template-columns: 1.2fr .8fr .9fr 1fr 32px; gap: 6px; align-items: end; }
.seg-row label { display: grid; gap: 2px; font-size: .78rem; }

/* ============================================================
   斷點：850／700／600
   ============================================================ */
@media (max-width: 1100px) {
  .exp-grid { grid-template-columns: 1fr; }
}
@media (max-width: 850px) {
  #workspace, #workspace.timelinepreview { grid-template-columns: minmax(0, 1fr); grid-template-areas: "map" "cal" "route"; }
  #map { height: 300px; }
  .brand { width: 200px; height: 53px; }
}
@media (max-width: 700px) {
  .paneltoolbar { gap: 8px; }
  .mapbuttons button { padding: 3px 10px; }
  .date-station { flex-basis: 56px; }
  .pie-wrap { grid-template-columns: 1fr; justify-items: center; }
  .pie { max-width: 220px; }
  .legend { width: 100%; }
}
@media (max-width: 600px) {
  body { font-size: 14.5px; }
  .site-header { gap: 10px; padding-top: 12px; }
  .brand { width: 168px; height: 44px; }
  .trip-summary h1 { font-size: 1.35rem; }
  .pagetabs button { padding: 5px 13px; font-size: .92rem; }
  .paneltoolbar { display: grid; grid-template-columns: 1fr auto; align-items: center; row-gap: 8px; }
  .pt-title { flex-direction: column; align-items: flex-start; gap: 0; margin: 0; }
  .calendar-viewtoggle { grid-column: 1; grid-row: 2; justify-self: start; }
  .toolbarbuttons { grid-column: 2; grid-row: 1 / span 2; }
  .timeline-list { grid-template-columns: 58px minmax(0, 1fr); height: clamp(440px, 70vh, 800px); }
  .timeline-cards { padding-left: 10px; padding-right: 10px; }
  .timeline-card { width: 100%; transform-origin: center center; }
  .timeline-time-row.timeline-current .timeline-card { transform: scaleY(1.05); }
  .form-grid { grid-template-columns: 1fr; }
  .seg-row { grid-template-columns: 1fr 1fr; }
  .seg-row .icon-btn { justify-self: end; }
  #popover { left: 16px !important; right: 16px; top: auto !important; bottom: 92px; width: auto; }
  .exp-card { padding: 14px; }
  .tot-row.big .amt { font-size: 1.35rem; }
}

/* ---------- 減少動態效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  html, .timeline-cards { scroll-behavior: auto; }
  .brand-train, .date-num.bounce, .date-illus.hop svg, .cal-item.pressing::before { animation: none !important; }
  .date-illus, .scale-dot, .timeline-card, .fab i, #routepanel .chev, .pk-bar span { transition: none !important; }
}
