:root {
  --paper: #EEF2F3;
  --ocean: #DCE6EA;
  --land: #F9FBFB;
  --border: #C3CFD5;
  --ink: #18233A;
  --ink-soft: #4E5B72;
  --rule: #C9D3D9;
  --mark-f: #D8E8F5;
  --mark-o: #F6E7B8;
  --serif: "Noto Sans TC", system-ui, sans-serif;
  --sans: "Noto Sans TC", system-ui, sans-serif;
  --num: "DM Sans", "Noto Sans TC", sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #131B2C; --ocean: #0F1625; --land: #1F2B42; --border: #2E3C58;
    --ink: #E5EBF2; --ink-soft: #A3AFC2; --rule: #2E3A52;
    --mark-f: #1F3A55; --mark-o: #4A3E17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #131B2C; --ocean: #0F1625; --land: #1F2B42; --border: #2E3C58;
  --ink: #E5EBF2; --ink-soft: #A3AFC2; --rule: #2E3A52;
  --mark-f: #1F3A55; --mark-o: #4A3E17;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.75 var(--sans);
  overflow-x: hidden;
}
a { color: inherit; text-decoration-color: color-mix(in srgb, currentColor 40%, transparent); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; border-radius: 2px; }
img { max-width: 100%; height: auto; }

/* ---------- home ---------- */

body.home { height: 100svh; overflow: hidden; }
.home-shell {
  display: grid;
  grid-template-columns: clamp(220px, 20vw, 300px) minmax(0, 1fr) clamp(290px, 27vw, 390px);
  height: 100svh;
  min-height: 0;
  background: var(--paper);
}
.masthead {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: clamp(22px, 3vw, 42px) clamp(18px, 2.7vw, 38px) 24px;
  border-right: 1px solid var(--rule);
}
.bob-id { display: flex; align-items: center; gap: 11px; font-size: 14px; line-height: 1.25; }
.bob-id > span:last-child { display: flex; flex-direction: column; gap: 3px; }
.bob-id b { font-weight: 700; }
.bob-id small { color: var(--ink-soft); font: 500 11px/1.2 var(--num); letter-spacing: 0.02em; }
.bob-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  color: var(--land);
  background: var(--ink);
  border-radius: 50% 47% 44% 52%;
  font: 700 21px/1 var(--num);
  transform: rotate(-4deg);
}
.home-title { margin: auto 0 clamp(28px, 6vh, 64px); }
.masthead h1 {
  margin: 0;
  font: 900 clamp(40px, 5.4vw, 78px)/0.98 var(--serif);
  letter-spacing: -0.055em;
  writing-mode: vertical-rl;
}
.tagline { margin: 20px 0 0; color: var(--ink-soft); font-size: 15px; line-height: 1.7; max-width: 14em; }
.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin: 0;
  border-top: 1px solid var(--rule);
}
.stats div { padding: 13px 0 10px; border-bottom: 1px solid var(--rule); }
.stats div:nth-child(odd) { padding-right: 12px; border-right: 1px solid var(--rule); }
.stats div:nth-child(even) { padding-left: 12px; }
.stats dt { color: var(--ink-soft); font-size: 12px; }
.stats dd { margin: 2px 0 0; font: 700 clamp(26px, 3vw, 38px)/1 var(--num); font-variant-numeric: tabular-nums; }
.stats dd small { margin-left: 3px; color: var(--ink-soft); font: 400 12px/1 var(--sans); }
.home-note { margin: 15px 0 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.masthead .viewnote { margin-top: 14px; font-size: 12px; }

.atlas {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--ocean);
}
.map-head {
  position: absolute;
  z-index: 2;
  top: clamp(18px, 3vw, 36px);
  left: clamp(18px, 3vw, 38px);
  pointer-events: none;
}
.map-head h2 { margin: 0; font: 700 16px/1.3 var(--sans); }
.map-head p { margin: 4px 0 0; color: var(--ink-soft); font-size: 12px; }
.world { display: block; width: 100%; height: 100%; min-height: 0; margin: 0; }
.world .graticule { fill: none; stroke: var(--border); stroke-width: 0.5; opacity: 0.5; }
.world .land { fill: var(--land); stroke: var(--border); stroke-width: 0.6; }
.world .land.visited { fill: color-mix(in srgb, var(--c) 26%, var(--land)); }
.world .route .line {
  fill: none; stroke: var(--c); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round;
  stroke-dasharray: 1; stroke-dashoffset: 0;
}
.world .route.planned .line { stroke-dasharray: 0.006 0.008; }
.world .route .pin { fill: var(--c); stroke: var(--land); stroke-width: 1.2; }
.world .map-label {
  font: 700 14px var(--sans);
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--land);
  stroke-width: 4px;
  stroke-linejoin: round;
  text-anchor: middle;
  cursor: pointer;
}
.world .map-en { fill: var(--ink-soft); font: 500 9px var(--num); letter-spacing: 0.02em; }
.world .map-link { text-decoration: none; }
.world .map-link:hover .map-zh, .world .map-link:focus .map-zh { text-decoration: underline; text-decoration-thickness: 2px; }
.world .route:has(.map-link:hover) .line, .world .route:has(.map-link:focus) .line, .world .route.on .line { stroke-width: 4; }
.world .map-link:focus { outline: none; }
.world .home circle { fill: var(--land); stroke: var(--ink); stroke-width: 2; }
.world .home .dot { fill: var(--ink); stroke: none; }
.world .home .map-label { text-anchor: start; }
.world.focus .route:not(.on) { opacity: 0.18; }
.world.focus .land.visited:not(.on) { fill: var(--land); }
.world .route, .world .route .line, .world .land { transition: opacity .2s, fill .2s, stroke-width .2s; }

/* the one orchestrated moment: routes draw in, oldest first */
@media (prefers-reduced-motion: no-preference) {
  .js .world .route .line { animation: draw 1.6s cubic-bezier(.5,0,.2,1) both; animation-delay: calc(var(--i) * 0.45s + 0.2s); stroke-dashoffset: 1; }
  .js .world .route.planned .line { animation-name: fade; }
  .js .world .route .pin, .js .world .route .map-label { animation: fade .4s both; animation-delay: calc(var(--i) * 0.45s + 1.3s); }
}
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.trip-board { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--rule); }
.trip-board > header { padding: clamp(22px, 3vw, 42px) clamp(18px, 2.5vw, 34px) 20px; border-bottom: 1px solid var(--rule); }
.trip-board > header h2 { margin: 0; font: 700 clamp(20px, 2.2vw, 28px)/1.2 var(--sans); letter-spacing: -0.03em; }
.trip-board > header p { margin: 4px 0 0; color: var(--ink-soft); font: 500 12px/1.4 var(--num); }
.trips { list-style: none; margin: 0; padding: 0; min-height: 0; overflow: auto; scrollbar-width: thin; }
.trip-row { border-top: 1px solid var(--rule); }
.trip-row:first-child { border-top: 0; }
.trip-row a {
  display: grid;
  grid-template-columns: 3.8rem minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  padding: clamp(14px, 2.2vh, 24px) clamp(16px, 2.5vw, 32px);
  text-decoration: none;
  position: relative;
}
.trip-row a::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--c); transition: width .16s;
}
.trip-row a:hover::before, .trip-row.on a::before { width: 5px; }
.trip-row a:hover .name > span, .trip-row.on .name > span { text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 3px; text-underline-offset: 5px; }
.when { display: flex; flex-direction: column; font-family: var(--num); line-height: 1; padding-top: 4px; }
.when .y { font-size: 16px; font-weight: 700; }
.when .m { margin-top: 4px; font-size: 12px; color: var(--ink-soft); }
.what { display: flex; flex-direction: column; min-width: 0; }
.name { display: flex; align-items: baseline; flex-wrap: wrap; gap: 2px 8px; font: 700 clamp(17px, 1.8vw, 22px)/1.25 var(--sans); }
.name small { color: var(--ink-soft); font: 500 11px/1.3 var(--num); }
.path { margin-top: 7px; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.path em { font: 400 10px var(--num); }
.path i { font-style: normal; padding: 0 0.38em; color: var(--c); }
.len { padding-top: 2px; font: 700 23px/1 var(--num); font-variant-numeric: tabular-nums; }
.len small { font: 400 14px var(--sans); color: var(--ink-soft); margin-left: 2px; }
.tag {
  display: inline-block; vertical-align: middle; padding: 1px 7px;
  font: 500 13px/1.6 var(--sans); border: 1px solid var(--c, var(--ink-soft)); border-radius: 99px; color: var(--ink-soft);
}
.foot { max-width: 1200px; margin: 0 auto; padding: 48px var(--gutter) 64px; color: var(--ink-soft); font-size: 14px; }
.viewnote {
  margin: 16px 0 0; padding: 10px 14px; max-width: 46em; font-size: 15px;
  background: color-mix(in srgb, var(--ocean) 60%, transparent); border-left: 3px solid var(--ink-soft); border-radius: 0 6px 6px 0;
}

/* ---------- trip ---------- */

.crumbs {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  max-width: 1240px; margin: 0 auto; padding: 20px var(--gutter) 0; font-size: 15px;
}
.crumbs a { font-weight: 700; text-decoration: none; }
.crumbs a::before { content: "‹ "; }
.crumbs .view { color: var(--ink-soft); }

.trip-head { max-width: 1240px; margin: 0 auto; padding: clamp(24px, 5vw, 56px) var(--gutter) 24px; }
.trip-head h1 {
  font: 900 clamp(44px, 9vw, 104px)/1 var(--serif); margin: 0;
  text-decoration: underline; text-decoration-color: var(--c); text-decoration-thickness: 0.09em; text-underline-offset: 0.16em;
}
.trip-head .en { margin: 18px 0 0; font: 600 clamp(18px, 2.4vw, 24px)/1.2 var(--num); color: var(--ink-soft); }
.trip-head .meta { margin: 10px 0 0; font-size: 17px; }
.planned-note { margin: 12px 0 0; font-weight: 700; color: var(--c); }

.trip-grid {
  display: grid; grid-template-columns: minmax(260px, 380px) minmax(0, 1fr); gap: clamp(24px, 4vw, 56px);
  max-width: 1240px; margin: 0 auto; padding: 0 var(--gutter);
}
.side { position: sticky; top: 16px; align-self: start; max-height: calc(100vh - 32px); overflow: auto; padding-bottom: 16px; }
.tripmap { display: block; width: 100%; height: auto; background: var(--ocean); border-radius: 10px; }
.tripmap .land { fill: var(--land); stroke: var(--border); stroke-width: 0.7; }
.tripmap .land.visited { fill: color-mix(in srgb, var(--c) 16%, var(--land)); }
.tripmap .line { fill: none; stroke: var(--c); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.tripmap .num circle { fill: var(--c); stroke: var(--land); stroke-width: 2; }
.tripmap .num text { font: 700 11px var(--num); fill: #fff; text-anchor: middle; }
.stops { margin: 14px 0 0; padding-left: 1.6em; font-size: 15px; columns: 2; column-gap: 20px; }
.stops li { break-inside: avoid; }
.stops li::marker { font: 700 13px var(--num); color: var(--c); }
.stops span { color: var(--ink-soft); font-size: 13px; }
.days { margin-top: 18px; border-top: 1px solid var(--rule); padding-top: 10px; }
.days summary { cursor: pointer; font-weight: 700; padding: 4px 0; }
.days ol { list-style: none; margin: 6px 0 0; padding: 0; font-size: 14px; line-height: 1.5; }
.days li a { display: flex; gap: 10px; padding: 5px 0; text-decoration: none; color: var(--ink-soft); }
.days li a:hover { color: var(--ink); }
.days li span { font: 700 14px var(--num); color: var(--ink); min-width: 3em; font-variant-numeric: tabular-nums; }

.content { min-width: 0; max-width: 46rem; }
.content h2 { font: 900 clamp(22px, 2.8vw, 28px)/1.35 var(--serif); margin: 0 0 12px; }
.content h3 { font: 700 18px/1.4 var(--sans); margin: 24px 0 8px; }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: 2px 0; }
.content li::marker { color: var(--c); }
.content p { margin: 10px 0; }
.content figure { margin: 16px 0; }
.content figure img { border-radius: 8px; border: 1px solid var(--rule); }
.content input[type="checkbox"] { accent-color: var(--c); margin-right: 6px; }
.content ul:has(> li > input[type="checkbox"]) { list-style: none; padding-left: 0; }

.block { padding: 8px 0 32px; border-bottom: 1px solid var(--rule); margin-bottom: 32px; }
.day {
  display: grid; grid-template-columns: 5.5rem minmax(0, 1fr); gap: 20px;
  padding-bottom: 32px; margin-bottom: 32px; border-bottom: 1px solid var(--rule);
  scroll-margin-top: 16px;
}
.rail { display: flex; flex-direction: column; align-items: flex-start; padding-top: 2px; }
.rail .date { font: 800 34px/1 var(--num); letter-spacing: -0.02em; color: var(--c); font-variant-numeric: tabular-nums; }
.rail .wd { font-size: 15px; font-weight: 700; margin-top: 6px; }
.rail .n { font-size: 13px; color: var(--ink-soft); }

.lv { border-radius: 4px; padding: 0 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.lv-f { background: var(--mark-f); }
.lv-o { background: var(--mark-o); }
div.lv { padding: 4px 14px; margin: 12px 0; border-radius: 8px; }
div.lv > :first-child { margin-top: 6px; }
div.lv > :last-child { margin-bottom: 6px; }

@media (max-width: 820px) {
  .trip-grid { grid-template-columns: 1fr; }
  .side { position: static; max-height: none; overflow: visible; }
  .day { grid-template-columns: 1fr; gap: 6px; }
  .rail { flex-direction: row; align-items: baseline; gap: 10px; }
  .rail .date { font-size: 28px; }
  .rail .wd { margin-top: 0; }
}
@media (max-width: 600px) {
  .trip-row a { grid-template-columns: 1fr auto; padding-left: 16px; }
  .when { grid-column: 1 / -1; }
  .when .y { font-size: 22px; }
  .len { font-size: 24px; }
  .world .map-label { font-size: 38px; stroke-width: 9px; }
  .world .home .map-label { display: none; }
  .stops { columns: 1; }
}
@media (max-width: 900px) {
  .home-shell { grid-template-columns: 1fr; grid-template-rows: 132px minmax(0, 1fr) 210px; }
  .masthead {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) minmax(280px, .9fr);
    gap: 16px;
    align-items: center;
    padding: 16px 20px;
    border-right: 0;
    border-bottom: 1px solid var(--rule);
  }
  .bob-id b { display: none; }
  .home-title { margin: 0; }
  .masthead h1 { writing-mode: horizontal-tb; font-size: clamp(28px, 5vw, 42px); letter-spacing: -0.05em; }
  .tagline { margin: 7px 0 0; max-width: 28em; font-size: 12px; line-height: 1.5; }
  .stats { grid-template-columns: repeat(4, 1fr); border: 0; }
  .stats div, .stats div:nth-child(odd), .stats div:nth-child(even) { padding: 5px 10px; border: 0; border-left: 1px solid var(--rule); }
  .stats dd { font-size: 25px; }
  .home-note, .masthead .viewnote { display: none; }
  .trip-board { border-left: 0; border-top: 1px solid var(--rule); }
  .trip-board > header { padding: 12px 20px 10px; }
  .trip-board > header h2 { font-size: 17px; }
  .trip-board > header p { display: none; }
  .trips { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(270px, 43vw); overflow-x: auto; overflow-y: hidden; }
  .trip-row { border-top: 0; border-right: 1px solid var(--rule); }
  .trip-row a { height: 100%; padding: 14px 18px; }
  .world .map-label { font-size: 12px; }
  .world .map-en { font-size: 8px; }
}
@media (max-width: 600px) {
  .home-shell { grid-template-rows: 154px minmax(0, 1fr) 182px; }
  .masthead { grid-template-columns: auto 1fr; gap: 8px 12px; padding: 12px 14px; }
  .bob-mark { width: 32px; height: 32px; font-size: 18px; }
  .bob-id small { font-size: 9px; }
  .home-title { align-self: center; }
  .masthead h1 { font-size: 28px; }
  .tagline { display: none; }
  .stats { grid-column: 1 / -1; align-self: end; }
  .stats div, .stats div:nth-child(odd), .stats div:nth-child(even) { padding: 3px 8px; }
  .stats div:first-child { border-left: 0; padding-left: 0; }
  .stats dt { font-size: 10px; }
  .stats dd { font-size: 21px; }
  .stats dd small { font-size: 10px; }
  .map-head { top: 12px; left: 14px; }
  .map-head h2 { font-size: 14px; }
  .map-head p { font-size: 10px; }
  .trip-board > header { padding: 8px 14px 7px; }
  .trips { grid-auto-columns: minmax(245px, 82vw); }
  .home .trip-row a { grid-template-columns: 3.2rem minmax(0, 1fr) auto; padding: 10px 14px; }
  .home .when { grid-column: auto; }
  .home .when .y { font-size: 14px; }
  .home .len { font-size: 20px; }
  .home .name { font-size: 16px; }
  .home .path { margin-top: 4px; line-height: 1.4; }
  .world .home .map-label { display: none; }
}
@media (min-width: 901px) and (max-height: 700px) {
  .masthead { padding-top: 20px; padding-bottom: 18px; }
  .home-title { margin-bottom: 20px; }
  .masthead h1 { font-size: 42px; }
  .tagline { margin-top: 12px; font-size: 13px; }
  .stats div { padding-top: 8px; padding-bottom: 7px; }
  .stats dd { font-size: 26px; }
  .home-note { display: none; }
  .trip-board > header { padding-top: 20px; padding-bottom: 14px; }
  .trip-row a { padding-top: 12px; padding-bottom: 12px; }
}
@media print {
  .side { position: static; }
  .atlas, .days { display: none; }
}

.price { white-space: normal; }
.asof { margin-left: 6px; font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
a.asof { text-decoration-style: dotted; }
