:root {
  --olive-dark: #454A34;
  --olive: #6E7550;
  --olive-soft: #939A72;
  --beige-bg: #F3EEE0;
  --beige-card: #FBF9F1;
  --gold: #B9A06A;
  --line: rgba(69,74,52,0.18);
  --text: #3A3C2E;
  --text-soft: #767A63;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--beige-bg);
  color: var(--text);
  font-family: 'Work Sans', sans-serif;
  font-weight: 400;
  scroll-behavior: smooth;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', serif;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--olive-dark);
  margin: 0;
}

a { color: inherit; }

/* ---------- NAV ---------- */
nav {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(243,238,224,0.92);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  gap: 8px;
}

nav.nav-autohide {
  opacity: 0;
  transition: opacity 0.35s ease;
}
nav.nav-autohide:hover,
nav.nav-autohide:focus-within {
  opacity: 1;
}

.monogram {
  font-family: 'Fraunces', serif;
  font-size: 19px;
  font-style: italic;
  color: var(--olive-dark);
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  gap: 4px;
}

.nav-links button {
  background: none;
  border: none;
  font-family: 'Work Sans', sans-serif;
  font-size: 14px;
  color: var(--text-soft);
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
  white-space: nowrap;
  min-height: 40px;
}

@media (max-width: 400px) {
  .nav-links button { padding: 9px 9px; font-size: 13px; }
  .monogram { font-size: 17px; }
}

.nav-links button.active {
  background: var(--olive-dark);
  color: var(--beige-card);
}

.nav-links button:not(.active):hover {
  background: rgba(69,74,52,0.08);
  color: var(--olive-dark);
}

/* ---------- VIEWS ---------- */
.view { display: none; animation: fadein 0.5s ease; }
.view.active { display: block; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- HERO ---------- */
.hero {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 20px 36px;
  text-align: center;
}

.branch { width: 170px; max-width: 60vw; height: auto; margin-bottom: 16px; }

.crest { width: 210px; max-width: 66vw; height: auto; margin-bottom: 8px; }

.gallery-crest { width: 110px; max-width: 40vw; margin: 0 auto 14px; display: block; }

.heart-accent {
  color: var(--gold);
  font-size: 0.85em;
  padding: 0 1px;
}

.hero p.sub {
  margin-top: 18px;
  font-size: 17px;
  color: var(--text-soft);
  line-height: 1.6;
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
}

.hero-actions {
  margin-top: 30px;
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  font-family: 'Work Sans', sans-serif;
  font-size: 15px;
  padding: 13px 26px;
  border-radius: 3px;
  border: 1px solid var(--olive-dark);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, color 0.2s ease;
  letter-spacing: 0.02em;
  min-height: 46px;
}

@media (max-width: 420px) {
  .hero-actions { flex-direction: column; align-items: stretch; }
}

.btn-solid {
  background: var(--olive-dark);
  color: var(--beige-card);
}
.btn-solid:hover { background: var(--olive); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--olive-dark);
}
.btn-outline:hover { background: rgba(69,74,52,0.08); transform: translateY(-1px); }

.qr-corner {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--beige-card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 14px 12px;
  width: 156px;
  text-align: center;
  z-index: 40;
  box-shadow: 0 4px 14px rgba(69,74,52,0.2);
}
.qr-corner p {
  margin: 6px 0 0;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-soft);
}
#qrcode-gallery { display: flex; justify-content: center; }
#qrcode-gallery img, #qrcode-gallery canvas { width: 100% !important; height: auto !important; border-radius: 3px; }
.qr-fallback { font-size: 12px; color: var(--text-soft); word-break: break-all; }

@media (max-width: 380px) {
  .qr-corner { width: 129px; bottom: 14px; right: 14px; padding: 11px 11px 9px; }
}

/* ---------- SECTION SHELL ---------- */
.section {
  max-width: 620px;
  margin: 0 auto;
  padding: 16px 18px 70px;
}

#view-gallery .section {
  position: relative;
  max-width: 100%;
  padding: 16px 20px 70px;
}

@media (max-width: 480px) {
  .card { padding: 20px 16px; }
  .dropzone { padding: 26px 14px; }
  .submit-row { flex-wrap: wrap; }
  .btn { padding: 13px 22px; }
}

.section-head {
  text-align: center;
  margin-bottom: 30px;
}

.section-head h2 { font-size: 30px; }
.section-head p {
  color: var(--text-soft);
  font-size: 15px;
  margin-top: 8px;
}

/* ---------- UPLOAD ---------- */
.card {
  background: var(--beige-card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 30px;
}

.field { margin-bottom: 20px; }

.field label {
  display: block;
  font-size: 13.5px;
  color: var(--text-soft);
  margin-bottom: 7px;
}

.field input[type="text"] {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #fff;
  font-family: 'Work Sans', sans-serif;
  font-size: 15px;
  color: var(--text);
}
.field input[type="text"]:focus {
  outline: 2px solid var(--olive-soft);
  outline-offset: 1px;
}

.dropzone {
  border: 1.5px dashed var(--olive-soft);
  border-radius: 6px;
  padding: 34px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
  color: var(--text-soft);
  font-size: 14.5px;
}
.dropzone:hover, .dropzone.drag {
  background: rgba(110,117,80,0.08);
  border-color: var(--olive-dark);
}
.dropzone strong { color: var(--olive-dark); }
.dropzone input { display: none; }

.previews {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}
.preview-item {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.preview-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.preview-item button {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  border: none;
  background: rgba(58,60,46,0.75);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

.submit-row {
  margin-top: 24px;
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-msg {
  font-size: 14px;
  color: var(--text-soft);
}
.status-msg.success { color: var(--olive-dark); }
.status-msg.error { color: #9C4A3A; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ---------- GALLERY ---------- */
.gallery-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  font-size: 13.5px;
  color: var(--text-soft);
  flex-wrap: wrap;
  gap: 10px;
}

.refresh-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  color: var(--olive-dark);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.2s ease;
}
.refresh-btn:hover { background: rgba(69,74,52,0.08); }
.refresh-btn svg { width: 13px; height: 13px; }
.refresh-btn.spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 14px;
}
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(4, 1fr); gap: 16px; }
}

.photo-card {
  position: relative;
  background: var(--beige-card);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 9px 9px 30px;
  box-shadow: 0 1px 4px rgba(69,74,52,0.09);
}

.frame-inner {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 2px;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 3px var(--beige-card), inset 0 0 0 4px var(--olive-soft);
}
.frame-inner img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  cursor: pointer;
  transition: transform 0.4s ease;
}
.photo-card:hover .frame-inner img { transform: scale(1.04); }

.frame-monogram {
  position: absolute;
  bottom: 8px; left: 8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(69,74,52,0.72);
  border: 1px solid var(--gold);
  color: var(--beige-card);
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 9.5px;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  pointer-events: none;
}

.photo-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 8px 10px 0;
  text-align: center;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 12px;
  color: var(--text-soft);
  pointer-events: none;
}

.download-btn {
  position: absolute;
  top: 8px; right: 8px;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: none;
  background: rgba(30,32,20,0.55);
  color: #F3EEE0;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease;
  z-index: 2;
}
.download-btn:hover { background: rgba(30,32,20,0.8); }
.download-btn svg { width: 15px; height: 15px; }

.empty-state, .loading-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-soft);
  font-size: 14.5px;
}

/* ---------- LIGHTBOX ---------- */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20,21,14,0.92);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.lightbox.open { display: flex; }

.lb-frame {
  background: var(--beige-card);
  padding: 14px 14px 20px;
  border-radius: 4px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.lb-frame .frame-inner {
  aspect-ratio: unset;
  border-radius: 2px;
  border: 1px solid var(--gold);
  box-shadow: inset 0 0 0 3px var(--beige-card), inset 0 0 0 4px var(--olive-soft);
  max-width: 88vw;
  max-height: 70vh;
  display: flex;
}
.lb-frame .frame-inner img {
  max-width: 88vw;
  max-height: 70vh;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  cursor: default;
}
.lb-frame .frame-monogram {
  width: 40px; height: 40px;
  font-size: 12px;
  bottom: 12px; left: 12px;
}
.lb-frame .lb-info {
  position: static;
  margin-top: 12px;
  font-family: 'Fraunces', serif;
  font-style: italic;
  font-size: 13px;
  color: var(--text-soft);
  text-align: center;
}

.lightbox .lb-close {
  position: absolute;
  top: 18px; right: 20px;
  color: #F3EEE0;
  background: none;
  border: none;
  font-size: 30px;
  cursor: pointer;
  line-height: 1;
  padding: 6px;
}
.lightbox .lb-download {
  position: absolute;
  top: 18px; right: 66px;
  color: #F3EEE0;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 999px;
  font-family: 'Work Sans', sans-serif;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}
.lightbox .lb-download svg { width: 14px; height: 14px; }
.lightbox .lb-info {
  position: absolute;
  bottom: 22px;
  left: 20px; right: 20px;
  color: #E4E0CE;
  font-size: 13px;
  text-align: center;
}
@media (max-width: 480px) {
  .lightbox .lb-download span { display: none; }
  .lightbox .lb-download { padding: 8px; right: 60px; }
}

footer {
  text-align: center;
  padding: 26px;
  font-size: 12.5px;
  color: var(--text-soft);
  border-top: 1px solid var(--line);
}

/* ---------- SLIDESHOW ---------- */
.slideshow-stage {
  min-height: calc(100vh - 66px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 20px 40px;
  position: relative;
  z-index: 1;
}

#view-slideshow {
  position: relative;
}

.slideshow-decor {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.slideshow-decor svg {
  position: absolute;
  opacity: 0.16;
}
.decor-branch { width: 90px; height: 90px; }
.decor-heart { width: 48px; height: 48px; }
.decor-heart-sm { width: 30px; height: 30px; }
.decor-heart-xs { width: 20px; height: 20px; }
.pos-tl { top: 4%; left: 3%; transform: rotate(-15deg); }
.pos-tr { top: 8%; right: 6%; transform: rotate(25deg); }
.pos-bl { bottom: 6%; left: 6%; transform: rotate(205deg); }
.pos-br { bottom: 5%; right: 4%; transform: rotate(-20deg); }
.pos-ml { top: 46%; left: 1.5%; transform: rotate(-95deg); }
.pos-mr { top: 46%; right: 1.5%; transform: rotate(95deg); }
.pos-tc { top: 3%; left: 48%; transform: rotate(10deg); }
.pos-bc { bottom: 4%; left: 50%; transform: rotate(-8deg); }
.pos-cl { top: 22%; left: 13%; transform: rotate(18deg); }
.pos-cr { top: 24%; right: 11%; transform: rotate(-18deg); }
.pos-bl2 { bottom: 22%; left: 22%; transform: rotate(30deg); }
.pos-br2 { bottom: 24%; right: 20%; transform: rotate(-30deg); }
.pos-tl2 { top: 20%; left: 26%; transform: rotate(-25deg); }
.pos-tr2 { top: 18%; right: 24%; transform: rotate(25deg); }

@media (max-width: 640px) {
  .pos-ml, .pos-mr, .pos-cl, .pos-cr, .pos-bl2, .pos-br2, .pos-tl2, .pos-tr2 { display: none; }
  .decor-branch { width: 64px; height: 64px; }
  .decor-heart { width: 34px; height: 34px; }
  .decor-heart-sm { width: 22px; height: 22px; }
}
.slideshow-header { margin-bottom: 4px; text-align: center; }
#view-slideshow .gallery-crest { width: 248px; max-width: 80vw; margin-bottom: 0; }
.slideshow-tagline {
  margin: 12px auto 0;
  font-size: 22px;
  font-style: italic;
  color: var(--olive-dark);
  line-height: 1.4;
  max-width: 560px;
}
.slideshow-grid {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  width: 100%;
}
.slideshow-slot {
  max-width: 570px;
  flex: 1 1 300px;
}
.slideshow-stage .frame-inner {
  aspect-ratio: 1 / 1;
  max-width: min(90vw, 510px);
  max-height: 65vh;
}
.slideshow-stage .frame-inner img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-width: none;
  max-height: none;
  transition: opacity 0.6s ease;
}
.slideshow-stage .empty-state {
  padding: 30px 10px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
