/* =========================================================
   日本旅遊行程規劃 — Design System
   Style: Aurora UI + Glassmorphism  (UI/UX Pro Max #37 Travel)
   Palette: Sky Blue #0EA5E9 + Adventure Orange #EA580C
   Fonts: Outfit (headings) + Noto Sans TC (body / 中文)
   ========================================================= */

:root {
  /* --- 核心配色（WCAG 對比達標） --- */
  --primary: #0EA5E9;
  --primary-dark: #0284C7;
  --primary-deep: #0C4A6E;
  --secondary: #38BDF8;
  --accent: #EA580C;
  --accent-soft: #FB923C;

  --bg: #EFF7FD;
  --fg: #0C4A6E;
  --card: #FFFFFF;
  --muted: #E8F2F8;
  --muted-fg: #5B7186;
  --border: #CDE7F7;
  --danger: #DC2626;
  --success: #16A34A;

  /* --- Glassmorphism tokens --- */
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-bg-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.7);
  --glass-blur: 16px;
  --glass-shadow: 0 10px 40px -12px rgba(12, 74, 110, 0.28);

  /* --- 交通工具色 --- */
  --t-walk: #16A34A;
  --t-train: #2563EB;
  --t-subway: #7C3AED;
  --t-bus: #EA580C;
  --t-car: #0891B2;
  --t-bike: #0D9488;
  --t-plane: #DB2777;
  --t-ferry: #0284C7;

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 26px;
  --shadow-sm: 0 2px 8px rgba(12, 74, 110, 0.10);

  --heading: "Outfit", "Noto Sans TC", system-ui, sans-serif;
  --body: "Noto Sans TC", "Outfit", system-ui, sans-serif;
}

* { box-sizing: border-box; }
/* 確保 hidden 屬性永遠有效（避免被 display:flex/grid 等規則覆蓋） */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--body);
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden; /* 內部各面板自行捲動 */
}

h1, h2, h3 { font-family: var(--heading); font-weight: 700; margin: 0; letter-spacing: -0.01em; }

/* =============== 極光背景 Aurora =============== */
.aurora {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background: linear-gradient(160deg, #E8F6FF 0%, #EFF7FD 45%, #FDF3EC 100%);
}
.aurora__blob {
  position: absolute; border-radius: 50%;
  filter: blur(70px); opacity: 0.55;
  mix-blend-mode: multiply;
  will-change: transform;
}
.aurora__blob--1 {
  width: 46vw; height: 46vw; top: -12vw; left: -8vw;
  background: radial-gradient(circle at 30% 30%, #38BDF8, transparent 70%);
  animation: drift1 22s ease-in-out infinite;
}
.aurora__blob--2 {
  width: 40vw; height: 40vw; bottom: -14vw; right: -6vw;
  background: radial-gradient(circle at 60% 40%, #FB923C, transparent 68%);
  animation: drift2 26s ease-in-out infinite;
}
.aurora__blob--3 {
  width: 34vw; height: 34vw; top: 30%; left: 45%;
  background: radial-gradient(circle at 50% 50%, #A78BFA, transparent 70%);
  animation: drift3 30s ease-in-out infinite;
}
@keyframes drift1 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(6vw,4vw) scale(1.12)} }
@keyframes drift2 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-5vw,-3vw) scale(1.08)} }
@keyframes drift3 { 0%,100%{transform:translate(0,0) scale(1)} 50%{transform:translate(-4vw,3vw) scale(0.92)} }
@media (prefers-reduced-motion: reduce) {
  .aurora__blob { animation: none; }
}

/* =============== Glass 通用 =============== */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
}

/* =============== 頂部列 =============== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 22px; margin: 12px 14px 0; border-radius: var(--radius);
  flex-wrap: wrap;
}
.topbar__brand { display: flex; align-items: center; gap: 14px; }
.topbar__logo { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.15)); }
.topbar__title { font-size: 20px; }
.topbar__sub { margin: 2px 0 0; font-size: 13px; color: var(--muted-fg); }
.syncstatus { display: inline-block; margin-top: 3px; font-size: 11px; font-weight: 600; letter-spacing: .01em; }
.topbar__actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* =============== 按鈕 =============== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--body); font-size: 14px; font-weight: 500;
  padding: 9px 15px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; transition: transform .12s ease, box-shadow .2s ease, background .2s ease;
  white-space: nowrap; color: var(--fg); background: transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn .ico { font-size: 15px; line-height: 1; }
.btn--sm { padding: 6px 11px; font-size: 13px; }
.btn--primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; box-shadow: 0 6px 18px -6px rgba(14,165,233,.6);
}
.btn--primary:hover { box-shadow: 0 10px 24px -6px rgba(14,165,233,.7); }
.btn--ghost { background: rgba(255,255,255,.55); border-color: var(--border); }
.btn--ghost:hover { background: #fff; }
.btn--danger { color: var(--danger); }
.btn--danger.btn--ghost { border-color: rgba(220,38,38,.35); }
.btn--danger.btn--ghost:hover { background: rgba(220,38,38,.08); }
.btn__label { display: inline; }

/* =============== 日期分頁 =============== */
.daybar { margin: 10px 14px 0; border-radius: var(--radius); padding: 8px; }
.daybar__scroll { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: thin; padding: 2px; }
.daytab {
  flex: 0 0 auto; display: flex; flex-direction: column; align-items: center;
  min-width: 88px; padding: 8px 14px; border-radius: 14px; cursor: pointer;
  background: rgba(255,255,255,.5); border: 1px solid var(--border);
  transition: all .18s ease; color: var(--fg);
}
.daytab:hover { background: #fff; transform: translateY(-2px); }
.daytab--active {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-color: transparent; color: #fff; box-shadow: 0 8px 20px -8px rgba(14,165,233,.7);
}
.daytab__day { font-family: var(--heading); font-weight: 700; font-size: 15px; }
.daytab__date { font-size: 11px; opacity: .85; margin-top: 2px; }
.daytab__count { font-size: 10px; margin-top: 3px; opacity: .8; }
.daytab--add {
  min-width: 52px; justify-content: center; font-size: 20px;
  color: var(--muted-fg); border-style: dashed;
}

/* =============== 版面 =============== */
.layout {
  flex: 1; display: grid; grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 14px; padding: 12px 14px; min-height: 0;
}
.panel { border-radius: var(--radius); min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.panel--itinerary { padding: 18px 6px 8px 18px; }
.panel--map { padding: 0; position: relative; }

.panel__head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 12px; padding-right: 12px; margin-bottom: 12px;
}
.panel__title { font-size: 22px; }
.panel__meta { margin: 3px 0 0; font-size: 13px; color: var(--muted-fg); }

/* =============== 時間軸 Timeline =============== */
.timeline { overflow-y: auto; padding-right: 12px; flex: 1; scrollbar-width: thin; }
.tl-item { position: relative; padding-left: 40px; }
.tl-item__dot {
  position: absolute; left: 6px; top: 20px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary); z-index: 2;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; color: var(--primary);
}
.tl-item__line {
  position: absolute; left: 15px; top: 30px; bottom: -6px; width: 2px;
  background: linear-gradient(var(--border), var(--border)); z-index: 1;
}
.tl-item:last-child .tl-item__line { display: none; }

.spot-card {
  background: var(--glass-bg-strong); border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform .14s ease, box-shadow .2s ease; position: relative;
}
.spot-card:hover { transform: translateX(3px); box-shadow: 0 8px 22px -10px rgba(12,74,110,.4); }
.spot-card__top { display: flex; align-items: center; gap: 8px; }
.spot-card__cat { font-size: 18px; }
.spot-card__name { font-family: var(--heading); font-weight: 600; font-size: 16px; flex: 1; }
.spot-card__time {
  font-size: 12px; font-weight: 600; color: var(--primary-dark);
  background: var(--muted); padding: 3px 9px; border-radius: 999px; white-space: nowrap;
}
.spot-card__meta { display: flex; gap: 12px; margin-top: 7px; font-size: 12px; color: var(--muted-fg); flex-wrap: wrap; }
.spot-card__meta span { display: inline-flex; align-items: center; gap: 4px; }
.spot-card__notes { margin-top: 8px; font-size: 12.5px; color: var(--fg); background: var(--muted); padding: 7px 10px; border-radius: 8px; opacity: .9; }
.spot-card__actions { position: absolute; top: 10px; right: 10px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; }
.spot-card:hover .spot-card__actions { opacity: 1; }
.icobtn {
  width: 26px; height: 26px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(255,255,255,.8); display: grid; place-items: center; font-size: 13px; color: var(--muted-fg);
}
.icobtn:hover { background: #fff; color: var(--primary); }
.icobtn:disabled { opacity: .3; cursor: not-allowed; }

/* 交通連接段 */
.tl-transport {
  position: relative; padding-left: 40px; margin: -2px 0 8px;
}
.tl-transport__pill {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 500;
  padding: 4px 12px; border-radius: 999px; color: #fff;
  box-shadow: 0 3px 10px -4px rgba(0,0,0,.35);
}
.tl-transport__badge {
  position: absolute; left: 8px; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; border: 2px dashed var(--border); z-index: 2;
}

/* =============== 空狀態 =============== */
.empty { text-align: center; padding: 40px 24px; color: var(--muted-fg); margin: auto 12px; }
.empty__art { font-size: 54px; margin-bottom: 10px; }
.empty h3 { color: var(--fg); margin-bottom: 6px; }
.empty p { font-size: 14px; max-width: 320px; margin: 0 auto 18px; line-height: 1.6; }

/* =============== 地圖 =============== */
#map { position: absolute; inset: 0; z-index: 1; border-radius: var(--radius); }
.leaflet-container { font-family: var(--body); background: #dce9f2; border-radius: var(--radius); }

.mapsearch {
  position: absolute; top: 14px; left: 14px; right: 14px; z-index: 500;
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px;
  background: var(--glass-bg-strong);
}
.mapsearch .ico { font-size: 15px; opacity: .7; }
.mapsearch input {
  flex: 1; border: none; background: transparent; font-family: var(--body);
  font-size: 14px; color: var(--fg); outline: none;
}
.mapsearch__clear { border: none; background: transparent; cursor: pointer; color: var(--muted-fg); font-size: 14px; }
.mapsearch__results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; list-style: none; margin: 0; padding: 6px;
  background: var(--glass-bg-strong); backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border); border-radius: var(--radius-sm);
  box-shadow: var(--glass-shadow); max-height: 320px; overflow-y: auto;
}
.mapsearch__results li {
  padding: 9px 12px; border-radius: 9px; cursor: pointer; font-size: 13.5px; line-height: 1.4;
  display: flex; gap: 8px; align-items: flex-start;
}
.mapsearch__results li:hover { background: var(--muted); }
.mapsearch__results li .r-name { font-weight: 600; }
.mapsearch__results li .r-addr { color: var(--muted-fg); font-size: 12px; }
.mapsearch__results .r-empty { color: var(--muted-fg); cursor: default; }

.maphint {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 500;
  padding: 7px 16px; border-radius: 999px; font-size: 12.5px; color: var(--fg);
  background: var(--glass-bg-strong); white-space: nowrap;
}

/* Leaflet 自訂編號標記 */
.pin {
  width: 30px; height: 30px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.35);
  display: grid; place-items: center;
}
.pin span { transform: rotate(45deg); color: #fff; font-weight: 700; font-size: 13px; font-family: var(--heading); }
.pin--temp { background: linear-gradient(135deg, var(--accent), var(--accent-soft)); }

/* =============== Modal =============== */
.modal { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(12,74,110,.35); backdrop-filter: blur(3px); }
.modal__card {
  position: relative; width: min(560px, 100%); max-height: 90vh; overflow-y: auto;
  border-radius: var(--radius-lg); background: var(--glass-bg-strong); padding: 22px 24px;
  animation: pop .22s cubic-bezier(.16,1,.3,1);
}
@keyframes pop { from { opacity: 0; transform: translateY(12px) scale(.97);} to { opacity:1; transform: none;} }
.modal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal__head h3 { font-size: 19px; }
.modal__close { border: none; background: var(--muted); width: 32px; height: 32px; border-radius: 50%; cursor: pointer; font-size: 14px; color: var(--muted-fg); }
.modal__close:hover { background: var(--border); }
.modal__foot { display: flex; align-items: center; gap: 8px; margin-top: 8px; grid-column: 1 / -1; }
.spacer { flex: 1; }

/* =============== 表單 =============== */
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field--full { grid-column: 1 / -1; }
.field__label { font-size: 13px; font-weight: 500; color: var(--muted-fg); }
.field__label b { color: var(--accent); }
.field input, .field select, .field textarea {
  font-family: var(--body); font-size: 14px; color: var(--fg);
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: rgba(255,255,255,.7);
  outline: none; transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.field textarea { resize: vertical; }
.dur { display: flex; align-items: center; gap: 6px; }
.dur input { width: 72px; }
.dur span { font-size: 13px; color: var(--muted-fg); }

/* 交通工具選擇 */
.transport { display: flex; flex-wrap: wrap; gap: 6px; }
.tbtn {
  display: inline-flex; align-items: center; gap: 5px; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: rgba(255,255,255,.7); cursor: pointer;
  font-family: var(--body); font-size: 13px; color: var(--fg); transition: all .15s;
}
.tbtn:hover { border-color: var(--primary); }
.tbtn--active { color: #fff; border-color: transparent; }
.tbtn .ico { font-size: 15px; }

.form__note { grid-column: 1/-1; font-size: 13px; color: var(--muted-fg); margin: 0; }

/* =============== Toast =============== */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--primary-deep); color: #fff; padding: 12px 22px; border-radius: 999px;
  font-size: 14px; z-index: 2000; opacity: 0; transition: all .3s cubic-bezier(.16,1,.3,1);
  box-shadow: 0 10px 30px -8px rgba(12,74,110,.6);
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============== 便利貼備忘錄 =============== */
.btn__badge {
  display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700;
  font-family: var(--heading); margin-left: 2px;
}

.notes-board { position: fixed; inset: 0; z-index: 1100; display: flex; }
.notes-board[hidden] { display: none; }
.notes-board__backdrop { position: absolute; inset: 0; background: rgba(12,74,110,.4); backdrop-filter: blur(4px); }
.notes-board__panel {
  position: relative; margin-left: auto; width: min(720px, 100%); height: 100%;
  display: flex; flex-direction: column; padding: 14px;
  background: linear-gradient(160deg, rgba(232,246,255,.85), rgba(253,243,236,.85));
  backdrop-filter: blur(var(--glass-blur)); box-shadow: -20px 0 60px -20px rgba(12,74,110,.5);
  animation: slideIn .32s cubic-bezier(.16,1,.3,1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.notes-board__head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius); margin-bottom: 14px;
}
.notes-board__head h3 { font-size: 19px; }
.notes-board__sub { margin: 3px 0 0; font-size: 12.5px; color: var(--muted-fg); }
.notes-board__headact { display: flex; align-items: center; gap: 8px; }

.notes-grid {
  flex: 1; overflow-y: auto; display: grid; gap: 16px; padding: 6px 4px 20px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); align-content: start;
  scrollbar-width: thin;
}

/* 單張便利貼 */
.note {
  --note-bg: #FEF3C7; --note-edge: #FDE68A;
  background: var(--note-bg); border-radius: 4px 4px 10px 10px;
  padding: 30px 14px 14px; position: relative;
  box-shadow: 0 8px 20px -8px rgba(12,74,110,.35), inset 0 -3px 0 rgba(0,0,0,.04);
  transition: transform .16s ease, box-shadow .2s ease;
  min-height: 130px; display: flex; flex-direction: column;
}
.note:nth-child(3n)   { transform: rotate(-1.2deg); }
.note:nth-child(3n+1) { transform: rotate(0.9deg); }
.note:nth-child(3n+2) { transform: rotate(-0.4deg); }
.note:hover { transform: rotate(0) translateY(-3px); box-shadow: 0 16px 30px -10px rgba(12,74,110,.45); z-index: 2; }
/* 膠帶效果 */
.note::before {
  content: ''; position: absolute; top: -9px; left: 50%; transform: translateX(-50%) rotate(-2deg);
  width: 74px; height: 20px; background: rgba(255,255,255,.5);
  border: 1px solid rgba(255,255,255,.35); border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.note__title {
  font-family: var(--heading); font-weight: 700; font-size: 16px; color: #4a3a12;
  border: none; background: transparent; outline: none; width: 100%; margin-bottom: 8px;
  border-bottom: 1px dashed rgba(0,0,0,.12); padding-bottom: 6px;
}
.note__title::placeholder { color: rgba(74,58,18,.4); }

.note__items { list-style: none; margin: 0; padding: 0; flex: 1; }
.note__item { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.note__check {
  appearance: none; -webkit-appearance: none; width: 17px; height: 17px; flex: 0 0 auto;
  border: 2px solid rgba(0,0,0,.3); border-radius: 5px; cursor: pointer; position: relative; background: rgba(255,255,255,.4);
}
.note__check:checked { background: var(--success); border-color: var(--success); }
.note__check:checked::after { content: '✓'; position: absolute; inset: 0; color: #fff; font-size: 12px; display: grid; place-items: center; }
.note__itemtext {
  flex: 1; border: none; background: transparent; outline: none; font-family: var(--body);
  font-size: 14px; color: #3f3f2e;
}
.note__item--done .note__itemtext { text-decoration: line-through; opacity: .5; }
.note__itemdel { border: none; background: transparent; cursor: pointer; color: rgba(0,0,0,.3); font-size: 13px; opacity: 0; transition: opacity .15s; }
.note__item:hover .note__itemdel { opacity: 1; }
.note__itemdel:hover { color: var(--danger); }

.note__additem {
  display: flex; align-items: center; gap: 8px; padding: 5px 0; margin-top: 2px;
  border-top: 1px dashed rgba(0,0,0,.1);
}
.note__additem .plus { color: rgba(0,0,0,.35); font-size: 16px; }
.note__additem input {
  flex: 1; border: none; background: transparent; outline: none; font-family: var(--body); font-size: 13.5px; color: #3f3f2e;
}
.note__additem input::placeholder { color: rgba(0,0,0,.32); }

.note__foot { display: flex; align-items: center; gap: 6px; margin-top: 10px; }
.note__colors { display: flex; gap: 5px; flex: 1; }
.note__swatch { width: 16px; height: 16px; border-radius: 50%; cursor: pointer; border: 2px solid rgba(255,255,255,.7); box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.note__swatch--active { outline: 2px solid rgba(0,0,0,.35); outline-offset: 1px; }
.note__progress { font-size: 11px; color: rgba(0,0,0,.45); font-weight: 600; }
.note__del { border: none; background: transparent; cursor: pointer; color: rgba(0,0,0,.35); font-size: 14px; }
.note__del:hover { color: var(--danger); }

.notes-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted-fg); padding: 24px; }
.notes-empty__art { font-size: 54px; margin-bottom: 10px; }
.notes-empty h3 { color: var(--fg); margin-bottom: 6px; }
.notes-empty p { font-size: 14px; max-width: 320px; margin: 0 auto 18px; line-height: 1.6; }

/* =============== 密碼閘門 =============== */
.gate {
  position: fixed; inset: 0; z-index: 999;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(239, 247, 253, .82);
  backdrop-filter: blur(10px);
}
.gate__card {
  max-width: 420px; width: 100%;
  padding: 34px 30px; text-align: center;
  border-radius: var(--radius-lg);
}
.gate__art { font-size: 52px; margin-bottom: 12px; }
.gate__card h2 { font-family: var(--heading); margin: 0 0 10px; color: var(--fg); }
.gate__card p { margin: 0 0 8px; font-size: 14px; line-height: 1.7; color: var(--muted-fg); }
.gate__hint { font-size: 12.5px !important; opacity: .8; margin-top: 14px !important; }
.gate__hint code {
  background: var(--muted); padding: 2px 6px; border-radius: 6px;
  font-size: 12px; word-break: break-all;
}
.gate__form { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.gate__form input {
  font-family: var(--body); font-size: 15px; color: var(--fg); text-align: center;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: rgba(255,255,255,.75);
  outline: none; transition: border .15s, box-shadow .15s;
}
.gate__form input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(14,165,233,.15);
}
.gate__form .btn { justify-content: center; padding: 12px; }
.gate__err {
  margin: 12px 0 0 !important; font-size: 13px !important;
  color: var(--danger) !important; font-weight: 500;
}

/* =============== 響應式：平板 (≤900px) =============== */
@media (max-width: 900px) {
  body {
    overflow: auto;
    /* 瀏海 / 圓角螢幕安全區（橫向時左右也留白） */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  }
  /* 改為單純的區塊流：兩面板上下排列、隨內容自然撐高，由整頁捲動。
     （桌機用 grid + 面板內獨立捲動；但在自動高度下 grid 列高不會跟著溢出內容成長，
       且 timeline 的 flex:1 會被壓成 0 高度，故手機改用 block flow 最穩） */
  .layout { display: block; height: auto; padding: 12px 14px; }
  .panel { overflow: visible; }
  .panel--itinerary { max-height: none; margin-bottom: 12px; }
  .panel--itinerary .timeline { flex: none; overflow: visible; padding-right: 4px; }
  /* 地圖仍需固定高度 + 裁切圓角；用 dvh 避免行動瀏覽器網址列造成的高度跳動 */
  .panel--map { height: 58vh; height: 58dvh; min-height: 340px; overflow: hidden; }
  .form { grid-template-columns: 1fr; }
  .notes-board__panel { width: 100%; }
}

/* =============== 響應式：手機 (≤560px) =============== */
@media (max-width: 560px) {
  /* 降低玻璃 / 光暈的模糊成本，手機捲動更順 */
  :root { --glass-blur: 10px; }
  .aurora__blob { filter: blur(48px); }

  /* 頂部列縮排 */
  .topbar { padding: 10px 14px; margin: 8px 8px 0; gap: 10px; }
  .topbar__logo { font-size: 24px; }
  .topbar__title { font-size: 17px; }
  .topbar__sub { font-size: 11px; }
  /* 頂部功能鈕：品牌獨立一行、按鈕整齊分組於整寬第二區，保留文字標籤（純 icon 難辨識）。
     用 6 欄 grid：主要功能（備忘錄／行程設定）各佔半排，工具（匯出／匯入／列印）各佔三分之一排。
     以按鈕 id 對位，避免被隱藏的 <input id=importFile> 干擾 nth-child 序號 */
  .topbar__brand { flex: 1 1 100%; }
  .topbar__actions {
    width: 100%; display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px;
  }
  .topbar__actions .btn {
    justify-content: center; padding: 9px 8px; font-size: 12.5px;
  }
  .topbar__actions .btn .btn__label { display: inline; }   /* 確保文字顯示 */
  .topbar__actions .btn .ico { font-size: 16px; }
  #btnNotes, #btnTripSettings { grid-column: span 3; }     /* 各半排 */

  /* 日期列 / 版面縮排 */
  .daybar { margin: 8px 8px 0; }
  .daytab { min-width: 76px; padding: 7px 10px; }
  .layout { padding: 8px; gap: 10px; }
  .panel--itinerary { padding: 14px 4px 6px 12px; }
  .panel__title { font-size: 19px; }

  /* 地圖提示允許換行、不再撐出畫面 */
  .maphint { font-size: 11.5px; padding: 6px 12px; white-space: normal; text-align: center; max-width: 84%; }

  /* 便利貼單欄 */
  .notes-grid { grid-template-columns: 1fr; }
  .notes-board__panel { padding: 10px; }

  /* 停留 / 路程時間欄位在窄螢幕允許換行 */
  .dur { flex-wrap: wrap; }

  /* 防 iOS 聚焦時自動放大畫面：輸入字級 ≥16px */
  .field input, .field select, .field textarea,
  .mapsearch input, .dur input,
  .note__title, .note__itemtext, .note__additem input {
    font-size: 16px;
  }

  /* Modal 改為由底部滑出的 bottom sheet */
  .modal { place-items: end center; padding: 0; }
  .modal__card {
    width: 100%; max-height: 92vh; max-height: 92dvh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
    animation: sheetUp .28s cubic-bezier(.16,1,.3,1);
  }
  /* 頂部小握把，暗示可下滑關閉 */
  .modal__card::before {
    content: ''; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 999px; background: var(--border);
  }

  /* Toast 避開底部安全區 */
  .toast { bottom: calc(20px + env(safe-area-inset-bottom)); }
}
@keyframes sheetUp { from { opacity: .6; transform: translateY(100%); } to { opacity: 1; transform: none; } }

/* =============== 觸控裝置：常顯操作鈕、加大觸控目標 =============== */
@media (hover: none) {
  /* 桌機是 hover 才顯示卡片動作鈕；觸控裝置沒有 hover，改為常駐並移到卡片底部一列 */
  .spot-card { display: flex; flex-direction: column; }
  .spot-card__actions {
    opacity: 1; position: static; order: 5;
    justify-content: flex-end; gap: 6px;
    margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border);
  }
  .icobtn { width: 34px; height: 34px; font-size: 15px; }   /* 加大到易點的觸控目標 */
  .note__itemdel { opacity: 1; }                              /* 便利貼刪除鈕常駐 */
  .spot-card:hover { transform: none; }                       /* 避免點擊後 hover 狀態卡住 */
}

/* =============== 列印 =============== */
@media print {
  .aurora, .topbar__actions, .panel--map, .maphint, .mapsearch, .btn, .spot-card__actions, .daytab--add { display: none !important; }
  body, html { overflow: visible; height: auto; background: #fff; }
  .layout { display: block; padding: 0; }
  .panel { box-shadow: none; border: none; background: #fff; }
  .glass { backdrop-filter: none; background: #fff; box-shadow: none; }
  .daybar { display: none; }
}
