/* styles.css — 重陽長週末相調 v5
   Direction: rail-timetable handbook. Each city is a "line" with its own colour; the day plan
   is drawn as a station line; one dark departure board carries the key facts.
   Fonts: system only (PingFang TC / Noto CJK stack; CJK serif for headings). No webfonts.
   Order: tokens · base · header · hero · route list · detail · content · accordion · map ·
          compare · checklist · dock/toast/modal · tablet · desktop · print · motion */

/* ---------- tokens ---------- */
:root {
  --paper: #F3F5F6;
  --surface: #FFFFFF;
  --ink: #17212B;
  --ink2: #46515C;
  --mute: #56616C;
  --line: #D9DFE4;
  --line2: #AEB8C1;
  --warn: #B45309;
  --warn-bg: #FDF0D3;
  --warn-ink: #6B3405;
  --warn-line: #E3B15A;
  --c: #17212B;           /* current line colour (per city) */
  --cw: #E9EDF0;          /* its pale wash */
  --stick: 52px;          /* sticky header height under the brand row */
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "PingFang HK", "Noto Sans CJK TC", "Noto Sans TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --serif: "Songti TC", "Source Han Serif TC", "Noto Serif CJK TC", "Noto Serif TC", "PMingLiU", "Hiragino Mincho ProN", Georgia, serif;
}
[data-city="gz"] { --c: #B4175A; --cw: #FBE9F0; }
[data-city="sz"] { --c: #0B6F6A; --cw: #E1F2F0; }
[data-city="sd"] { --c: #2D4DA0; --cw: #E6ECF9; }

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html.is-locked { overflow: hidden; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 17px/1.7 var(--sans); -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
[id] { scroll-margin-top: var(--stick); }
img { display: block; max-width: 100%; height: auto; }
a { color: var(--c); }
button { font-family: inherit; cursor: pointer; }
a, button, summary, label, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; border-radius: 4px; }
.cmpbar :focus-visible, .board :focus-visible { outline-color: #fff; }
main:focus { outline: none; }
h1, h2, h3, h4, h5 { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.offscreen { position: fixed; left: -9999px; }
.ico { flex: none; }
.skip { position: fixed; left: 8px; top: -80px; z-index: 200; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 6px; }
.skip:focus { top: 8px; }
.boot, .plain { padding: 56px 16px; text-align: center; color: var(--ink2); }
.noscript { padding: 24px 16px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border: 1.5px solid var(--ink); border-radius: 24px; background: transparent; color: var(--ink); font: 600 16px/1 var(--sans); text-decoration: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost:hover { background: rgba(23, 33, 43, .07); }
.btn.is-off { opacity: .6; pointer-events: none; }
.icon-btn { display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: transparent; color: var(--ink); }
.icon-btn:hover { background: rgba(23, 33, 43, .08); }

.box { position: relative; flex: none; width: 24px; height: 24px; border: 2px solid var(--ink2); border-radius: 5px; background: #fff; }
.box::after { content: ""; position: absolute; left: 4px; top: 4px; width: 12px; height: 6px; border: solid #fff; border-width: 0 0 3px 3px; transform: rotate(-45deg); opacity: 0; }
input:checked + .box { background: var(--c); border-color: var(--c); }
input:checked + .box::after { opacity: 1; }
input:focus-visible + .box { outline: 3px solid var(--ink); outline-offset: 2px; }
.route-cmp input, .chk input { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 1px 10px; border: 1px solid var(--line2); border-radius: 14px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; line-height: 1.3; text-decoration: none; font-variant-numeric: tabular-nums; }
.chip-cost { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.chip-warn .ico { color: var(--warn); }
.risk-mid { border-color: var(--warn-line); color: var(--warn-ink); }
.risk-hi { border: 2px solid var(--ink); }

/* ---------- header: brand row scrolls away, tab row stays ---------- */
.top { position: sticky; top: calc(var(--stick) * -1); z-index: 50; display: grid; grid-template-columns: 1fr auto; grid-template-areas: "brand acts" "tabs tabs"; background: var(--paper); }
.brand { grid-area: brand; display: flex; align-items: center; min-height: var(--stick); padding-left: 16px; color: var(--ink); font: 700 21px/1 var(--serif); letter-spacing: .04em; text-decoration: none; }
.brand small { margin-left: 8px; color: var(--mute); font: 600 14px var(--sans); letter-spacing: 0; }
.acts { grid-area: acts; display: flex; padding-right: 4px; }
.tabs { grid-area: tabs; display: grid; grid-template-columns: 1fr 1fr 1fr 1.1fr; background: var(--paper); border-bottom: 1px solid var(--line); }
.tab { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--stick); color: var(--ink2); font-size: 17px; font-weight: 600; text-decoration: none; }
.tab[data-city]::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--c); }
.tab.is-on { color: var(--ink); font-weight: 700; box-shadow: inset 0 -4px 0 var(--c); background: var(--surface); }
.tab-chk { gap: 4px; font-size: 16px; }
.tab:hover { background: rgba(23, 33, 43, .05); }

.view { min-height: 60vh; max-width: 760px; margin: 0 auto; }

/* ---------- hero + departure board ---------- */
.hero { padding: 26px 16px 4px; }
.hero-t { font: 700 34px/1.15 var(--serif); letter-spacing: .03em; }
.hero-s { margin: 8px 0 18px; color: var(--ink2); font-size: 16px; line-height: 1.5; }
.board { margin: 0; padding: 0 16px 4px; overflow: hidden; border-radius: 10px; background: var(--ink); color: #F3F5F6; }
.board::before { content: ""; display: block; height: 6px; margin: 0 -16px 4px; background: linear-gradient(90deg, #B4175A 0 33.4%, #0B6F6A 0 66.7%, #2D4DA0 0); }
.board-row { display: grid; grid-template-columns: 2.6em 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255, 255, 255, .16); }
.board-row:last-child { border-bottom: 0; }
.board dt { padding-top: 3px; color: #AEBBC7; font-size: 15px; }
.board dd { margin: 0; }
.board strong { display: block; font-size: 20px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.board dd span { display: block; margin-top: 2px; color: #AEBBC7; font-size: 14px; line-height: 1.5; }

/* ---------- route list ---------- */
.routes { padding: 24px 16px 8px; }
.routes-h { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 12px; }
.routes-h h2 { font: 700 26px/1.2 var(--serif); }
.routes-h p { margin: 0; color: var(--mute); font-size: 14px; }
.route-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.route { position: relative; display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: 6px 14px; padding: 14px 12px 6px 12px; border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 6px; background: var(--surface); }
.route-img { width: 72px; height: 72px; border-radius: 4px; object-fit: cover; background: var(--cw); }
.route-main { min-width: 0; }
.route-title { font: 700 20px/1.3 var(--serif); }
.route-title a { color: var(--ink); text-decoration: none; }
.route-title a::after { content: ""; position: absolute; inset: 0; }
.route-sub { margin: 2px 0 0; color: var(--c); font-size: 14px; font-weight: 600; line-height: 1.45; }
.route-pos { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; margin: 4px 0 0; overflow: hidden; color: var(--ink2); font-size: 15px; line-height: 1.55; }
.route-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; }
.route-cmp { position: relative; z-index: 2; display: inline-flex; align-items: center; gap: 8px; min-height: 48px; margin-left: auto; padding: 0 4px 0 2px; font-size: 15px; font-weight: 600; cursor: pointer; }

/* ---------- detail ---------- */
.detail { padding-bottom: 24px; }
.d-back { padding: 6px 8px 0; }
.d-back .btn { border-color: transparent; padding-left: 10px; }
.d-img { width: 100%; max-height: 420px; aspect-ratio: 16 / 9; object-fit: cover; background: var(--cw); }
.d-head, .d-aud, .d-body, .d-hint, .d-more { padding-left: 16px; padding-right: 16px; }
.d-head { padding-top: 20px; }
.d-head::before { content: ""; display: block; width: 48px; height: 6px; margin-bottom: 14px; background: var(--c); }
.d-title { font: 700 32px/1.2 var(--serif); }
.d-sub { margin: 6px 0 0; color: var(--c); font-size: 15px; font-weight: 600; line-height: 1.5; }
.d-pos { margin: 12px 0 14px; }
.d-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.deadline { display: flex; align-items: flex-start; gap: 12px; margin: 16px 16px 0; padding: 12px 14px; border-left: 6px solid var(--warn); border-radius: 4px; background: var(--warn-bg); color: var(--warn-ink); }
.deadline .ico { margin-top: 3px; color: var(--warn); }
.deadline p { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.6; }
.d-aud { margin: 14px 0 0; color: var(--ink2); font-size: 16px; }
.d-aud b { margin-right: 10px; padding: 1px 8px; border-radius: 4px; background: var(--cw); color: var(--c); font-size: 14px; }
.d-body { display: grid; gap: 12px; margin-top: 18px; }
.d-tl, .d-rest, .mapbox { min-width: 0; }
.d-tl, .d-rest { display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 8px; }
.d-hint { margin: 14px 0 0; color: var(--mute); font-size: 14px; }
.d-more { margin-top: 24px; }
.d-more h3 { margin-bottom: 8px; font: 700 18px/1.3 var(--serif); }
.d-more ul { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.d-more a { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 56px; padding: 0 14px; border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 6px; background: var(--surface); color: var(--ink); text-decoration: none; }
.d-more span { color: var(--mute); font-size: 14px; }
.d-more .to-list a { border-left-color: var(--ink); }

/* ---------- authored content ---------- */
button.spot { position: relative; margin: 0; padding: 0; border: 0; background: none; color: var(--c); font: inherit; font-weight: 600; text-align: inherit; text-decoration: underline dotted 2px; text-underline-offset: 4px; cursor: pointer; }
button.spot::after { content: ""; position: absolute; inset: -9px -2px; }
button.spot:hover { background: var(--cw); }
.unconf { display: inline-flex; align-items: center; gap: 3px; padding: 0 7px 0 3px; border: 1px solid var(--warn-line); border-radius: 10px; background: var(--warn-bg); color: var(--warn-ink); font-size: 13px; font-weight: 700; line-height: 1.5; white-space: nowrap; vertical-align: 1px; }
.unconf::before { content: "?"; display: inline-grid; place-items: center; width: 15px; height: 15px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 11px; line-height: 1; }
a.tel { color: var(--c); font-weight: 600; white-space: nowrap; }
.acc-b p { margin: 0 0 10px; }
.acc-b ul { margin: 0; padding-left: 1.25em; }
.acc-b li { margin: 0 0 8px; padding-left: 2px; }
.acc-b li:last-child { margin-bottom: 0; }
.acc-b blockquote { margin: 12px 0 0; padding: 10px 14px; border-left: 4px solid var(--c); background: var(--cw); font-size: 16px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 16px; }
th { padding: 6px 8px; border-bottom: 2px solid var(--ink); color: var(--mute); font-size: 14px; font-weight: 600; text-align: left; }
td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.t2 th:last-child, .t2 td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { border-top: 2px solid var(--ink); border-bottom: 0; background: var(--cw); font-size: 18px; }

/* day plan drawn as a station line */
.day-h { display: flex; align-items: center; gap: 12px; margin: 22px 0 14px; font: 700 19px/1.3 var(--serif); }
.day-h:first-child { margin-top: 2px; }
.day-h::after { content: ""; flex: 1; height: 2px; background: var(--c); opacity: .35; }
.tl-item { position: relative; display: grid; grid-template-columns: 56px minmax(0, 1fr); column-gap: 28px; margin: 0; padding-bottom: 16px; }
.tl-item::before { content: ""; position: absolute; left: 69px; top: 16px; bottom: -3px; width: 2px; background: var(--c); opacity: .35; }
.tl-item::after { content: ""; position: absolute; left: 64px; top: 9px; width: 12px; height: 12px; border: 3px solid var(--c); border-radius: 50%; background: #fff; }
.tl > .tl-item:last-child::before { display: none; }
.tl-t { text-align: right; line-height: 1.5; padding-top: 2px; font-variant-numeric: tabular-nums; }
.tl-t b { display: block; font-size: 17px; }
.tl-t small { display: block; color: var(--mute); font-size: 13px; }
.tl-x { min-width: 0; }
.tl-item.tl-note { display: block; margin: 0 0 14px 84px; padding: 8px 12px; border-radius: 4px; background: var(--cw); font-size: 15px; }
.tl-item.tl-note::before, .tl-item.tl-note::after { display: none; }

/* ---------- accordion ---------- */
.acc { border: 1px solid var(--line); border-left: 6px solid var(--line2); border-radius: 6px; background: var(--surface); }
.d-tl .acc { border-left-color: var(--c); }
.acc.sec-risk { border-left-color: var(--warn); }
.acc > summary { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 0 14px; list-style: none; cursor: pointer; }
.acc > summary::-webkit-details-marker { display: none; }
.acc-t { flex: 1; min-width: 0; font: 700 18px/1.35 var(--serif); }
.acc-m { color: var(--mute); font-size: 14px; font-variant-numeric: tabular-nums; }
.acc > summary .ico { color: var(--ink2); }
.acc[open] > summary { border-bottom: 1px solid var(--line); }
.acc[open] > summary .ico { transform: rotate(180deg); }
.acc-b { padding: 14px 14px 16px; }
.acc-note { color: var(--mute); font-size: 14px; }

/* ---------- map ---------- */
.mapbox { overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.mapbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 6px 2px 14px; }
.mapbox-bar h3 { font: 700 18px/1.3 var(--serif); }
.mapbox-bar .btn { min-height: 48px; border-color: transparent; padding: 0 12px; }
.map-frame { position: relative; isolation: isolate; height: 170px; margin: 0 12px 12px; overflow: hidden; border: 1px solid var(--line); border-radius: 4px; background: #E4E9EC; }
.mapbox.is-full .map-frame { height: 320px; }
.map-canvas { position: absolute; inset: 0; }
.mapbox:not(.is-full) .map-canvas { cursor: zoom-in; }
.map-ph, .map-err { display: grid; place-items: center; height: 100%; margin: 0; padding: 0 16px; color: var(--mute); font-size: 14px; text-align: center; }
.map-legend { position: absolute; z-index: 800; top: 8px; right: 8px; display: flex; gap: 12px; padding: 3px 10px; border-radius: 14px; background: rgba(255, 255, 255, .95); font-size: 13px; font-weight: 600; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.lg { display: inline-block; width: 20px; height: 0; margin-right: 6px; border-top: 4px solid; vertical-align: middle; }
.lg.d1 { border-color: #EC4899; }
.lg.d2 { border-color: #18181B; border-top-style: dashed; }
.pin-wrap { border: 0; background: none; }
.pin { display: block; width: 18px; height: 18px; border: 3px solid #fff; border-radius: 50%; box-shadow: 0 1px 5px rgba(0, 0, 0, .5); }
.pin.d1 { background: #EC4899; }
.pin.d2 { background: #18181B; }
.spot-tip { padding: 2px 7px; border: 0; color: var(--ink); font: 600 13px var(--sans); }

/* ---------- compare ---------- */
.cmpview, .chkview { padding: 4px 16px 32px; }
.cmpview .d-back, .chkview .d-back { margin: 0 0 0 -10px; padding: 0; }
.view-t { margin: 12px 0 14px; font: 700 30px/1.2 var(--serif); }
.cmp-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.cmp-x { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 12px 0 14px; border: 1.5px solid var(--line2); border-radius: 24px; background: var(--surface); color: var(--ink); font-size: 15px; font-weight: 600; }
.cmp-head { position: sticky; top: var(--stick); z-index: 20; display: grid; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); background: var(--paper); }
.cmp-head.n2, .cmp-cells.n2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cmp-head.n3, .cmp-cells.n3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cmp-col { border-top: 5px solid var(--c); border-radius: 0 0 6px 6px; background: var(--surface); }
.cmp-col a { display: block; min-height: 56px; padding: 6px 10px; color: var(--ink); text-decoration: none; }
.cmp-city { display: block; color: var(--c); font-size: 13px; font-weight: 700; }
.cmp-col strong { font: 700 16px/1.3 var(--serif); }
.cmp-row { margin-top: 16px; }
.cmp-row h3 { margin-bottom: 6px; color: var(--mute); font: 600 15px/1.4 var(--sans); }
.cmp-cells { display: grid; gap: 8px; }
.cmp-cell { min-width: 0; padding: 10px; border: 1px solid var(--line); border-top: 3px solid var(--line2); border-radius: 4px; background: var(--surface); font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.cmp-cell.diff { border-top-color: var(--c); background: var(--cw); font-weight: 700; }
.cmp-note { margin: 18px 0 0; color: var(--mute); font-size: 14px; }

/* ---------- checklist ---------- */
.chk-intro { margin: 0 0 12px; color: var(--ink2); }
.chk-prog { position: sticky; top: var(--stick); z-index: 20; padding: 8px 0; background: var(--paper); }
.chk-prog p { margin: 4px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
progress { display: block; width: 100%; height: 12px; border: 0; border-radius: 6px; background: var(--line); -webkit-appearance: none; appearance: none; overflow: hidden; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--ink); }
progress::-moz-progress-bar { background: var(--ink); }
.chk-city { margin-top: 24px; }
.chk-city h3 { margin-bottom: 8px; color: var(--c); font: 700 22px/1.3 var(--serif); }
.chk-list { margin: 0; padding: 0; list-style: none; border: 1px solid var(--line); border-left: 6px solid var(--c); border-radius: 6px; background: var(--surface); }
.chk-list li { padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.chk-list li:last-child { border-bottom: 0; }
.chk { position: relative; display: flex; align-items: flex-start; gap: 14px; min-height: 48px; padding: 12px 14px 2px; cursor: pointer; }
.chk .box { margin-top: 2px; }
.chk-t { font-size: 16px; line-height: 1.55; }
input:checked ~ .chk-t { color: var(--mute); text-decoration: line-through; }
.chk-route { display: inline-flex; align-items: center; min-height: 44px; margin-left: 52px; color: var(--c); font-size: 14px; font-weight: 600; }

/* ---------- footer / dock / toast ---------- */
.foot { max-width: 760px; margin: 24px auto 0; padding: 20px 16px calc(104px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--mute); font-size: 14px; line-height: 1.6; }
.foot p { margin: 0 0 8px; }
.dock { position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; max-width: 640px; margin: 0 auto; padding: 0 12px calc(12px + env(safe-area-inset-bottom)); pointer-events: none; }
.dock > * { pointer-events: auto; }
.cmpbar { align-self: stretch; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; border-radius: 12px; background: var(--ink); color: #fff; box-shadow: 0 6px 24px rgba(10, 16, 22, .35); }
.cmpbar-t { flex: 1; min-width: 0; }
.cmpbar-t strong { display: block; font-size: 15px; line-height: 1.4; }
.cmpbar-t span { display: block; overflow: hidden; color: #C3CDD6; font-size: 13px; line-height: 1.4; text-overflow: ellipsis; white-space: nowrap; }
.cmpbar .btn { padding: 0 14px; font-size: 15px; }
.cmpbar .btn-ghost { border-color: rgba(255, 255, 255, .55); color: #fff; }
.cmpbar .btn-ghost:hover { background: rgba(255, 255, 255, .12); }
.cmpbar .btn-primary { border-color: #fff; background: #fff; color: var(--ink); }
.backtop { display: none; place-items: center; width: 48px; height: 48px; border: 1.5px solid var(--ink); border-radius: 50%; background: #fff; color: var(--ink); box-shadow: 0 2px 10px rgba(10, 16, 22, .25); }
.backtop.show { display: grid; }
.toast { position: fixed; z-index: 120; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); max-width: 90vw; padding: 10px 18px; border-radius: 22px; background: var(--ink); color: #fff; font-size: 15px; opacity: 0; transform: translate(-50%, 8px); pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- spot modal ---------- */
.modal[hidden] { display: none; }
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(10, 16, 22, .55); }
.modal-panel { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 560px; max-height: 90vh; max-height: 90dvh; overflow: hidden; border-radius: 14px 14px 0 0; background: var(--surface); }
.modal-body { overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
.modal-close { position: absolute; z-index: 2; top: 8px; right: 8px; display: grid; place-items: center; width: 48px; height: 48px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .96); color: var(--ink); box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
.m-photo { width: 100%; aspect-ratio: 16 / 10; object-fit: cover; background: var(--cw); }
.m-in { padding: 18px 18px 24px; }
.m-title { padding-right: 52px; font: 700 26px/1.25 var(--serif); }
.m-en { margin: 2px 0 0; color: var(--mute); font-size: 14px; }
.m-tags { display: flex; gap: 6px; margin: 10px 0 0; }
.m-tags span { padding: 1px 10px; border: 1px solid var(--line2); border-radius: 12px; font-size: 14px; font-weight: 600; }
.m-facts { margin: 14px 0 0; }
.m-facts div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.m-facts dt { color: var(--mute); font-size: 15px; }
.m-facts dd { margin: 0; font-size: 16px; }
.m-facts dd.yes { font-weight: 700; }
.m-facts dd.no { color: var(--warn-ink); font-weight: 700; }
.m-brief { margin: 14px 0 0; }
.m-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.m-unc { margin-top: 16px; padding: 10px 12px; border-left: 6px solid var(--warn); border-radius: 4px; background: var(--warn-bg); color: var(--warn-ink); font-size: 15px; }
.m-unc p { display: flex; gap: 8px; margin: 0; }
.m-unc p + p { margin-top: 6px; }
.m-unc .ico { margin-top: 3px; color: var(--warn); }

/* ---------- tablet ---------- */
@media (min-width: 768px) {
  .modal { align-items: center; }
  .modal-panel { border-radius: 10px; }
  .hero-t { font-size: 40px; }
}

/* ---------- desktop master-detail ---------- */
@media (min-width: 1024px) {
  :root { --stick: 64px; }
  .top { top: 0; grid-template-columns: 280px minmax(0, 1fr) auto; grid-template-areas: "brand tabs acts"; align-items: center; border-bottom: 1px solid var(--line); }
  .brand { padding-left: 0; }
  .tabs { max-width: 520px; border-bottom: 0; background: transparent; }
  .chk-cities .chk-city { margin-top: 0; }
  .tab { min-height: var(--stick); }
  .acts { padding-right: 0; }
  :root { --gutter: max(32px, calc((100% - 1320px) / 2 + 32px)); }
  .view { max-width: none; }
  .top { padding-left: var(--gutter); padding-right: var(--gutter); }
  .md { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 32px; align-items: start; padding: 24px var(--gutter) 40px; }
  .cmpview, .chkview { padding: 8px var(--gutter) 40px; }
  .cmpview > * { max-width: 960px; }
  .chkview > .chk-intro, .chkview > .chk-prog { max-width: 720px; }
  .chk-cities { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 24px; align-items: start; }
  .tv-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
  .tv-b .t-lab { margin-top: 0; }
  .rail .hero-s, .rail .board dd span { display: none; }
  .rail .hero-t { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .rail .hero { padding-top: 0; }
  .rail .board-row { padding: 9px 0; }
  .rail .routes { padding-top: 16px; }
  .rail .tally { margin-bottom: 10px; padding: 8px 12px; }
  .rail .tally li { min-height: 30px; }
  .rail .route { padding-top: 12px; }
  .rail .route-pos, .rail .route-sub { display: none; }
  .rail .route { grid-template-columns: 72px minmax(0, 1fr); grid-template-areas: "img main" "img chips" "act act"; align-items: start; }
  .rail .route-img { grid-area: img; }
  .rail .route-main { grid-area: main; }
  .rail .route-foot { display: contents; }
  .rail .chips { grid-area: chips; }
  .rail .route-act { grid-area: act; }
  .rail .board-row { grid-template-columns: 2.6em 1fr; padding: 7px 0; }
  .rail .board strong { font-size: 17px; line-height: 1.3; }
  .rail .tally-h { margin-bottom: 2px; }
  .rail .routes-h p { display: none; }
  .rail .routes-h { margin-bottom: 8px; }
  .rail .route-list { gap: 8px; }
  .rail .routes { padding-top: 10px; }
  .rail .tally { padding: 6px 12px; margin-bottom: 8px; }
  .rail .route { padding-top: 10px; padding-bottom: 2px; }
  .rail .route-cmp, .rail .vote { min-height: 44px; }
  .rail .tally li { min-height: 28px; }
  .rail .route-title { font-size: 18px; }
  .rail .route { row-gap: 2px; }
  .rail { position: sticky; top: calc(var(--stick) + 12px); max-height: calc(100vh - var(--stick) - 20px); overflow-y: auto; overscroll-behavior: contain; padding-right: 4px; scrollbar-width: thin; }
  .rail .hero { padding: 0 0 4px; }
  .rail .hero-t { font-size: 28px; }
  .rail .hero-s { margin-bottom: 14px; }
  .rail .board strong { font-size: 18px; }
  .rail .routes { padding: 22px 0 8px; }
  .rail .routes-h h2 { font-size: 22px; }
  .route:hover { border-color: var(--line2); border-left-color: var(--c); }
  .route.is-active { background: var(--cw); box-shadow: inset 0 0 0 2px var(--c); border-color: var(--c); }
  .route.is-active .route-title a { color: var(--c); }
  .pane { min-width: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
  .pane .d-back, .d-more { display: none; }
  .pane .d-img { aspect-ratio: 21 / 8; max-height: 320px; }
  .pane .d-head, .pane .d-aud, .pane .d-body, .pane .d-hint { padding-left: 28px; padding-right: 28px; }
  .pane .deadline { margin-left: 28px; margin-right: 28px; }
  .pane .d-head { padding-top: 24px; }
  .pane .d-title { font-size: 36px; }
  .pane .d-body { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); grid-template-rows: auto 1fr; grid-template-areas: "tl map" "tl rest"; gap: 16px 28px; align-items: start; }
  .pane .mapbox { grid-area: map; }
  .pane .d-tl { grid-area: tl; }
  .pane .d-rest { grid-area: rest; }
  .pane .d-hint { padding-bottom: 8px; }
  .cmp-head { top: var(--stick); }
  .foot { max-width: none; margin-top: 0; padding-left: var(--gutter); padding-right: var(--gutter); }
  .dock { max-width: 1320px; padding-left: 32px; padding-right: 32px; }
  .cmpbar { max-width: 520px; align-self: flex-start; }
}

/* ---------- print: current view only, everything open, chrome hidden ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; line-height: 1.55; }
  .top, .dock, .modal, .toast, .skip, .d-back, .d-acts, .mapbox, .d-hint, .d-more, .route-cmp, .rail, .foot .no-print, .acc > summary .ico { display: none !important; }
  .md { display: block; padding: 0; }
  .pane, .view { max-width: none; border: 0; border-radius: 0; }
  .view { min-height: 0; }
  .board { background: #fff; color: #000; border: 1.5px solid #000; }
  .board dt, .board dd span { color: #333; }
  .board::before { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .d-img { max-height: 6cm; }
  .d-body, .pane .d-body { display: block; }
  .d-tl, .d-rest { display: block; }
  .acc { margin: 0 0 8px; break-inside: auto; }
  details.acc:not([open]) > .acc-b { display: block; }
  details.acc::details-content { content-visibility: visible; display: block; }
  .acc > summary { min-height: 0; padding: 6px 12px; }
  .tl-item { break-inside: avoid; }
  .route { break-inside: avoid; }
  a, button.spot { color: inherit; text-decoration: none; }
  button.spot::after { display: none; }
  .chip-cost { background: #fff; color: #000; border-color: #000; }
}

/* ---------- motion (only when the user hasn't asked for less) ---------- */
@media (prefers-reduced-motion: no-preference) {
  .acc > summary .ico { transition: transform .18s ease; }
  .toast { transition: opacity .2s ease, transform .2s ease; }
  .btn, .tab, .route { transition: background-color .15s ease, border-color .15s ease, box-shadow .15s ease; }
}

/* ---------- vote + tally + sz timeline transport tag ---------- */
.route-act { display: flex; align-items: center; justify-content: space-between; gap: 6px; width: 100%; position: relative; z-index: 2; }
.route-act .route-cmp { margin-left: 0; }
.vote { position: relative; z-index: 2; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 0 14px; border: 1.5px solid var(--c); border-radius: 24px; background: var(--surface); color: var(--c); font: 700 15px/1 var(--sans); }
.vote[aria-pressed="true"] { background: var(--c); color: #fff; }
.vote[aria-pressed="true"] .ico { fill: currentColor; }
.d-acts .vote { border-width: 1.5px; }
.cmp-votes { margin-top: 10px; }
.cmp-votes .vote { width: 100%; padding: 0 6px; }
.tl-tr { display: block; margin-top: 2px; color: var(--mute); font-size: 14px; }
.myvote { display: inline-flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 16px; border: 0; border-radius: 24px; background: var(--ink); color: #fff; font: 700 15px/1 var(--sans); box-shadow: 0 2px 10px rgba(10, 16, 22, .3); }
.myvote .ico { fill: currentColor; }
.v-pick { display: flex; align-items: center; gap: 10px; margin: 14px 0 0; font: 700 22px/1.35 var(--serif); }
.v-code { margin: 14px 0 0; color: var(--mute); font-size: 14px; font-variant-numeric: tabular-nums; }
.t-lab { display: block; margin: 16px 0 6px; font-weight: 700; }
.t-in { width: 100%; padding: 12px; border: 1.5px solid var(--line2); border-radius: 6px; background: var(--surface); color: var(--ink); font: 16px/1.5 var(--sans); }
.t-out { margin: 16px 0 0; padding: 0; list-style: none; }
.t-out li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-left: 6px solid var(--c); background: var(--surface); margin-bottom: 8px; border-radius: 6px; }
.t-out .t-none { border-left-color: var(--line2); color: var(--mute); }
@media print { .vote, .myvote { display: none !important; } }

.v-count { margin: 10px 0 0; color: var(--mute); font-weight: 700; }
.v-picks { margin: 10px 0 0; padding: 0; list-style: none; }
.v-picks li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--c); font: 700 18px/1.4 var(--serif); }
.v-picks .ico { fill: currentColor; }

/* ---------- live tally ---------- */
.vote .vc { min-width: 22px; padding: 1px 6px; border-radius: 11px; background: var(--cw); color: var(--c); font-size: 13px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.vote[aria-pressed="true"] .vc { background: rgba(255, 255, 255, .25); color: #fff; }
.vc[hidden] { display: none; }
.tally:empty { display: none; }
.tally { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.tally-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; font-size: 15px; }
.tally-h span { color: var(--mute); font-size: 14px; }
.tally ul { margin: 0; padding: 0; list-style: none; }
.tally li { display: grid; grid-template-columns: minmax(0, 9em) minmax(0, 1fr) 2.2em; align-items: center; gap: 10px; min-height: 40px; }
.tally li a { overflow: hidden; color: var(--ink); font-size: 15px; font-weight: 600; text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.tally-bar { height: 10px; border-radius: 5px; background: var(--cw); overflow: hidden; }
.tally-bar i { display: block; height: 100%; min-width: 2px; background: var(--c); }
.tally li strong { text-align: right; font-variant-numeric: tabular-nums; }
.tally-all li { grid-template-columns: minmax(0, 11em) minmax(0, 1fr) 2.2em; }

/* v4.3.1: 投票 tab — heart accent */
.tab.tab-tally[aria-current="page"],.tab.tab-tally.is-on{color:var(--accent-deep)}
.tab .ico{vertical-align:-3px}

/* ---------- estimate tag (not an unverified fact: a planning figure) ---------- */
.est { display: inline-block; margin: 0 3px 0 4px; padding: 0 7px; border: 1px solid var(--line2); border-radius: 10px; background: var(--surface); color: var(--ink2); font-size: 12px; font-weight: 600; line-height: 1.55; white-space: nowrap; vertical-align: 1px; }
@media print { .est { border-color: #000; color: #000; } }

/* ---------- v4.5 audit fixes ---------- */
a.chip-warn { position: relative; }
a.chip-warn::after { content: ""; position: absolute; inset: -9px -4px; }
.tally li { min-height: 44px; }
.tally li a { display: block; padding: 11px 0; }
.rail .tally li { min-height: 24px; }
.rail .tally li a { padding: 0; line-height: 1.5; }
.leaflet-container .leaflet-control-attribution { background: rgba(255, 255, 255, .92); }
.leaflet-control-attribution a { color: #0B5A7D; }

/* v4.6 */
.t-lab { padding: 10px 0; }
