/* ============================== 色彩 ============================== */
:root {
  color-scheme: light;
  --bg: #f5f2ec;
  --surface: #ffffff;
  --surface-2: #efeae1;
  --text: #18212c;
  --muted: #5d6877;
  --line: #e2dbcf;
  --brand: #0b7a85;
  --on-brand: #ffffff;
  --accent: #d9680f;
  --danger: #c93a3a;
  --danger-bg: #fcebea;
  --warn-text: #8a4b06;
  --warn-bg: #fff3e0;
  --shadow: 0 1px 2px rgba(20, 30, 40, .05), 0 4px 14px rgba(20, 30, 40, .06);

  --c-eat: #dd6f14;
  --c-sight: #2f7bd9;
  --c-shop: #9a4fd6;
  --c-act: #1e9a57;
  --c-rest: #7b8696;
  --c-meet: #d23f3f;
  --c-hotel: #5866d6;
  --c-arrive: #0b7a85;
  --c-home: #0b7a85;
  --c-split: #c2410c;

  --hero-1: #0b7a85;
  --hero-2: #0d5d78;
  --hero-3: #173c62;

  --radius: 16px;
  --top-h: 52px;
  --tab-h: 62px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Segoe UI", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0c121a;
    --surface: #141c27;
    --surface-2: #1b2532;
    --text: #e6ebf1;
    --muted: #94a1b1;
    --line: #273345;
    --brand: #3bbfca;
    --on-brand: #04161a;
    --accent: #ffa04a;
    --danger: #ff7a7a;
    --danger-bg: #3a1a1d;
    --warn-text: #ffc37a;
    --warn-bg: #33250f;
    --shadow: none;
    --c-eat: #f29447;
    --c-sight: #61a4f2;
    --c-shop: #be86ef;
    --c-act: #45c17e;
    --c-rest: #8f9bab;
    --c-meet: #ff6b6b;
    --c-hotel: #8b95f0;
    --c-arrive: #3bbfca;
    --c-home: #3bbfca;
    --c-split: #f08a4b;
    --hero-1: #0d5f69;
    --hero-2: #0d4a60;
    --hero-3: #142d4b;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c121a;
  --surface: #141c27;
  --surface-2: #1b2532;
  --text: #e6ebf1;
  --muted: #94a1b1;
  --line: #273345;
  --brand: #3bbfca;
  --on-brand: #04161a;
  --accent: #ffa04a;
  --danger: #ff7a7a;
  --danger-bg: #3a1a1d;
  --warn-text: #ffc37a;
  --warn-bg: #33250f;
  --shadow: none;
  --c-eat: #f29447;
  --c-sight: #61a4f2;
  --c-shop: #be86ef;
  --c-act: #45c17e;
  --c-rest: #8f9bab;
  --c-meet: #ff6b6b;
  --c-hotel: #8b95f0;
  --c-arrive: #3bbfca;
  --c-home: #3bbfca;
  --c-split: #f08a4b;
  --hero-1: #0d5f69;
  --hero-2: #0d4a60;
  --hero-3: #142d4b;
}

/* ============================== 基本 ============================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--top-h) + 64px); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); }
h1, h2, h3 { line-height: 1.3; margin: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px; }

main.wrap { padding-top: 16px; padding-bottom: calc(var(--tab-h) + 28px + env(safe-area-inset-bottom)); }

/* ============================== 頂部 ============================== */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.top-in { display: flex; align-items: center; gap: 12px; height: var(--top-h); }

.brand { font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; white-space: nowrap; }

.clocks { margin-left: auto; display: flex; gap: 10px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.clocks b { color: var(--text); font-variant-numeric: tabular-nums; }

.theme-btn {
  width: 36px; height: 36px; flex: none;
  border: 1px solid var(--line); border-radius: 50%;
  background: var(--surface); cursor: pointer; font-size: 16px; line-height: 1;
}

/* 日期切換 */
.days {
  position: sticky;
  top: calc(var(--top-h) + env(safe-area-inset-top));
  z-index: 15;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.days-in { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding-top: 8px; padding-bottom: 8px; }
.days a {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 5px 0 6px;
  border-radius: 12px;
  color: var(--muted); text-decoration: none;
  font-size: 12px; line-height: 1.3;
}
.days a b { font-size: 15px; color: var(--text); }
.days a.on { background: var(--brand); color: var(--on-brand); }
.days a.on b { color: var(--on-brand); }
.days a.today::after {
  content: ""; position: absolute; top: 5px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
}

/* 提示列 */
.banner {
  max-width: 640px; margin: 8px auto 0; padding: 0 16px;
  font-size: 13px;
}
.banner > div {
  display: flex; gap: 8px; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-radius: 12px;
  background: var(--warn-bg); color: var(--warn-text);
}
.banner a { color: inherit; font-weight: 700; }

/* ============================== 底部選單 ============================== */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  max-width: 640px; margin: 0 auto;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
@media (min-width: 641px) {
  .tabbar { bottom: 12px; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); height: var(--tab-h); padding-bottom: 0; }
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar a span { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .7; }
.tabbar a.on { color: var(--brand); }
.tabbar a.on span { filter: none; opacity: 1; }

/* ============================== 共用 ============================== */
.sec { margin-top: 26px; }
.sec-h { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.sec-h h2 { font-size: 18px; }
.sec-h small { color: var(--muted); font-size: 13px; }

.panel {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 14px 16px;
}

.btn {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 36px; padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text); text-decoration: none;
  font-size: 14px; font-weight: 600;
}
.btn-brand { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }

.todo {
  display: inline-block;
  padding: 0 8px;
  border: 1px dashed var(--muted);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

/* ============================== 總覽 ============================== */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 20px 18px 18px;
  color: #fff;
  background: linear-gradient(140deg, var(--hero-1), var(--hero-2) 55%, var(--hero-3));
}
.hero::after {
  /* 海浪 */
  content: ""; position: absolute; left: -10%; right: -10%; bottom: -46px; height: 90px;
  background: radial-gradient(60px 26px at 50% 0, transparent 98%, rgba(255,255,255,.08) 100%) 0 0 / 120px 40px repeat-x,
              rgba(255,255,255,.06);
  border-radius: 50% 50% 0 0;
  pointer-events: none;
}
.hero-k { font-size: 13px; opacity: .85; letter-spacing: .02em; }
.hero h1 { font-size: 26px; margin-top: 4px; }
.hero h1 b { font-size: 34px; }
.hero-sub { margin-top: 8px; font-size: 15px; opacity: .95; }
.hero-now { margin-top: 12px; display: grid; gap: 8px; }
.hero-now div {
  background: rgba(255,255,255,.14);
  border-radius: 12px; padding: 8px 12px; font-size: 14px;
}
.hero-now small { display: block; opacity: .8; font-size: 12px; }
.hero .btn { margin-top: 14px; background: #fff; border-color: #fff; color: #0b5560; position: relative; z-index: 1; }

/* 不能遲到 */
.dues { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.dues a {
  display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  color: var(--text); text-decoration: none;
}
.dues .d-date { font-size: 12px; color: var(--muted); line-height: 1.25; }
.dues .d-date b { display: block; font-size: 17px; color: var(--danger); font-variant-numeric: tabular-nums; }
.dues .d-title { font-weight: 600; font-size: 15px; line-height: 1.35; }
.dues .d-title small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }
.dues .d-left { font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.dues .soon { border-color: var(--danger); background: var(--danger-bg); }
.dues .soon .d-left { color: var(--danger); font-weight: 700; }
.dues .done { opacity: .5; }
.dues .done .d-date b { color: var(--muted); }

/* 五日流程 */
.dflow { list-style: none; margin: 0; padding: 0; }
.dflow li { position: relative; display: grid; grid-template-columns: 44px 1fr; gap: 12px; padding-bottom: 12px; }
.dflow li::before {
  content: ""; position: absolute; left: 21px; top: 0; bottom: 0; width: 2px; background: var(--line);
}
.dflow li:first-child::before { top: 22px; }
.dflow li:last-child::before { bottom: auto; height: 22px; }
.dnum {
  position: relative; z-index: 1;
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface); border: 2px solid var(--brand); color: var(--brand);
  font-weight: 800; font-size: 15px;
}
.dflow li.is-today .dnum { background: var(--brand); color: var(--on-brand); }
.dflow li.is-done .dnum { border-color: var(--line); color: var(--muted); }
.dcard {
  display: block; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
}
.dflow li.is-today .dcard { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.dcard-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dcard h3 { font-size: 17px; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chips span { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.by { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap; }
.by-agency { background: var(--surface-2); color: var(--muted); }
.by-self { background: var(--brand); color: var(--on-brand); }
.today-tag { color: var(--accent); font-weight: 700; }

.hotel { display: flex; align-items: center; gap: 12px; }
.hotel-ic { font-size: 28px; }
.hotel-tx { flex: 1; min-width: 0; }
.hotel-tx b { display: block; }
.hotel-tx small { color: var(--muted); font-size: 13px; }

/* ============================== 每日行程 ============================== */
.day-head { margin-bottom: 14px; }
.day-k { font-size: 13px; font-weight: 700; color: var(--brand); letter-spacing: .03em; }
.day-head h1 { font-size: 24px; margin-top: 2px; }
.day-head .lead { color: var(--muted); margin-top: 4px; font-size: 15px; }
.agency-note {
  margin-top: 10px; padding: 8px 12px; border-radius: 12px;
  background: var(--surface-2); color: var(--muted); font-size: 13px;
}

/* 必帶清單 */
.check { margin-bottom: 18px; }
.check h2 { font-size: 15px; margin-bottom: 6px; }
.check ul { list-style: none; margin: 0; padding: 0; }
.check label {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 7px 0; cursor: pointer; font-size: 15px; line-height: 1.45;
}
.check li + li label { border-top: 1px solid var(--line); }
input[type="checkbox"] { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--brand); }
input[type="checkbox"]:checked + span { color: var(--muted); text-decoration: line-through; }

/* 時間軸（流程圖） */
.tl { list-style: none; margin: 0; padding: 0; }

.row {
  --c: var(--c-sight);
  display: grid;
  grid-template-columns: 46px 30px minmax(0, 1fr);
  column-gap: 8px;
}
.tl.no-time .row { grid-template-columns: 30px minmax(0, 1fr); }
.tl.no-time .tm { display: none; }

.t-eat { --c: var(--c-eat); }
.t-sight { --c: var(--c-sight); }
.t-shop { --c: var(--c-shop); }
.t-act { --c: var(--c-act); }
.t-rest { --c: var(--c-rest); }
.t-meet { --c: var(--c-meet); }
.t-hotel { --c: var(--c-hotel); }
.t-arrive { --c: var(--c-arrive); }
.t-home { --c: var(--c-home); }
.t-split { --c: var(--c-split); }
.move { --c: var(--brand); }

.tm {
  padding-top: 15px;
  text-align: right;
  font-size: 14px; line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.tm b { display: block; }
.tm span { display: block; color: var(--muted); font-size: 12px; }
.tm em { display: inline-block; margin-top: 3px; font-style: normal; font-size: 10px; padding: 0 4px; border-radius: 4px; background: var(--surface-2); color: var(--muted); }
.move .tm { padding-top: 11px; color: var(--muted); font-size: 12px; font-weight: 400; }

.rail { position: relative; display: flex; justify-content: center; }
.rail::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: 50%;
  width: 2px; margin-left: -1px; background: var(--line);
}
.tl > .row:first-child .rail::before { top: 22px; }
.tl > .row:last-child .rail::before { bottom: auto; height: 22px; }
.move .rail::before {
  background: repeating-linear-gradient(to bottom, var(--brand) 0 5px, transparent 5px 10px);
  opacity: .7;
}

.dot {
  position: relative; z-index: 1;
  width: 30px; height: 30px; margin-top: 10px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 15px; line-height: 1;
  border: 2px solid var(--c);
  background: var(--surface);
  background: color-mix(in srgb, var(--c) 16%, var(--surface));
  box-shadow: 0 0 0 4px var(--bg);
}
.move .dot { width: 26px; height: 26px; margin-top: 8px; font-size: 13px; border-style: dashed; background: var(--bg); }

.card {
  margin: 6px 0 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--c);
  border-radius: 14px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card h3 { font-size: 17px; }
.card .eng { color: var(--muted); font-size: 13px; }
.card p { margin-top: 6px; font-size: 15px; }
.card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; min-height: 22px; }
.tag {
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  color: var(--c);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--c) 13%, transparent);
}
.place { margin-top: 6px; font-size: 14px; color: var(--muted); }
.alert {
  margin-top: 8px; padding: 6px 10px; border-radius: 10px;
  background: var(--danger-bg); color: var(--danger);
  font-size: 14px; font-weight: 700;
}
.must {
  margin-top: 8px; padding: 6px 10px; border-radius: 10px;
  background: var(--warn-bg); color: var(--warn-text);
  font-size: 14px; font-weight: 600;
}
.tips { margin: 8px 0 0; padding: 0; list-style: none; font-size: 14px; color: var(--muted); }
.tips li { position: relative; padding-left: 16px; margin-top: 3px; }
.tips li::before { content: "💡"; position: absolute; left: -2px; top: 0; font-size: 11px; }
.tips b { color: var(--text); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.actions:empty { display: none; }

/* 交通（流程圖中的連接線） */
.move .card {
  margin: 4px 0 8px;
  padding: 8px 12px;
  background: transparent;
  border: 1.5px dashed var(--line);
  box-shadow: none;
  font-size: 14px;
}
.mv-title { font-weight: 700; font-size: 15px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.route { color: var(--text); font-size: 14px; }
.mv-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.move .card p { font-size: 14px; color: var(--muted); margin-top: 4px; }

/* 分岔與會合 */
.fork {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  margin-top: 10px;
  padding: 20px 0;
}
.fork::before, .fork::after {
  content: ""; position: absolute; left: 25%; right: 25%; height: 20px;
  border: 2px solid var(--c);
  opacity: .55;
}
.fork::before { top: 0; border-bottom: 0; border-radius: 12px 12px 0 0; }
.fork::after { bottom: 0; border-top: 0; border-radius: 0 0 12px 12px; }
.br {
  padding: 10px; border-radius: 12px;
  background: var(--surface-2);
  font-size: 14px; line-height: 1.5;
  min-width: 0;
}
.br-h { font-weight: 700; margin-bottom: 4px; }
.br-h small { display: block; color: var(--muted); font-weight: 600; font-size: 12px; }
.br .btn { margin-top: 8px; min-height: 30px; padding: 3px 10px; font-size: 13px; background: var(--surface); }
.merge {
  text-align: center; font-weight: 700; font-size: 14px; color: var(--c);
}

/* 即時狀態 */
.live:empty { display: none; }
.live {
  margin-left: auto;
  font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; white-space: nowrap;
}
.is-now .live { background: var(--brand); color: var(--on-brand); }
.is-next .live { border: 1px solid var(--accent); color: var(--accent); }
.is-now .card { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.is-now.move .card { border-style: solid; }
.is-now .dot { animation: pulse 1.8s ease-out infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 4px var(--brand); }
  100% { box-shadow: 0 0 0 4px var(--bg), 0 0 0 14px transparent; }
}
.is-past .card, .is-past .tm { opacity: .5; }
.is-past .dot { filter: grayscale(1); opacity: .6; }

/* ============================== 購物 ============================== */
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .2s; }
.shop-g + .shop-g { margin-top: 12px; }
.shop-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.shop-h h3 { font-size: 16px; }
.shop-h a { font-size: 12px; white-space: nowrap; }
.del {
  margin-left: auto; flex: none;
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.add { display: flex; gap: 8px; margin-top: 10px; }
.add input {
  flex: 1; min-width: 0; min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 16px;
}
.add .btn { border-radius: 12px; cursor: pointer; }
.shop-h small { color: var(--muted); font-size: 12px; }
.shop-g .place { margin-top: 0; }
.shop-note { font-size: 12px; color: var(--warn-text); margin-top: 2px; }
.shop-g .actions { margin: 8px 0 4px; }
.call { display: flex; flex-direction: column; gap: 6px; flex: none; }
.tip-list { margin: 0; list-style: none; display: grid; gap: 8px; font-size: 14px; color: var(--muted); }
.tip-list b { color: var(--text); }

/* ============================== 資訊 ============================== */
.info-g + .info-g { margin-top: 12px; }
.info-g h2 { font-size: 16px; margin-bottom: 4px; }
.kv { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 10px; padding: 9px 0; font-size: 15px; line-height: 1.45; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv dd small { display: block; color: var(--muted); font-size: 12px; }
.kv dd a { font-weight: 600; }
.notes textarea {
  width: 100%; min-height: 120px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--bg); color: var(--text);
  font: inherit; font-size: 16px; resize: vertical;
}
.notes small { color: var(--muted); font-size: 12px; }
.howto { margin: 0; padding-left: 18px; font-size: 14px; color: var(--muted); }
.foot { margin-top: 24px; text-align: center; font-size: 12px; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .is-now .dot { animation: none; }
  .progress i { transition: none; }
}

@media (max-width: 360px) {
  .clocks { gap: 6px; font-size: 12px; }
  .brand { font-size: 15px; }
  .fork { grid-template-columns: 1fr; }
  .fork::before, .fork::after { left: 50%; right: auto; width: 0; border: 0; border-left: 2px solid var(--c); border-radius: 0; }
}
