/* Japan trip viewer: mobile-first, light/dark */

:root {
  --bg: #f7f3ec;
  --surface: #fffdf9;
  --surface-2: #f1ebe1;
  --text: #24201c;
  --muted: #6e665d;
  --border: #e4dccf;
  --accent: #c8402f;          /* torii vermilion */
  --accent-soft: #f8e3dd;
  --link: #a33626;
  --shadow: 0 1px 2px rgb(60 40 20 / 6%), 0 4px 16px rgb(60 40 20 / 6%);

  --tokyo: #3b4f9a;
  --kyoto: #c8402f;
  --hiroshima: #1d8577;
  --osaka: #c27a12;

  --pace-easy: #3f8f5a;
  --pace-moderate: #c27a12;
  --pace-busy: #c8402f;
  --pace-event: #7b4fb0;

  --warn-bg: #fdf0e3;  --warn-fg: #9a4b07;
  --note-bg: #eef2f8;  --note-fg: #34518a;
  --alt-bg: #f2eef8;   --alt-fg: #5d3f8f;
  --good-bg: #ebf5ee;  --good-fg: #2f6f45;
  --muted-bg: #f1ede6; --muted-fg: #6e665d;

  --radius: 16px;
  --gutter: 16px;
  --tabbar-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16141a;
    --surface: #211e25;
    --surface-2: #2b2730;
    --text: #efe9e1;
    --muted: #a59d93;
    --border: #3a3540;
    --accent: #ef6a55;
    --accent-soft: #3b2420;
    --link: #f08b79;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 25%);
    --tokyo: #8a9df0;
    --kyoto: #ef6a55;
    --hiroshima: #4fc4b3;
    --osaka: #f0a843;
    --pace-easy: #6cc58a;
    --pace-moderate: #f0a843;
    --pace-busy: #ef6a55;
    --pace-event: #b391e6;
    --warn-bg: #3a2814;  --warn-fg: #f6c48a;
    --note-bg: #1e2638;  --note-fg: #a9bdf0;
    --alt-bg: #2a2238;   --alt-fg: #cdb6f2;
    --good-bg: #1c2e22;  --good-fg: #9bdcb0;
    --muted-bg: #2b2730; --muted-fg: #a59d93;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16141a; --surface: #211e25; --surface-2: #2b2730; --text: #efe9e1; --muted: #a59d93;
  --border: #3a3540; --accent: #ef6a55; --accent-soft: #3b2420; --link: #f08b79;
  --tokyo: #8a9df0; --kyoto: #ef6a55; --hiroshima: #4fc4b3; --osaka: #f0a843;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Roboto, sans-serif;
  overflow-x: hidden;
}

a { color: var(--link); text-underline-offset: 2px; }
p { margin: 0 0 .75em; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
strong { font-weight: 650; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* City accents: any element with city-* sets --city */
.city-tokyo { --city: var(--tokyo); }
.city-kyoto { --city: var(--kyoto); }
.city-hiroshima { --city: var(--hiroshima); }
.city-osaka { --city: var(--osaka); }

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 680px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px var(--gutter);
}
.brand { color: var(--text); text-decoration: none; font-weight: 700; letter-spacing: .01em; }
.brand-mark { color: var(--accent); }
.topbar-date { color: var(--muted); font-size: .8125rem; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Layout ---------- */

.app {
  max-width: 680px; margin: 0 auto;
  padding: 12px var(--gutter) calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
}
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

.page-title { font-size: 1.75rem; margin: 8px 0 12px; }
.section-title { font-size: 1rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 28px 0 10px; }
.eyebrow { font-size: .8125rem; color: var(--muted); letter-spacing: .02em; }

.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 14px 0;
  color: inherit;
}
.card > :last-child { margin-bottom: 0; }
.card-link { text-decoration: none; }
.card-link:active { transform: scale(.995); }
.card-title { font-size: 1.0625rem; display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.card-row { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.card-row .card-title { margin-bottom: 0; }

.button {
  display: inline-block; padding: 10px 16px; border-radius: 999px;
  background: var(--accent); color: #fff; text-decoration: none; font-weight: 600;
}

/* ---------- Date strip ---------- */

.datestrip {
  position: relative;
  display: flex; gap: 6px;
  overflow-x: auto; scroll-snap-type: x proximity;
  margin: 0 calc(-1 * var(--gutter)) 12px;
  padding: 4px var(--gutter) 8px;
  scrollbar-width: none;
}
.datestrip::-webkit-scrollbar { display: none; }
.ds-item {
  flex: 0 0 auto; width: 48px; scroll-snap-align: center;
  display: flex; flex-direction: column; align-items: center;
  padding: 6px 0 8px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); text-decoration: none;
  border-bottom: 3px solid var(--city, var(--border));
}
.ds-wd { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.ds-num { font-size: 1.125rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.ds-item.is-today .ds-wd { color: var(--accent); font-weight: 700; }
.ds-item.is-current { background: var(--city); border-color: var(--city); color: #fff; }
.ds-item.is-current .ds-wd { color: rgb(255 255 255 / 85%); }

/* ---------- Day ---------- */

.hero {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px 16px;
  overflow: hidden;
}
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 5px;
  background: var(--city, var(--accent));
}
.hero h1 { font-size: 1.5rem; margin: 6px 0 10px; text-wrap: balance; }
.hero-summary { color: var(--muted); margin: 12px 0 0; }
.today-tag { color: var(--accent); font-weight: 700; }

.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .8125rem; font-weight: 600;
  padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--text);
}
.badge-city { background: color-mix(in srgb, var(--city, var(--accent)) 14%, transparent); color: var(--city, var(--accent)); }
.badge[class*="pace-"]::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--pace); }
.pace-easy { --pace: var(--pace-easy); }
.pace-moderate { --pace: var(--pace-moderate); }
.pace-busy { --pace: var(--pace-busy); }
.pace-event { --pace: var(--pace-event); }

.meta { margin: 14px 0 0; display: grid; gap: 8px; }
.meta div { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.meta dt { font-size: .6875rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.meta dd { margin: 0; }

.day-content { margin-top: 18px; }
.day-content > p, .day-content > .list { padding: 0 4px; }

.highlight {
  margin: 0 0 14px; padding: 10px 14px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
}

/* Timeline */
.timeline { list-style: none; margin: 0 0 16px; padding: 0; }
.tl-item {
  display: grid; grid-template-columns: 4.75rem 14px 1fr; gap: 10px;
  position: relative; padding-bottom: 16px;
}
.tl-item::before {
  content: ""; position: absolute; left: calc(4.75rem + 10px + 6px); top: 14px; bottom: -2px;
  width: 2px; background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-time {
  font-size: .8125rem; font-weight: 700; color: var(--city, var(--accent));
  font-variant-numeric: tabular-nums; padding-top: 2px; text-align: right; line-height: 1.35;
  overflow-wrap: anywhere;
}
.tl-dot {
  width: 14px; height: 14px; margin-top: 4px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--city, var(--accent)); position: relative; z-index: 1;
}
.tl-body {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px; min-width: 0; overflow-wrap: anywhere;
}
.tl-item.is-past .tl-body { opacity: .6; }
.tl-item.is-past .tl-dot { background: var(--city, var(--accent)); }
.tl-item.is-now .tl-dot { background: var(--city, var(--accent)); box-shadow: 0 0 0 5px color-mix(in srgb, var(--city, var(--accent)) 25%, transparent); }
.tl-item.is-now .tl-body { border-color: var(--city, var(--accent)); box-shadow: var(--shadow); }
.now-pill {
  display: inline-block; margin-top: 4px; padding: 1px 6px; border-radius: 999px;
  background: var(--city, var(--accent)); color: #fff; font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em;
}

.list { margin: 0 0 14px; padding-left: 1.25em; }
.list li { margin: 0 0 6px; }
.list li::marker { color: var(--city, var(--accent)); }

/* Callouts */
.callout {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--c-bg); color: var(--text);
  border-left: 4px solid var(--c-fg);
}
.callout-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; color: var(--c-fg); margin-bottom: 2px; }
.callout-warn { --c-bg: var(--warn-bg); --c-fg: var(--warn-fg); }
.callout-note { --c-bg: var(--note-bg); --c-fg: var(--note-fg); }
.callout-alt { --c-bg: var(--alt-bg); --c-fg: var(--alt-fg); }
.callout-good { --c-bg: var(--good-bg); --c-fg: var(--good-fg); }
.callout-muted { --c-bg: var(--muted-bg); --c-fg: var(--muted-fg); }

/* Pager */
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 4px; }
.pager-btn {
  display: flex; flex-direction: column; padding: 10px 14px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text);
}
.pager-btn span { font-size: .75rem; color: var(--muted); }
.pager-next { text-align: right; }

/* ---------- Countdown / Today ---------- */

.countdown {
  margin: 8px 0 14px; padding: 22px 18px; border-radius: var(--radius);
  background:
    radial-gradient(circle at 88% 18%, color-mix(in srgb, var(--accent) 85%, white) 0 34px, transparent 35px),
    linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #3b1d4a));
  color: #fff;
}
.countdown .eyebrow { color: rgb(255 255 255 / 85%); }
.countdown-big { font-size: 2rem; font-weight: 800; margin: 4px 0 6px; line-height: 1.15; }
.countdown p { color: rgb(255 255 255 / 92%); }
.countdown .button { background: #fff; color: var(--accent); }
.countdown .chain-stop { background: rgb(255 255 255 / 18%); color: #fff; }
.countdown .chain-arrow { color: rgb(255 255 255 / 70%); }

.tomorrow .card-title { margin: 4px 0 6px; }

.chain { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin: 10px 0 4px; }
.chain-stop {
  font-size: .8125rem; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--city) 14%, transparent); color: var(--city);
}
.chain-arrow { color: var(--muted); font-size: .8125rem; }

.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 2px 0 10px; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: inherit; transition: width .3s ease; }

/* ---------- Days list ---------- */

.leg { margin: 18px 0 8px; }
.leg-head { padding: 0 2px 8px; border-left: 4px solid var(--city); padding-left: 12px; margin-bottom: 10px; }
.leg-head h2 { font-size: 1.25rem; color: var(--city); }
.leg-priorities { font-size: .875rem; color: var(--muted); }
.dayrows { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dayrow {
  display: grid; grid-template-columns: 48px 1fr auto; gap: 12px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 10px 12px; text-decoration: none; color: var(--text);
}
.dayrow.is-today { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.dayrow.is-past { opacity: .6; }
.dr-date { display: flex; flex-direction: column; align-items: center; line-height: 1.1; }
.dr-date span { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.dr-date strong { font-size: 1.375rem; color: var(--city); }
.dr-body { min-width: 0; }
.dr-title { font-weight: 650; }
.dr-sub { font-size: .8125rem; color: var(--muted); overflow-wrap: anywhere; }
.pace-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pace); }

.pill {
  display: inline-block; vertical-align: 2px; margin-left: 6px;
  font-size: .6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 1px 7px; border-radius: 999px; background: var(--accent); color: #fff;
}
.pill-done { background: var(--pace-easy); }

/* ---------- Bookings ---------- */

.prio { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.prio-high { background: var(--pace-busy); }
.prio-medium { background: var(--pace-moderate); }
.prio-optional { background: var(--pace-event); }

.bk-list { list-style: none; margin: 0; padding: 0; }
.bk { display: grid; grid-template-columns: 44px 1fr; gap: 8px; padding: 10px 0; border-top: 1px solid var(--border); }
.bk:first-child { border-top: 0; padding-top: 0; }
.bk-check { position: relative; width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; }
.bk-check input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
.bk-box {
  width: 26px; height: 26px; border-radius: 8px;
  border: 2px solid var(--muted); background: var(--surface);
  display: grid; place-items: center; transition: background .15s, border-color .15s;
}
.bk-check input:checked + .bk-box { background: var(--pace-easy); border-color: var(--pace-easy); }
.bk-check input:checked + .bk-box::after { content: "✓"; color: #fff; font-weight: 800; font-size: 16px; line-height: 1; }
.bk-check input:focus-visible + .bk-box { outline: 3px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 2px; }
.bk-body { min-width: 0; padding-top: 9px; }
.bk-title { font-weight: 650; }
.bk.is-booked .bk-title { color: var(--muted); }
.bk-dates { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.chip {
  font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--surface-2); color: var(--text); text-decoration: none;
}
.chip-plain { color: var(--muted); }
.bk-detail { font-size: .8125rem; color: var(--muted); }
.bk-action { font-size: .875rem; overflow-wrap: anywhere; }
.bk-status { color: var(--muted); }

/* ---------- Info ---------- */

.info-section h3 { font-size: 1rem; margin: 16px 0 8px; }
.rowcards { display: grid; gap: 8px; margin: 0 0 12px; }
.rowcard { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.rowcard-title { font-weight: 650; margin-bottom: 4px; }
.rowcard dl { margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 4px 12px; }
.rowcard dt { font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rowcard dd { margin: 0; font-size: .9375rem; }

/* ---------- Tab bar ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tab-icon { font-size: 1.25rem; line-height: 1; }
.tabbar a.is-active { color: var(--accent); }
.tab-badge {
  position: absolute; top: 8px; left: calc(50% + 8px);
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: #fff; font-size: .6875rem; line-height: 18px; text-align: center;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30;
  bottom: calc(var(--tabbar-h) + 16px + env(safe-area-inset-bottom));
  max-width: calc(100% - 2 * var(--gutter));
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: .875rem; font-weight: 600;
  box-shadow: var(--shadow);
}

@media (min-width: 560px) {
  .page-title { font-size: 2rem; }
  .hero h1 { font-size: 1.75rem; }
  .tl-item { grid-template-columns: 6rem 14px 1fr; }
  .tl-item::before { left: calc(6rem + 10px + 6px); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
