:root {
  --bg: #faf6f1; --card: #ffffff; --ink: #2a211c; --muted: #7a6c63; --line: #eadfd4;
  --accent: #b4441d; --accent-ink: #fff; --chip: #f3e9df;
  --lv0: #6f9a4a; --lv1: #d6a21e; --lv2: #e07b24; --lv3: #c8341c; --lv4: #8d5a3b; --lv5: #8a8178;
  --warn: #b7791f; --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17120f; --card: #221b17; --ink: #f1e8e1; --muted: #a99a8f; --line: #3a2f29;
    --accent: #e0683c; --chip: #2e2520; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #17120f; --card: #221b17; --ink: #f1e8e1; --muted: #a99a8f; --line: #3a2f29;
  --accent: #e0683c; --chip: #2e2520; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line);
  border-radius: 20px; padding: 28px 22px; display: grid; gap: 12px; text-align: center; }
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; }
.login-leaf { width: 44px; height: 44px; color: var(--accent); margin: 0 auto; }
.login-card label { display: grid; gap: 4px; text-align: left; font-size: 13px; color: var(--muted); }
.login-card label.check { display: flex; align-items: center; gap: 8px; }
input { font: inherit; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); }
.login-card button { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 12px; font-weight: 600; }
.login-card button:disabled { opacity: .6; }
.err { color: #c62828; min-height: 1.2em; font-size: 14px; }

/* shell */
.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-title { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.top-title svg { width: 20px; height: 20px; color: var(--accent); }
.ghost { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 4px 10px; }
main { max-width: 760px; margin: 0 auto; padding: 12px 16px calc(84px + env(safe-area-inset-bottom)); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; padding: 12px 0 14px; color: var(--muted); font-weight: 600; }
.tabs button[aria-selected="true"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* day chips */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 12px; padding: 6px 10px; text-align: center; line-height: 1.2; }
.chip b { display: block; font-size: 15px; }
.chip span { font-size: 11px; color: var(--muted); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip[aria-pressed="true"] span { color: inherit; opacity: .85; }
.chip.today { outline: 2px dashed var(--accent); outline-offset: 2px; }

h2 { font-size: 19px; margin: 6px 0 4px; }
h3 { font-size: 16px; margin: 18px 0 8px; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.koyo-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 4px; }

/* timeline */
.timeline { list-style: none; margin: 8px 0 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.timeline > li { position: relative; padding-left: 24px; margin-bottom: 10px; }
.timeline > li::before { content: ""; position: absolute; left: 2px; top: 16px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--accent); }
.timeline > li.move::before { border-color: var(--muted); border-radius: 3px; }
.timeline > li.pic::before, .timeline > li.fare::before { display: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.item-title { font-weight: 650; white-space: pre-line; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 13px; margin-top: 2px; }
.meta .time { color: var(--ink); font-variant-numeric: tabular-nums; white-space: pre-line; }
.route { font-size: 14px; margin-top: 2px; }
.route .arrow { color: var(--muted); margin: 0 4px; }
.note { white-space: pre-line; font-size: 14px; margin-top: 6px; padding: 6px 8px; background: var(--chip); border-radius: 8px; }
.links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.links a { font-size: 12.5px; text-decoration: none; background: var(--chip); padding: 4px 8px; border-radius: 8px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shot { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.fare-line { font-size: 13px; color: var(--muted); padding: 2px 0 4px; }
.total { margin-top: 10px; text-align: right; color: var(--muted); font-size: 13px; }

/* koyo */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 650; color: #fff; white-space: nowrap; background: var(--lv5); border: 0; }
.badge.lv0 { background: var(--lv0); } .badge.lv1 { background: var(--lv1); color: #2a211c; }
.badge.lv2 { background: var(--lv2); } .badge.lv3 { background: var(--lv3); }
.badge.lv4 { background: var(--lv4); } .badge.lv5 { background: var(--lv5); }
.badge.none { background: var(--chip); color: var(--muted); }
.badge.warn { background: none; color: var(--warn); border: 1px solid var(--warn); }
button.badge { cursor: pointer; }
.scale { display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; margin: 8px 0; }
.scale div { font-size: 11px; text-align: center; padding: 4px 0; border-radius: 6px; color: #fff; }
.spot { margin-bottom: 12px; }
.spot-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.spot-name { font-weight: 700; }
.forecast { font-size: 13.5px; margin-top: 6px; }
.forecast li { margin: 2px 0; }
.forecast ul { margin: 4px 0 0; padding-left: 18px; }
.src-table { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 13px; }
.src-table td { padding: 6px 4px; border-top: 1px solid var(--line); vertical-align: top; }
.src-table td:first-child { width: 40%; }
.tier { font-size: 10.5px; padding: 1px 5px; border-radius: 4px; border: 1px solid var(--line); color: var(--muted); margin-left: 4px; white-space: nowrap; }
.tier.t1 { border-color: var(--accent); color: var(--accent); }
.hist { color: var(--muted); font-size: 12px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.rules { font-size: 13.5px; }
.rules li { margin: 3px 0; }

/* hotel */
.opt { padding: 8px 0; border-top: 1px solid var(--line); white-space: pre-line; }
.opt:first-of-type { border-top: 0; }
.opt.pick { font-weight: 600; }
.opt .tag { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 4px; padding: 1px 6px; margin-right: 6px; }
.price { color: var(--muted); font-size: 13px; }
.gallery { display: grid; gap: 10px; }

.lightbox { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.92); display: grid; place-items: center; overflow: auto; }
.lightbox img { max-width: 100%; height: auto; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.banner { font-size: 13px; padding: 8px 10px; border-radius: 10px; background: var(--chip); margin: 4px 0 10px; }
.orig { display: block; font-size: 11px; color: var(--muted); font-weight: 400; line-height: 1.35; margin-top: 1px; }
.scale .orig { color: inherit; opacity: .8; font-size: 9.5px; }
.opt .tag.pending { background: var(--warn); }
.timeline > li.tip::before { border-color: var(--warn); background: var(--warn); }
.tip-card { border-left: 4px solid var(--warn); }
.tip-card summary { font-weight: 650; color: var(--ink); font-size: 15px; }
.tip-card ul { margin: 6px 0 0; padding-left: 18px; font-size: 14px; }
.tip-card li { margin: 3px 0; }

/* phone layout (iPhone ≈ 390–430px) */
input { font-size: 16px; } /* <16px makes iOS Safari zoom in on focus and stay zoomed */
.card { overflow-wrap: break-word; }
.spot-head > div:last-child { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.lightbox { display: block; -webkit-overflow-scrolling: touch; }
.lightbox img { display: block; max-width: none; margin: 48px auto 24px; }
.lightbox-close { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 12px; z-index: 21;
  background: rgba(255,255,255,.15); color: #fff; border: 1px solid rgba(255,255,255,.4); border-radius: 999px; padding: 6px 14px; }
@media (max-width: 600px) {
  main { padding-left: 12px; padding-right: 12px; }
  .chips { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; overflow: visible; }
  .chip { padding: 6px 2px; }
  .scale { grid-template-columns: repeat(3, 1fr); }
  .scale div { font-size: 12px; padding: 5px 2px; }
  .scale .orig { font-size: 10px; }
  .src-table, .src-table tbody, .src-table tr, .src-table td { display: block; width: 100%; }
  .src-table tr { border-top: 1px solid var(--line); padding: 6px 0; }
  .src-table td { border-top: 0; padding: 2px 0; }
  .src-table td:first-child { width: auto; font-weight: 600; }
  .timeline > li { padding-left: 20px; }
}
