:root {
  color-scheme: light dark;
  --bg: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #ebe7de;
  --text: #1c211f;
  --muted: #646b67;
  --line: #e0dbd0;
  --accent: #1e6b58;
  --accent-hover: #185847;
  --accent-ink: #ffffff;
  --accent-soft: #dcebe4;
  --warn: #8a4a12;
  --warn-soft: #f7ead9;
  --danger: #a3372f;
  --shadow: 0 1px 2px rgb(30 25 15 / .06), 0 6px 20px rgb(30 25 15 / .07);
  --radius: 14px;
  --top-h: 56px;
  --dock-h: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111412;
    --surface: #1a1e1c;
    --surface-2: #242a27;
    --text: #ebeae5;
    --muted: #9aa19d;
    --line: #2d3330;
    --accent: #63b9a0;
    --accent-hover: #78c7af;
    --accent-ink: #0b1a15;
    --accent-soft: #1d362e;
    --warn: #e7ad73;
    --warn-soft: #362a1c;
    --danger: #e98379;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--font);
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
}
body.noscroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; }
code { font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
.ic { width: 22px; height: 22px; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
[hidden] { display: none !important; }

/* ---------- 按鈕 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 16px; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
@media (hover: hover) { .btn.primary:hover { background: var(--accent-hover); } .btn:not(.primary):hover { background: var(--surface-2); } }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.big { min-height: 54px; font-size: 17px; border-radius: 14px; }
.btn.block { display: flex; width: 100%; }
.btn .ic { width: 20px; height: 20px; }
.btn:focus-visible, .chip:focus-visible, .tile:focus-visible, .icon-btn:focus-visible, .trip-card:focus-visible, .avatar:focus-visible, .up-summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.icon-btn {
  width: 44px; height: 44px; display: inline-grid; place-items: center;
  border: 0; background: transparent; border-radius: 12px; cursor: pointer; flex: none;
}
@media (hover: hover) { a.icon-btn:hover, button.icon-btn:hover { background: var(--surface-2); } }

/* ---------- 單頁置中（登入等） ---------- */
.solo {
  min-height: 100dvh; max-width: 420px; margin: 0 auto;
  padding: 48px 24px calc(48px + var(--safe-b));
  display: flex; flex-direction: column; justify-content: center; gap: 16px; text-align: center;
}
.solo h1 { font-size: 26px; line-height: 1.3; }
.solo .lead { color: var(--muted); font-size: 17px; }
.solo .fine { color: var(--muted); font-size: 13px; }
.solo .notice { background: var(--warn-soft); color: var(--warn); border-radius: 12px; padding: 10px 14px; font-size: 15px; }
.solo .btn { margin-top: 4px; }
.solo-mark {
  width: 72px; height: 72px; margin: 0 auto 8px; border-radius: 20px;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink);
}
.solo-mark .ic { width: 38px; height: 38px; }
.solo-mark.warn { background: var(--warn-soft); color: var(--warn); }

.center-load { min-height: 60dvh; display: grid; place-items: center; }
.spinner {
  width: 32px; height: 32px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 頂部列 ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  height: calc(var(--top-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 8px 0 16px;
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(14px); backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid var(--line);
}
.top:has(> a.icon-btn) { padding-left: 4px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 17px; flex: 1; min-width: 0; color: var(--text); }
.brand > .ic { color: var(--accent); }
.tag { font-size: 12px; font-weight: 600; background: var(--accent-soft); color: var(--accent); padding: 2px 8px; border-radius: 99px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 16px; margin-right: 4px;
}
.top-title { flex: 1; min-width: 0; text-align: center; }
.top-title h1 { font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title p { font-size: 13px; color: var(--muted); }

/* ---------- 頁面 ---------- */
.page {
  max-width: 1100px; margin: 0 auto;
  padding: 20px 16px calc(32px + var(--dock-h) + var(--safe-b));
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.page-head h1 { font-size: 24px; }

.banner {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 16px;
}
.banner > div { flex: 1; min-width: 0; }
.banner strong { display: block; font-size: 15px; }
.banner p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.banner.warn { background: var(--warn-soft); border-color: transparent; }
.banner.warn strong { color: var(--warn); }
.banner-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.banner > .ic { color: var(--warn); }

.empty { text-align: center; padding: 64px 16px; color: var(--text); }
.empty .ic { width: 44px; height: 44px; color: var(--muted); margin-bottom: 12px; }
.empty p:first-of-type { font-size: 17px; font-weight: 600; }

/* ---------- 旅行卡片 ---------- */
.trips { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .trips { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .trips { grid-template-columns: repeat(3, 1fr); } }
.trip-card {
  display: block; background: var(--surface); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); border: 1px solid var(--line);
  transition: transform .15s;
}
.trip-card:active { transform: scale(.99); }
.cover { aspect-ratio: 16 / 10; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .ph .ic, .tile .ph .ic { width: 30px; height: 30px; color: var(--muted); opacity: .6; }
.trip-meta { padding: 12px 16px 14px; }
.trip-meta h2 { font-size: 17px; line-height: 1.35; }
.trip-meta p { font-size: 14px; color: var(--muted); margin-top: 2px; }
.trip-card.sk .trip-meta i { display: block; height: 14px; border-radius: 6px; background: var(--surface-2); width: 60%; }
.trip-card.sk .trip-meta i + i { width: 35%; margin-top: 8px; }
.sk .cover, .grid.sk .tile { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }

/* ---------- 照片牆 ---------- */
.trip-page { padding-top: 12px; padding-left: 0; padding-right: 0; }
.trip-page > .banner { margin-left: 16px; margin-right: 16px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 16px 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 36px; padding: 0 14px; border-radius: 99px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); font-size: 14px; font-weight: 600;
}
.chip[aria-selected="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.day {
  position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); z-index: 5;
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 14px 16px 8px; background: var(--bg);
}
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px; }
@media (min-width: 600px) { .grid { grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 0 16px; } }
@media (min-width: 900px) { .grid { grid-template-columns: repeat(6, 1fr); } }
.tile {
  position: relative; aspect-ratio: 1; border: 0; padding: 0; margin: 0; cursor: pointer;
  background: var(--surface-2); overflow: hidden; display: grid; place-items: center;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
@media (min-width: 600px) { .tile { border-radius: 6px; } }
.vbadge {
  position: absolute; right: 6px; bottom: 6px;
  display: inline-flex; align-items: center; gap: 2px;
  background: rgb(0 0 0 / .55); color: #fff; font-size: 12px; font-weight: 600;
  padding: 2px 7px 2px 4px; border-radius: 99px;
}
.vbadge .ic { width: 14px; height: 14px; }

/* ---------- 底部浮動區 ---------- */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 0 12px calc(12px + var(--safe-b));
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none;
  max-width: 640px; margin: 0 auto;
}
#dock > * { pointer-events: auto; }
#dock-action:empty { display: none; }
#dock-action .btn { box-shadow: 0 6px 20px rgb(20 60 50 / .28); }

.upbar {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); overflow: hidden;
}
.up-progress { height: 4px; background: var(--surface-2); }
.up-progress i { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.upbar.is-wait .up-progress i { background: var(--warn); }
.upbar.is-error .up-progress i { background: var(--danger); }
.up-row { display: flex; align-items: center; gap: 4px; padding: 4px 8px 4px 4px; }
.up-summary {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 10px; border: 0; background: transparent; cursor: pointer;
  font-size: 15px; font-weight: 600; text-align: left;
}
.up-summary span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-summary .ic { width: 20px; height: 20px; }
.upbar.is-done .up-summary .ic:first-child { color: var(--accent); }
.upbar.is-wait .up-summary .ic:first-child { color: var(--warn); }
.upbar.is-error .up-summary .ic:first-child { color: var(--danger); }
.up-list { list-style: none; margin: 0; padding: 0 0 4px; max-height: min(46dvh, 360px); overflow-y: auto; border-top: 1px solid var(--line); }
.up-item { position: relative; display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.up-name { flex: 1; min-width: 0; }
.up-item .icon-btn.sm { width: 36px; height: 36px; margin-right: -8px; color: var(--muted); }
.up-item .icon-btn.sm .ic { width: 18px; height: 18px; }
.up-name span { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.up-name small { display: block; font-size: 12px; color: var(--muted); }
.up-item.error small { color: var(--danger); }
.up-item.done small { color: var(--accent); }
.up-mini { position: absolute; left: 14px; right: 14px; bottom: 0; height: 2px; }
.up-mini i { display: block; height: 100%; background: var(--accent); opacity: .7; }
.up-item.done .up-mini, .up-item.queued:not(:has(small)) .up-mini { display: none; }
.up-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 14px 12px; }
.up-foot .note { flex-basis: 100%; }

.note { font-size: 13px; color: var(--muted); }
.note.warn { color: var(--warn); }

/* ---------- 對話框 ---------- */
dialog {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  width: min(460px, calc(100vw - 24px)); max-height: calc(100dvh - 32px);
  border-radius: 20px; box-shadow: 0 20px 60px rgb(0 0 0 / .25);
}
dialog::backdrop { background: rgb(15 18 16 / .45); }
@media (max-width: 560px) {
  dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; }
}
.dlg-body { padding: 22px 20px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 14px; }
.dlg-body h2 { font-size: 20px; line-height: 1.35; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dlg-actions .btn { min-width: 96px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.field input {
  font: inherit; font-size: 17px; font-weight: 400; color: var(--text);
  min-height: 48px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg);
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.err { color: var(--danger); font-size: 14px; }

.choices { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.choices legend { font-size: 14px; font-weight: 600; margin-bottom: 8px; padding: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice-box {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--bg);
}
.choice-box > span { display: flex; flex-direction: column; }
.choice-box b { font-size: 16px; }
.choice-box small { font-size: 13px; color: var(--muted); }
.choice-box .ic { color: var(--muted); }
.choice input:checked + .choice-box { border-color: var(--accent); background: var(--accent-soft); }
.choice input:checked + .choice-box .ic { color: var(--accent); }
.choice input:focus-visible + .choice-box { outline: 2px solid var(--accent); outline-offset: 2px; }

.howto { background: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.howto h3 { font-size: 15px; }

/* ---------- 看大圖 ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  display: grid; grid-template-rows: auto 1fr auto;
}
.v-top {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 4px 4px;
}
.v-top .icon-btn { color: #fff; }
.v-count { font-size: 15px; font-variant-numeric: tabular-nums; opacity: .85; }
.v-stage { position: relative; min-height: 0; display: grid; place-items: center; }
.v-stage img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.v-stage img.noimg { width: 60%; aspect-ratio: 1; background: #1c1c1c; border-radius: 12px; }
.v-play {
  position: absolute; display: inline-flex; align-items: center; gap: 8px;
  background: rgb(255 255 255 / .92); color: #111; font-weight: 700;
  padding: 12px 20px 12px 14px; border-radius: 99px;
}
.v-play .ic { width: 26px; height: 26px; }
.v-nav {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgb(255 255 255 / .14); color: #fff; display: none; place-items: center;
}
.v-nav.prev { left: 12px; }
.v-nav.next { right: 12px; }
@media (hover: hover) and (pointer: fine) { .v-nav { display: grid; } }
.v-info { padding: 12px 16px calc(14px + var(--safe-b)); display: flex; flex-direction: column; gap: 2px; }
.v-info b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.v-info span { font-size: 13px; opacity: .75; }

/* ---------- 提示 ---------- */
.toast {
  position: fixed; left: 50%; z-index: 60;
  bottom: calc(24px + var(--dock-h) + var(--safe-b));
  transform: translate(-50%, 16px); opacity: 0; pointer-events: none;
  max-width: calc(100vw - 32px); width: max-content;
  background: var(--text); color: var(--bg); font-size: 15px;
  padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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