/* ── Reset & base ───────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
  background: #fafaf9;
  color: #1c1917;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
button, a { cursor: pointer; text-decoration: none; }
img { display: block; }
[hidden] { display: none !important; }

/* ── CSS vars ────────────────────────────────────────────────────────────────── */
:root {
  --orange: #f97316;
  --orange-dark: #ea580c;
  --orange-light: #fff7ed;
  --orange-border: #fed7aa;
  --bg: #fafaf9;
  --surface: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --text-sub: #78716c;
  --text-muted: #a8a29e;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --header-h: 56px;
  --nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--orange);
  color: #fff;
  border: none;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 600;
  padding: 14px 24px;
  transition: background 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn-primary:hover:not(:disabled) { background: var(--orange-dark); }
.btn-primary:active:not(:disabled) { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-large { width: 100%; font-size: 16px; padding: 16px; border-radius: 16px; }

.btn-ghost {
  flex: 1;
  background: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-sub);
  -webkit-tap-highlight-color: transparent;
}
.btn-danger {
  flex: 1;
  background: var(--danger);
  border: none;
  border-radius: 12px;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  -webkit-tap-highlight-color: transparent;
}
.btn-danger:active { opacity: 0.85; }

/* ── Auth screen ─────────────────────────────────────────────────────────────── */
.auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 38px;
  padding: 60px 28px calc(40px + var(--safe-bottom));
  background: #f9f7ef;
}
.auth-visual {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.auth-logo-wrap { margin-bottom: 8px; }
.auth-logo-icon { width: 80px; height: 80px; border-radius: 24px; box-shadow: 0 8px 24px rgba(249,115,22,0.3); }
.auth-app-name { font-size: 32px; font-weight: 800; color: var(--text); letter-spacing: -0.5px; }
.auth-tagline { font-size: 16px; font-weight: 650; color: #245544; }
.auth-desc { font-size: 14px; color: var(--text-sub); line-height: 1.6; max-width: 240px; }
.auth-cta { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 12px; }
.auth-cta .btn-primary { background: #245544; }
.auth-cta .btn-primary:hover:not(:disabled) { background: #30644f; }
.auth-note { text-align: center; font-size: 12px; color: var(--text-muted); }
.auth-form-page { gap: 16px; padding-inline: 12px; }
#auth-form { max-width: 100%; }

/* ── App layout ──────────────────────────────────────────────────────────────── */
#auth-signed-in {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(250,250,249,0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-brand { display: flex; align-items: center; gap: 8px; }
.header-emoji { font-size: 22px; }
.header-name { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.header-user-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  overflow: hidden;
  background: var(--border);
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s;
}
.header-user-btn:hover { border-color: var(--orange); }
.user-avatar { width: 100%; height: 100%; object-fit: cover; }

.header-actions { display: flex; align-items: center; gap: 10px; }
.header-lang-btn {
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}
.header-lang-btn:hover { border-color: var(--orange); color: var(--orange); }

/* ── Main ───────────────────────────────────────────────────────────────────── */
.app-main { flex: 1; position: relative; overflow: hidden; }
.page {
  display: none;
  position: absolute;
  inset: 0;
}
.page.active { display: block; }
.page-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 20px 16px calc(var(--nav-h) + 16px + var(--safe-bottom));
}

/* ── Loading state ───────────────────────────────────────────────────────────── */
.loading-state { padding: 4px 0; }

/* ── Empty state ─────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: calc(100dvh - var(--header-h) - var(--nav-h) - 40px);
  text-align: center;
  padding: 24px;
}
.empty-art { margin-bottom: 4px; }
.empty-title { font-size: 20px; font-weight: 700; color: var(--text); }
.empty-body { font-size: 14px; color: var(--text-sub); line-height: 1.6; }

/* ── Restaurant list ─────────────────────────────────────────────────────────── */
.restaurant-list { display: flex; flex-direction: column; gap: 12px; }

.restaurant-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.restaurant-card-emoji {
  font-size: 28px;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--orange-light);
  border-radius: 12px;
}
.restaurant-card-body { flex: 1; min-width: 0; }
.restaurant-card-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.restaurant-card-note {
  font-size: 13px;
  color: var(--text-sub);
  margin-top: 3px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.restaurant-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.source-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}
.source-badge.personal {
  background: var(--orange-light);
  color: var(--orange-dark);
}
.source-badge.friend {
  background: #f0fdf4;
  color: #15803d;
}
.source-badge.google {
  background: #eff6ff;
  color: #1d4ed8;
}
.distance-pill {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.tag-pill {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f5f5f4;
  color: var(--text-sub);
}
.restaurant-card-del {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: 6px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, background 0.15s;
  opacity: 0;
}
.restaurant-card:hover .restaurant-card-del,
.restaurant-card:focus-within .restaurant-card-del { opacity: 1; }
.restaurant-card-del:hover { color: var(--danger); background: var(--danger-light); }

/* ── 附近搜尋工具（定位／地址／語音）─────────────────────────────────────────── */
.nearby-tools { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.nearby-address-row { display: flex; gap: 8px; }
.nearby-address-row .field-input { flex: 1; }
.mic-btn {
  flex: none;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.mic-btn.listening { background: var(--orange-light); border-color: var(--orange); animation: micPulse 1s infinite; }
@keyframes micPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ── 附近餐廳（Google 備援）───────────────────────────────────────────────────── */
.nearby-section { margin-top: 24px; }
.nearby-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.nearby-title { font-size: 15px; font-weight: 700; color: var(--text); }

/* ── FAB ────────────────────────────────────────────────────────────────────── */
.fab {
  position: absolute;
  right: 20px;
  bottom: calc(var(--nav-h) + 20px + var(--safe-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(249,115,22,0.45);
  z-index: 90;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, transform 0.15s, box-shadow 0.15s;
}
.fab:hover { background: var(--orange-dark); box-shadow: 0 6px 20px rgba(249,115,22,0.5); }
.fab:active { transform: scale(0.93); }

/* ── Bottom Sheet ────────────────────────────────────────────────────────────── */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bottom-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 210;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 12px 20px calc(28px + var(--safe-bottom));
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: slideUp 0.25s cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 20px;
}
.sheet-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}
.sheet-subtitle {
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.6;
  margin-bottom: 16px;
}
.sheet-step { display: flex; flex-direction: column; gap: 12px; }

/* ── Input step ──────────────────────────────────────────────────────────────── */
.raw-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  resize: none;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.6;
}
.raw-textarea:focus { border-color: var(--orange); }
.char-count { font-size: 12px; color: var(--text-muted); text-align: right; margin-top: -8px; }
.input-error {
  font-size: 13px;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: 10px;
  padding: 10px 14px;
}

/* ── Confirm step ────────────────────────────────────────────────────────────── */
.confirm-header { display: flex; flex-direction: column; gap: 4px; }
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-size: 14px;
  color: var(--orange);
  font-weight: 600;
  padding: 0;
  margin-bottom: 4px;
  -webkit-tap-highlight-color: transparent;
}
.confirm-fields { display: flex; flex-direction: column; gap: 4px; }
.field-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 12px;
  margin-bottom: 2px;
}
.field-input, .field-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color 0.15s;
}
.field-input:focus, .field-textarea:focus { border-color: var(--orange); }
.field-textarea { resize: none; line-height: 1.6; }

#sheet-step-confirm .field-input,
#sheet-step-confirm .field-textarea { font-size: 16px; }
.capture-header { display: flex; align-items: center; justify-content: space-between; }
.capture-header .sheet-title { margin: 0; }
.capture-close {
  min-width: 40px;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--bg);
  color: var(--text);
  font-size: 24px;
  line-height: 1;
}
.capture-location { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; }
.capture-location .back-btn { margin: 0; min-height: 32px; }
.capture-location .back-btn:disabled { opacity: 0.55; }
#confirm-location-title { color: var(--text-sub); font-size: 13px; }
.capture-types { border: 0; padding: 0; min-width: 0; }
.capture-types .tag-toggle,
#confirm-memory-prompts .tag-toggle { min-height: 34px; }
#confirm-memory-prompts { margin: 0 0 6px; }
.capture-memory-question { color: var(--text-sub); font-size: 13px; margin-top: 4px; }
#confirm-note:placeholder-shown + .capture-memory-question { display: none; }
.capture-import { align-self: center; justify-content: center; min-height: 36px; margin: 0; }

/* 來源切換 */
.source-toggle {
  display: flex;
  gap: 8px;
}
.source-btn {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}
.source-btn.active {
  background: var(--orange-light);
  border-color: var(--orange-border);
  color: var(--orange-dark);
}

.friend-row { display: flex; }

/* 標籤編輯 */
.tags-editor {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.tag-toggle {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-sub);
  -webkit-tap-highlight-color: transparent;
  transition: all 0.15s;
}
.tag-toggle.selected {
  background: var(--orange-light);
  border-color: var(--orange-border);
  color: var(--orange-dark);
  font-weight: 600;
}

/* ── Delete dialog ───────────────────────────────────────────────────────────── */
.delete-dialog {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  z-index: 310;
  background: var(--surface);
  border-radius: 20px;
  padding: 24px 20px;
  width: calc(100% - 48px);
  max-width: 320px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: popIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popIn {
  from { transform: translate(-50%, -50%) scale(0.9); opacity: 0; }
  to   { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}
.delete-text { font-size: 16px; font-weight: 600; color: var(--text); text-align: center; margin-bottom: 20px; }
.delete-actions { display: flex; gap: 10px; }

/* ── Settings ────────────────────────────────────────────────────────────────── */
.settings-user-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.settings-avatar { border-radius: 50%; object-fit: cover; background: var(--border); }
.settings-user-info { min-width: 0; }
.settings-name { font-size: 16px; font-weight: 700; color: var(--text); }
.settings-email { font-size: 13px; color: var(--text-sub); margin-top: 2px; word-break: break-all; }

.settings-group { margin-bottom: 16px; }
.settings-group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 4px;
  margin-bottom: 6px;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: var(--surface);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 15px 16px;
  font-size: 15px;
  color: var(--text);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.settings-row:first-child { border-radius: 16px 16px 0 0; }
.settings-row:last-child { border-radius: 0 0 16px 16px; border-bottom: none; }
.settings-row:only-child { border-radius: 16px; border-bottom: none; }
.settings-row:hover { background: #f5f5f4; }
.settings-row:active { background: #e7e5e4; }
.settings-row-danger { color: var(--danger); }
.settings-row-chevron { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.settings-footer { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 32px; }

/* ── Bottom nav ──────────────────────────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  background: rgba(250,250,249,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  height: calc(var(--nav-h) + var(--safe-bottom));
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 8px;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s;
}
.nav-btn.active { color: var(--orange); }
.nav-btn:active { opacity: 0.7; }
.nav-icon { width: 22px; height: 22px; }
.nav-label { font-size: 10px; font-weight: 600; }

/* ── Loading skeleton ────────────────────────────────────────────────────────── */
@keyframes shimmer {
  from { background-position: -300px 0; }
  to   { background-position:  300px 0; }
}
.skeleton {
  background: linear-gradient(90deg, #e7e5e4 25%, #f5f5f4 50%, #e7e5e4 75%);
  background-size: 300px 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}

/* ── 情境篩選 chips ──────────────────────────────────────────────────────────── */
#filter-budget.source-toggle { flex-wrap: wrap; }
#filter-budget .source-btn { flex: 1 1 auto; min-width: 60px; }

/* ── 滑卡決定畫面（Step 5）──────────────────────────────────────────────────── */
.swipe-screen {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 16px 20px calc(20px + var(--safe-bottom));
}
.swipe-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex: none;
}
.swipe-count { font-size: 13px; font-weight: 600; color: var(--text-muted); }

.swipe-stack {
  position: relative;
  flex: 1;
  min-height: 0;
}
.swipe-card {
  position: absolute;
  inset: 0;
  background: var(--surface);
  border-radius: 20px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.swipe-card.dragging { transition: none; }
.swipe-card-emoji { font-size: 40px; }
.swipe-card-name { font-size: 22px; font-weight: 800; color: var(--text); letter-spacing: -0.3px; }
.swipe-card-note { font-size: 14px; color: var(--text-sub); line-height: 1.6; }
.swipe-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.swipe-card-stamp {
  position: absolute;
  top: 24px;
  font-size: 22px;
  font-weight: 900;
  padding: 4px 14px;
  border-radius: 8px;
  border: 3px solid;
  opacity: 0;
  transform: rotate(-12deg);
}
.swipe-card-stamp.skip { left: 24px; color: var(--danger); border-color: var(--danger); }
.swipe-card-stamp.keep { right: 24px; color: var(--orange); border-color: var(--orange); transform: rotate(12deg); }

.swipe-actions {
  display: flex;
  justify-content: center;
  gap: 24px;
  padding: 20px 0 4px;
  flex: none;
}
.swipe-action-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.1s;
}
.swipe-action-btn:active { transform: scale(0.9); }
.swipe-skip { color: var(--danger); }
.swipe-choose { color: var(--orange); }

.swipe-result { display: flex; flex-direction: column; align-items: center; text-align: center; padding-top: 20px; }
.swipe-result .restaurant-list { width: 100%; margin-top: 16px; text-align: left; }

/* ── Sheet tabs ──────────────────────────────────────────────────────────────── */
.sheet-tabs {
  display: flex;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 3px;
}
.sheet-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-sub);
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sheet-tab.active {
  background: var(--surface);
  color: var(--orange-dark);
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Tab content ─────────────────────────────────────────────────────────────── */
.tab-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#btn-add-manual:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Multi-select ────────────────────────────────────────────────────────────── */
.multi-select-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 42vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.multi-select-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.multi-select-item:has(.multi-select-cb:checked),
.multi-select-item:has(.influencer-cb:checked) {
  border-color: var(--orange-border);
  background: var(--orange-light);
}
.multi-select-cb, .influencer-cb {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--orange);
}
.multi-select-info { flex: 1; min-width: 0; }
.multi-select-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.multi-select-sub {
  font-size: 12px;
  color: var(--text-sub);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Influencer sheet ────────────────────────────────────────────────────────── */
.influencer-videos {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.video-link {
  display: block;
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  border-radius: 10px;
  padding: 10px 14px;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.video-link:hover { background: #e0f2fe; }
.video-link-title {
  font-size: 13px;
  font-weight: 600;
  color: #0369a1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.video-link-channel { font-size: 11px; color: #0284c7; margin-top: 2px; }

/* ── 地點收藏 ───────────────────────────────────────────────────────────────── */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  clip-path: inset(50%);
  overflow: hidden;
  white-space: nowrap;
}
.saved-places {
  --journal-ink: #193b30;
  --journal-muted: #56645a;
  --journal-border: #dedfd1;
  --journal-paper: #fffdf7;
  background: #f9f7ef;
  color: var(--journal-ink);
  padding-top: 16px;
  padding-bottom: calc(var(--nav-h) + 88px + var(--safe-bottom));
}
.journal-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  min-height: 222px;
  padding: clamp(22px, 6vw, 38px);
  border-radius: 24px;
  color: #fffdf5;
  background: linear-gradient(115deg, #183d31, #235243);
}
.journal-hero-copy { position: relative; z-index: 1; }
.journal-hero h1 {
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(28px, 7vw, 48px);
  line-height: 1.15;
  letter-spacing: .015em;
  text-wrap: balance;
}
.journal-hero p {
  max-width: 19rem;
  margin: 10px 0 20px;
  color: #e0ede0;
  font-size: 14px;
  line-height: 1.65;
  text-wrap: pretty;
}
.journal-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 9px;
  background: #ffd18e;
  color: #283a2d;
  font: inherit;
  font-size: 14px;
  font-weight: 750;
  transition: background .16s, transform .16s;
}
.journal-add:hover { background: #ffe1b2; }
.journal-add:active { transform: translateY(2px); }
.journal-hero-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.journal-add-map { border: 1px solid #d7e6d4a3; background: transparent; color: #fffdf5; }
.journal-add-map:hover { background: #ffffff1a; }
.journal-hero-actions button:focus-visible { outline: 2px solid #fffdf5; outline-offset: 2px; }
.journal-save-feedback.has-saved-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 12px;
  padding: 6px 10px 6px 14px;
  border: 1px solid #d5e1d2;
  border-radius: 12px;
  background: #edf3e7;
  color: var(--journal-ink);
  font-size: 14px;
}
#btn-view-saved {
  min-height: 44px;
  padding: 6px 12px;
  border: 0;
  border-radius: 8px;
  background: #315c49;
  color: #fffdf7;
  font: inherit;
  font-weight: 700;
}
#btn-view-saved:hover { background: #214834; }
#btn-view-saved:focus-visible { outline: 2px solid #315c49; outline-offset: 2px; }
.journal-hero-art {
  position: absolute;
  right: -36px;
  bottom: -46px;
  width: clamp(164px, 40vw, 340px);
  aspect-ratio: 1;
  transform: rotate(-21deg);
  border: 1px solid #88aa8f57;
  border-radius: 47% 53% 61% 39%;
  background: repeating-radial-gradient(ellipse at 41% 60%, #c3daaf00 0 14px, #a8c4a047 15px 16px, #c3daaf00 17px 23px);
  pointer-events: none;
}
.journal-hero-art span {
  position: absolute;
  top: 25%;
  left: 23%;
  width: 21px;
  height: 21px;
  transform: rotate(-24deg);
  border: 5px solid #ffd18e;
  border-radius: 50% 50% 50% 2px;
  background: #285444;
}
.trip-panel {
  margin-top: 16px;
  border: 1px solid var(--journal-border);
  border-radius: 15px;
  background: var(--journal-paper);
}
.trip-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 54px;
  padding: 12px 16px;
  list-style: none;
  cursor: pointer;
}
.trip-summary::-webkit-details-marker { display: none; }
.trip-summary::after {
  width: 8px;
  height: 8px;
  transform: rotate(45deg);
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
}
.trip-panel[open] .trip-summary::after { transform: rotate(225deg); }
.trip-heading { flex: 1; font-size: 16px; font-weight: 750; }
.trip-count { color: var(--journal-muted); font-size: 13px; white-space: nowrap; }
.trip-content { padding: 0 16px 12px; }
.trip-empty {
  padding-top: 11px;
  border-top: 1px solid var(--journal-border);
  color: var(--journal-muted);
  font-size: 14px;
  line-height: 1.55;
}
.trip-list { list-style: none; }
.trip-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 10px 0 6px;
  border-top: 1px solid var(--journal-border);
}
.trip-item-info { min-width: 0; overflow-wrap: anywhere; }
.trip-item-name { font-size: 15px; font-weight: 720; }
.trip-item-area { margin-top: 3px; color: var(--journal-muted); font-size: 13px; }
.trip-item-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.trip-item-actions .card-action {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-radius: 8px;
  background: transparent;
  color: var(--journal-ink);
  font: inherit;
  font-size: 13px;
}
.trip-item-actions .card-action:hover { background: #e8eee2; }
#trip-status:not(.visually-hidden) {
  margin-top: 8px;
  padding: 9px 12px;
  border: 1px solid #dfbd9c;
  border-radius: 10px;
  background: #fff1df;
  color: #753e23;
  font-size: 14px;
  line-height: 1.45;
}
.place-collection { margin-top: 25px; }
.collection-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}
.collection-heading h2 { font-size: clamp(21px, 4vw, 26px); }
#place-count { color: var(--journal-muted); font-size: 13px; }
.place-controls { display: grid; gap: 11px; margin-bottom: 16px; }
.place-search-field {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--journal-border);
  border-radius: 12px;
  background: var(--journal-paper);
  color: var(--journal-muted);
}
.place-search-field:focus-within { border-color: #47755e; box-shadow: 0 0 0 2px #47755e33; }
.place-search-icon {
  position: relative;
  flex: 0 0 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 50%;
  margin-right: 4px;
}
.place-search-icon::after {
  position: absolute;
  top: 9px;
  left: 8px;
  width: 7px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
  transform: rotate(45deg);
  transform-origin: left;
  content: "";
}
#place-search {
  width: 100%;
  min-width: 0;
  padding: 12px 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--journal-ink);
  font: inherit;
}
#place-search::placeholder { color: #697368; }
.place-filter-row, .place-type-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.place-type-filter, .place-clear-filters {
  min-height: 36px;
  padding: 5px 11px;
  border: 1px solid var(--journal-border);
  border-radius: 999px;
  background: var(--journal-paper);
  color: var(--journal-ink);
  font: inherit;
  font-size: 13px;
  font-weight: 650;
}
.place-type-filter[aria-pressed="true"] { border-color: #315c49; background: #315c49; color: #fffdf7; }
.place-clear-filters { border-color: transparent; background: none; text-decoration: underline; }
.saved-places button:focus-visible, .saved-places a:focus-visible, .trip-summary:focus-visible {
  outline: 2px solid #b45f33;
  outline-offset: 2px;
}
.place-empty {
  display: grid;
  justify-items: start;
  gap: 8px;
  padding: 22px;
  border: 1px dashed #c8ccb9;
  border-radius: 16px;
  background: var(--journal-paper);
}
.place-empty h3 { font-size: 17px; }
.place-empty p { color: var(--journal-muted); font-size: 14px; line-height: 1.6; }
.place-card-grid { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; gap: 14px; }
.place-card {
  min-width: 0;
  overflow: clip;
  border: 1px solid var(--journal-border);
  border-radius: 17px;
  background: var(--journal-paper);
  box-shadow: 0 4px 14px #2b37220a;
}
.place-card.is-memory-open { border-color: #c9be9e; }
.place-card:focus { outline: 2px solid #47755e; outline-offset: 2px; }
.place-card-content { padding: 17px 17px 12px; }
.place-card-front, .place-card-memory { display: grid; gap: 7px; }
.place-card-type {
  justify-self: start;
  border-radius: 6px;
  padding: 3px 7px;
  background: #e6eee1;
  color: #264935;
  font-size: 12px;
  font-weight: 730;
}
.place-card[data-place-type="展覽"] .place-card-type { background: #eee7f2; color: #5b3b6a; }
.place-card[data-place-type="散步"] .place-card-type { background: #e3edf3; color: #315267; }
.place-card[data-place-type="美食"] .place-card-type { background: #f8e9d6; color: #764923; }
.place-card-name { font-size: 20px; line-height: 1.3; overflow-wrap: anywhere; }
.place-card-area, .place-card-meta { color: var(--journal-muted); font-size: 13px; overflow-wrap: anywhere; }
.place-card-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; }
.place-card-memory {
  margin-top: 12px;
  padding: 13px 15px;
  border-left: 3px solid #d69051;
  border-radius: 2px 9px 9px 2px;
  background: #fbedd8;
  transform-origin: left;
  animation: reveal-memory .3s ease-out both;
}
.place-card-memory-title { color: #704b30; font-size: 12px; font-weight: 750; }
.place-card-note, .place-card-note-empty { font-size: 15px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.place-card-note-empty { color: #6c5845; }
.place-visit-section {
  display: grid;
  gap: 10px;
  min-width: 0;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #dcc7a6;
}
.place-visit-heading, .place-visit-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.place-visit-heading { justify-content: space-between; }
.place-visit-heading h4 { color: #513c27; font-size: 15px; }
.place-visit-section .card-action {
  min-height: 44px;
  border: 1px solid #d8c7aa;
  border-radius: 8px;
  background: #fffdf7;
  color: #294639;
  font-family: inherit;
  font-size: 13px;
}
.place-visit-section .card-action:hover { background: #f4ead7; }
.place-visit-section .card-action[type="submit"] { border-color: #315c49; background: #315c49; color: #fffdf7; }
.place-visit-section .card-action[type="submit"]:hover:not(:disabled) { background: #214834; }
.place-visit-section button:disabled { opacity: .65; }
.place-visit-form {
  display: grid;
  gap: 9px;
  min-width: 0;
  padding: 12px;
  border: 1px solid #e1cbaa;
  border-radius: 10px;
  background: #fffaf1;
}
.place-visit-fields { display: grid; gap: 10px; min-width: 0; border: 0; padding: 0; }
.place-visit-field { display: grid; gap: 4px; min-width: 0; color: #513c27; font-size: 14px; }
.place-visit-field input, .place-visit-field textarea { box-sizing: border-box; width: 100%; min-width: 0; font: inherit; font-size: 16px; }
.place-visit-field input[type="date"], .place-visit-field textarea {
  min-height: 44px;
  padding: 8px;
  border: 1px solid #cdbd9f;
  border-radius: 7px;
  background: #fffdf9;
  color: #273c31;
}
.place-visit-field textarea { min-height: 78px; resize: vertical; }
.place-visit-field input[type="file"] { min-height: 44px; }
.place-visit-field input::file-selector-button {
  min-height: 36px;
  margin-inline-end: 8px;
  padding: 4px 8px;
  border: 1px solid #d8c7aa;
  border-radius: 7px;
  background: #fffdf9;
  color: #294639;
}
.place-visit-help, .place-visit-status, .place-visit-empty, .place-visit-photo-status, .place-visit-photo-name {
  color: #645342;
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.place-visit-feedback { color: #285744; font-size: 14px; line-height: 1.5; }
.place-visit-section [aria-invalid="true"] { border-color: #9f3929; }
.place-visit-section [role="alert"] { color: #8f3021; }
.place-visit-list { display: grid; gap: 8px; min-width: 0; list-style: none; }
.place-visit-item { display: grid; justify-items: start; gap: 6px; padding: 10px; border-radius: 8px; background: #fff8e9; }
.place-visit-date { color: #63492e; font-size: 13px; font-weight: 700; }
.place-visit-note { color: #293f32; font-size: 15px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.place-visit-photo { width: 100%; min-width: 0; }
.place-visit-image { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; border-radius: 7px; }
.place-visit-more { justify-self: start; }
.place-card-actions { display: flex; flex-wrap: wrap; gap: 5px; padding: 9px 13px 12px; border-top: 1px dashed #e1dfd2; }
.place-card-actions .card-action {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border-color: transparent;
  border-radius: 8px;
  background: transparent;
  color: #44584c;
  font-family: inherit;
  font-size: 13px;
}
.place-card-actions .card-action:hover { background: #f1f1e6; }
.place-card-actions .place-card-toggle { background: #e8eee2; color: #214834; }
.place-card-actions .place-card-toggle[aria-expanded="true"] { background: #315c49; color: #fffdf7; }
.place-card-actions .place-card-trip[aria-pressed="true"] { background: #eedfbd; color: #59431b; }
.trip-selection-mark { margin-inline-end: 3px; }
.place-card-actions .place-card-delete { margin-left: auto; }
#page-home .fab { background: #245544; box-shadow: 0 4px 16px #163c3050; }
#page-home .fab:hover { background: #30644f; }
#page-home .fab:focus-visible { outline: 2px solid #b45f33; outline-offset: 3px; }
#auth-signed-in .nav-btn.active { color: #245544; }
@keyframes reveal-memory {
  from { opacity: 0; transform: perspective(500px) rotateY(-16deg) translateY(-3px); }
  to { opacity: 1; transform: perspective(500px) rotateY(0) translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .journal-add { transition: none; }
  .place-card-memory { animation: none; }
}

.section-kicker {
  color: var(--orange-dark);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.restaurant-card { align-items: flex-start; }
.restaurant-card-body { flex: 1; min-width: 0; }
.restaurant-card-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.card-action {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-sub);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 10px;
}
.location-status { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--text-muted); }
.location-status.confirmed { color: #15803d; }
.location-confirm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  background: var(--bg);
}
.location-confirm-row strong { display: block; font-size: 13px; }
.location-confirm-row p { color: var(--text-sub); font-size: 11px; line-height: 1.45; margin-top: 3px; }
.location-confirm-row .btn-ghost { flex: none; font-size: 12px; padding: 9px 10px; }

.share-dialog {
  max-width: 360px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}
.share-success { color: #15803d; font-size: 13px; margin: 10px 0; }
#share-result { display: flex; flex-direction: column; gap: 10px; }
.share-dialog-actions { margin-top: 16px; justify-content: flex-end; }
.share-active-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--border); }
.share-active-section h3 { font-size: 14px; }
.share-active-status { font-size: 12px; color: var(--text-sub); margin-top: 6px; }
.share-active-list { list-style: none; padding: 0; }
.share-active-list li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 10px;
  padding-top: 8px;
}
.share-active-list .btn-ghost { flex: none; }
.share-active-dates { font-size: 12px; line-height: 1.5; color: var(--text-sub); }
.share-active-dates span { display: block; }

.shared-preview {
  position: fixed;
  inset: 0;
  z-index: 600;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 24px;
  background: linear-gradient(160deg, #fff7ed, #fafaf9);
}
.shared-preview-card {
  width: min(100%, 380px);
  background: var(--surface);
  border: 1px solid var(--orange-border);
  border-radius: 28px;
  padding: 28px 22px;
  box-shadow: 0 18px 60px rgba(124,45,18,.12);
  text-align: center;
}
.shared-preview-emoji { font-size: 48px; margin-bottom: 12px; }
.shared-preview-card h1 { font-size: 26px; margin: 8px 0; }
.shared-preview-card > p { color: var(--text-sub); line-height: 1.65; margin-bottom: 14px; }
.shared-preview-card .restaurant-card-meta { justify-content: center; margin-bottom: 18px; }
.shared-home-link { display: block; margin-top: 10px; }

/* ── Responsive cap ──────────────────────────────────────────────────────────── */
@media (min-width: 480px) {
  .auth-screen { max-width: 420px; margin: 0 auto; }
  #auth-signed-in { max-width: 860px; margin: 0 auto; }
  .bottom-nav { width: min(100%, 860px); left: 50%; right: auto; transform: translateX(-50%); }
  .saved-places { padding-inline: clamp(16px, 4vw, 32px); }
  .bottom-sheet { max-width: 420px; left: 50%; transform: translateX(-50%); border-radius: 24px 24px 0 0; }
  .sheet-overlay { max-width: none; }
  .swipe-screen { max-width: 420px; left: 50%; transform: translateX(-50%); }
}
@media (min-width: 670px) {
  .place-card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
