/* 日本行程 — Samsung Z Fold 6: cover ~320–400px, inner ~700–900px */
:root {
  --bg: #F6F1EA;
  --surface: #FFFCF8;
  --surface-2: #EFE8DE;
  --text: #1F1A16;
  --muted: #5C534B;
  --border: #E4D9CC;
  --accent: #F4A261;
  --accent-deep: #B85C1A;
  --crit-bg: #F4A261;
  --crit-fg: #2B1608;
  --ok-bg: #E6F3EC;
  --ok-fg: #1F4F3A;
  --pub-bg: #F3EBD3;
  --pub-fg: #5C4A1F;
  --pend-bg: #F6E8E3;
  --pend-fg: #6B3A2F;
  --link: #8A3F0E;
  --shadow: 0 1px 2px rgba(31, 26, 22, 0.06), 0 8px 24px rgba(31, 26, 22, 0.05);
  --header-h: 3.25rem;
  --dock-h: 3.25rem;
  --nav-h: 3.75rem;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --font: system-ui, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --radius: 14px;
  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161310;
    --surface: #211C18;
    --surface-2: #2A2420;
    --text: #F3EDE6;
    --muted: #B8AFA6;
    --border: #3A322C;
    --crit-bg: #B85C1A;
    --crit-fg: #FFF6EC;
    --ok-bg: #1C2E26;
    --ok-fg: #8FCBAA;
    --pub-bg: #2E2818;
    --pub-fg: #E0C98A;
    --pend-bg: #32201C;
    --pend-fg: #E0A898;
    --link: #F4A261;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.28);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  min-height: 100%;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

img, svg { max-width: 100%; height: auto; display: block; }
button, a, input { font: inherit; color: inherit; }
button { color: var(--text); background: none; border: 0; padding: 0; cursor: pointer; }
a { color: var(--link); text-underline-offset: 0.15em; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible {
  outline: 3px solid var(--accent-deep);
  outline-offset: 2px;
}
.skip {
  position: absolute;
  left: 0.75rem;
  top: -4rem;
  z-index: 80;
  background: var(--surface);
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
}
.skip:focus { top: calc(var(--safe-t) + 0.5rem); }

.app {
  min-height: 100dvh;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* —— Sticky compact header (cover) —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tap);
  padding: calc(var(--safe-t) + 0.35rem) calc(var(--safe-r) + 0.75rem) 0.4rem calc(var(--safe-l) + 0.75rem);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  text-decoration: none;
  color: var(--text);
  flex: 1;
}
.brand-mark {
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 9px;
}
.brand-text { min-width: 0; }
.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
  line-height: 1.2;
}
.brand-sub {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-meta {
  flex: 0 0 auto;
  text-align: right;
  font-size: 0.7rem;
  color: var(--muted);
  line-height: 1.3;
  max-width: 42%;
}

/* —— Sidebar: hidden on cover, used on inner screen —— */
.sidebar {
  display: none;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: calc(var(--safe-t) + 0.75rem) 0.75rem calc(var(--safe-b) + 0.75rem) calc(var(--safe-l) + 0.75rem);
  overflow: auto;
}
.sidebar .brand { margin-bottom: 0.85rem; padding: 0.15rem 0.25rem; }
.nav-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.85rem 0.65rem 0.3rem;
}
.nav-list, .day-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.nav-list a, .day-list a, .chip, .tab, .bottom-nav a, .filter-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: var(--tap);
  padding: 0.45rem 0.7rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  min-width: 0;
}
.nav-list a:hover, .day-list a:hover, .chip:hover, .filter-tab:hover, .bottom-nav a:hover {
  background: var(--surface-2);
}
.nav-list a[aria-current="page"],
.day-list a[aria-current="page"],
.chip[aria-current="page"],
.filter-tab[aria-selected="true"],
.bottom-nav a[aria-current="page"] {
  background: var(--surface-2);
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--accent-deep);
}
.bottom-nav a[aria-current="page"] {
  box-shadow: inset 0 -3px 0 var(--accent-deep);
}
.day-list a { justify-content: space-between; }
.day-list .dow { color: var(--muted); font-size: 0.8rem; font-weight: 500; }
.day-city { color: var(--muted); font-size: 0.75rem; font-weight: 500; }

/* —— Main pane —— */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.content {
  flex: 1;
  min-width: 0;
  padding: 0.9rem calc(var(--safe-r) + 0.85rem) 1.5rem calc(var(--safe-l) + 0.85rem);
  padding-bottom: calc(var(--nav-h) + var(--dock-h) + var(--safe-b) + 1.25rem);
}
.page-title {
  font-size: 1.45rem;
  font-weight: 750;
  line-height: 1.25;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}
.lede, .note, .muted { color: var(--muted); }
.lede { margin: 0 0 1rem; }

.grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
  min-width: 0;
}
.cards-2, .cards-3, .stay-grid { display: grid; gap: 0.75rem; grid-template-columns: 1fr; min-width: 0; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h2, .section-h {
  font-size: 0.95rem;
  margin: 0 0 0.55rem;
  font-weight: 750;
}
.card p { margin: 0.35rem 0; }
.card p:first-child { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }
.kicker {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.04em;
  margin: 0 0 0.2rem;
}

.day-card {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text);
  min-height: var(--tap);
}
.day-card .date-col {
  flex: 0 0 auto;
  width: 3.7rem;
  text-align: center;
  padding-right: 0.65rem;
  border-right: 1px solid var(--border);
}
.day-card .md { font-size: 1.15rem; font-weight: 750; line-height: 1.1; }
.day-card .wk { font-size: 0.75rem; color: var(--muted); }
.day-card .body { flex: 1; min-width: 0; }
.day-card .title { font-weight: 700; }
.day-card .sum { font-size: 0.88rem; color: var(--muted); }

/* status & critical */
.badge, .status {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  min-height: 1.5rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.3;
  vertical-align: middle;
  max-width: 100%;
  overflow-wrap: break-word;
}
.status-confirmed { background: var(--ok-bg); color: var(--ok-fg); }
.status-published { background: var(--pub-bg); color: var(--pub-fg); }
.status-pending { background: var(--pend-bg); color: var(--pend-fg); }
.status-locked { background: var(--ok-bg); color: var(--ok-fg); }
.status-reco { background: var(--pub-bg); color: var(--pub-fg); }

.event {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem;
  min-width: 0;
}
.event + .event, .timeline .event { margin-top: 0.65rem; }
.event.critical {
  background: var(--crit-bg);
  color: var(--crit-fg);
  border-color: transparent;
}
.event.critical a { color: inherit; font-weight: 700; }
.event.critical .muted,
.event.critical .status { color: inherit; }
.event.critical .status {
  background: color-mix(in srgb, #fff 35%, transparent);
  border: 1px solid color-mix(in srgb, var(--crit-fg) 25%, transparent);
}
.event-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.7rem;
  margin-bottom: 0.3rem;
}
.event-time {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}
.event-title { font-weight: 750; flex: 1 1 12rem; min-width: 0; overflow-wrap: break-word; }
.backup {
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  background: color-mix(in srgb, #fff 28%, transparent);
  border: 1px dashed color-mix(in srgb, currentColor 35%, transparent);
}
.event:not(.critical) .backup {
  background: var(--surface-2);
  border-color: var(--border);
}
.backup strong { display: block; font-size: 0.78rem; margin-bottom: 0.15rem; }
.sources-inline, .src-list { margin: 0.4rem 0 0; padding: 0; list-style: none; }
.sources-inline li, .src-list li { margin: 0.2rem 0; overflow-wrap: break-word; }
.src-list a, .sources-inline a { display: inline; }

/* day filters */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.85rem;
  position: sticky;
  top: calc(var(--safe-t) + var(--header-h));
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  padding: 0.35rem 0;
}
.filter-tab {
  border: 1px solid var(--border);
  background: var(--surface);
  flex: 1 1 auto;
  justify-content: center;
  min-width: 5.5rem;
}
.filter-tab[aria-selected="true"] {
  box-shadow: inset 0 -3px 0 var(--accent-deep);
  background: var(--surface-2);
  font-weight: 700;
}

/* bottom day dock + app nav (cover / one-handed) */
.dock {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  padding-left: var(--safe-l);
  padding-right: var(--safe-r);
  padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.day-dock {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.4rem 0.55rem 0.15rem;
  justify-content: center;
}
.day-dock .chip {
  flex: 0 0 auto;
  min-width: var(--tap);
  justify-content: center;
  padding: 0.25rem 0.45rem;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
}
.day-dock .chip small {
  display: block;
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--muted);
}
.day-dock .chip[aria-current="page"] small { color: inherit; opacity: 0.85; }
.bottom-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  gap: 0.15rem;
  padding: 0.15rem 0.25rem 0.25rem;
}
.bottom-nav a {
  flex: 1 1 3.6rem;
  flex-direction: column;
  justify-content: center;
  gap: 0.05rem;
  min-width: 3.4rem;
  min-height: var(--tap);
  font-size: 0.68rem;
  font-weight: 650;
  text-align: center;
  padding: 0.25rem 0.2rem;
}
.bottom-nav .ico { font-size: 1.05rem; line-height: 1; }

.callout {
  border-radius: var(--radius);
  padding: 0.8rem 0.95rem;
  margin: 0 0 0.85rem;
  border: 1px solid var(--border);
  background: var(--surface);
  min-width: 0;
}
.callout.warn {
  background: var(--crit-bg);
  color: var(--crit-fg);
  border-color: transparent;
}
.callout.info { background: var(--pub-bg); color: var(--pub-fg); }
.callout.ok { background: var(--ok-bg); color: var(--ok-fg); }
.callout .lead { font-weight: 750; margin: 0 0 0.25rem; }

.kv {
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.3rem 0.7rem;
  min-width: 0;
}
.kv dt { color: var(--muted); font-size: 0.82rem; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: break-word; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0.4rem 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 16rem;
}
th, td {
  text-align: start;
  vertical-align: top;
  padding: 0.55rem 0.55rem;
  border-bottom: 1px solid var(--border);
  overflow-wrap: break-word;
}
th { font-size: 0.75rem; color: var(--muted); font-weight: 700; }

.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.55rem; }
.check-list li {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.85rem;
  min-height: var(--tap);
}
.check-box {
  flex: 0 0 auto;
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.2rem;
  border: 2px solid var(--muted);
  border-radius: 4px;
  opacity: 0.7;
}
.check-list .why { font-size: 0.85rem; color: var(--muted); margin: 0.2rem 0 0; }

.meal {
  display: grid;
  gap: 0.55rem;
}
.meal .who { font-weight: 750; }
.price { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 0.88rem; }

.phone {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  padding: 0 0.15rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--link);
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.6rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.9rem;
}
.btn.primary {
  background: var(--accent-deep);
  color: #FFF6EC;
  border-color: transparent;
}

.footer-note {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--muted);
}
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0.4rem 0 1rem; }

/* Wide / inner screen: two-pane, not a stretched phone column */
@media (min-width: 700px) and (min-height: 540px) {
  .app {
    display: grid;
    grid-template-columns: minmax(16.5rem, 19.5rem) minmax(0, 1fr);
    grid-template-rows: 1fr;
    height: 100dvh;
    overflow: hidden;
  }
  .sidebar { display: flex; height: 100dvh; }
  .topbar, .dock { display: none; }
  .main { height: 100dvh; overflow: auto; }
  .content {
    padding: 1.25rem 1.6rem 2.5rem;
    max-width: 58rem;
  }
  .filters { top: 0; }
  .cards-2, .stay-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cards-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .overview-days { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) and (min-height: 540px) {
  .overview-days { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .content { padding-inline: 2rem; }
}

/* Mid width (or short landscape): still wrap, no clipped rows */
@media (min-width: 600px) and (max-width: 699.98px),
       (min-width: 600px) and (max-height: 539.98px) {
  .cards-2, .stay-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .day-dock { justify-content: flex-start; }
}

@media (orientation: landscape) and (max-height: 539.98px) {
  .topbar { min-height: 2.75rem; }
  .brand-sub { display: none; }
  .content { padding-bottom: calc(var(--nav-h) + var(--dock-h) + var(--safe-b) + 0.75rem); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

body:not([data-view="day"]) .content {
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 1.25rem);
}
.day-dock[hidden] { display: none !important; }
tr.critical-row td {
  background: var(--crit-bg);
  color: var(--crit-fg);
}
@media (min-width: 700px) and (min-height: 540px) {
  body:not([data-view="day"]) .content,
  .content { padding-bottom: 2.5rem; }
}

@media (min-width: 700px) and (min-height: 540px) {
  .day-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.3rem;
  }
  .day-list a {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0.05rem;
    min-height: var(--tap);
    padding: 0.25rem 0.2rem;
    font-weight: 700;
  }
  .day-list a[aria-current="page"] {
    box-shadow: inset 0 0 0 2px var(--accent-deep);
  }
  .nav-list a { min-height: 2.6rem; }
  .kv { grid-template-columns: 5.5rem minmax(0, 1fr); }
}
.kv dd { overflow-wrap: break-word; word-break: normal; }
