/* ===== CSS Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }


:root {
  --primary:       #d9607e;
  --primary-dark:  #b84868;
  --primary-light: #fce4ed;
  --primary-bg:    #fff8fb;
  --accent:   #e88aa8;
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #3b82f6;
  --text:       #2a1f24;
  --text-muted: #7a6570;
  --text-light: #b8a0ac;
  --border:     #f0dde5;
  --border-dark:#e4c8d4;
  --bg:         #ffffff;
  --bg-card:    #ffffff;
  --bg-hover:   #fff5f8;
  --shadow-sm: 0 1px 4px rgba(180,80,110,.07);
  --shadow:    0 4px 16px rgba(180,80,110,.09);
  --shadow-lg: 0 8px 32px rgba(180,80,110,.12);
  --radius:    14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --font: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.65;
  min-height: 100vh;
  overflow-x: hidden;
}
.hidden { display: none !important; }

/* ===== LOGIN PAGE ===== */
#login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(160deg, #fef5f8 0%, #fce0ea 55%, #f8c8d8 100%);
  position: relative; overflow: hidden;
}
#login-page::before {
  content: ''; position: absolute;
  width: 450px; height: 450px; background: rgba(255,255,255,.06);
  border-radius: 50%; top: -140px; right: -120px;
}
#login-page::after {
  content: ''; position: absolute;
  width: 320px; height: 320px; background: rgba(255,255,255,.04);
  border-radius: 50%; bottom: -90px; left: -90px;
}
.login-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 40px 32px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 56px rgba(180,80,110,.15);
  position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { font-size: 52px; line-height: 1; margin-bottom: 10px; }
.login-logo h1 { font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); margin-bottom: 4px; }
.login-logo p  { color: var(--text-muted); font-size: .875rem; }
.tab-switcher {
  display: flex; background: #fff5f8;
  border-radius: var(--radius-sm); padding: 4px; margin-bottom: 24px; gap: 4px;
}
.tab-switcher button {
  flex: 1; padding: 8px; border: none; border-radius: 6px;
  background: transparent; cursor: pointer;
  font-size: .875rem; font-weight: 500; color: var(--text-muted); transition: all .2s;
}
.tab-switcher button.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: .8125rem; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
}
.form-label.required::after { content: ' *'; color: var(--primary); }
.form-control {
  width: 100%; padding: 10px 14px;
  border: 1.5px solid var(--border-dark); border-radius: var(--radius-sm);
  font-size: .9375rem; font-family: var(--font);
  color: var(--text); background: #fff; transition: border-color .2s, box-shadow .2s; outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217,96,126,.15); }
.form-control::placeholder { color: var(--text-light); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { appearance: none; cursor: pointer; }
.form-hint { font-size: .75rem; color: var(--text-light); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: all .2s; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(217,96,126,.30); }
.btn-secondary { background: #fce4ed; color: var(--primary-dark); }
.btn-secondary:hover:not(:disabled) { background: #f5b8d0; }
.btn-outline   { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: var(--primary-light); }
.btn-ghost     { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text); }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-block { width: 100%; }
.btn-lg  { padding: 13px 24px; font-size: 1rem; }
.btn-sm  { padding: 6px 12px; font-size: .8rem; }
.btn-icon{ padding: 6px; width: 32px; height: 32px; border-radius: 6px; }

/* ===== ALERTS ===== */
.alert {
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: .875rem; line-height: 1.5; margin-bottom: 12px;
}
.alert-error   { background: #fef2f2; color: #991b1b; border-left: 3px solid var(--danger); }
.alert-success { background: #f0fdf4; color: #166534; border-left: 3px solid var(--success); }
.alert-warning { background: #fffbeb; color: #92400e; border-left: 3px solid var(--warning); }
.alert-info    { background: #eff6ff; color: #1e40af; border-left: 3px solid var(--info); }

/* ===== APP HEADER ===== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, #b84868 0%, #d9607e 60%, #e87a98 100%);
  padding: 0 16px; height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 12px rgba(180,70,100,.22);
}
.header-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 1.1rem; font-weight: 700; color: #fff;
}
.header-brand span:first-child { font-size: 1.3rem; }
.header-user { display: flex; align-items: center; gap: 10px; }
.header-username { font-size: .8125rem; color: rgba(255,255,255,.85); font-weight: 500; }
.btn-logout {
  background: rgba(255,255,255,.18); color: #fff;
  border: 1px solid rgba(255,255,255,.3);
  padding: 5px 12px; border-radius: 20px;
  font-size: .75rem; font-weight: 600; cursor: pointer; transition: background .2s;
}
.btn-logout:hover { background: rgba(255,255,255,.28); }

/* ===== TAB NAVIGATION ===== */
.tab-nav {
  display: flex; background: #fff;
  border-bottom: 2px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
  position: sticky; top: 56px; z-index: 90;
}
.tab-nav::-webkit-scrollbar { display: none; }
.tab-btn {
  flex: 1; min-width: 64px; padding: 12px 8px;
  background: none; border: none; cursor: pointer;
  font-size: .78rem; font-weight: 600; color: var(--text-light);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: color .2s; white-space: nowrap; position: relative;
}
.tab-btn::after {
  content: ''; position: absolute; bottom: -2px; left: 0; right: 0;
  height: 2px; background: var(--primary); transform: scaleX(0); transition: transform .2s;
}
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after { transform: scaleX(1); }
.badge {
  background: var(--primary); color: #fff;
  font-size: .65rem; padding: 1px 5px; border-radius: 10px; line-height: 1.4; font-weight: 700;
}

/* ===== TAB CONTENT ===== */
.tab-content { display: none; padding: 16px; padding-bottom: 32px; }
.tab-content.active { display: block; }

/* ===== CARDS ===== */
.card { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--border); overflow: hidden; }
.card-header {
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); background: #fff5f8;
}
.card-header h3 { font-size: .9375rem; font-weight: 700; color: var(--primary-dark); }
.card-body { padding: 16px; }

/* ===== SECTION HEADERS ===== */
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }

/* ===== TRIP CARDS ===== */
.trips-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.trip-card {
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--border);
  padding: 0;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.trip-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 14px 32px rgba(214,51,132,0.18);
}
.trip-card-cover {
  position: relative;
  min-height: 130px;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}
.trip-card-cover::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
}
.trip-card-cover-overlay {
  position: relative;
  z-index: 2;
  flex: 1;
  min-width: 0;
  color: white;
}
.trip-card-name {
  font-size: 1.3rem;
  font-weight: 800;
  text-shadow: 0 1px 6px rgba(0,0,0,0.5);
  line-height: 1.3;
  margin-bottom: 8px;
  word-break: break-word;
}
.trip-card-status { display: flex; gap: 6px; flex-wrap: wrap; }
.trip-badge {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(255,255,255,0.96);
  color: var(--text);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  letter-spacing: 0.02em;
}
.trip-badge-active { background: #fef3c7; color: #92400e; }
.trip-badge-soon { background: #fed7aa; color: #c2410c; }
.trip-badge-past { background: rgba(255,255,255,0.75); color: #555; }
.trip-badge-future { background: rgba(255,255,255,0.95); color: var(--text); }

.trip-card-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  display: flex;
  gap: 4px;
}
.trip-card-action-btn {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.92);
  border: none;
  border-radius: 50%;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s ease, background .15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  padding: 0;
}
.trip-card-action-btn:hover { background: white; transform: scale(1.1); }

.trip-card-body {
  padding: 14px 16px 16px;
}
.trip-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.82rem;
  color: var(--text-muted);
}
.trip-card-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* + 新增行程 卡片 */
.trip-card-add {
  border: 2px dashed var(--border);
  background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 16px;
  min-height: 220px;
  text-align: center;
  box-shadow: none;
}
.trip-card-add:hover {
  border-color: var(--primary);
  background: white;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(214,51,132,0.12);
}
.trip-card-add-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.55;
}
.trip-card-add-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 4px;
}
.trip-card-add-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ===== TRIP DETAIL ===== */
.trip-detail-header {
  background: linear-gradient(135deg, #b84868, #e87a98);
  color: #fff; border-radius: var(--radius); padding: 20px; margin-bottom: 16px;
}
.trip-detail-name { font-size: 1.3rem; font-weight: 700; margin-bottom: 6px; }
.trip-detail-dates { font-size: .875rem; opacity: .85; margin-bottom: 6px; }
.trip-detail-desc  { font-size: .85rem; opacity: .8; margin-bottom: 12px; white-space: pre-line; line-height: 1.55; }
.trip-detail-actions { display: flex; gap: 8px; }

/* ===== DAY CARDS ===== */
.day-card {
  background: #fff; border-radius: var(--radius);
  border: 1.5px solid var(--border); margin-bottom: 14px;
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.day-card-header {
  padding: 12px 16px; display: flex; align-items: center; gap: 10px;
  background: #fff5f8; border-bottom: 1.5px solid var(--border);
}
.day-number {
  background: var(--primary); color: #fff;
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8125rem; font-weight: 700; flex-shrink: 0;
}
.day-card-title { flex: 1; }
.day-name { font-weight: 700; font-size: .9375rem; color: var(--text); }
.day-date { font-size: .75rem; color: var(--text-muted); }
.day-card-body { padding: 12px; }

/* ===== 新增景點按鈕：手機僅顯示 + ===== */
.btn-add-icon { font-weight: 700; }
@media (max-width: 600px) {
  .btn-add-place { padding: 4px 10px; min-width: 32px; }
  .btn-add-text { display: none; }
}

/* ===== Day collapse ===== */
.day-card-toggle { transition: transform .2s; }
.day-card.collapsed .day-card-toggle { transform: rotate(-90deg); }
.day-card.collapsed .day-card-body { display: none; }
.day-card.collapsed .day-card-header { border-bottom: none; }
.day-card.collapsed { background: #fafafa; }

/* ===== Extras (transit / overview) collapse ===== */
.extras-card-toggle { transition: transform .2s; display: inline-block; }
.extras-card.collapsed .extras-card-toggle { transform: rotate(-90deg); }
.extras-card.collapsed .extras-card-body { display: none; }

/* ===== Pre-trip preparation ===== */
.prep-checklist {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 6px 14px;
}
.prep-checklist li {
  font-size: 0.92rem;
  color: var(--text);
  padding: 4px 0;
}
.prep-notes {
  margin-top: 12px;
  padding: 12px 14px;
  background: #fffbea;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--text);
  white-space: pre-wrap;
}
.prep-notes::before {
  content: "⚠️ 注意事項";
  display: block;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 6px;
  font-size: 0.85rem;
}

/* ===== Day theme / table-style place row ===== */
.day-title-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.day-theme { font-size: .9rem; color: var(--primary); font-weight: 600; }
.day-place-count { display: block; font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.day-highlight {
  margin-top: 10px;
  padding: 10px 12px;
  background: linear-gradient(90deg, #fff5f8, #fff);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  font-size: 0.875rem;
  color: var(--text);
  line-height: 1.55;
}
.place-time {
  flex: 0 0 64px;
  text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  white-space: pre-line;
  line-height: 1.2;
  padding: 4px 2px;
  border-right: 1px dashed var(--border);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.place-time-empty {
  color: var(--text-muted);
  font-weight: 400;
  font-size: 0.92rem;
  font-family: var(--font);
}
@media (max-width: 480px) {
  .place-time { flex: 0 0 52px; font-size: 0.78rem; }
}

/* ===== PLACE ITEMS ===== */
.place-list  { display: flex; flex-direction: column; gap: 6px; }
.place-empty { text-align: center; color: var(--text-light); font-size: .85rem; padding: 16px; }
.place-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--bg);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: grab; transition: all .15s;
  user-select: none; -webkit-user-select: none;
}
.place-item:active { cursor: grabbing; }
/* 按鈕區仍可以正常點擊 */
.place-item .place-actions button,
.place-item .place-actions a { cursor: pointer; }
.place-item:hover { border-color: #f5a0bc; background: #fff5f8; }
.place-item.dragging { opacity: .5; box-shadow: var(--shadow); }
.place-item.drag-over { border-color: var(--primary); background: var(--primary-light); }
.place-order {
  background: #fce4ed; color: var(--primary-dark);
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 700; flex-shrink: 0;
}
.place-info { flex: 1; min-width: 0; }
.place-name    { font-weight: 600; font-size: .875rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-address { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-actions { display: flex; gap: 2px; }
.place-source  { font-size: .65rem; padding: 2px 6px; border-radius: 10px; font-weight: 600; }
.source-line   { background: #dcfce7; color: #166534; }
.source-gmaps  { background: #dbeafe; color: #1e40af; }
.source-manual { background: #fce4ed; color: #7a0a37; }

/* ===== EMPTY / LOADING ===== */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-state h3 { font-size: 1rem; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.empty-state p  { font-size: .875rem; margin-bottom: 16px; }
.loading-state {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 40px; color: var(--text-muted); font-size: .875rem;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid #fce4ed; border-top-color: var(--primary);
  animation: spin .7s linear infinite; display: inline-block;
}
.spinner-dark { border-color: var(--border); border-top-color: var(--primary); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== PHOTOS ===== */
.photo-upload-area {
  border: 2px dashed #f5a0bc; border-radius: var(--radius);
  padding: 32px 16px; text-align: center; cursor: pointer;
  background: #fff8fb; transition: all .2s;
}
.photo-upload-area:hover, .photo-upload-area.dragover {
  border-color: var(--primary); background: var(--primary-light);
}
.upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.upload-text { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.upload-hint { font-size: .75rem; color: var(--text-muted); }
.upload-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.preview-img { width: 80px; height: 80px; object-fit: cover; border-radius: var(--radius-sm); border: 2px solid var(--border); }
.category-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.filter-btn {
  padding: 6px 14px; border-radius: 20px;
  background: #fff; border: 1.5px solid var(--border-dark);
  color: var(--text-muted); font-size: .8rem; font-weight: 600; cursor: pointer; transition: all .2s;
}
.filter-btn.active, .filter-btn:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.photo-gallery { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.photo-item {
  position: relative; aspect-ratio: 1; overflow: hidden;
  border-radius: var(--radius-sm); cursor: pointer; background: #ffe0ed;
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s; }
.photo-item:hover img { transform: scale(1.06); }
.photo-category-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(185,72,104,.82); color: #fff;
  font-size: .65rem; font-weight: 700; padding: 2px 7px; border-radius: 10px;
}
.photo-item-overlay {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(30,15,22,.68));
  color: #fff; font-size: .7rem; padding: 18px 8px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  opacity: 0; transition: opacity .2s;
}
.photo-item:hover .photo-item-overlay { opacity: 1; }
.photo-delete-btn {
  position: absolute; top: 6px; right: 6px;
  background: rgba(239,68,68,.85); color: #fff;
  border: none; border-radius: 50%; width: 22px; height: 22px;
  font-size: .7rem; cursor: pointer; display: none;
  align-items: center; justify-content: center;
}
.photo-item:hover .photo-delete-btn { display: flex; }

/* ===== LINE PENDING ===== */
.pending-list { display: flex; flex-direction: column; gap: 10px; }
.pending-item {
  display: flex; gap: 12px; padding: 14px;
  background: #fff; border-radius: var(--radius);
  border: 1.5px solid var(--border); box-shadow: var(--shadow-sm);
}
.pending-icon { font-size: 1.5rem; flex-shrink: 0; }
.pending-info { flex: 1; min-width: 0; }
.pending-name    { font-weight: 700; font-size: .9375rem; margin-bottom: 3px; }
.pending-address { font-size: .8rem; color: var(--text-muted); margin-bottom: 3px; }
.pending-time    { font-size: .75rem; color: var(--text-light); }
.pending-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; justify-content: center; }

/* ===== MAP ===== */
.map-container { border-radius: var(--radius); overflow: hidden; background: #fff8fb; border: 1.5px solid var(--border); }
.map-container-lg { height: 360px; }
.map-placeholder {
  height: 100%; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px; color: var(--text-muted); padding: 40px;
}
.url-parser {
  background: #fff8fb; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px; margin-bottom: 14px;
}
.url-parser-title { font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }

/* ===== SETTINGS ===== */
.settings-section {
  background: #fff; border-radius: var(--radius);
  border: 1.5px solid var(--border); margin-bottom: 14px;
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.settings-section-header {
  padding: 12px 16px; font-size: .875rem; font-weight: 700;
  color: var(--primary-dark); background: #fff5f8;
  border-bottom: 1px solid var(--border);
}
.settings-section-body { padding: 16px; }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border);
}
.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: .875rem; font-weight: 600; color: var(--text); }
.settings-value { font-size: .875rem; color: var(--text-muted); }
.text-small { font-size: .75rem !important; }

.toggle { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border-dark);
  border-radius: 12px; cursor: pointer; transition: .3s;
}
.toggle-slider::before {
  content: ''; position: absolute;
  width: 18px; height: 18px; background: #fff;
  border-radius: 50%; left: 3px; top: 3px; transition: .3s;
  box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

.instruction-box {
  background: #f5eff2; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px;
}
.instruction-box ol { padding-left: 20px; }
.instruction-box li { font-size: .85rem; margin-bottom: 6px; color: var(--text); }
.link-code {
  background: #f5eff2; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: monospace; font-size: .85rem; color: var(--primary-dark);
}

/* ===== MODALS ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(30,15,22,.40);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; backdrop-filter: blur(3px);
}
.modal {
  background: #fff; border-radius: var(--radius-lg);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 64px rgba(180,80,110,.14);
  animation: modalIn .22s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(.97); }
  to   { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  background: #fff5f8; color: var(--text-muted);
  font-size: .875rem; cursor: pointer; transition: background .2s;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #fce4ed; color: var(--primary); }
.modal-body   { padding: 18px 20px; }
.modal-footer {
  padding: 12px 20px 18px;
  display: flex; justify-content: flex-end; gap: 10px;
  border-top: 1px solid var(--border);
}

/* ===== AUTOCOMPLETE ===== */
.search-box { position: relative; }
.search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  font-size: 1rem; pointer-events: none;
}
.search-box .form-control { padding-left: 36px; }
.autocomplete-dropdown {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 300;
  background: #fff; border: 1.5px solid var(--border);
  border-top: none; border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  box-shadow: var(--shadow); max-height: 240px; overflow-y: auto;
}
.autocomplete-item { padding: 10px 14px; cursor: pointer; transition: background .15s; border-bottom: 1px solid var(--border); }
.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: #fff5f8; }
.autocomplete-item .main-text      { font-size: .875rem; font-weight: 600; color: var(--text); }
.autocomplete-item .secondary-text { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }

/* ===== LIGHTBOX ===== */
.lightbox {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(10,5,8,.90);
  display: flex; align-items: center; justify-content: center; cursor: zoom-out;
}
.lightbox img { max-width: 94vw; max-height: 90vh; border-radius: var(--radius-sm); object-fit: contain; }
.lightbox-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(255,255,255,.15); color: #fff;
  border: none; border-radius: 50%; width: 36px; height: 36px;
  font-size: 1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 600; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: 90%; max-width: 340px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius-sm);
  background: var(--text); color: #fff;
  font-size: .875rem; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toastIn .3s ease; text-align: center;
}
.toast.success { background: #065f46; }
.toast.error   { background: #991b1b; }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}

/* ===== UTILITIES ===== */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 14px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 14px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  .login-card { padding: 28px 20px; }
  .form-row { grid-template-columns: 1fr; }
  .trips-grid { grid-template-columns: 1fr; }
  .photo-gallery { grid-template-columns: repeat(3, 1fr); }
  .pending-item { flex-wrap: wrap; }
  .pending-actions { flex-direction: row; width: 100%; }
  .modal { border-radius: var(--radius); }

  /* App-like bottom nav on phones */
  .tab-nav {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    border-top: 1px solid var(--border); border-bottom: none;
    box-shadow: 0 -2px 8px rgba(0,0,0,.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
  }
  .tab-btn { font-size: .72rem; padding: 10px 6px; min-height: 56px; }
  .tab-btn::after { top: 0; bottom: auto; }
  .tab-content { padding-bottom: calc(76px + env(safe-area-inset-bottom, 0)); }
  /* Bigger tap targets */
  .btn-sm { min-height: 36px; }
  button, .btn { min-height: 40px; }
}

/* PWA standalone mode: trim browser-like chrome */
@media (display-mode: standalone) {
  body { -webkit-tap-highlight-color: transparent; }
}

/* ===== Trip Extras (per-trip transit & overview cards) ===== */
.trip-extras {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}
.extras-card {
  background: linear-gradient(135deg, #fff 0%, var(--primary-light) 100%);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 10px rgba(214, 51, 132, 0.06);
}
.extras-card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.ticket-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.ticket-card {
  background: #fff;
  border: 1px solid rgba(214, 51, 132, 0.18);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform .15s ease, box-shadow .15s ease;
}
.ticket-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(214, 51, 132, 0.12);
}
.ticket-name {
  font-weight: 600;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.35;
}
.ticket-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}
.ticket-price {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.ticket-price-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}
.ticket-use {
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px dashed var(--border);
  padding-top: 6px;
  line-height: 1.4;
}
.extras-note {
  margin-top: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.7);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  font-size: 0.82rem;
  color: var(--text);
  line-height: 1.5;
}

/* Overview timeline */
.overview-timeline {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
}
.overview-day {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: #fff;
  border: 1px solid rgba(214, 51, 132, 0.15);
  border-radius: 10px;
  padding: 10px 14px;
  position: relative;
  transition: transform .15s ease, box-shadow .15s ease;
}
.overview-day:hover {
  transform: translateX(4px);
  box-shadow: 0 3px 10px rgba(214, 51, 132, 0.1);
}
.overview-day-badge {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(214, 51, 132, 0.25);
}
.overview-day-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.overview-day-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}
.overview-day-dow {
  color: var(--primary);
}
.overview-day-theme {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.overview-day-area {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 600px) {
  .ticket-grid { grid-template-columns: 1fr; }
  .extras-card { padding: 14px; }
  .ticket-price { font-size: 1.25rem; }
  .overview-day-badge { width: 38px; height: 38px; font-size: 0.82rem; }
}

/* ===== Edit Extras Modal ===== */
.extras-edit-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.extras-edit-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  transition: box-shadow .15s ease, opacity .15s ease;
}
.extras-edit-row.dragging { opacity: 0.45; }
.extras-edit-row:hover { box-shadow: 0 2px 6px rgba(214,51,132,0.08); }
.extras-edit-handle {
  flex-shrink: 0;
  width: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--text-muted);
  font-size: 1.1rem;
  user-select: none;
}
.extras-edit-handle:active { cursor: grabbing; }
.extras-edit-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.extras-edit-fields .form-control {
  font-size: 0.85rem;
  padding: 6px 10px;
}
.extras-edit-remove {
  flex-shrink: 0;
  align-self: flex-start;
  color: var(--danger, #d63384);
}
.extras-edit-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 20px 0;
  background: var(--primary-light);
  border-radius: 8px;
  border: 1px dashed var(--border);
}

/* 行程總覽 - 每日預計費用 */
.overview-day-cost {
  font-size: 0.85rem;
  font-weight: 700;
  color: #c2410c;
  margin-top: 4px;
  background: linear-gradient(135deg, #fff7ed 0%, #fed7aa 100%);
  padding: 4px 10px;
  border-radius: 8px;
  display: inline-block;
}
.overview-totals {
  margin-top: 14px;
  padding: 12px 14px;
  background: #fff;
  border: 1px dashed var(--primary);
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.overview-total-pill {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary);
  color: white;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.extras-currency-select {
  max-width: 140px;
  flex-shrink: 0;
}

/* ===== 手機板 place-item 排版修正 ===== */
@media (max-width: 600px) {
  .place-item {
    flex-wrap: wrap;
    align-items: flex-start;
    padding: 12px;
    gap: 8px;
  }
  .place-info {
    flex: 1 1 0;
    min-width: 0;
  }
  .place-info > div {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
  /* source badge + actions 包在最後一個 child wrapper —
     強制改成水平 row、佔整行、放在 info 下方 */
  .place-item > div:last-child {
    flex-basis: 100% !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-top: 4px;
    gap: 8px;
  }
  .place-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px !important;
  }
  .place-actions .btn-icon {
    width: 36px;
    height: 36px;
  }
  .place-order {
    align-self: flex-start;
  }
}

/* 景點動作下拉選單 */
.place-action-menu {
  position: fixed;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.18);
  padding: 6px;
  z-index: 10000;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  animation: place-menu-in .12s ease-out;
}
@keyframes place-menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.place-action-menu button,
.place-action-menu a {
  background: none;
  border: none;
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.92rem;
  font-family: var(--font);
  color: var(--text);
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  white-space: nowrap;
  text-decoration: none;
  transition: background .12s;
}
.place-action-menu button:hover,
.place-action-menu a:hover {
  background: var(--primary-light);
}
.place-action-menu button.danger {
  color: var(--danger, #ef4444);
}
.place-action-menu button.danger:hover {
  background: #fee2e2;
}
.place-action-menu span {
  font-size: 1.05rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.place-more-btn {
  letter-spacing: 0.05em;
}
.action-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* place notes 樣式（從 inline style 移出） */
.place-notes {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  word-break: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* Admin: 使用者管理區塊 */
.admin-user-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: box-shadow .15s;
}
.admin-user-card:hover {
  box-shadow: 0 4px 12px rgba(214,51,132,0.10);
}
.admin-user-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.admin-user-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
}
.admin-user-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.admin-user-stats {
  display: flex;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.admin-user-devices {
  border-top: 1px dashed var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.admin-user-devices-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* ===== Trip Sharing ===== */
.trip-card-shared-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  padding: 3px 8px;
  border-radius: 999px;
  margin-bottom: 6px;
  backdrop-filter: blur(4px);
}

.trip-detail-shared {
  display: inline-block;
  font-size: 0.78rem;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  padding: 4px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.share-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 2px;
}

.share-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #f0d4dd);
  border-radius: 8px;
}

.share-row-name {
  font-size: 0.92rem;
  font-weight: 600;
}

.share-row-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.share-add-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: stretch;
}

.share-add-row .form-control {
  margin: 0;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}
