:root {
  --bg: #f7f3ea;
  --bg-card: #fffdf8;
  --ink: #221c14;
  --muted: #7d7362;
  --muted2: #a89d87;
  --line: #e6ddc9;
  --navy: #10203a;
  --navy-soft: #1a2f52;
  --gold: #c89a4a;
  --terracotta: #bb5a3a;
  --shadow: 0 8px 24px rgba(16,32,58,.10);
  --shadow-sm: 0 2px 8px rgba(16,32,58,.08);
  --radius: 16px;
  --font-serif: 'Fraunces', Georgia, serif;
  --font-sans: 'Inter', Arial, Helvetica, sans-serif;
  --heading: var(--navy);
}
:root[data-theme="dark"] {
  --heading: #e9dfc4;
  --bg: #15191f;
  --bg-card: #1e242c;
  --ink: #ece7db;
  --muted: #9a9284;
  --muted2: #6f6a60;
  --line: #2d333c;
  --navy: #0c1626;
  --navy-soft: #16263f;
  --gold: #d7ae66;
  --terracotta: #d4745a;
  --shadow: 0 8px 24px rgba(0,0,0,.35);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

header {
  position: relative;
  background:
    radial-gradient(1200px 400px at 85% -60%, rgba(200,154,74,.16), transparent 60%),
    linear-gradient(135deg, var(--navy) 0%, var(--navy-soft) 100%);
  color: #f6f1e4;
  box-shadow: 0 6px 28px rgba(16,32,58,.22);
  overflow: hidden;
}
header::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
  background: linear-gradient(90deg, transparent, var(--gold) 20%, var(--gold) 80%, transparent);
  opacity: .8;
}
.header-inner { display: flex; justify-content: space-between; align-items: flex-start; padding: 32px 36px 0; }
.brand { display: flex; align-items: flex-start; gap: 14px; }
.brand-mark {
  width: 40px; height: 40px; flex-shrink: 0; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; background: rgba(200,154,74,.16); color: var(--gold); font-size: 17px;
  border: 1px solid rgba(200,154,74,.35); margin-top: 2px;
}
header h1 { font-family: var(--font-serif); font-weight: 600; font-size: 34px; letter-spacing: .3px; margin: 0 0 5px; }
header p { margin: 0; font-size: 13.5px; color: #c3cde0; letter-spacing: .2px; }
.countdown-bar {
  text-align: center; margin: 22px 36px 0; padding: 12px 20px; font-size: 15px; font-weight: 700;
  color: var(--gold); background: rgba(200,154,74,.1); border-top: 1px solid rgba(200,154,74,.25);
  border-bottom: 1px solid rgba(200,154,74,.25); letter-spacing: .03em;
}
.header-right { display: flex; align-items: center; gap: 14px; padding-top: 4px; }
.theme-toggle {
  background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.2);
  width: 36px; height: 36px; border-radius: 50%; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s ease;
}
.theme-toggle:hover { background: rgba(255,255,255,.22); }
#authArea { padding-top: 0; }
#authArea button {
  background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.2);
  border-radius: 999px; padding: 10px 20px; font-size: 13px; cursor: pointer; font-family: var(--font-sans);
  font-weight: 600; transition: background .15s ease, transform .15s ease;
}
#authArea button:hover { background: rgba(255,255,255,.26); transform: translateY(-1px); }
#authArea .who { font-size: 13px; color: #d7dfed; display: flex; align-items: center; gap: 12px; }
#authArea .who button { background: transparent; border: none; text-decoration: underline; padding: 0; font-weight: 400; }

.tabs-row { padding: 26px 36px 0; }
nav.tabs {
  display: inline-flex; gap: 4px; background: rgba(255,255,255,.07); padding: 5px; border-radius: 14px;
  border: 1px solid rgba(255,255,255,.08);
}
nav.tabs button {
  background: transparent; border: none; color: #b7c1d6; font-size: 14.5px; font-family: var(--font-sans);
  font-weight: 600; padding: 11px 22px; cursor: pointer; border-radius: 10px; display: flex; align-items: center;
  gap: 8px; transition: all .18s ease;
}
.tab-ico { font-size: 15px; filter: grayscale(.3); }
nav.tabs button.active { color: var(--navy); background: #f6f1e4; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
nav.tabs button:not(.active):hover { color: #fff; background: rgba(255,255,255,.08); }

main { max-width: 1900px; margin: 0 auto; padding: 0; }
.view { padding: 28px 28px; }

#mapLayout { display: flex; gap: 20px; height: 540px; }
#sidebar {
  width: 248px; flex-shrink: 0; overflow-y: auto; overflow-x: hidden; background: var(--bg-card);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm);
}
#sidebar h4.sidebar-title {
  font-family: var(--font-serif); font-size: 15px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; margin: 0 0 14px;
}
.daylist { display: flex; flex-direction: column; gap: 7px; }
.daylist .chip {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; padding: 11px 14px;
  border-radius: 12px; font-size: 14px;
}
.chip .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; display: inline-block; margin-right: 2px; }
.daylist .chip.active { box-shadow: 0 4px 12px rgba(16,32,58,.18); }
.sidebar-hint { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.5; }

#map { flex: 1; min-width: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
@media (max-width: 820px) {
  #mapLayout { flex-direction: column; height: auto; }
  #sidebar { width: 100%; order: 2; }
  .daylist { flex-direction: row; flex-wrap: wrap; }
  .daylist .chip { width: auto; text-align: center; }
  #map { height: 440px; order: 1; }
}

.chiprow { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 14px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: var(--bg-card); color: var(--muted); border-radius: 999px;
  padding: 7px 15px; font-size: 13px; cursor: pointer; white-space: nowrap; font-family: var(--font-sans);
  font-weight: 600; transition: all .15s ease;
}
.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip.active { color: #fff; border-color: transparent; box-shadow: var(--shadow-sm); }
.chip.active-navy { background: var(--navy); }

.gallery-filters { display: flex; flex-wrap: wrap; gap: 28px; margin-bottom: 8px; }
.filter-label {
  font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase;
  letter-spacing: .07em; margin: 0 0 8px;
}

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid .ph {
  display: block; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--line);
  position: relative; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease;
}
.grid .ph:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .ph .tag {
  position: absolute; left: 6px; bottom: 6px; font-size: 10px; font-weight: 600; color: #fff;
  background: rgba(16,32,58,.68); padding: 3px 9px; border-radius: 999px; letter-spacing: .2px;
}
.empty { color: var(--muted); font-size: 14px; padding: 10px 0; font-family: var(--font-sans); }

#sidebar h3 { font-family: var(--font-serif); font-weight: 600; font-size: 22px; color: var(--heading); margin: 0 0 4px; }
#sidebar .count { font-size: 13px; color: var(--muted); margin: 0 0 14px; }

.trip-pin {
  width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; color: #fff;
  font-size: 11px; font-weight: 700; font-family: var(--font-sans); border: 3px solid #fff;
  border-radius: 50%; box-shadow: 0 3px 10px rgba(16,32,58,.35); transition: transform .15s ease;
}
.trip-pin:hover { transform: scale(1.15); }

.fab {
  position: fixed; right: 22px; bottom: 22px; width: 60px; height: 60px; border-radius: 30px;
  background: var(--terracotta); color: #fff; border: none; font-size: 28px;
  box-shadow: 0 8px 22px rgba(187,90,58,.42); cursor: pointer; display: flex; align-items: center;
  justify-content: center; z-index: 20; transition: transform .15s ease, box-shadow .15s ease;
}
.fab:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(187,90,58,.5); }

.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(16,20,30,.5); backdrop-filter: blur(2px);
  z-index: 1000; display: none; place-items: center; padding: 16px;
}
.sheet-backdrop.open { display: grid; }
.sheet {
  background: var(--bg-card); width: 100%; max-width: 480px; border-radius: 20px; padding: 28px 24px;
  max-height: 86vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(16,32,58,.3);
}
.sheet h2 { font-family: var(--font-serif); font-weight: 600; font-size: 26px; margin: 0 0 4px; color: var(--heading); }
.sheet .subt { font-size: 13px; color: var(--muted); margin: 0 0 16px; }

.authTabs { display: flex; gap: 6px; margin-bottom: 20px; background: var(--bg); padding: 4px; border-radius: 12px; }
.authTabs button {
  flex: 1; background: transparent; border: none; border-radius: 9px; padding: 10px; cursor: pointer;
  font-family: var(--font-sans); font-weight: 600; color: var(--muted); transition: all .15s ease;
}
.authTabs button.active { background: var(--navy); color: #fff; }

.field { margin-bottom: 15px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.field select, .field input {
  width: 100%; padding: 11px 13px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg);
  color: var(--ink); font-size: 15px; font-family: var(--font-sans); transition: border-color .15s ease;
}
.field select:focus, .field input:focus { outline: none; border-color: var(--gold); }

.filebtn {
  display: flex; align-items: center; justify-content: center; gap: 10px; border: 2px dashed var(--line);
  border-radius: 16px; padding: 28px; cursor: pointer; color: var(--muted); font-size: 15px; margin-bottom: 16px;
  transition: border-color .15s ease, color .15s ease;
}
.filebtn:hover { border-color: var(--gold); color: var(--ink); }
.filebtn.has-file { border-color: var(--gold); color: var(--ink); background: rgba(200,154,74,.08); }

.actions { display: flex; gap: 10px; }
button.primary {
  flex: 1; background: var(--navy); color: #fff; border: none; border-radius: 12px; padding: 13px;
  font-size: 15px; font-weight: 700; cursor: pointer; font-family: var(--font-sans); transition: background .15s ease;
}
button.primary:hover { background: var(--navy-soft); }
button.secondary {
  background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 16px; cursor: pointer; font-family: var(--font-sans); font-weight: 600; transition: border-color .15s ease;
}
button.secondary:hover { border-color: var(--muted2); }
.status { font-size: 13px; color: var(--terracotta); margin-top: 8px; min-height: 16px; font-weight: 500; }

.maps-link {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--heading); font-weight: 600;
  background: var(--line); border-radius: 999px; padding: 7px 14px; text-decoration: none; margin-bottom: 14px;
  transition: background .15s ease;
}
.maps-link:hover { background: var(--gold); color: #fff; }
.place-add-btn {
  width: 100%; background: var(--terracotta); color: #fff; border: none; border-radius: 12px; padding: 13px;
  font-size: 15px; font-weight: 700; cursor: pointer; margin-top: 16px; font-family: var(--font-sans);
  transition: filter .15s ease;
}
.place-add-btn:hover { filter: brightness(1.08); }

.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); background: var(--navy); color: #fff;
  padding: 11px 20px; border-radius: 999px; font-size: 14px; z-index: 40; opacity: 0; transition: opacity .25s;
  pointer-events: none; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; }

/* Stats strip */
.stats-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card { background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-card .num { font-family: var(--font-serif); font-size: 28px; font-weight: 600; color: var(--heading); line-height: 1; margin: 0 0 4px; }
.stat-card .lbl { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Guestbook */
.guestbook-view { max-width: 720px; margin: 0 auto; }
.guestbook-form { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.guestbook-form .field { flex: 1; min-width: 160px; margin-bottom: 0; }
.guestbook-entry { background: var(--bg-card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.guestbook-entry .gb-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.guestbook-entry .gb-name { font-family: var(--font-serif); font-weight: 600; color: var(--heading); font-size: 15px; }
.guestbook-entry .gb-date-row { display: flex; align-items: center; gap: 8px; }
.guestbook-entry .gb-date { font-size: 11px; color: var(--muted2); }
.guestbook-entry .gb-delete {
  background: transparent; border: none; color: var(--muted2); font-size: 18px; line-height: 1; cursor: pointer;
  padding: 0 2px; transition: color .15s ease;
}
.guestbook-entry .gb-delete:hover { color: var(--terracotta); }
.guestbook-entry .gb-msg { font-size: 14px; color: var(--ink); line-height: 1.5; }

/* Upload progress */
.progress-track { width: 100%; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 10px; }
.progress-fill { height: 100%; width: 0%; background: var(--terracotta); transition: width .2s ease; }

/* Drag and drop onto the file picker */
.filebtn.dragover { border-color: var(--terracotta); background: rgba(187,90,58,.08); color: var(--ink); }

/* QR / share */
.qr-container { display: flex; justify-content: center; margin: 16px 0; }
.qr-container svg { width: 200px; height: 200px; }
.qr-url { font-size: 13px; color: var(--muted); word-break: break-all; margin: 0 0 18px; }

/* Reactions */
.reaction-row { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; margin-bottom: 4px; }
.reaction-btn {
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.18); color: #f0ece0;
  border-radius: 999px; padding: 6px 12px; font-size: 14px; cursor: pointer; display: flex; align-items: center;
  gap: 6px; font-family: var(--font-sans); transition: background .15s ease, transform .1s ease;
}
.reaction-btn:hover { background: rgba(255,255,255,.18); }
.reaction-btn:active { transform: scale(0.94); }
.reaction-btn .rcount { font-size: 12px; color: #c9c2b2; min-width: 10px; text-align: left; }

/* Lightbox caption editing */
.lightbox-edit-row { display: flex; gap: 8px; width: 100%; margin-bottom: 10px; }
.lightbox-edit-row input { flex: 1; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--line); font-family: var(--font-sans); font-size: 14px; }

/* Lightbox */
.lightbox-backdrop { background: rgba(10,14,22,.86); }
.lightbox-backdrop.open { display: flex; align-items: center; justify-content: center; }
.lightbox { display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 92vw; max-height: 92vh; }
.lightbox img { max-width: 92vw; max-height: 76vh; object-fit: contain; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; color: #f0ece0; }
.lightbox-bar #lightboxCaption { font-size: 13px; color: #d7d0bf; }
.lightbox-actions { display: flex; gap: 10px; }
.lightbox-actions .place-add-btn { margin-top: 0; width: auto; padding: 11px 18px; display: inline-flex; align-items: center; text-decoration: none; }
.lightbox-actions .secondary { border-color: rgba(255,255,255,.3); color: #e8e4d8; }
.lightbox-counter { font-size: 13px; color: #a9a290; }
.grid .ph { cursor: zoom-in; }

.lightbox-nav {
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.2); color: #fff;
  width: 48px; height: 48px; border-radius: 50%; font-size: 26px; cursor: pointer; z-index: 1010;
  display: flex; align-items: center; justify-content: center; transition: background .15s ease;
  flex-shrink: 0; margin: 0 16px;
}
.lightbox-nav:hover { background: rgba(255,255,255,.22); }
@media (max-width: 700px) {
  .lightbox-backdrop { flex-direction: column; }
  .lightbox-nav { position: absolute; top: 50%; transform: translateY(-50%); margin: 0; }
  .lightbox-nav-prev { left: 8px; } .lightbox-nav-next { right: 8px; }
}

/* Itinerary timeline */
.itin-view { max-width: 820px; margin: 0 auto; }
.day-block { background: var(--bg-card); border: 1px solid var(--line); border-radius: var(--radius); padding: 26px 28px; margin-bottom: 20px; box-shadow: var(--shadow-sm); }
.day-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.day-badge {
  width: 42px; height: 42px; border-radius: 50%; color: #fff; display: flex; align-items: center;
  justify-content: center; font-family: var(--font-serif); font-weight: 600; font-size: 18px; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.day-head h2 { font-family: var(--font-serif); font-weight: 600; font-size: 21px; margin: 0; color: var(--heading); }
.day-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.weather-chip {
  margin-left: auto; font-size: 12px; color: var(--muted); background: var(--bg); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 12px; white-space: nowrap; flex-shrink: 0;
}
@media (max-width: 560px) { .weather-chip { margin-left: 0; margin-top: 8px; } }

.tl-row { display: flex; gap: 16px; align-items: stretch; }
.tl-marker { width: 22px; display: flex; flex-direction: column; align-items: center; }
.tl-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--gold); flex-shrink: 0; margin-top: 2px; }
.tl-dot.strong { background: var(--navy); }
.tl-dot.small { width: 7px; height: 7px; background: var(--muted2); margin-top: 7px; }
.tl-line { width: 2px; flex: 1; background: var(--line); margin-top: 4px; }
.tl-body { flex: 1; padding: 0 0 16px; }
.tl-time { font-size: 12.5px; color: var(--gold); font-weight: 700; margin: 0 0 2px; text-transform: uppercase; letter-spacing: .03em; }
.tl-title { font-size: 15.5px; margin: 0; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--ink); }
.tl-sub { font-size: 13px; color: var(--muted); font-style: italic; margin: 1px 0 0; }
.tl-tag { font-size: 11px; color: var(--muted); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.tl-photos-btn {
  font-size: 11.5px; color: var(--heading); background: rgba(200,154,74,.14); border: none;
  border-radius: 999px; padding: 4px 11px; cursor: pointer; font-family: var(--font-sans); font-weight: 600;
  transition: background .15s ease;
}
.tl-photos-btn:hover { background: rgba(200,154,74,.3); }
