:root {
  --ink: #12141a;
  --ink-soft: #4b5563;
  --muted: #8a8f98;
  --bg: #ffffff;
  --card-border: #edeef1;
  --card-bg: #ffffff;
  --surface: #f6f7f9;
  --accent: #16181d;
  --accent-contrast: #ffffff;
  --brand: #e0693f;
  --danger: #dc2626;
  --success: #1a9c5b;
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-md: 0 8px 24px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, 0.14);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
img { max-width: 100%; display: block; }
button { font-family: inherit; }
a { color: inherit; text-decoration: none; }

#app { min-height: 100%; display: flex; flex-direction: column; }

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

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 999px; padding: 15px 24px; font-size: 16px; font-weight: 600;
  cursor: pointer; transition: transform .15s ease, opacity .15s ease, box-shadow .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--accent-contrast); box-shadow: var(--shadow-sm); }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-secondary { background: var(--surface); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--ink-soft); padding: 10px 14px; }
.btn-block { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.92);
  box-shadow: var(--shadow-sm); border: none; display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink); cursor: pointer;
}
.btn-sm { padding: 8px 14px; font-size: 13px; }

/* ---------- Header ---------- */
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 18px 6px;
}
.app-header .brand { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
.pro-badge {
  background: var(--accent); color: #fff; font-size: 12px; font-weight: 700;
  padding: 6px 12px; border-radius: 999px; display: inline-flex; gap: 6px; align-items: center;
}

/* ---------- Page scaffolding ---------- */
.page { flex: 1; display: flex; flex-direction: column; padding-bottom: calc(88px + var(--safe-bottom)); }
.page.no-nav { padding-bottom: 24px; }
.title-xl { font-size: 30px; line-height: 1.15; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 8px; }
.title-lg { font-size: 22px; font-weight: 800; letter-spacing: -.01em; margin: 0 0 6px; }
.subtitle { color: var(--ink-soft); font-size: 15.5px; line-height: 1.5; margin: 0 0 20px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card-bg); border: 1px solid var(--card-border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); padding: 22px; margin-bottom: 16px;
}

/* ---------- Upload dropzone ---------- */
.dropzone {
  border: 2px dashed #d7dae0; border-radius: var(--radius-lg); padding: 40px 20px;
  text-align: center; background: var(--surface); transition: border-color .2s, background .2s;
}
.dropzone.dragover { border-color: var(--accent); background: #eef0f4; }
.dropzone .cloud-icon { color: var(--ink); margin-bottom: 14px; }
.dropzone h2 { font-size: 19px; font-weight: 800; margin: 0 0 8px; }
.dropzone p { color: var(--ink-soft); font-size: 14.5px; margin: 0 0 20px; line-height: 1.5; }
.dropzone .hint { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.file-input { display: none; }

.privacy-note {
  display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 13.5px;
  padding: 12px 14px; background: var(--surface); border-radius: var(--radius-md); margin: 16px 0;
}

/* ---------- Status checklist ---------- */
.status-list { display: flex; flex-direction: column; gap: 14px; }
.status-item { display: flex; align-items: center; gap: 12px; font-size: 14.5px; color: var(--ink-soft); }
.status-item .dot {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--ink);
}
.status-item.active .dot { background: var(--accent); color: #fff; }
.status-item.active { color: var(--ink); font-weight: 600; }

/* ---------- Progress ---------- */
.progress-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.progress-header h3 { font-size: 16px; margin: 0; font-weight: 700; }
.progress-track { height: 8px; background: var(--surface); border-radius: 999px; overflow: hidden; margin-bottom: 6px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; width: 0%; transition: width .3s ease; }
.progress-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.thumb-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumb-cell {
  position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface);
}
.thumb-cell img { width: 100%; height: 100%; object-fit: cover; }
.thumb-cell .check {
  position: absolute; top: 5px; right: 5px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; color: #fff;
}
.thumb-cell.more {
  display: flex; align-items: center; justify-content: center; background: var(--ink); color: #fff;
  font-weight: 700; font-size: 15px;
}

/* ---------- Landing ---------- */
.landing-hero { padding: 60px 0 20px; text-align: center; }
.landing-hero .emoji { font-size: 48px; margin-bottom: 10px; }
.landing-actions { display: flex; flex-direction: column; gap: 12px; margin-top: 28px; }
.landing-link { text-align: center; color: var(--ink-soft); font-size: 14px; margin-top: 6px; }

/* ---------- Hero (trip page) ---------- */
.hero { position: relative; border-radius: 0 0 var(--radius-xl) var(--radius-xl); overflow: hidden; }
.hero-media { position: relative; height: 300px; background: #1a1c22 linear-gradient(180deg, rgba(0,0,0,.05), rgba(0,0,0,.55)); }
.hero-media img { width: 100%; height: 100%; object-fit: cover; }
.hero-media::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,.15) 0%, rgba(0,0,0,0) 30%, rgba(0,0,0,.75) 100%);
}
.hero-topbar {
  position: absolute; top: 0; left: 0; right: 0; padding: 14px 16px; display: flex; justify-content: space-between; z-index: 2;
  padding-top: max(14px, env(safe-area-inset-top));
}
.hero-topbar .right { display: flex; gap: 8px; }
.hero-text { position: absolute; left: 20px; right: 20px; bottom: 20px; color: #fff; z-index: 2; }
.hero-text h1 { font-size: 27px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.01em; }
.hero-text .dates { font-size: 14px; opacity: .92; }
.hero-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: #fff; margin: 0 14px; border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: 16px 8px; position: relative; top: -28px; z-index: 3;
}
.hero-stat { text-align: center; }
.hero-stat .val { font-weight: 800; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 4px; }
.hero-stat .lbl { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Day tabs ---------- */
.day-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 18px 4px; margin-top: -14px; scrollbar-width: none; }
.day-tabs::-webkit-scrollbar { display: none; }
.day-tab {
  flex-shrink: 0; padding: 10px 16px; border-radius: 16px; background: var(--surface); text-align: center;
  cursor: pointer; border: 1px solid transparent; min-width: 68px;
}
.day-tab .d1 { font-size: 12.5px; font-weight: 700; }
.day-tab .d2 { font-size: 11px; color: var(--muted); margin-top: 1px; }
.day-tab.active { background: var(--accent); }
.day-tab.active .d1, .day-tab.active .d2 { color: #fff; }

/* ---------- Map card ---------- */
.map-card { margin: 12px 18px; border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow-sm); border: 1px solid var(--card-border); position: relative; }
.map-el { width: 100%; height: 240px; background: var(--surface); }
.map-expand { position: absolute; right: 10px; bottom: 10px; z-index: 400; }
.marker-badge {
  width: 26px; height: 26px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 12.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(0,0,0,.3); border: 2px solid #fff;
}

/* ---------- Timeline ---------- */
.timeline-section { padding: 4px 18px 0; }
.day-block-title { font-size: 15px; color: var(--muted); margin: 18px 0 4px; font-weight: 600; }
.spot-card { position: relative; }
.spot-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.spot-title { font-size: 18px; font-weight: 800; margin: 0; }
.spot-desc { color: var(--ink-soft); font-size: 14.5px; line-height: 1.5; margin: 0 0 14px; }
.spot-photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.spot-photo { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 1; background: var(--surface); cursor: pointer; }
.spot-photo img { width: 100%; height: 100%; object-fit: cover; }
.spot-photo .heart { position: absolute; top: 6px; right: 6px; color: #fff; filter: drop-shadow(0 1px 3px rgba(0,0,0,.5)); }

/* ---------- Bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--card-border);
  display: flex; justify-content: space-around; padding: 8px 4px calc(8px + var(--safe-bottom)); z-index: 50;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--muted); font-size: 11px;
  background: none; border: none; padding: 6px 10px; cursor: pointer; font-weight: 600;
}
.nav-item.active { color: var(--ink); }

/* ---------- Empty state ---------- */
.empty-hint { text-align: center; padding: 60px 20px; color: var(--muted); }

/* ---------- Toast / loading ---------- */
.toast {
  position: fixed; bottom: calc(100px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px;
  box-shadow: var(--shadow-lg); z-index: 200; max-width: 90vw; text-align: center;
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.shimmer {
  background: linear-gradient(90deg, var(--surface) 25%, #ececef 37%, var(--surface) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Fade / slide utility (used by animations.js) ---------- */
.fade-in { animation: fadeIn .45s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slide-up { animation: slideUp .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes slideUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Slideshow ---------- */
.slideshow {
  position: fixed; inset: 0; background: #000; z-index: 500; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.slideshow-slide {
  position: absolute; inset: 0; opacity: 0; display: flex; align-items: center; justify-content: center;
}
.slideshow-slide.active { opacity: 1; z-index: 1; }
.slideshow-slide img {
  width: 100%; height: 100%; object-fit: cover;
}
.slideshow-slide.active img { animation: kenburns 4.6s ease-out both; }
@keyframes kenburns { from { transform: scale(1.06); } to { transform: scale(1); } }
.slideshow-scrim {
  position: absolute; left: 0; right: 0; bottom: 0; height: 45%; z-index: 2;
  background: linear-gradient(180deg, rgba(0,0,0,0), rgba(0,0,0,.75));
  pointer-events: none;
}
.slideshow-info { position: absolute; left: 22px; right: 22px; bottom: calc(28px + var(--safe-bottom)); color: #fff; z-index: 3; }
.slideshow-info .day-pill {
  display: inline-block; background: rgba(255,255,255,.18); padding: 4px 10px; border-radius: 999px; font-size: 11.5px;
  font-weight: 700; margin-bottom: 8px; backdrop-filter: blur(6px);
}
.slideshow-info h3 { font-size: 20px; margin: 0 0 4px; font-weight: 800; }
.slideshow-info p { margin: 0; font-size: 14px; opacity: .9; }
.slideshow-topbar { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 4; display: flex; justify-content: space-between; }
.slideshow-progress { position: absolute; top: max(10px, env(safe-area-inset-top)); left: 16px; right: 16px; z-index: 4; display: flex; gap: 4px; }
.slideshow-progress .seg { flex: 1; height: 3px; background: rgba(255,255,255,.3); border-radius: 3px; overflow: hidden; }
.slideshow-progress .seg .fill { height: 100%; width: 0%; background: #fff; }
.slideshow-progress .seg.done .fill { width: 100%; }
.slideshow-nav-zone { position: absolute; top: 0; bottom: 0; width: 34%; z-index: 3; }
.slideshow-pause-icon {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 5;
  color: #fff; opacity: 0; pointer-events: none;
}
.slideshow-pause-icon.show { animation: pulseIcon .5s ease; }
@keyframes pulseIcon { 0% { opacity: 0; transform: scale(.8); } 30% { opacity: .9; transform: scale(1); } 100% { opacity: 0; } }

/* ---------- Edit sheet ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(10,10,14,.45); z-index: 300; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; background: #fff; z-index: 301; border-radius: 24px 24px 0 0;
  padding: 20px 20px calc(24px + var(--safe-bottom)); max-height: 86vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.sheet-handle { width: 36px; height: 4px; background: #dcdfe4; border-radius: 999px; margin: 0 auto 16px; }
.sheet h3 { font-size: 19px; font-weight: 800; margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1px solid var(--card-border);
  font-size: 15px; font-family: inherit; background: var(--surface); color: var(--ink);
}
.field textarea { resize: vertical; min-height: 70px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.photo-check-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 6px; }
.photo-check { position: relative; border-radius: 10px; overflow: hidden; aspect-ratio: 1; cursor: pointer; border: 2px solid transparent; }
.photo-check.selected { border-color: var(--accent); }
.photo-check img { width: 100%; height: 100%; object-fit: cover; }
.edit-row {
  display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--card-border);
}
.edit-row:last-child { border-bottom: none; }
.icon-btn-row { display: flex; gap: 6px; }
.icon-btn-row button {
  border: none; background: var(--surface); width: 34px; height: 34px; border-radius: 50%; color: var(--ink-soft); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.icon-btn-row button.danger { color: var(--danger); }

@media (min-width: 480px) {
  .thumb-grid { grid-template-columns: repeat(6, 1fr); }
}
