/* 機票追蹤網站
   設計：沖繩的海。整頁安靜的淺色，唯一的重點是上方深海色的「航班看板」，價格用翻牌數字顯示。
   價格日曆用單一青色色階（便宜＝深），每格一定寫數字；最便宜那天另外加金色外框和「最低」字樣。 */

:root {
  --bg: #f2f6f7;
  --card: #ffffff;
  --ink: #102733;
  --muted: #566b75;
  --line: #d9e3e6;
  --sea: #0b6e79;
  --sea-ink: #ffffff;
  --lagoon: #3fb8af;
  --sun: #d99a12;
  --down: #08805f;
  --up: #b5432f;
  --board: #0e2430;
  --board-2: #16323f;
  --tile: #1c3c4a;
  --tile-ink: #f4f1e6;
  --b0: #0b6e79; --b0-ink: #ffffff;
  --b1: #79c0c3; --b1-ink: #0c2a33;
  --b2: #b0dad9; --b2-ink: #102733;
  --b3: #d8ecea; --b3-ink: #102733;
  --b4: #eef4f4; --b4-ink: #3c525c;
  --range: #e3f2f1;
  --shadow: 0 1px 2px rgba(16, 39, 51, .06), 0 8px 24px rgba(16, 39, 51, .06);
  --r: 14px;
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in: cubic-bezier(.55, 0, 1, .45);
  --font: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --num: "Barlow Condensed", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b171d; --card: #11222a; --ink: #e4edf0; --muted: #9bb0b8; --line: #22373f;
    --sea: #3fb8af; --sea-ink: #062026; --lagoon: #3fb8af; --sun: #f0b43a; --down: #4fd0a0; --up: #ff8a73;
    --board: #071419; --board-2: #0f252d; --tile: #17323c; --tile-ink: #f4f1e6;
    --b0: #3fb8af; --b0-ink: #062026;
    --b1: #2b8b87; --b1-ink: #f2fbfa;
    --b2: #1f6766; --b2-ink: #e8f4f3;
    --b3: #194a4d; --b3-ink: #e0eef0;
    --b4: #16323a; --b4-ink: #b9cdd3;
    --range: #123137;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}
/* 選單裡手動選「深色」：同一組深色色票 */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b171d; --card: #11222a; --ink: #e4edf0; --muted: #9bb0b8; --line: #22373f;
  --sea: #3fb8af; --sea-ink: #062026; --lagoon: #3fb8af; --sun: #f0b43a; --down: #4fd0a0; --up: #ff8a73;
  --board: #071419; --board-2: #0f252d; --tile: #17323c; --tile-ink: #f4f1e6;
  --b0: #3fb8af; --b0-ink: #062026;
  --b1: #2b8b87; --b1-ink: #f2fbfa;
  --b2: #1f6766; --b2-ink: #e8f4f3;
  --b3: #194a4d; --b3-ink: #e0eef0;
  --b4: #16323a; --b4-ink: #b9cdd3;
  --range: #123137;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* 有 display 設定的元件（選單、底部列）也要藏得住 */
html { -webkit-text-size-adjust: 100%; }
@media (pointer: fine) { html { overscroll-behavior: none; } }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.6 var(--font); font-variant-numeric: tabular-nums;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
select { background-color: var(--card); color: var(--ink); }
a { color: var(--sea); }
:focus-visible { outline: 2px solid var(--sea); outline-offset: 2px; border-radius: 6px; }
.sr, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip:focus { position: fixed; top: 8px; left: 8px; z-index: 99; background: var(--card); padding: 8px 12px; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.muted { color: var(--muted); }

/* ---------- 上方列 ---------- */
.top { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1240px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { color: var(--sea); display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: color-mix(in srgb, var(--sea) 12%, transparent); }
.trip-pick select {
  appearance: none; border: 1px solid var(--line); border-radius: 10px; padding: 7px 34px 7px 12px; min-height: 40px;
  font-weight: 700; font-size: 16px; background: var(--card) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23566b75' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center;
}
.top-status { font-size: 13px; color: var(--muted); flex: 1; min-width: 160px; }
.top-status b { color: var(--ink); font-weight: 500; }
.top-actions { display: flex; gap: 8px; }
.btn {
  border: 1px solid var(--sea); background: var(--sea); color: var(--sea-ink); border-radius: 10px;
  padding: 8px 14px; min-height: 40px; font-weight: 500; white-space: nowrap;
  transition: transform .1s var(--ease-out), background-color .15s, opacity .15s;
}
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; color: var(--sea); }
.btn[disabled] { opacity: .55; cursor: default; }
.btn.small { min-height: 34px; padding: 5px 10px; font-size: 14px; }
.btn.danger { border-color: var(--up); background: transparent; color: var(--up); }
.icon-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; font-size: 18px; color: var(--muted); }
.icon-btn:hover { background: var(--line); }
.progress { height: 3px; background: color-mix(in srgb, var(--sea) 15%, transparent); overflow: hidden; }
.progress .bar { height: 100%; background: var(--sea); transform-origin: left; transform: scaleX(0); transition: transform .4s var(--ease-out); }

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

/* ---------- 提醒 ---------- */
.warn { border: 1px solid var(--up); background: color-mix(in srgb, var(--up) 8%, var(--card)); border-radius: var(--r); padding: 12px 16px; margin-bottom: 12px; }

/* ---------- 航班看板（全頁唯一的重點） ---------- */
.board { background: var(--board); color: var(--tile-ink); border-radius: 18px; padding: 18px 20px 16px; box-shadow: var(--shadow); }
.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.board h1 { font-size: 17px; font-weight: 500; color: color-mix(in srgb, var(--tile-ink) 80%, transparent); }
.seg { display: inline-flex; background: var(--board-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--tile-ink); opacity: .75; border-radius: 8px; padding: 6px 11px; min-height: 36px; font-size: 14px; transition: background-color .15s var(--ease-out), opacity .15s; }
.seg button[aria-checked="true"] { background: var(--tile-ink); color: var(--board); opacity: 1; font-weight: 700; }
.seg button:hover { opacity: 1; }
.board-body { display: flex; align-items: center; gap: 20px 28px; margin-top: 14px; flex-wrap: wrap; }
.flap { display: flex; align-items: baseline; gap: 4px; perspective: 400px; }
.flap .d {
  display: inline-grid; place-items: center; min-width: .62em; padding: 0 .06em; height: 1.18em;
  font: 700 56px/1 var(--num); background: var(--tile); border-radius: 6px; color: var(--tile-ink);
  position: relative; box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .35);
}
.flap .d::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: rgba(0, 0, 0, .35); }
.flap .d.sep { background: transparent; box-shadow: none; min-width: .25em; }
.flap .d.sep::after { display: none; }
.flap .unit { font-size: 18px; margin-left: 6px; opacity: .8; }
.flap .d.flip { animation: flip .26s var(--ease-out) both; }
@keyframes flip { from { transform: rotateX(-88deg); opacity: .4; } to { transform: rotateX(0); opacity: 1; } }
.board-trip { display: grid; gap: 6px; font-size: 15px; min-width: 0; }
.leg-line { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.leg-line .tag { font-size: 12px; padding: 1px 8px; border-radius: 99px; background: var(--board-2); color: var(--lagoon); font-weight: 700; }
.leg-line .num { font-size: 18px; }
.board-trip .note { font-size: 13px; opacity: .72; }
.muted-on-dark { opacity: .72; }
.insight { margin: 12px 0 0; font-size: 13px; color: color-mix(in srgb, var(--tile-ink) 75%, transparent); }
.alts { display: flex; gap: 8px; margin-top: 12px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; }
.alt { flex: 0 0 auto; border: 1px solid var(--board-2); background: var(--board-2); color: var(--tile-ink); border-radius: 10px; padding: 7px 12px; text-align: left; font-size: 13px; transition: border-color .15s, transform .1s var(--ease-out); }
.alt:hover { border-color: var(--lagoon); }
.alt:active { transform: scale(.97); }
.alt .num { font-size: 18px; display: block; line-height: 1.2; }

/* ---------- 篩選 ---------- */
.filters { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 14px; margin: 14px 0; display: grid; gap: 8px; }
.filter-row { display: flex; gap: 10px; align-items: flex-start; }
.filter-label { flex: 0 0 64px; font-size: 13px; color: var(--muted); padding-top: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card);
  border-radius: 99px; padding: 4px 12px 4px 6px; min-height: 36px; font-size: 14px;
  transition: border-color .15s, background-color .15s var(--ease-out);
}
.chip.plain { padding-left: 12px; }
.chip:hover { border-color: var(--sea); }
.chip[aria-pressed="true"] { border-color: var(--sea); background: color-mix(in srgb, var(--sea) 12%, var(--card)); font-weight: 500; }
.chip .num { font-size: 15px; color: var(--muted); }
.chip[aria-pressed="true"] .num { color: var(--ink); }
.chip small { color: var(--muted); font-size: 12px; }
.logo { width: 24px; height: 24px; border-radius: 6px; object-fit: contain; background: #fff; flex: 0 0 auto; }
.mono { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 6px; background: var(--b3); color: var(--b3-ink); font: 700 12px/1 var(--num); flex: 0 0 auto; }
.times { display: flex; gap: 6px 18px; flex-wrap: wrap; }
.time-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tg-name { font-size: 13px; color: var(--muted); }
.applied { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.applied .pill { display: inline-flex; align-items: center; gap: 2px; border-radius: 99px; background: color-mix(in srgb, var(--sea) 12%, var(--card)); padding: 2px 4px 2px 10px; }
.applied .pill button { border: 0; background: transparent; width: 28px; height: 28px; border-radius: 99px; color: var(--muted); }
.applied .clear { border: 0; background: transparent; color: var(--sea); text-decoration: underline; min-height: 32px; }
.filters-toggle { display: none; }

/* ---------- 版面 ---------- */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.cal-wrap, .detail { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; }
.detail { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow: auto; overscroll-behavior: contain; }
.cal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-head h2 { font-size: 18px; }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; border-radius: 8px; padding: 5px 12px; min-height: 34px; font-size: 14px; color: var(--muted); transition: background-color .15s var(--ease-out), color .15s; }
.tabs button[aria-selected="true"] { background: var(--sea); color: var(--sea-ink); font-weight: 500; }
.hint { margin: 10px 0 12px; font-size: 14px; color: var(--muted); min-height: 1.6em; }
.hint b { color: var(--ink); font-weight: 500; }
.hint .reset { border: 0; background: none; color: var(--sea); text-decoration: underline; padding: 0 4px; min-height: 28px; }

/* ---------- 月曆 ---------- */
.months { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.month h3 { font-size: 15px; margin-bottom: 6px; }
.dow, .grid7 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.dow span { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.dow span:first-child, .dow span:last-child { color: var(--up); }
.cell {
  position: relative; border: 0; border-radius: 10px; min-height: 56px; padding: 5px 2px 4px; display: grid;
  grid-template-rows: auto 1fr; justify-items: center; align-items: center; background: var(--b4); color: var(--b4-ink);
  transition: transform .1s var(--ease-out), box-shadow .15s var(--ease-out), background-color .25s var(--ease-out);
}
.cell .dn { font-size: 12px; line-height: 1; opacity: .85; }
.cell.we .dn { color: var(--up); font-weight: 700; opacity: 1; }
.cell.b0 .dn, .cell.b1 .dn { color: inherit; }
.cell .pr { font: 600 16px/1 var(--num); }
.cell .hd { position: absolute; top: 5px; right: 6px; width: 6px; height: 6px; border-radius: 99px; background: var(--up); }
.cell.b0 { background: var(--b0); color: var(--b0-ink); }
.cell.b1 { background: var(--b1); color: var(--b1-ink); }
.cell.b2 { background: var(--b2); color: var(--b2-ink); }
.cell.b3 { background: var(--b3); color: var(--b3-ink); }
.cell.b4 { background: var(--b4); color: var(--b4-ink); }
.cell.none { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.cell.none .pr { font-family: var(--font); font-size: 13px; font-weight: 400; }
.cell.off { background: transparent; color: color-mix(in srgb, var(--muted) 55%, transparent); cursor: default; }
.cell.before { background: transparent; color: var(--muted); }
.cell.blank { visibility: hidden; }
.cell:not(.off):not(.blank):hover { transform: translateY(-1px); box-shadow: 0 0 0 2px var(--sea); }
.cell:not(.off):active { transform: scale(.96); }
.cell.best { box-shadow: 0 0 0 2px var(--sun); }
.cell .bt { position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%); font-size: 12px; line-height: 1; padding: 2px 6px; border-radius: 99px; background: var(--sun); color: #1d1300; font-weight: 700; white-space: nowrap; }
.cell.inrange { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--sea) 45%, transparent); }
.cell.sel-dep, .cell.sel-ret { box-shadow: 0 0 0 3px var(--ink); z-index: 1; }
.cell .mk { position: absolute; top: -8px; left: 50%; transform: translateX(-50%); font-size: 12px; line-height: 1; padding: 3px 7px; border-radius: 99px; background: var(--ink); color: var(--bg); font-weight: 700; }
.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.legend .scale { display: inline-flex; gap: 2px; align-items: center; }
.legend .scale i { width: 22px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .sw { display: inline-flex; gap: 6px; align-items: center; }
.legend .best-sw { width: 14px; height: 14px; border-radius: 4px; box-shadow: 0 0 0 2px var(--sun); display: inline-block; }
.legend .hd-sw { width: 6px; height: 6px; border-radius: 99px; background: var(--up); display: inline-block; }

/* ---------- 價格圖 ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .bar { transition: opacity .15s; cursor: pointer; }
.chart .bar:hover { opacity: .8; }
.chart text { font-family: var(--font); fill: var(--muted); font-size: 12px; }
.chart .lbl { fill: var(--ink); font: 600 13px var(--num); }
.chart .axis { stroke: var(--line); }

/* ---------- 日期表格 ---------- */
.dgrid-wrap { overflow-x: auto; }
.dgrid { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 520px; }
.dgrid th { font-size: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; padding: 2px 4px; }
.dgrid th.corner { text-align: left; }
.dgrid td { padding: 0; }
.dgrid .cell { width: 100%; min-height: 44px; grid-template-rows: 1fr; }
.dgrid .nav { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.grid-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; color: var(--muted); align-items: center; }

/* ---------- 右邊：選好的行程 ---------- */
.detail h2 { font-size: 15px; font-weight: 500; color: var(--muted); }
.total { font: 700 40px/1.1 var(--num); margin: 4px 0 2px; }
.total small { font: 400 14px var(--font); color: var(--muted); margin-left: 6px; }
.leg { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.leg-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.leg-head h3 { font-size: 16px; }
.leg-head .route { font-size: 13px; color: var(--muted); }
.nearby { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; margin: 10px 0; }
.nearby button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 0; min-height: 44px; font-size: 12px; line-height: 1.25; transition: border-color .15s; }
.nearby button .num { display: block; font-size: 14px; font-weight: 600; }
.nearby button[aria-current="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.nearby button.cheap .num { color: var(--down); }
.nearby button:disabled { opacity: .5; cursor: default; }
.pos { margin: 8px 0 4px; font-size: 13px; color: var(--muted); }
.posbar { position: relative; height: 8px; border-radius: 99px; background: linear-gradient(90deg, var(--b0), var(--b2), var(--b4)); margin: 6px 0 4px; }
.posbar i { position: absolute; top: 50%; width: 14px; height: 14px; border-radius: 99px; background: var(--card); border: 3px solid var(--ink); transform: translate(-50%, -50%); transition: left .3s var(--ease-out); }
.posbar-l { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.spark { margin: 10px 0 2px; }
.spark svg { width: 100%; height: 64px; display: block; }
.spark .ln { fill: none; stroke: var(--sea); stroke-width: 2; }
.spark .pt { fill: var(--sea); }
.spark .gd { stroke: var(--line); stroke-dasharray: 3 3; }
.spark-t { font-size: 12px; color: var(--muted); }
.sort { display: flex; gap: 4px; align-items: center; margin: 10px 0 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.sort button { border: 1px solid var(--line); background: var(--card); border-radius: 99px; padding: 2px 10px; min-height: 32px; font-size: 13px; }
.sort button[aria-pressed="true"] { border-color: var(--sea); color: var(--sea); font-weight: 500; }
.fl {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 6px; cursor: pointer;
  transition: border-color .15s, background-color .15s var(--ease-out);
}
.fl:hover { border-color: var(--sea); }
.fl input { accent-color: var(--sea); width: 18px; height: 18px; margin: 0; }
.fl:has(input:checked) { border-color: var(--sea); background: color-mix(in srgb, var(--sea) 8%, var(--card)); }
.fl-t { display: block; font: 600 18px/1.2 var(--num); }
.fl-a { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fl-p { font: 700 19px var(--num); text-align: right; }
.fl-p small { display: block; font: 400 12px var(--font); color: var(--muted); }
.more { border: 0; background: none; color: var(--sea); text-decoration: underline; min-height: 36px; padding: 0; font-size: 14px; }
.leg-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.leg-actions a { font-size: 14px; display: inline-flex; align-items: center; min-height: 40px; }
.live-step { font-size: 13px; color: var(--muted); }
.chg-down { color: var(--down); font-weight: 700; }
.chg-up { color: var(--up); }
.empty { padding: 18px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; }

/* ---------- 紀錄 ---------- */
.runs { margin-top: 16px; background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 16px; }
.runs summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 32px; }
.runs summary::-webkit-details-marker { display: none; }
.runs summary::after { content: "展開"; font-size: 13px; color: var(--sea); }
.runs details[open] summary::after { content: "收起"; }
.runs h2 { font-size: 16px; }
.scroll { overflow-x: auto; }
table.plain { border-collapse: collapse; width: 100%; font-size: 14px; margin-top: 8px; }
table.plain th, table.plain td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.plain th { font-size: 12px; color: var(--muted); font-weight: 500; }

/* ---------- 對話框 ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 32px);
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}
dialog[open] { animation: dlg-in .22s var(--ease-out); }
dialog::backdrop { background: rgba(8, 20, 26, .45); animation: fade-in .2s var(--ease-out); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fade-in { from { opacity: 0; } }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px 20px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.dlg-head h2 { font-size: 18px; }
.dlg-body { padding: 4px 20px 20px; overflow: auto; overscroll-behavior: contain; }
.dlg-body h3 { font-size: 15px; margin: 18px 0 8px; }
.rt { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.rt-name { font-weight: 700; }
.rt-meta { font-size: 13px; color: var(--muted); }
.rt-ctl { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rt-ctl label { font-size: 13px; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.rt-ctl input[type="number"] { width: 92px; }
.switch { position: relative; width: 44px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--line); transition: background-color .15s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 99px; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .18s var(--ease-out); }
.switch input:checked + span { background: var(--sea); }
.switch input:checked + span::after { transform: translateX(18px); }
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form .full { grid-column: 1 / -1; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field input, .field select, .rt-ctl input {
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 42px; background: var(--card); color: var(--ink); font-size: 16px;
}
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; min-height: 40px; }
.check input { width: 18px; height: 18px; accent-color: var(--sea); }
.form-note { font-size: 13px; color: var(--muted); margin: 0; }
.form-err { color: var(--up); font-size: 14px; margin: 0; }
.quick { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.stepper { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 10px; }
.stepper button { border: 0; background: transparent; width: 40px; height: 40px; font-size: 18px; }
.stepper output { min-width: 3em; text-align: center; font-weight: 700; }

/* ---------- 通知、底部列 ---------- */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); border-radius: 12px; padding: 10px 14px; font-size: 14px; box-shadow: var(--shadow); animation: toast-in .22s var(--ease-out); }
.toast.err { background: var(--up); color: #fff; }
.toast.out { animation: toast-out .18s var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }
.sumbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15; background: var(--card); border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: flex; align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .08); transform: translateY(0); transition: transform .22s var(--ease-out);
}
.sumbar[data-hide="1"] { transform: translateY(110%); transition-timing-function: var(--ease-in); }
.sumbar .num { font-size: 24px; font-weight: 700; }
.sumbar .s-d { font-size: 13px; color: var(--muted); }

.skeleton { border-radius: 10px; background: linear-gradient(90deg, var(--b4), var(--b3), var(--b4)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- 手機、平板 ---------- */
@media (max-width: 1023px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 699px) {
  .top-in { gap: 8px; }
  .top-actions { margin-left: auto; }
  .sf-pax { display: none !important; }   /* 手機省一排；看板上已經寫幾位大人 */
  .trip-pick { flex: 1; }
  .trip-pick select { width: 100%; }
  .top-status { order: 3; flex-basis: 100%; }
  .top-actions .btn { padding: 8px 10px; }
  .board { padding: 14px 14px 12px; border-radius: 16px; }
  .flap .d { font-size: 44px; }
  .filters { padding: 8px 12px; }
  .filters-toggle { display: flex; justify-content: space-between; align-items: center; border: 0; background: none; min-height: 40px; padding: 0; font-weight: 500; }
  .filters-toggle::after { content: "展開"; font-size: 13px; color: var(--sea); font-weight: 400; }
  .filters[data-open="1"] .filters-toggle::after { content: "收起"; }
  .filters:not([data-open="1"]) .filter-row { display: none; }
  .filter-row { flex-direction: column; gap: 4px; }
  .filter-label { flex: none; padding-top: 0; }
  .cal-wrap, .detail { padding: 12px; }
  .months { grid-template-columns: minmax(0, 1fr); }
  .dow, .grid7 { gap: 3px; }
  .cell { min-height: 50px; border-radius: 8px; }
  .cell .pr { font-size: 14px; }
  .form { grid-template-columns: minmax(0, 1fr); }
  .rt { grid-template-columns: minmax(0, 1fr); }
  .rt-ctl { justify-content: flex-start; }
}
@media (min-width: 1024px) { .sumbar { display: none !important; } }
/* 手指點的裝置：每個按鈕至少 44px 高 */
@media (pointer: coarse) {
  .btn, .chip, .seg button, .tabs button, .sort button, .more, .hint .reset, .applied .clear, .filters-toggle { min-height: 44px; }
  .applied .pill button { width: 44px; height: 44px; }
  .btn.small, .trip-pick select, .leg-actions a, .fchip, .menu-btn, .clear-all, .menu-theme button, .pop-head button, .linkish { min-height: 44px; }
  .swap { width: 44px; height: 44px; }
}

/* ---------- 上方列：品牌、選單 ---------- */
.brand-name { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); text-decoration: none; font-weight: 700; font-size: 16px; }
.top-status .src { border: 0; background: none; padding: 0; color: var(--sea); text-decoration: underline; text-underline-offset: 2px; font-size: 13px; }
.menu-wrap { position: relative; }
.menu-btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--card); border-radius: 10px; padding: 7px 12px; min-height: 40px; font-size: 14px; }
.menu-btn:hover, .menu-btn[aria-expanded="true"] { border-color: var(--sea); }
.menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 230px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); padding: 6px; display: grid; transform-origin: top right; animation: pop-in .16s var(--ease-out);
}
.menu > button { text-align: left; border: 0; background: none; border-radius: 9px; padding: 10px 12px; min-height: 44px; font-size: 15px; }
.menu > button:hover, .menu > button:focus-visible { background: color-mix(in srgb, var(--sea) 10%, var(--card)); }
.menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.menu-theme { display: flex; align-items: center; gap: 4px; padding: 6px 8px; font-size: 13px; color: var(--muted); }
.menu-theme span { margin-right: auto; }
.menu-theme button { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 4px 9px; min-height: 34px; font-size: 13px; }
.menu-theme button[aria-pressed="true"] { border-color: var(--sea); color: var(--sea); font-weight: 500; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }

/* ---------- 搜尋列：出發地、目的地、去程、回程、人數 ---------- */
.search {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) auto; gap: 8px; align-items: stretch;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 8px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.sf-route { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 4px; }
.sf-dates { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.sf-dates > *, .sf-route > * { min-width: 0; }
.sf-l .best-note { color: var(--sea); font-weight: 500; }
.sf-field {
  display: grid; align-content: center; gap: 0; text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 12px;
  padding: 6px 12px; min-height: 56px; position: relative; transition: border-color .15s, box-shadow .15s var(--ease-out);
}
.sf-field:hover, .sf-field:focus-within { border-color: var(--sea); }
.sf-l { font-size: 12px; color: var(--muted); line-height: 1.3; }
.sf-v { font-size: 16px; font-weight: 700; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sf-v.empty { color: var(--muted); font-weight: 400; }
.sf-field select {
  appearance: none; border: 0; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23566b75' stroke-width='1.6' fill='none'/%3E%3C/svg%3E") no-repeat right 0 center;
  padding: 0 18px 0 0; font-size: 16px; font-weight: 700; width: 100%; min-height: 26px; cursor: pointer;
}
.sf-field select:focus { outline: none; }
.sf-date { cursor: pointer; }
.sf-date[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.swap { width: 38px; height: 38px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; color: var(--sea); transition: transform .2s var(--ease-out), border-color .15s; }
.swap:hover { border-color: var(--sea); }
.swap:active { transform: rotate(180deg); }
.sf-pax { min-width: 108px; }

/* ---------- 篩選：下拉選單 ---------- */
.filterbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 14px 0; }
.fchip-wrap { position: relative; }
.fchip {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); background: var(--card); border-radius: 99px;
  padding: 6px 14px; min-height: 40px; font-size: 14px; transition: border-color .15s, background-color .15s var(--ease-out);
}
.fchip:hover, .fchip[aria-expanded="true"] { border-color: var(--sea); }
.fchip.on { border-color: var(--sea); background: color-mix(in srgb, var(--sea) 12%, var(--card)); color: var(--ink); font-weight: 500; }
.fchip svg { transition: transform .18s var(--ease-out); }
.fchip[aria-expanded="true"] svg { transform: rotate(180deg); }
.clear-all { border: 0; background: none; color: var(--sea); text-decoration: underline; min-height: 40px; font-size: 14px; }
.pop {
  position: absolute; left: 0; top: calc(100% + 6px); z-index: 25; width: min(340px, calc(100vw - 32px)); background: var(--card);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 8px; animation: pop-in .16s var(--ease-out);
  max-height: 70vh; overflow: auto; overscroll-behavior: contain;
}
.pop-row { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 8px; border-radius: 10px; min-height: 44px; cursor: pointer; }
.pop-row:hover { background: color-mix(in srgb, var(--sea) 8%, var(--card)); }
.pop-row input { width: 18px; height: 18px; accent-color: var(--sea); margin: 0; }
.pop-row .num { color: var(--muted); font-size: 15px; }
.pop-row small { color: var(--muted); font-size: 12px; display: block; }
.pop-only { border: 0; background: none; color: var(--sea); font-size: 13px; padding: 4px 6px; min-height: 32px; border-radius: 8px; }
.pop-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 8px; font-size: 13px; color: var(--muted); }
.pop-head button { border: 0; background: none; color: var(--sea); font-size: 13px; min-height: 32px; }
.pop-foot { display: none; padding: 8px; }
.scrim { position: fixed; inset: 0; z-index: 24; background: rgba(8, 20, 26, .4); animation: fade-in .18s var(--ease-out); }

/* ---------- 選日期的對話框 ---------- */
#dlg-dates { width: min(760px, calc(100vw - 24px)); }
.dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px 6px 20px; position: sticky; top: 0; background: var(--card); z-index: 1; }
.dd-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 4px 20px 0; }
#dlg-dates .hint { padding: 0 20px; margin: 10px 0 6px; }
.dd-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 20px 16px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: var(--card); flex-wrap: wrap; }
.dd-actions { display: flex; gap: 8px; }
#dd-sum .num { font-size: 26px; font-weight: 700; }
#dd-sum small { color: var(--muted); margin-left: 6px; }
#dlg-dates[open], #dlg-info[open], #dlg-manage[open] { display: flex; flex-direction: column; }
#dlg-dates .dlg-body, #dlg-info .dlg-body, #dlg-manage .dlg-body { flex: 1; min-height: 0; }

/* ---------- 說明頁 ---------- */
.info h3 { font-size: 16px; margin: 20px 0 8px; }
.info p, .info li { font-size: 15px; line-height: 1.75; }
.info ul { padding-left: 1.2em; margin: 6px 0; }
.info .lead { font-size: 16px; margin-top: 4px; }
.flow { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; margin: 12px 0 4px; align-items: stretch; }
.flow-box { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: color-mix(in srgb, var(--sea) 5%, var(--card)); display: grid; align-content: start; gap: 4px; }
.flow-box .fb-t { font-weight: 700; font-size: 15px; }
.flow-box .fb-s { font-size: 12px; color: var(--sea); font-weight: 500; }
.flow-box p { font-size: 13px; line-height: 1.6; margin: 0; color: var(--muted); }
.flow-step { display: grid; grid-template-columns: minmax(0, 1fr) 46px; }
.flow-step:last-child { grid-template-columns: minmax(0, 1fr); }
.flow-arrow { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--sea); font-size: 11px; text-align: center; line-height: 1.3; padding: 0 2px; }
.flow-arrow svg { width: 28px; height: 14px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 8px 0; }
.fact { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.fact .num { font-size: 24px; font-weight: 700; display: block; line-height: 1.2; }
.fact span:last-child { font-size: 12px; color: var(--muted); }
.foot { text-align: center; font-size: 13px; color: var(--muted); margin: 24px 0 0; }
.linkish { border: 0; background: none; padding: 0; color: var(--sea); text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }

@media (max-width: 899px) {
  .search { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .sf-route { grid-column: 1 / -1; }
  .sf-dates { grid-column: 1 / -1; }
  .sf-pax { grid-column: 1 / -1; display: flex; gap: 8px; align-items: center; min-height: 44px; }
}
@media (max-width: 699px) {
  .brand-name > span:last-child { display: none; }
  .menu-btn span { display: none; }
  .search { padding: 6px; gap: 6px; border-radius: 14px; }
  .sf-field { min-height: 52px; padding: 5px 10px; }
  .flow { grid-template-columns: minmax(0, 1fr); }
  .flow-step { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 40px; }
  .flow-arrow { grid-auto-flow: column; justify-content: center; gap: 6px; }
  .flow-arrow svg { transform: rotate(90deg); }
  /* 手機：篩選下拉改成從下面滑出的面板 */
  .pop { position: fixed; left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 18px 18px 0 0; max-height: 75vh; padding: 12px 12px calc(12px + env(safe-area-inset-bottom)); animation: sheet-in .24s var(--ease-out); }
  .pop-foot { display: block; position: sticky; bottom: -12px; background: var(--card); padding: 10px 0 0; }
  .pop-foot .btn { width: 100%; }
  dialog#dlg-dates, dialog#dlg-info, dialog#dlg-manage { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
}
@keyframes sheet-in { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
