/* 2027 京阪奈神 — 行程工具頁樣式
 * 以「車票」作為交通區塊的主視覺；每座城市一個傳統色。 */

:root {
  --paper: #F1F3EF;
  --card: #FFFFFF;
  --ink: #22262C;
  --muted: #61676F;
  --line: #D6DAD3;
  --soft: #E6E9E3;
  --now: #A8325A;        /* 梅色：現在 */
  --fare: #8E5C12;       /* 金茶：金額 */
  --rail: #2C4A73;       /* 藍：交通 */
  --rail-soft: #E7EDF5;
  --kyoto: #6E4A86;      /* 京紫 */
  --osaka: #B0442E;      /* 朱 */
  --nara: #5A7A33;       /* 若草 */
  --himeji: #56677A;     /* 白鷺灰 */
  --kobe: #245A8C;       /* 港藍 */
  --tone: var(--kyoto);
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --radius-s: 6px;
  --radius-m: 12px;
  --tab-h: 56px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #15181D;
    --card: #1E2228;
    --ink: #E8EAE6;
    --muted: #A0A6AE;
    --line: #353B43;
    --soft: #262B32;
    --now: #E0769B;
    --fare: #E0B062;
    --rail: #9DB8DE;
    --rail-soft: #222B38;
    --kyoto: #B595CC;
    --osaka: #E68A72;
    --nara: #A5C47A;
    --himeji: #A9B6C4;
    --kobe: #7FB0DE;
  }
}
:root[data-theme="dark"] {
  --paper: #15181D; --card: #1E2228; --ink: #E8EAE6; --muted: #A0A6AE; --line: #353B43; --soft: #262B32;
  --now: #E0769B; --fare: #E0B062; --rail: #9DB8DE; --rail-soft: #222B38;
  --kyoto: #B595CC; --osaka: #E68A72; --nara: #A5C47A; --himeji: #A9B6C4; --kobe: #7FB0DE;
}

.tone-kyoto { --tone: var(--kyoto); }
.tone-osaka { --tone: var(--osaka); }
.tone-nara { --tone: var(--nara); }
.tone-himeji { --tone: var(--himeji); }
.tone-kobe { --tone: var(--kobe); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 128px; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px);
  font-variant-numeric: tabular-nums;
}
a { color: inherit; }
h1, h2, h3 { margin: 0; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
:focus-visible { outline: 2px solid var(--now); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

/* ───────── 頂部 ───────── */
.top {
  position: sticky; top: 0; z-index: 1000;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 8px) 0 0;
}
.top-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 16px; max-width: 760px; margin: 0 auto; }
.top h1 { font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: .04em; }
.top h1 a { text-decoration: none; }
.status { font-size: 13px; color: var(--muted); white-space: nowrap; }

.daystrip {
  display: flex; gap: 6px; overflow-x: auto; scroll-snap-type: x proximity;
  padding: 8px 16px 10px; max-width: 760px; margin: 0 auto;
  scrollbar-width: none;
}
.daystrip::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; scroll-snap-align: center;
  display: grid; grid-template-columns: auto auto; grid-template-rows: auto auto; column-gap: 4px;
  align-items: center; min-width: 58px; padding: 5px 9px 5px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-s); background: var(--card);
  text-decoration: none; line-height: 1.2; position: relative;
}
.chip-date { grid-column: 1; font-weight: 700; font-size: 15px; }
.chip-dow { grid-column: 1; font-size: 11px; color: var(--muted); }
.chip-city {
  grid-column: 2; grid-row: 1 / span 2;
  font-family: var(--serif); font-size: 15px; font-weight: 700; color: var(--tone);
  border-left: 1px solid var(--line); padding-left: 6px;
}
.chip.is-active { background: var(--tone); border-color: var(--tone); color: #fff; }
.chip.is-active .chip-dow, .chip.is-active .chip-city { color: #fff; border-color: rgba(255,255,255,.4); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .chip.is-active { color: #15181D; } :root:not([data-theme="light"]) .chip.is-active .chip-dow, :root:not([data-theme="light"]) .chip.is-active .chip-city { color: #15181D; border-color: rgba(0,0,0,.25); } }
.chip.is-today::after { content: ""; position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--now); }

/* ───────── 主要區塊 ───────── */
main { max-width: 760px; margin: 0 auto; padding: 0 16px; outline: none; }

.day-head { display: grid; grid-template-columns: 64px 1fr; gap: 14px; padding: 22px 0 14px; align-items: start; }
.seal {
  width: 64px; height: 64px; border-radius: var(--radius-s);
  background: var(--tone); color: #fff;
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 38px; font-weight: 700; line-height: 1;
  box-shadow: inset 0 0 0 3px var(--tone), inset 0 0 0 5px rgba(255,255,255,.55);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .seal { color: #15181D; box-shadow: inset 0 0 0 3px var(--tone), inset 0 0 0 5px rgba(0,0,0,.35); } }
.day-date { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.day-num { font-family: var(--serif); font-size: 30px; font-weight: 700; color: var(--ink); line-height: 1.1; letter-spacing: -.01em; }
.day-city { color: var(--tone); font-weight: 600; }
.day-head h2 { font-family: var(--serif); font-size: 21px; font-weight: 700; line-height: 1.35; margin-top: 2px; }
.brief { color: var(--muted); font-size: 15px; margin-top: 6px; }

.facts { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.facts::-webkit-scrollbar { display: none; }
.fact {
  flex: 0 0 auto; display: flex; flex-direction: column; padding: 7px 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s);
  text-decoration: none; line-height: 1.3; max-width: 70vw;
}
.fact span { font-size: 12px; color: var(--muted); }
.fact b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.fact b { text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }

.nowbar {
  display: block; margin-top: 12px; padding: 10px 14px;
  background: var(--now); color: #fff; border-radius: var(--radius-s);
  font-weight: 600; text-decoration: none;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .nowbar { color: #15181D; } }

.alert {
  margin-top: 12px; padding: 12px 14px; font-size: 14px;
  background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--now); border-radius: var(--radius-s);
}
.alert b { display: block; color: var(--now); margin-bottom: 2px; }

/* ───────── 地圖 ───────── */
.mapbox { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--card); overflow: hidden; }
.mapbox > summary {
  list-style: none; cursor: pointer; padding: 11px 14px; font-weight: 600;
  display: flex; justify-content: space-between; align-items: center;
}
.mapbox > summary::-webkit-details-marker { display: none; }
.mapbox > summary::after { content: "展開"; font-size: 13px; color: var(--muted); font-weight: 400; }
.mapbox[open] > summary::after { content: "收起"; }
.map { height: min(56vh, 380px); border-top: 1px solid var(--line); background: var(--soft); position: relative; z-index: 0; isolation: isolate; }
.map-off { padding: 16px; color: var(--muted); font-size: 14px; }
.pin { display: grid; place-items: center; }
.pin span {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--tone); color: #fff; font-weight: 700; font-size: 13px;
  border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.pin-sub span { width: 14px; height: 14px; font-size: 0; }
.pin-hotel span { background: var(--ink); font-family: var(--serif); font-size: 13px; }
.leaflet-container { font-family: var(--sans); }
.leaflet-popup-content { font-size: 14px; line-height: 1.5; }
.leaflet-popup-content a { color: var(--rail); }
path.route { stroke: var(--tone); }

/* ───────── 時間軸 ───────── */
.timeline { margin-top: 18px; position: relative; }
.stop { display: grid; grid-template-columns: 54px 1fr; gap: 12px; position: relative; padding-bottom: 22px; }
.stop::before { /* 軸線 */
  content: ""; position: absolute; left: 26px; top: 26px; bottom: 0; width: 2px; background: var(--line);
}
.stop:last-child::before { display: none; }
.time { position: relative; z-index: 1; text-align: center; line-height: 1.2; padding-top: 2px; background: var(--paper); }
.time b { display: block; font-size: 15px; font-weight: 700; }
.time span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.flag { display: inline-block; margin-top: 6px; padding: 1px 6px; font-style: normal; font-size: 11px; font-weight: 700; color: #fff; background: var(--now); border-radius: 4px; }
.flag-next { background: transparent; color: var(--now); border: 1px solid var(--now); }

.body { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 14px 12px; }
.stop.is-now .body { border-color: var(--now); box-shadow: 0 0 0 1px var(--now); }
.stop.is-past .body { opacity: .62; }
.body h3 { font-size: 17px; font-weight: 700; line-height: 1.4; }
.desc { margin-top: 4px; font-size: 15px; color: var(--ink); }

/* 交通行程本身沒有白卡，只留票券 */
.stop.is-move .body { background: transparent; border: 0; padding: 0; }
.stop.is-move .body h3 { font-size: 15px; color: var(--rail); padding: 2px 0 8px; }
.stop.is-move.is-now .body { box-shadow: none; }
.stop.is-move.is-now .ticket { box-shadow: 0 0 0 2px var(--now); }

/* ───────── 票券 ───────── */
.ticket {
  --notch: 8px;
  position: relative; background: var(--rail-soft); border-radius: var(--radius-s);
  padding: 10px 12px 10px 18px;
  border-left: 2px dashed color-mix(in srgb, var(--rail) 45%, transparent);
  -webkit-mask: radial-gradient(circle var(--notch) at 0 50%, transparent 98%, #000) ;
          mask: radial-gradient(circle var(--notch) at 0 50%, transparent 98%, #000);
}
.ticket.is-compact { margin-bottom: 10px; padding: 7px 10px 7px 16px; }
.legs { display: grid; gap: 8px; }
.ticket.is-compact .legs { gap: 4px; }
.leg {
  display: grid; grid-template-columns: 1fr auto auto; grid-template-areas: "mode min fare" "route route route" "note note note";
  column-gap: 10px; align-items: baseline;
}
.leg-mode { grid-area: mode; font-weight: 700; color: var(--rail); font-size: 14px; }
.leg-route { grid-area: route; font-size: 15px; }
.leg-route i { font-style: normal; color: var(--muted); margin: 0 6px; }
.leg-min { grid-area: min; font-size: 13px; color: var(--muted); }
.leg-fare { grid-area: fare; font-size: 14px; font-weight: 700; color: var(--fare); }
.leg-note { grid-area: note; font-size: 13px; color: var(--muted); }
.leg.is-walk .leg-mode { font-weight: 600; color: var(--muted); }
.ticket.is-compact .leg { grid-template-areas: "mode route min fare" "note note note note"; grid-template-columns: auto 1fr auto auto; }
.ticket.is-compact .leg-mode, .ticket.is-compact .leg-route { font-size: 13px; }
.ticket.is-compact .leg-note { display: none; }
.ticket-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 10px; padding-top: 8px;
  border-top: 1px dashed color-mix(in srgb, var(--rail) 35%, transparent); font-size: 13px; color: var(--muted);
}
.ticket-foot .btn { margin-left: auto; }
.ticket.is-compact .ticket-foot { margin-top: 6px; padding-top: 6px; }
.ticket.is-compact.is-walkonly .ticket-foot span:nth-child(2) { display: none; }
.alts { margin-top: 8px; display: grid; gap: 4px; }
.alts li { font-size: 13px; color: var(--muted); padding-left: 14px; position: relative; }
.alts li::before { content: "或"; position: absolute; left: 0; color: var(--rail); font-size: 11px; top: 2px; }

/* ───────── 地點、按鈕 ───────── */
.places { margin-top: 10px; display: grid; gap: 2px; }
.place { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 8px; padding: 6px 0; border-top: 1px solid var(--soft); }
.place:first-child { border-top: 0; }
.place-name { font-size: 15px; font-weight: 600; min-width: 0; flex: 1 1 9em; }
.place-actions { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.tag { display: inline-block; font-size: 11px; padding: 0 5px; margin-right: 6px; border: 1px solid var(--muted); border-radius: 4px; color: var(--muted); vertical-align: 2px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 11px; border-radius: var(--radius-s);
  font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); white-space: nowrap;
}
.btn-solid { background: var(--tone); border-color: var(--tone); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-solid { color: #15181D; } }
.btn-line { border-color: var(--rail); color: var(--rail); background: transparent; min-height: 30px; }
.btn:active { transform: translateY(1px); }

/* ───────── 費用、提醒、餐廳 ───────── */
.costs { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.cost { display: inline-flex; align-items: baseline; gap: 6px; font-size: 13px; padding: 3px 8px; border-radius: var(--radius-s); background: var(--soft); }
.cost span { font-size: 11px; color: var(--muted); }
.cost b { color: var(--fare); }

.tips { margin-top: 10px; display: grid; gap: 4px; }
.tips li { position: relative; padding-left: 14px; font-size: 14px; color: var(--muted); }
.tips li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--tone); }

.eat { margin-top: 12px; border-top: 1px solid var(--soft); }
.eat > summary { cursor: pointer; padding: 10px 0 4px; font-weight: 600; font-size: 15px; color: var(--tone); list-style: none; display: flex; align-items: center; gap: 8px; }
.eat > summary::-webkit-details-marker { display: none; }
.eat > summary::before { content: "+"; display: inline-grid; place-items: center; width: 18px; height: 18px; border: 1px solid currentColor; border-radius: 4px; font-size: 14px; line-height: 1; }
.eat[open] > summary::before { content: "−"; }
.count { font-size: 12px; color: var(--muted); font-weight: 400; }
.eat ul { display: grid; gap: 0; }
.eat li { padding: 10px 0; border-top: 1px dashed var(--line); }
.eat li:first-child { border-top: 0; }
.eat-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.eat-name { font-weight: 700; font-size: 15px; text-decoration: underline; text-decoration-color: var(--line); text-underline-offset: 3px; }
.eat-price { font-size: 13px; color: var(--fare); font-weight: 600; white-space: nowrap; }
.eat-type { font-size: 12px; color: var(--muted); }
.eat p { font-size: 14px; margin-top: 2px; }

/* ───────── 當日小計、筆記、換頁 ───────── */
.daysum, .memo { margin-top: 6px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px; }
.daysum h3, .memo label { font-family: var(--serif); font-size: 16px; font-weight: 700; display: block; }
.daysum dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; margin: 10px 0 0; }
.daysum dl div { background: var(--soft); border-radius: var(--radius-s); padding: 6px 10px; }
.daysum dt { font-size: 12px; color: var(--muted); }
.daysum dd { margin: 0; font-weight: 700; color: var(--fare); }
.sum-total { margin-top: 10px; font-size: 15px; }
.sum-total b { color: var(--fare); }
.sum-note { margin-top: 4px; font-size: 12px; color: var(--muted); }
.memo { margin-top: 12px; }
.memo textarea {
  width: 100%; margin-top: 8px; padding: 10px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-s); resize: vertical;
}
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 8px; }
.pager a { padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-s); text-decoration: none; font-size: 14px; background: var(--card); }
.pager a:last-child { text-align: right; }

/* ───────── 其他頁 ───────── */
.page { padding: 22px 0 8px; }
.page h2 { font-family: var(--serif); font-size: 24px; font-weight: 700; }
.page h3 { font-family: var(--serif); font-size: 17px; font-weight: 700; margin: 22px 0 8px; }
.lead { margin-top: 6px; color: var(--muted); }
.lead b { color: var(--fare); }
.tablewrap { margin-top: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--card); }
.budget { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
.budget th, .budget td { padding: 8px 6px; text-align: right; border-bottom: 1px solid var(--soft); }
.budget th:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
.budget thead th { font-size: 12px; color: var(--muted); font-weight: 600; }
.budget tfoot th, .budget tfoot td { border-bottom: 0; font-weight: 700; color: var(--fare); }
.budget a { text-decoration: none; font-weight: 600; }
.notes { margin-top: 10px; display: grid; gap: 6px; }
.notes li { position: relative; padding-left: 14px; font-size: 14px; color: var(--muted); }
.notes li::before { content: ""; position: absolute; left: 2px; top: .7em; width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }

.todos { margin-top: 14px; display: grid; gap: 8px; }
.todos li { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 10px 12px; }
.todos label { flex: 1; display: grid; grid-template-columns: 24px 1fr; column-gap: 10px; cursor: pointer; }
.todos input { grid-row: 1 / span 2; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--now); }
.todo-when { font-size: 12px; color: var(--now); font-weight: 600; }
.todo-text { font-size: 15px; }
.todos li.is-done { opacity: .55; }
.todos li.is-done .todo-text { text-decoration: line-through; }

.cards { display: grid; gap: 8px; }
.cards li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; }
.cards p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.cards .row, .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row span { font-size: 14px; }
.row-actions { display: flex; gap: 8px; margin-top: 8px; }
.row-actions .btn-solid, .cards .btn-solid { background: var(--rail); border-color: var(--rail); }
.flight-no { display: flex; gap: 10px; align-items: baseline; font-size: 13px; color: var(--muted); }
.flight-no b { font-size: 17px; color: var(--ink); }
.flight-route { font-size: 16px; font-weight: 600; margin-top: 4px; }
.flight-route i { font-style: normal; color: var(--muted); margin: 0 8px; }
.rate { display: flex; align-items: center; gap: 8px; }
.rate input { width: 96px; padding: 8px; font: inherit; font-size: 16px; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-s); }

/* ───────── 底部分頁 ───────── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1000;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--card) 94%, transparent);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar a { display: grid; place-items: center; text-decoration: none; font-size: 15px; font-weight: 600; color: var(--muted); }
.tabbar a[aria-current="page"] { color: var(--ink); box-shadow: inset 0 3px 0 var(--now); }

@media (min-width: 640px) {
  .day-head { grid-template-columns: 76px 1fr; }
  .seal { width: 76px; height: 76px; font-size: 46px; }
  .day-num { font-size: 36px; }
  .day-head h2 { font-size: 24px; }
  .stop { grid-template-columns: 64px 1fr; gap: 16px; }
  .stop::before { left: 31px; }
}

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

@media print {
  .top, .tabbar, .mapbox, .memo, .pager, .btn { display: none !important; }
  body { padding: 0; background: #fff; }
  .eat { display: block; }
  .stop { break-inside: avoid; }
}
