/* =====================================================================
   Vandai Memorial — Full Stylesheet
   Palette:
     Gold       #C9A96E   (primary)
     Gold dark  #b8934d
     Brown 900  #2C1810   (headings)
     Brown 700  #3a2818   (body text)
     Brown 500  #5a4639
     Brown 400  #8B7355   (subtle text / dates)
     Cream      #faf7f3 / #f5f0eb (backgrounds)
   Typography:
     Headings: 'Cormorant Garamond', Georgia, serif
     Body:     'Inter', system-ui, sans-serif
   ===================================================================== */

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #faf7f3;
  color: #3a2818;
  min-height: 100vh;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, iframe { max-width: 100%; display: block; }
img { height: auto; }
a { color: #b8934d; text-decoration: none; transition: color 0.2s; }
a:hover { color: #8b6f5e; text-decoration: underline; }

/* -------------------------------------------------- 2. Layout */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem;
}
.container-narrow {
  max-width: 720px;
}

.section {
  padding: 4.5rem 0;
}
.section + .section { /* subtle separation */ }
.section-funeral { background: #f5f0eb; }
.section-story   { background: #faf7f3; }
.section-gallery { background: #f5f0eb; }
.section-playlist{ background: #faf7f3; }
.section-guestbook { background: #f5f0eb; }

/* -------------------------------------------------- 3. Typography */
h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  color: #2C1810;
  font-weight: 500;
  line-height: 1.2;
}

.section-title {
  font-size: clamp(2rem, 4vw, 2.6rem);
  text-align: center;
  margin-bottom: 0.5rem;
  letter-spacing: 0.02em;
}

.section-subtitle {
  text-align: center;
  color: #8B7355;
  font-style: italic;
  font-size: 1.05rem;
  max-width: 620px;
  margin: 0 auto 3rem;
  line-height: 1.6;
}

.eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: #8B7355;
  text-align: center;
}

.optional {
  color: #8B7355;
  font-weight: 400;
  font-size: 0.85em;
  font-style: italic;
}

/* Divider */
.divider {
  width: 60px;
  height: 1px;
  background: #C9A96E;
  margin: 1.5rem auto;
  position: relative;
}
.divider::before,
.divider::after {
  content: '';
  width: 5px;
  height: 5px;
  background: #C9A96E;
  border-radius: 50%;
  position: absolute;
  top: -2px;
}
.divider::before { left: -10px; }
.divider::after  { right: -10px; }

.divider-small {
  width: 40px;
  margin: 1rem auto;
}

/* -------------------------------------------------- 4. Hero */
.hero {
  min-height: 90vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 5rem 1.5rem 4rem;
  background: linear-gradient(180deg, #fdf6f0 0%, #f7ede2 60%, #efe0d3 100%);
  text-align: center;
  position: relative;
}

.hero-inner {
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.portrait {
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  border: 4px solid #fff;
  box-shadow: 0 8px 28px rgba(44,24,16,0.18);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 2rem;
  background-size: cover;
  background-position: center;
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.portrait-label {
  color: #8B7355;
  font-style: italic;
  font-size: 0.95rem;
  letter-spacing: 0.1em;
}
.portrait:has(img) .portrait-label { display: none; }

.section-photo-btn {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(44,24,16,0.85);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  cursor: pointer;
  display: none; /* visible only in edit mode */
  white-space: nowrap;
  font-family: 'Inter', sans-serif;
}
body.editing .section-photo-btn { display: inline-block; }
.section-photo-btn:hover { background: #2C1810; }

.hero-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: clamp(2.6rem, 6vw, 4.2rem);
  font-weight: 500;
  color: #2C1810;
  margin: 0.5rem 0 0.3rem;
  letter-spacing: 0.01em;
}

.hero-dates {
  font-size: 1.1rem;
  color: #8B7355;
  font-style: italic;
  letter-spacing: 0.05em;
}

.hero-tagline {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.4rem;
  color: #5a4639;
  font-style: italic;
  margin-top: 0.5rem;
  max-width: 560px;
  line-height: 1.5;
}

.scroll-hint {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  color: #C9A96E;
  font-size: 1.8rem;
  animation: bounce 2.5s ease-in-out infinite;
  user-select: none;
}
@keyframes bounce {
  0%, 100% { transform: translate(-50%, 0); opacity: 0.5; }
  50%      { transform: translate(-50%, 8px); opacity: 1; }
}

/* -------------------------------------------------- 5. Funeral Section */
.funeral-card {
  background: #fff;
  border-radius: 8px;
  border-left: 3px solid #C9A96E;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 2.5rem;
  margin-top: 1rem;
}

.funeral-details {
  display: flex;
  flex-direction: column;
  gap: 1.3rem;
  margin-bottom: 1.8rem;
}
.funeral-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  line-height: 1.5;
}
.funeral-row strong {
  color: #2C1810;
  font-weight: 600;
  display: block;
  margin-bottom: 0.15rem;
}
.funeral-row span {
  color: #5a4639;
}
.funeral-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1.2;
}

.funeral-map {
  margin: 1.5rem 0 1.5rem;
}
.map-link { display: block; text-decoration: none; }
.map-link:hover { text-decoration: none; }
.map-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  background: #f5f0eb;
  border: 1px dashed #C9A96E;
  border-radius: 8px;
  padding: 1.2rem;
  color: #5a4639;
  font-weight: 500;
  transition: background 0.2s, border-color 0.2s;
}
.map-placeholder:hover {
  background: #efe0d3;
  border-color: #b8934d;
  border-style: solid;
}
.map-pin { font-size: 1.3rem; }

.funeral-note {
  text-align: center;
  color: #5a4639;
  font-style: italic;
  margin: 1.5rem 0 0;
  line-height: 1.6;
}

.funeral-donate {
  display: flex;
  justify-content: center;
  margin: 1.8rem 0 0.5rem;
}

/* Speaker prompt + form */
.funeral-speaker {
  margin-top: 2rem;
  padding-top: 1.8rem;
  border-top: 1px solid #f0e6da;
  text-align: center;
}
.funeral-speaker-prompt {
  color: #5a4639;
  margin-bottom: 1rem;
  font-style: italic;
  line-height: 1.5;
}

.speaker-form-wrap {
  margin-top: 1.2rem;
  background: #faf7f3;
  border: 1px solid #f0e6da;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: left;
  animation: fadeSlideIn 0.35s ease;
}

.speaker-form .form-row { margin-bottom: 1rem; }
.speaker-form .form-row:last-of-type { margin-bottom: 1.25rem; }
.speaker-form .form-status { margin-top: 0.75rem; }

/* Speaker list */
.speaker-list {
  margin-top: 1.8rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f0e6da;
}
.speaker-list-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.4rem;
  color: #2C1810;
  text-align: center;
  margin-bottom: 1rem;
  font-weight: 500;
}
.speaker-ol {
  list-style: decimal inside;
  max-width: 480px;
  margin: 0 auto;
  color: #3a2818;
  line-height: 1.9;
  padding-left: 0;
}
.speaker-ol li {
  padding: 0.25rem 0;
  border-bottom: 1px dashed #f0e6da;
}
.speaker-ol li:last-child { border-bottom: none; }
.spkr-name {
  font-weight: 600;
  color: #2C1810;
}
.spkr-topic {
  color: #8B7355;
  font-style: italic;
  font-size: 0.92em;
  margin-left: 0.25rem;
}

/* -------------------------------------------------- 6. Buttons */
.btn-gold,
button.btn-gold {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.8rem;
  background: #C9A96E;
  color: #fff;
  border: none;
  border-radius: 50px;
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
  text-decoration: none;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(201,169,110,0.25);
}
.btn-gold:hover,
button.btn-gold:hover {
  background: #b8934d;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201,169,110,0.4);
  color: #fff;
  text-decoration: none;
}
.btn-gold:active { transform: translateY(0); }

.btn-donate {
  background: linear-gradient(135deg, #d4b27a 0%, #b8934d 100%);
}
.btn-donate:hover {
  background: linear-gradient(135deg, #C9A96E 0%, #a8843d 100%);
}

.btn-speaker {
  background: transparent;
  color: #b8934d;
  border: 2px solid #C9A96E;
  box-shadow: none;
}
.btn-speaker:hover {
  background: #C9A96E;
  color: #fff;
}

/* -------------------------------------------------- 7. Forms */
.form-row {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}
.form-row label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #5a4639;
  margin-bottom: 0.4rem;
  letter-spacing: 0.02em;
}
.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  padding: 0.7rem 0.95rem;
  font-size: 0.95rem;
  font-family: 'Inter', sans-serif;
  color: #2C1810;
  background: #fff;
  border: 1px solid #e6dccf;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-row input:focus,
.form-row textarea:focus {
  border-color: #C9A96E;
  box-shadow: 0 0 0 3px rgba(201,169,110,0.15);
}
.form-row textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.6;
}
.form-row input[type="file"] {
  padding: 0.55rem;
  background: #faf7f3;
  cursor: pointer;
}

.form-row-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-row-split .form-row { margin-bottom: 0; }

.form-status {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #5a4639;
  min-height: 1.2em;
}
.form-status.error { color: #c44; }
.form-status.success { color: #4a7a3a; }

/* -------------------------------------------------- 8. Timeline / Life Story */
.timeline {
  position: relative;
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem 0;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, transparent 0%, #C9A96E 8%, #C9A96E 92%, transparent 100%);
  transform: translateX(-50%);
}

.timeline-item {
  position: relative;
  width: 50%;
  padding: 1.5rem 2.5rem;
}
.timeline-item.left  { left: 0;   text-align: right; }
.timeline-item.right { left: 50%; text-align: left;  }

.timeline-item::before {
  content: '';
  position: absolute;
  top: 2rem;
  width: 14px;
  height: 14px;
  background: #C9A96E;
  border: 3px solid #faf7f3;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #C9A96E;
  z-index: 2;
}
.timeline-item.left::before  { right: -7px; }
.timeline-item.right::before { left: -7px;  }

.timeline-content {
  background: #fff;
  border-radius: 8px;
  border-left: 3px solid #C9A96E;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 1.8rem 1.8rem 1.6rem;
  position: relative;
  text-align: left; /* keep body LTR even when item is right-aligned */
}
.timeline-item.left .timeline-content { border-left: none; border-right: 3px solid #C9A96E; }
.timeline-content h3 {
  font-size: 1.5rem;
  color: #2C1810;
  margin-bottom: 0.6rem;
  text-align: left;
}
.timeline-content p {
  color: #3a2818;
  font-size: 1rem;
  line-height: 1.75;
}

/* -------------------------------------------------- 9. Flipbook (inside timeline cards) */
.flipbook {
  position: relative;
  margin-top: 1.2rem;
  display: none; /* hidden when empty AND not editing */
}
.flipbook:not(.is-empty),
.flipbook.is-editing {
  display: block;
}

.flipbook-viewport {
  position: relative;
  width: 100%;
  background: #f5f0eb;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 4 / 3;
}
.flipbook-viewport img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
}

.flipbook-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(44,24,16,0.55);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  z-index: 3;
}
.flipbook-arrow:hover { background: rgba(44,24,16,0.85); }
.flipbook-prev { left: 0.6rem; }
.flipbook-next { right: 0.6rem; }

.flipbook-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 0.6rem;
}
.flipbook-dot {
  width: 8px;
  height: 8px;
  background: #d8c9b3;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}
.flipbook-dot.active { background: #C9A96E; transform: scale(1.25); }

.flipbook-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.7rem 1rem;
  background: #faf7f3;
  border: 1px dashed #C9A96E;
  border-radius: 6px;
  color: #b8934d;
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}
.flipbook-add:hover { background: #f5e9d3; }

.flipbook-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(196,68,68,0.9);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}
.flipbook-remove:hover { background: #a83232; }

/* -------------------------------------------------- 10. Gallery / Carousel */
.section-gallery .container { max-width: 1100px; }

.carousel {
  position: relative;
  margin: 0 auto;
  max-width: 900px;
  padding: 0 3.2rem;
}

.carousel-track {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #C9A96E #f5f0eb;
  border-radius: 8px;
  box-shadow: 0 4px 24px rgba(44,24,16,0.12);
  background: #f5f0eb;
  gap: 0.5rem;
  padding: 0.5rem;
}
.carousel-slide {
  flex: 0 0 auto;
  width: 250px;
  scroll-snap-align: start;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}
.carousel-slide img {
  display: block;
  width: 250px;
  height: 250px;
  object-fit: cover;
  cursor: zoom-in;
}

.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  color: #2C1810;
  border: 1px solid #e6dccf;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  transition: background 0.2s, color 0.2s, transform 0.15s;
  z-index: 3;
}
.carousel-arrow:hover {
  background: #C9A96E;
  color: #fff;
  border-color: #C9A96E;
  transform: translateY(-50%) scale(1.05);
}
.carousel-arrow-prev { left: 0; }
.carousel-arrow-next { right: 0; }

.carousel-dots {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 1rem;
}
.carousel-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #d8c9b3;
  border: none;
  cursor: pointer;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}
.carousel-dot.active { background: #C9A96E; transform: scale(1.3); }

/* -------------------------------------------------- 11. Music / Playlist */
.section-playlist .container { text-align: center; }
.spotify-embed {
  max-width: 640px;
  margin: 1.5rem auto 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(44,24,16,0.1);
}
.spotify-embed iframe { display: block; width: 100%; }

.music-toggle {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1999;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: #C9A96E;
  color: #fff;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(44,24,16,0.25);
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.music-toggle:hover { transform: scale(1.1); background: #b8934d; }

@keyframes pulseHighlight {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,169,110,0); }
  50%      { box-shadow: 0 0 0 14px rgba(201,169,110,0.3); }
}
.pulse-highlight { animation: pulseHighlight 2s ease; }

/* -------------------------------------------------- 12. Memory Wall (Guestbook) */
.message-form {
  background: #fff;
  border-radius: 8px;
  border-left: 3px solid #C9A96E;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 2rem;
  margin-bottom: 2.5rem;
}
.message-form .form-row { margin-bottom: 1.1rem; }
.message-form > .btn-gold { margin-top: 0.5rem; }

.messages {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.messages-empty {
  text-align: center;
  color: #8B7355;
  font-style: italic;
  padding: 2rem;
}

/* Individual message card */
.message-card {
  position: relative;
  background: #fff;
  border-radius: 8px;
  border-left: 3px solid #C9A96E;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
  padding: 1.6rem 1.8rem;
  transition: box-shadow 0.2s;
}
.message-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,0.07);
}

.message-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #f5f0eb;
}
.message-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: #2C1810;
}
.message-date {
  font-size: 0.82rem;
  color: #8B7355;
  font-style: italic;
}

.message-body {
  color: #3a2818;
  line-height: 1.75;
  font-size: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.message-media {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

/* Single photo wrap (with caption overlay) */
.comment-photo-wrap {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f0eb;
  max-width: 540px;
}
.comment-photo {
  display: block;
  width: 100%;
  height: auto;
  cursor: zoom-in;
  max-height: 480px;
  object-fit: cover;
}
.comment-photo-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, rgba(44,24,16,0) 0%, rgba(44,24,16,0.78) 100%);
  color: #fff;
  padding: 1.6rem 1rem 0.85rem;
  font-size: 0.88rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  pointer-events: none;
}
.caption-name {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.02em;
}
.caption-text {
  opacity: 0.92;
  font-style: italic;
  line-height: 1.4;
}

/* Multi-photo gallery (inside a single message card) */
.message-gallery {
  position: relative;
  width: 100%;
  max-width: 540px;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #f5f0eb;
}
.message-gallery-track {
  position: absolute;
  inset: 0;
  display: flex;
  width: 100%;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  background: #f5f0eb;
}
.message-gallery-track::-webkit-scrollbar { display: none; }
.message-gallery-slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  position: relative;
  background: #f5f0eb;
  overflow: hidden;
}
.message-gallery-slide img,
.message-gallery-slide .comment-photo {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  border-radius: 0;
  box-shadow: none;
  cursor: zoom-in;
}
.message-gallery-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 5;
  background: rgba(44,24,16,0.55);
  color: #fff;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  transition: background 0.2s;
}
.message-gallery-arrow:hover { background: rgba(44,24,16,0.85); }
.message-gallery-prev { left: 0.6rem; }
.message-gallery-next { right: 0.6rem; }
.message-gallery .comment-photo-caption {
  background: linear-gradient(180deg, rgba(44,24,16,0) 0%, rgba(44,24,16,0.78) 100%);
}

/* Video embed */
.comment-video {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 */
  height: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #000;
  max-width: 720px;
}
.comment-video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* -------------------------------------------------- 13. Edit-mode buttons on message cards */
.msg-edit-btn,
.msg-delete-btn,
.msg-add-photos-btn {
  display: none; /* hidden by default; revealed in editing mode */
  position: absolute;
  background: #fff;
  border: 1px solid #e6dccf;
  border-radius: 50px;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  padding: 0.3rem 0.6rem;
  color: #5a4639;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.msg-edit-btn {
  top: 0.6rem;
  right: 2.4rem;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  display: none;
}
.msg-delete-btn {
  top: 0.6rem;
  right: 0.6rem;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 50%;
  color: #c44;
  display: none;
}
.msg-add-photos-btn {
  bottom: 0.6rem;
  right: 0.6rem;
  padding: 0.35rem 0.75rem;
  display: none;
}
body.editing .msg-edit-btn,
body.editing .msg-delete-btn,
body.editing .msg-add-photos-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.msg-edit-btn:hover { background: #C9A96E; color: #fff; border-color: #C9A96E; }
/* Always visible */
.msg-edit-btn,
.msg-delete-btn,
.msg-add-photos-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.msg-delete-btn:hover { background: #c44; color: #fff; border-color: #c44; }
.msg-add-photos-btn:hover { background: #C9A96E; color: #fff; border-color: #C9A96E; }

/* Inline edit form */
.msg-edit-name-input,
.msg-edit-body-input {
  width: 100%;
  padding: 0.55rem 0.8rem;
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  color: #2C1810;
  border: 1px solid #C9A96E;
  border-radius: 6px;
  background: #faf7f3;
  outline: none;
}
.msg-edit-body-input { min-height: 110px; resize: vertical; line-height: 1.6; }
.msg-edit-name-input:focus,
.msg-edit-body-input:focus {
  box-shadow: 0 0 0 3px rgba(201,169,110,0.2);
}

.msg-edit-actions {
  margin-top: 0.8rem;
  display: flex;
  gap: 0.6rem;
}
.msg-edit-save,
.msg-edit-cancel {
  padding: 0.45rem 1rem;
  border-radius: 50px;
  font-family: 'Inter', sans-serif;
  font-size: 0.88rem;
  cursor: pointer;
  border: none;
  transition: background 0.2s, color 0.2s;
}
.msg-edit-save {
  background: #C9A96E;
  color: #fff;
}
.msg-edit-save:hover { background: #b8934d; }
.msg-edit-cancel {
  background: transparent;
  color: #5a4639;
  border: 1px solid #d8c9b3;
}
.msg-edit-cancel:hover { background: #faf7f3; border-color: #C9A96E; }

.msg-photos-upload-wrap {
  margin-top: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.msg-photos-status {
  font-size: 0.82rem;
  color: #5a4639;
  font-style: italic;
}

/* -------------------------------------------------- 14. Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(20,12,8,0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 1.5rem;
  cursor: zoom-out;
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lightbox.open {
  display: flex;
  opacity: 1;
}
.lightbox-content {
  position: relative;
  max-width: min(95vw, 1200px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  cursor: default;
}
.lightbox img,
#lightbox-img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  background: #1a110b;
}
.lightbox-close {
  position: absolute;
  top: -2.5rem;
  right: 0;
  background: transparent;
  color: #fff;
  border: none;
  font-size: 2.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  opacity: 0.8;
  transition: opacity 0.2s, transform 0.2s;
}
.lightbox-close:hover { opacity: 1; transform: scale(1.1); }
.lightbox-caption {
  color: #f7ede2;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.05rem;
  text-align: center;
  font-style: italic;
  max-width: 720px;
  line-height: 1.5;
  min-height: 1.5em;
  padding: 0 0.5rem;
}
.lightbox-caption[contenteditable="true"] {
  background: rgba(255,255,255,0.06);
  border: 1px dashed rgba(255,255,255,0.3);
  border-radius: 6px;
  padding: 0.3rem 0.6rem;
  outline: none;
}

/* -------------------------------------------------- 15. Edit mode (global) */
.edit-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1500;
  background: rgba(44,24,16,0.85);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  cursor: pointer;
  display: none; /* shown via JS when ?edit=1 */
  letter-spacing: 0.02em;
}
.edit-toggle.visible { display: inline-flex; align-items: center; gap: 0.3rem; }
.edit-toggle[aria-pressed="true"] {
  background: #C9A96E;
}

body.editing [contenteditable] {
  outline: 1px dashed rgba(201,169,110,0.5);
  outline-offset: 4px;
  border-radius: 3px;
  transition: outline-color 0.2s, background 0.2s;
}
body.editing [contenteditable]:hover {
  outline-color: #C9A96E;
  background: rgba(201,169,110,0.06);
}
body.editing [contenteditable]:focus {
  outline: 2px solid #C9A96E;
  background: rgba(201,169,110,0.1);
}
body.editing [contenteditable].dirty {
  outline-color: #b8934d;
}

/* Save status pill */
.save-status {
  position: fixed;
  bottom: 5.5rem;
  right: 1.5rem;
  background: rgba(44,24,16,0.9);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 2000;
  font-family: 'Inter', sans-serif;
}
.save-status.visible {
  opacity: 1;
  transform: translateY(0);
}
.save-status.error { background: #c44; }

/* -------------------------------------------------- 16. Fade-in animations */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}
.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------- 17. Footer */
.footer {
  background: #2C1810;
  color: #d8c9b3;
  padding: 3rem 0 2rem;
  text-align: center;
}
.footer .divider { background: #C9A96E; opacity: 0.5; }
.footer-line {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.4rem;
  font-style: italic;
  color: #f5f0eb;
  margin-bottom: 0.5rem;
}
.footer-copy {
  font-size: 0.85rem;
  color: #8B7355;
  letter-spacing: 0.05em;
}

/* -------------------------------------------------- 18. Responsive */
@media (max-width: 900px) {
  .timeline::before { left: 22px; }
  .timeline-item,
  .timeline-item.left,
  .timeline-item.right {
    width: 100%;
    left: 0;
    padding: 1rem 1rem 1rem 3rem;
    text-align: left;
  }
  .timeline-item.left::before,
  .timeline-item.right::before {
    left: 15px;
    right: auto;
  }
  .timeline-item.left .timeline-content {
    border-right: none;
    border-left: 3px solid #C9A96E;
  }
}

@media (max-width: 720px) {
  .section { padding: 3rem 0; }
  .hero { min-height: 80vh; padding: 4rem 1rem 3rem; }
  .portrait { width: 170px; height: 170px; }
  .hero-name { font-size: 2.6rem; }
  .hero-tagline { font-size: 1.15rem; }

  .funeral-card { padding: 1.6rem; }
  .funeral-row { gap: 0.7rem; }
  .funeral-icon { font-size: 1.25rem; }

  .form-row-split {
    grid-template-columns: 1fr;
    gap: 0;
  }
  .form-row-split .form-row { margin-bottom: 1rem; }

  .carousel { padding: 0 0.5rem; }
  .carousel-arrow {
    width: 36px;
    height: 36px;
    font-size: 0.95rem;
  }
  .carousel-arrow-prev { left: 0.3rem; }
  .carousel-arrow-next { right: 0.3rem; }

  .message-card { padding: 1.2rem 1.1rem; }
  .message-head { flex-direction: column; align-items: flex-start; gap: 0.15rem; }
  .message-name { font-size: 1.15rem; }

  .msg-edit-btn,
  .msg-delete-btn { width: 26px; height: 26px; }
  .msg-add-photos-btn {
    position: static;
    margin-top: 0.6rem;
    align-self: flex-start;
  }

  .music-toggle {
    bottom: 1rem;
    right: 1rem;
    width: 2.6rem;
    height: 2.6rem;
    font-size: 1rem;
  }

  .save-status {
    right: 1rem;
    bottom: 4.5rem;
  }

  .lightbox-close { top: -2.2rem; font-size: 1.9rem; }
}

@media (max-width: 480px) {
  .hero-name { font-size: 2.2rem; }
  .funeral-card { padding: 1.3rem; }
  .message-form { padding: 1.4rem; }
  .timeline-content { padding: 1.4rem; }
  .timeline-content h3 { font-size: 1.3rem; }
  .section-subtitle { font-size: 0.95rem; margin-bottom: 2rem; }
}

/* -------------------------------------------------- Utility */
.hidden { display: none !important; }
