/**
 * ================================================
 * Main Stylesheet (style.css)
 * Contains the core layout, component, and responsive styles.
 * ================================================
 */

:root {
  --primary-teal: #66c1be;
  --primary-gray: rgb(55, 65, 81);
  --background-body: #f8f9fa;
  --text-dark: #1f2937;
  --text-light: #6b7280;
  --card-bg: #ffffff;
  --border-color: #e5e7eb;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 20px 40px -8px rgba(0, 0, 0, 0.12);
  --memorial-section-gap: clamp(2.5rem, 5vw, 3.75rem);
  --success-green: #10b981;
  --error-red: #ef4444;
  --warning-bg: #fffbeb;
  --warning-text: #b45309;
  --warning-border: #fde68a;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

:focus-visible {
  outline: 2px solid var(--theme-primary, var(--primary-gray));
  outline-offset: 2px;
}

body {
  font-family: var(--theme-font, "Poppins", sans-serif);
  background-color: var(--background-body);
  background: linear-gradient(to bottom, #f8f9fa, #eef2f6);
  color: var(--text-dark);
  margin: 0;
  line-height: 1.7;
  min-height: 100vh;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  margin-top: 0;
  line-height: 1.3;
}

.hidden {
  display: none !important;
}

/* --- Scroll Animations --- */
.reveal-on-scroll {
  /* opacity: 0; */
  /* transform: translateY(30px); */
  /* transition: opacity 0.8s cubic-bezier(0.5, 0, 0, 1), transform 0.8s cubic-bezier(0.5, 0, 0, 1); */
  /* will-change: opacity, transform; */
  opacity: 1 !important;
  transform: none !important;
}

.reveal-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

/* --- Global Styles --- */
.container {
  max-width: var(--container-max, 1440px);
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.memorial-stack {
  display: flex;
  flex-direction: column;
  gap: var(--section-gap, clamp(3rem, 6vw, 5rem));
  margin: 0;
}

.memorial-stack > [data-related-slot]:empty,
.memorial-stack > [data-order-slot]:empty,
.memorial-stack > [data-keepsakes-slot]:empty {
  display: none;
}
.button {
  background-color: var(--theme-primary, var(--primary-gray));
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
.button:hover {
  background-color: color-mix(in srgb, var(--theme-primary, var(--primary-gray)), black 10%);
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}
.button:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
}

.button--outline {
  background-color: transparent;
  color: var(--theme-primary, var(--primary-gray));
  border: 2px solid var(--theme-primary, var(--primary-gray));
}
.button--outline:hover {
  background-color: var(--theme-primary, var(--primary-gray));
  color: white;
}

.button--icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background-color: transparent;
  border: 1px solid transparent;
  color: var(--text-light);
  transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.button--icon:hover {
  background-color: var(--background-body);
  border-color: var(--border-color);
  color: var(--text-dark);
}

.button--subtle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
  border-radius: 50%;
  transition: background-color 0.2s;
}
.button--subtle:hover {
  background-color: #f3f4f6;
}
.button--subtle .feather {
  color: var(--text-light);
}
.button--danger {
  background-color: var(--error-red);
  color: white;
  border-color: var(--error-red);
}
.button--danger:hover {
  background-color: color-mix(in srgb, var(--error-red), black 10%);
  border-color: color-mix(in srgb, var(--error-red), black 10%);
}
.button--danger.button--outline {
  background-color: transparent;
  color: var(--error-red);
}
.button--danger.button--outline:hover {
  background-color: var(--error-red);
  color: white;
}

/* --- Header --- */
.header {
  height: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: transparent;
  overflow: hidden;
  display: block;
}
.header-content {
  display: none;
}
.header__logo img {
  height: 30px;
}

/* --- Footer --- */
.footer {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 100;
}

/* --- Hero Section --- */
.hero {
  position: relative;
  background-color: var(--card-bg); /* Default background */
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  min-height: 100svh;
  min-height: 100vh;
}
.hero-content-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3rem;
  max-width: 1200px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
  padding: 4rem 1.5rem;
  margin-top: auto;
  margin-bottom: clamp(2.5rem, 8vh, 5rem);
}

/* --- Homepage Hero --- */
.hero__video {
  position: absolute;
  top: 50%;
  left: 50%;
  width: auto;
  height: auto;
  min-width: 100%;
  min-height: 100%;
  transform: translate(-50%, -50%);
  object-fit: cover;
  z-index: 0;
  opacity: 0;
  animation: fadeIn 1.5s ease-out forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.homepage-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: clamp(2rem, 4vw, 3rem);
  background: linear-gradient(135deg, rgba(102, 193, 190, 0.12), rgba(55, 65, 81, 0.08));
  border-radius: 32px;
  padding: clamp(2.5rem, 5vw, 4rem);
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}

.homepage-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at top right, rgba(102, 193, 190, 0.2), transparent 55%);
  pointer-events: none;
}

.homepage-hero__content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.homepage-hero__logo {
  max-width: 275px;
  margin-bottom: 1rem;
  height: auto;
}

.homepage-hero__eyebrow {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--text-light);
}

.homepage-hero__title {
  font-family: "Playfair Display", serif;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.2;
  margin: 0;
}

.homepage-hero__lead {
  font-size: 1.1rem;
  color: var(--text-light);
  margin: 0;
}

.homepage-hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.homepage-admin-callout {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(10px);
}

.homepage-admin-callout__icon {
  display: inline-flex;
  width: 48px;
  height: 48px;
  border-radius: 16px;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-dark);
}

.homepage-admin-callout__icon .feather {
  width: 22px;
  height: 22px;
}

.homepage-admin-callout__text h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
}

.homepage-admin-callout__text p {
  margin: 0;
  color: var(--text-light);
}

.homepage-hero__card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  backdrop-filter: blur(8px);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.homepage-hero__card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.homepage-hero__card h3 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.homepage-hero__list {
  margin: 0;
  padding-left: 1.25rem;
  display: grid;
  gap: 0.75rem;
  color: var(--text-dark);
}

.homepage-hero__list li {
  list-style: disc;
}

.homepage-hero__closing {
  margin: 0;
  color: var(--text-light);
}

.site-footer {
  margin-top: clamp(2rem, 6vw, 3.5rem);
  background: #ffffff;
  border-radius: 24px;
  padding: clamp(1.75rem, 4vw, 2.5rem);
  box-shadow: var(--shadow-md);
}

.site-footer__content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
  color: var(--text-light);
  font-size: 0.95rem;
}

.site-footer__links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.site-footer__link {
  color: var(--text-light);
  text-decoration: none;
  font-size: 0.9rem;
  transition: color 0.2s;
}

.site-footer__link:hover {
  color: var(--theme-primary, var(--primary-gray));
}

@media (max-width: 768px) {
  .homepage-hero {
    padding: 2rem;
  }

  .homepage-admin-callout {
    flex-direction: column;
    text-align: left;
  }

  .homepage-admin-callout__icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
  }

  .homepage-hero__logo {
    max-width: 200px;
  }
}

body[class*="theme-"] .hero-content-wrapper {
  margin-left: auto;
  margin-right: auto;
}
.hero__text {
  text-align: left;
}
.hero__photo {
  width: 180px;
  height: 180px;
  border-radius: 16px; /* Rounded square */
  object-fit: cover;
  border: 5px solid var(--card-bg);
  box-shadow: var(--shadow-md);
  flex-shrink: 0;
}
.hero__name {
  font-family: var(--theme-font, "Poppins", sans-serif);
  font-size: 3rem;
  font-weight: 700;
  color: var(--theme-primary, var(--primary-gray));
  margin: 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
.hero__dates {
  font-size: 1.1rem;
  color: var(--text-light);
  margin: 1rem 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.hero__message {
  font-size: 1.2rem;
  margin: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hero-tribute-anchor {
  position: relative;
  height: 0;
  width: 100%;
  pointer-events: none;
  z-index: 35;
}

@media (max-width: 1023px) {
  .hero-tribute-anchor {
    display: none;
  }
}

.hero-tribute-cloud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + clamp(0.5rem, 1.5vw, 1rem));
  left: 0;
  right: 0;
  margin: 0 auto;
  pointer-events: none;
  z-index: 35;
  contain: layout style;
  transform: translateZ(0);
  padding: 0 clamp(0.75rem, 1.5vw, 1.5rem);
  overflow: hidden;
}

.hero-tribute-track {
  display: flex;
  align-items: stretch;
  justify-content: flex-start;
  gap: var(--hero-tribute-gap, clamp(0.85rem, 1.2vw, 1.4rem));
  width: max-content;
  pointer-events: none;
  animation: hero-tribute-marquee var(--hero-tribute-marquee-duration, 56s) linear infinite;
}

.hero-tribute-track:hover {
  animation-play-state: paused;
}

.hero-tribute-cloud[data-tribute-static="true"] .hero-tribute-track,
.hero-tribute-cloud[data-tribute-reduced="true"] .hero-tribute-track {
  animation: none;
  transform: translateX(0);
}

@keyframes hero-tribute-marquee {
  from {
    transform: translateX(0);
  }
  to {
    transform: translateX(calc(-1 * var(--hero-tribute-marquee-distance, 0px)));
  }
}

.hero-tribute-card {
  position: relative;
  flex: 0 0 auto;
  min-width: clamp(220px, 28vw, 320px);
  max-width: clamp(240px, 32vw, 360px);
  width: auto;
  padding: 1.15rem 1.35rem;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid rgba(255, 255, 255, 0.48);
  color: #0f172a;
  box-shadow: 0 26px 65px rgba(15, 23, 42, 0.16);
  backdrop-filter: blur(18px) saturate(125%);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  will-change: transform;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hero-tribute-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hero-tribute-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0));
  opacity: 0.42;
  pointer-events: none;
}

.hero-tribute-card > * {
  position: relative;
  z-index: 1;
}

.hero-tribute-card__message {
  font-size: 0.95rem;
  line-height: 1.7;
  color: #111827;
}

.hero-tribute-card__author {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(51, 65, 85, 0.78);
}

body.theme-glass .hero-tribute-card {
  background: linear-gradient(
        180deg,
        rgba(255, 255, 255, var(--glass-tint-hi, 0.12)),
        rgba(255, 255, 255, var(--glass-tint-lo, 0.04))
      )
      padding-box,
    linear-gradient(
        135deg,
        rgba(99, 162, 213, var(--glass-edge-blue, 0.2)),
        rgba(255, 255, 255, var(--glass-edge-blue, 0.2))
      )
      border-box;
  border: 1px solid transparent;
  -webkit-backdrop-filter: blur(var(--glass-blur, 14px)) saturate(var(--glass-saturation, 130%));
  backdrop-filter: blur(var(--glass-blur, 14px)) saturate(var(--glass-saturation, 130%));
  box-shadow: 0 18px 40px rgba(99, 162, 213, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.45);
  color: rgba(17, 24, 39, 0.92);
}

body.theme-glass .hero-tribute-card::after {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0));
  opacity: 0.32;
}

body.theme-glass .hero-tribute-card__message {
  color: rgba(17, 24, 39, 0.88);
}

body.theme-glass .hero-tribute-card__author {
  color: rgba(17, 24, 39, 0.65);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .hero-tribute-cloud {
    width: min(100%, 520px);
    padding: 0 clamp(0.5rem, 4vw, 1rem);
  }

  .hero-tribute-track {
    gap: var(--hero-tribute-gap, clamp(0.65rem, 2vw, 1rem));
  }

  .hero-tribute-card {
    min-width: min(88vw, 320px);
    max-width: min(88vw, 340px);
  }
}

@media (max-width: 600px) {
  .hero-tribute-track {
    gap: var(--hero-tribute-gap, clamp(0.55rem, 4vw, 0.85rem));
  }

  .hero-tribute-card {
    min-width: min(100%, 280px);
    max-width: min(100%, 320px);
    margin-inline: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-tribute-track {
    animation: none !important;
    transform: translateX(0) !important;
  }
}

/* --- Nav Bar (Full Width Dock) --- */
.memorial-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  padding: 0.75rem 1rem;
  margin: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  /* Scroll reveal logic */
  transform: translateY(100%);
  transition: transform 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.memorial-nav.scrolled-visible {
  transform: translateY(0);
}

.memorial-nav::-webkit-scrollbar {
  display: none;
}

.memorial-nav a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-light);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  transition: all 0.2s ease;
  flex: 0 0 auto;
  white-space: nowrap;
  position: relative;
}

.memorial-nav a .feather {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.memorial-nav [hidden] {
  display: none !important;
}

.memorial-nav a:hover {
  background-color: rgba(0, 0, 0, 0.05);
  color: var(--text-dark);
}

.memorial-nav a:hover .feather {
  transform: scale(1.1);
}

.memorial-nav a:active {
  transform: scale(0.96);
}

@media (max-width: 768px) {
  .memorial-nav {
    padding: 0.75rem 0.5rem;
    gap: 0.5rem;
    justify-content: flex-start;
  }

  .memorial-nav a {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
  }

  .memorial-nav a .feather {
    display: none;
  }
}

/* --- Page Sections --- */
.memorial-section {
  background-color: var(--card-bg);
  padding: clamp(2rem, 4vw, 2.75rem);
  border-radius: 16px;
  box-shadow: var(--shadow-md);
  margin: 0 0 var(--memorial-section-gap);
  position: relative;
}

.memorial-stack .memorial-section {
  margin: 0;
}

.section-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 0.75rem;
  margin-bottom: clamp(1.75rem, 3vw, 2.25rem);
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.section-header h2 {
  font-family: var(--theme-font, "Poppins", sans-serif);
  font-size: 2rem;
  color: var(--theme-primary, var(--primary-gray));
  margin: 0;
}

.section-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* --- Modern Homepage Redesign --- */
.modern-hero {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #fcfcfc; /* Ultra-clean off-white */
  color: #1a1a1a;
  padding: 2rem;
  overflow: hidden;
}

/* Subtle background grain or gradient for texture */
.modern-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(102, 193, 190, 0.08), transparent 40%),
    radial-gradient(circle at 20% 80%, rgba(55, 65, 81, 0.05), transparent 40%);
  pointer-events: none;
  z-index: 0;
}

.modern-hero__header {
  position: relative;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding-top: 1rem;
}

.modern-hero__logo {
  height: 40px;
  width: auto;
  opacity: 0.9;
}

.modern-hero__content {
  position: relative;
  z-index: 10;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center; /* Center alignment */
  text-align: center;
  max-width: 1200px;
  margin: 0 auto;
  padding: 4rem 0;
}

.modern-hero__eyebrow {
  display: block;
  font-family: "Poppins", sans-serif;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: #9ca3af;
  margin-bottom: 2rem;
  font-weight: 500;
}

.modern-hero__title {
  font-family: "Playfair Display", serif;
  font-size: clamp(3.5rem, 8vw, 6.5rem); /* Massive, high-impact type */
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: #111827;
  margin: 0 0 2.5rem;
}

.modern-hero__text {
  font-family: "Poppins", sans-serif;
  font-size: clamp(1.1rem, 2vw, 1.25rem);
  line-height: 1.8;
  color: #4b5563;
  max-width: 500px;
  margin: 0 auto;
  font-weight: 300;
}

.modern-hero__footer {
  position: relative;
  z-index: 10;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding-bottom: 1rem;
  text-align: center;
  color: #9ca3af;
  font-size: 0.875rem;
}

/* Animations */
.fade-in-up {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Button Override for this section */
.modern-hero .button--subtle {
  font-size: 0.9rem;
  color: #6b7280;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.modern-hero .button--subtle:hover {
  background-color: white;
  border-color: #e5e7eb;
  color: #111827;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

@media (max-width: 768px) {
  .modern-hero {
    padding: 1.5rem;
    justify-content: center;
  }

  .modern-hero__header {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    right: 1.5rem;
    width: auto;
    padding: 0;
  }

  .modern-hero__footer {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    right: 0;
    padding: 0;
  }

  .modern-hero__title {
    font-size: 3rem;
  }
}

.section-header--with-actions h2 {
  text-align: center;
}

.section-header--with-actions .section-actions {
  justify-content: center;
}

/* --- Immersive Eulogy Section --- */
.immersive-section-wrapper {
  margin: 0;
  padding: clamp(6rem, 12vw, 9rem) clamp(1.5rem, 4vw, 2.25rem); /* Significantly increased padding */
  background-color: var(--background-body);
}
.immersive-eulogy {
  margin: 0 auto;
  text-align: center;
  background-color: transparent;
  box-shadow: none;
  padding: 0 clamp(2.25rem, 6vw, 3.5rem);
}
.immersive-eulogy .section-header {
  margin: 0 auto clamp(2.5rem, 4vw, 3.2rem); /* Removed top margin */
  padding-bottom: 1.75rem;
  justify-content: center;
  text-align: center;
  border-bottom: none;
}
.immersive-eulogy .section-header h2 {
  margin: 0 auto;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 0.5rem;
}
.immersive-eulogy .section-header h2::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(160px, 60%);
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.75;
}
.eulogy-content {
  line-height: 2;
  font-size: 1.2rem;
  text-align: left;
  max-width: 620px;
  margin: clamp(1.75rem, 4vw, 2.5rem) auto 0;
  color: var(--text-dark);
}

/* --- Virtual Candles --- */
.virtual-candles-section {
  position: relative;
  padding: clamp(2.75rem, 5vw, 3.75rem);
  border-radius: 22px;
  border: 1px solid rgba(244, 114, 182, 0.08);
  background: linear-gradient(160deg, #fff9f1 0%, #fef3e5 55%, #fde5de 100%);
  box-shadow: 0 28px 60px -34px rgba(113, 63, 18, 0.22);
  overflow: hidden;
  z-index: 0;
}

.virtual-candles-section::before,
.virtual-candles-section::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: -1;
}

.virtual-candles-section::before {
  inset: auto auto -18% -12%;
  width: clamp(14rem, 30vw, 22rem);
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle, rgba(254, 215, 170, 0.65) 0%, rgba(254, 215, 170, 0) 70%);
  opacity: 0.7;
}

.virtual-candles-section::after {
  inset: -18% -10% auto auto;
  width: clamp(12rem, 26vw, 20rem);
  aspect-ratio: 1 / 1;
  background: radial-gradient(circle, rgba(253, 164, 175, 0.4) 0%, rgba(253, 164, 175, 0) 70%);
  opacity: 0.6;
}

.virtual-candles-section > * {
  position: relative;
  z-index: 1;
}

.virtual-candles-section .section-header {
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
}

.candle-stats {
  display: inline-flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.45rem 1rem;
  border-radius: 999px;
  background: rgba(244, 114, 182, 0.12);
  color: rgba(67, 20, 7, 0.82);
  font-size: 0.95rem;
  box-shadow: inset 0 0 0 1px rgba(244, 114, 182, 0.1);
}

.candle-count {
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1;
}

.virtual-candles-board {
  margin-top: 2rem;
  position: relative;
}

.candle-grid {
  display: grid;
  gap: 1.75rem;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.candle-card {
  position: relative;
  display: flex;
  gap: 1.5rem;
  align-items: center;
  padding: 1.65rem 1.85rem;
  border-radius: 22px;
  background: linear-gradient(150deg, rgba(255, 247, 237, 0.95), rgba(254, 226, 226, 0.9));
  border: 1px solid rgba(249, 115, 22, 0.12);
  box-shadow: 0 26px 46px -30px rgba(113, 63, 18, 0.35);
  overflow: hidden;
  animation: candleCardReveal 0.8s ease both;
  transition: transform 0.6s cubic-bezier(0.22, 0.61, 0.36, 1), box-shadow 0.6s ease;
}

.candle-card::before,
.candle-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.candle-card::before {
  background: radial-gradient(circle at 25% -30%, rgba(255, 255, 255, 0.85), transparent 60%);
  opacity: 0.5;
}

.candle-card::after {
  background: radial-gradient(circle at 50% 110%, rgba(249, 168, 212, 0.25), transparent 70%);
  opacity: 0;
}

.candle-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 34px 60px -30px rgba(113, 63, 18, 0.42);
}

.candle-card:hover::after {
  opacity: 1;
}

.candle-visual {
  position: relative;
  width: 72px;
  height: 110px;
  display: inline-flex;
  justify-content: center;
  align-items: flex-end;
}

.candle-glow {
  position: absolute;
  bottom: 6px;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(252, 211, 77, 0.45), rgba(253, 186, 116, 0.05) 70%);
  filter: blur(24px);
  opacity: 0.85;
  animation: candleAura 8s ease-in-out infinite alternate;
}

.candle-flame {
  position: absolute;
  top: -12px;
  width: 26px;
  height: 44px;
  border-radius: 50% 50% 48% 48%;
  background: radial-gradient(
    circle at 50% 18%,
    rgba(255, 253, 245, 0.95) 0%,
    rgba(255, 232, 174, 0.92) 45%,
    rgba(255, 172, 94, 0.9) 78%,
    rgba(217, 119, 6, 0.85) 100%
  );
  transform-origin: 50% 90%;
  filter: drop-shadow(0 0 18px rgba(255, 193, 94, 0.6));
  animation: candleFlicker 4.8s ease-in-out infinite;
  z-index: 2;
}

.candle-flame::before,
.candle-flame::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.candle-flame::before {
  bottom: 18%;
  width: 14px;
  height: 24px;
  border-radius: 50% 50% 46% 46%;
  background: radial-gradient(
    circle at 50% 20%,
    rgba(255, 255, 255, 0.95) 0%,
    rgba(255, 243, 208, 0.8) 60%,
    rgba(255, 184, 94, 0) 100%
  );
  filter: blur(1px);
}

.candle-flame::after {
  top: -12px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 244, 214, 0.9), rgba(255, 244, 214, 0));
  opacity: 0.7;
}

.candle-wick {
  position: absolute;
  bottom: 66px;
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(45, 27, 14, 0.9), rgba(15, 10, 5, 0.4));
  z-index: 1;
}

.candle-wick::after {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(249, 168, 38, 0.9) 0%, rgba(249, 168, 38, 0) 70%);
  transform: translateX(-50%);
  opacity: 0.85;
}

.candle-body {
  position: absolute;
  bottom: 16px;
  width: 46px;
  height: 76px;
  border-radius: 22px 22px 16px 16px;
  background: linear-gradient(180deg, #fffaf3 0%, #fde4c9 48%, #fbd3a7 100%);
  box-shadow: inset 0 -10px 20px rgba(191, 128, 64, 0.28), inset 0 8px 12px rgba(255, 255, 255, 0.85);
  overflow: hidden;
}

.candle-base {
  position: absolute;
  bottom: 2px;
  width: 78px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(120, 53, 15, 0.22), rgba(120, 53, 15, 0));
  opacity: 0.75;
}

@keyframes candleFlicker {
  0% {
    transform: scaleX(1) scaleY(1) translateY(0) rotate(0deg);
    opacity: 0.92;
  }
  20% {
    transform: scaleX(0.96) scaleY(1.06) translateY(-2px) rotate(-1.5deg);
    opacity: 1;
  }
  40% {
    transform: scaleX(1.02) scaleY(0.95) translateY(2px) rotate(1.8deg);
    opacity: 0.9;
  }
  60% {
    transform: scaleX(0.98) scaleY(1.02) translateY(-1px) rotate(-1deg);
    opacity: 0.96;
  }
  80% {
    transform: scaleX(1.01) scaleY(0.98) translateY(1px) rotate(1.2deg);
    opacity: 0.88;
  }
  100% {
    transform: scaleX(1) scaleY(1.03) translateY(-1px) rotate(0.6deg);
    opacity: 0.94;
  }
}

@keyframes candleAura {
  0% {
    transform: scale(0.9);
    opacity: 0.65;
  }
  50% {
    transform: scale(1.08);
    opacity: 0.92;
  }
  100% {
    transform: scale(0.95);
    opacity: 0.7;
  }
}

@keyframes candleCardReveal {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .candle-card {
    animation: none;
    transition: none;
  }

  .candle-flame,
  .candle-glow {
    animation: none;
  }
}

.candle-details {
  flex: 1;
}

.candle-name {
  margin: 0;
  font-size: 1.15rem;
  color: rgba(67, 20, 7, 0.92);
  letter-spacing: 0.01em;
}

.candle-meta {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: rgba(88, 28, 15, 0.65);
}

.candle-empty {
  margin-top: 1.5rem;
  text-align: center;
  color: rgba(88, 28, 15, 0.55);
  font-size: 1rem;
}

.candle-form {
  margin-top: clamp(2rem, 4vw, 2.5rem);
  display: grid;
  gap: 0.75rem;
  max-width: min(100%, 420px);
  margin-left: auto;
  margin-right: auto;
}

.candle-form-row {
  display: grid;
  gap: 0.75rem;
  align-items: center;
  grid-template-columns: minmax(0, 1fr);
}

.candle-form input[type="text"] {
  width: 100%;
  min-width: 0;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.95);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.candle-form input[type="text"]:focus {
  outline: none;
  border-color: var(--primary-color, #4f46e5);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}

.candle-form .button {
  width: 100%;
  min-width: 0;
  white-space: nowrap;
  justify-self: stretch;
}

@media (min-width: 520px) {
  .candle-form-row {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .candle-form .button {
    width: auto;
    min-width: 150px;
    justify-self: start;
  }
}

.form-feedback {
  font-size: 0.95rem;
  border-radius: 12px;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.05);
  color: var(--text-dark);
}

.form-feedback.success {
  background: rgba(34, 197, 94, 0.15);
  color: #047857;
}

.form-feedback.error {
  background: rgba(248, 113, 113, 0.2);
  color: #b91c1c;
}

.features-testing-panel {
  margin-top: 2rem;
  padding: 1.75rem;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(248, 250, 252, 0.85), rgba(255, 255, 255, 0.78));
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 20px 40px -32px rgba(15, 23, 42, 0.35);
  display: grid;
  gap: 1.5rem;
}

.features-testing-panel .switch-row {
  align-items: stretch;
}

.feature-toggle {
  display: flex;
  align-items: flex-start;
  gap: 1.25rem;
  padding: 1.25rem 1.35rem;
  margin: 0;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 36px -28px rgba(15, 23, 42, 0.35);
}

.feature-toggle__switch {
  flex-shrink: 0;
}

.feature-toggle__content {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.feature-toggle .switch {
  width: 54px;
  height: 30px;
}

.feature-toggle .switch-slider:before {
  width: 24px;
  height: 24px;
  top: 3px;
  left: 3px;
}

.feature-toggle .switch input:checked + .switch-slider:before {
  transform: translateX(24px);
}

.feature-toggle .feature-toggle-status {
  margin-top: 0.5rem;
}

@media (max-width: 640px) {
  .feature-toggle {
    flex-direction: column;
    align-items: flex-start;
  }

  .feature-toggle__switch {
    margin-bottom: 0.5rem;
  }

  .feature-toggle .feature-toggle-status {
    margin-top: 0.25rem;
  }
}

.feature-toggle-status {
  display: inline-flex;
  align-items: center;
  margin-top: 0.65rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  background: rgba(15, 23, 42, 0.08);
  color: rgba(15, 23, 42, 0.65);
  transition: background 0.3s ease, color 0.3s ease;
}

.feature-toggle-status[data-state="on"] {
  background: rgba(34, 197, 94, 0.18);
  color: #047857;
}

.feature-toggle-status[data-state="pending"] {
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
}

.feature-toggle-status[data-state="error"] {
  background: rgba(248, 113, 113, 0.24);
  color: #b91c1c;
}

.admin-candle-insight .insight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.insight-card {
  background: rgba(15, 23, 42, 0.04);
  border-radius: 16px;
  padding: 1.2rem 1.4rem;
  box-shadow: 0 16px 35px -32px rgba(15, 23, 42, 0.5);
}

.insight-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-light);
  margin-bottom: 0.4rem;
}

.insight-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text-dark);
}

.insight-sub {
  display: block;
  font-size: 0.95rem;
  color: var(--text-light);
  margin-top: 0.35rem;
}

@media (max-width: 640px) {
  .candle-form-row {
    flex-direction: column;
  }

  .candle-form .button {
    width: 100%;
  }

  .candle-card {
    flex-direction: column;
    align-items: flex-start;
  }

  .candle-visual {
    margin-bottom: 0.75rem;
  }
}

/* --- Tributes & Photo Gallery --- */
.tributes-grid,
.photo-gallery-grid {
  display: block;
}
.tribute-card,
.photo-card {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  break-inside: avoid; /* Prevent items from breaking across columns */
  margin-bottom: 1.5rem;
  display: inline-block;
  width: 100%;
}
.tribute-card img,
.photo-card img {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 1rem;
}
.photo-card img {
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.3s ease;
}
.lazy-img {
  opacity: 0;
}
.lazy-img.loaded {
  opacity: 1;
}
.photo-card img:hover {
  transform: scale(1.01);
}
.tribute-card img {
  transition: transform 0.2s ease, opacity 0.3s ease;
}
.hero__photo {
  transition: transform 0.2s ease, opacity 0.3s ease;
}
.tribute-cta {
  text-align: center;
  padding: 2rem;
  background-color: var(--background-body);
  border-radius: 12px;
  margin-top: 1.5rem;
}
.tribute-cta p {
  font-size: 1.1rem;
  color: var(--text-light);
  margin: 0 0 1rem 0;
}
.card-content {
  padding: 0.5rem;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}
.tribute-card__author {
  font-weight: 600;
  margin: 0;
}
.photo-card__details {
  text-align: left;
}
.photo-caption {
  font-size: 0.9rem;
  color: var(--text-dark);
  font-weight: 500;
  margin: 0;
}
.photo-date {
  font-size: 0.8rem;
  color: var(--text-light);
  font-style: italic;
  margin-top: 0.25rem;
}
.card-admin-controls {
  display: flex;
  gap: 0.25rem;
}

/* Masonry layout for galleries */
@media (min-width: 768px) {
  .tributes-grid,
  .photo-gallery-grid {
    column-count: 2;
    column-gap: 1.5rem;
  }
}
@media (min-width: 1200px) {
  .tributes-grid,
  .photo-gallery-grid {
    column-count: 3;
  }
}

/* --- Relationships Section --- */
.relationship-groups-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 2rem;
}

.relationship-group {
  padding: clamp(1rem, 2vw, 1.5rem);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.relationship-group h4 {
  margin: 0;
  color: var(--theme-primary, var(--primary-gray));
  border-bottom: 2px solid var(--theme-primary, var(--primary-gray));
  padding-bottom: 0.5rem;
}
.related-memorials-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.related-memorials-list li {
  margin-bottom: 0.5rem;
}
.related-memorials-list a {
  font-weight: 600;
  color: var(--text-dark);
  text-decoration: none;
}
.related-memorials-list a:hover {
  text-decoration: underline;
}

/* --- Admin Dashboard --- */
.admin-dashboard .admin-panel__header {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
}
.memorial-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.memorial-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-dark);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease-in-out;
}
.memorial-list-item:hover {
  border-color: var(--primary-teal);
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.memorial-list-item__details {
  display: flex;
  flex-direction: column;
}
.memorial-list-item__name {
  font-weight: 600;
  font-size: 1.25rem;
}
.memorial-list-item__date {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 0.25rem;
}
.memorial-list-item__action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--primary-teal);
  font-weight: 600;
}

/* --- Admin Panel Redesign --- */
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#admin-panel {
  border-top: none;
  padding: 0;
  background-color: transparent;
  box-shadow: none;
}
.admin-panel-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2.5rem;
  align-items: start;
}
.admin-panel-nav {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
  position: sticky;
  top: 5.5rem; /* Sticky sidebar */
}
.admin-edit-card,
.admin-photo-plan-card {
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  background-color: var(--background-body);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.03);
}
.admin-edit-card h3,
.admin-photo-plan-card h3 {
  font-size: 1.1rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
}
.admin-edit-card p,
.admin-photo-plan-card p {
  color: var(--text-light);
  font-size: 0.85rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}
.admin-photo-plan-card .button {
  width: 100%;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  padding: 0.6rem;
}
.progress-bar-container {
  background-color: #e5e7eb;
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
  margin: 0.75rem 0 0.5rem;
}
.progress-bar {
  background-color: var(--theme-primary, var(--primary-gray));
  height: 100%;
  border-radius: 99px;
  transition: width 0.3s ease-in-out;
}
.photo-usage-text {
  font-size: 0.75rem !important;
  text-align: center;
  margin: 0;
  opacity: 0.8;
}
.admin-nav-links {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}
.admin-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-light);
  font-weight: 500;
  font-size: 0.95rem;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}
.admin-nav-link span:not(.badge) {
  flex-grow: 1;
}
.admin-nav-link:hover {
  background-color: var(--background-body);
  color: var(--text-dark);
}
.admin-nav-link.active {
  background-color: color-mix(in srgb, var(--theme-primary, var(--primary-gray)), white 90%);
  color: var(--theme-primary, var(--primary-gray));
  font-weight: 600;
  border-color: color-mix(in srgb, var(--theme-primary, var(--primary-gray)), white 80%);
}
.admin-nav-link .feather {
  width: 18px;
  height: 18px;
  color: inherit;
  opacity: 0.8;
}
.admin-nav-link.active .feather {
  opacity: 1;
}
.admin-nav-link .badge {
  background-color: rgba(0, 0, 0, 0.06);
  color: var(--text-light);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 99px;
  font-weight: 600;
}
.admin-nav-link.active .badge {
  background-color: white;
  color: var(--theme-primary, var(--primary-gray));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.admin-nav-link.has-pending {
  font-weight: 600;
  background-color: var(--warning-bg);
}
.admin-nav-link.has-pending:hover {
  background-color: #fef9c3;
}
.admin-nav-link.has-pending.active {
  background-color: var(--theme-primary, var(--primary-gray));
  color: white;
}
.admin-nav-link .badge.has-pending {
  background-color: var(--error-red);
  color: white;
  animation: pulse 2s infinite;
}

@media (max-width: 640px) {
  .admin-panel-nav {
    padding: 1.15rem 1rem;
  }

  .admin-nav-links {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem;
  }

  .admin-nav-link {
    border-radius: 12px;
    padding: 0.5rem 0.7rem;
    font-size: 0.9rem;
    min-width: 0;
    gap: 0.5rem;
  }

  .admin-nav-link .badge {
    margin-left: 0.25rem;
  }
}
.admin-panel-content {
  background-color: var(--card-bg);
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
}
.admin-notice {
  background-color: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}
.admin-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}
.admin-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}
.admin-section .help-hint {
  margin: 0.5rem 0 0.75rem;
  color: var(--text-light);
  font-size: 0.9rem;
}
.admin-section .section-divider {
  height: 1px;
  width: 100%;
  background: var(--border-color);
  margin: 0.75rem 0 1rem;
}
.keepsakes-section {
  padding-bottom: 1.25rem;
}
.admin-section-description {
  color: var(--text-light);
  margin-top: -0.5rem;
}
.admin-tab-content {
  display: none;
  animation: fadeIn 0.3s ease-in-out forwards;
}
.admin-tab-content.active {
  display: block;
}
.admin-tabs {
  display: none; /* Hide old tabs */
}
.badge {
  background-color: var(--theme-primary, var(--primary-gray));
  color: white;
  font-size: 0.75rem;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}
.admin-empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-light);
}
.admin-empty-state .feather {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
}
.admin-empty-state p {
  font-size: 1.1rem;
  font-weight: 500;
  margin: 0;
}

/* Centered, prominent load more for gallery */
.gallery-loadmore {
  margin-top: 1rem;
  text-align: center;
}
.gallery-loadmore .button {
  min-width: 240px;
}
@media (max-width: 640px) {
  .hero {
    padding: clamp(4.25rem, 14vw, 5.5rem) 1rem clamp(2.25rem, 9vw, 3rem);
  }
  .hero__photo {
    width: min(65vw, 220px);
    height: min(65vw, 220px);
  }
  .hero__name {
    font-size: clamp(1.75rem, 7.5vw, 2.1rem);
  }
  .hero-tribute-cloud {
    width: min(100%, 460px);
  }
  .hero-tribute-card {
    padding: 1.1rem 1.25rem;
  }
  .homepage-hero {
    padding: clamp(1.75rem, 7vw, 2.1rem);
  }
  .homepage-hero__actions {
    flex-direction: column;
    align-items: stretch;
  }
  .homepage-hero__actions .button {
    width: 100%;
  }
  .gallery-loadmore .button {
    width: 100%;
  }
  .share-url {
    flex-direction: column;
    align-items: stretch;
  }
  .share-url .button {
    width: 100%;
  }
  .candle-grid {
    grid-template-columns: 1fr;
  }
  .modal-overlay {
    padding: clamp(1.5rem, 6vw, 2rem) 1rem;
  }
  .footer {
    position: fixed;
    bottom: clamp(0.75rem, 4vw, 1.25rem);
    right: clamp(0.75rem, 4vw, 1.25rem);
    margin: 0;
    width: auto;
  }
  .footer-auth-controls {
    width: auto;
    display: flex;
    justify-content: flex-end;
  }
}

/* Soft fade-in utility for revealed items */
.fade-in-soft {
  animation: fadeInSoft 0.3s ease-in-out;
}
@keyframes fadeInSoft {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Redesigned Share Tools */
.share-tools {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1.5rem;
  align-items: center;
}
.share-url {
  display: flex;
  gap: 0.5rem;
}
.share-url input {
  flex-grow: 1;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
}
.share-url .button {
  padding: 0.75rem;
}
.share-qr {
  text-align: center;
}
#qrcode-container img {
  max-width: 150px;
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 8px;
  margin-bottom: 1rem;
}

.tribute-moderation-card,
.photo-moderation-card {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
  transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}
.tribute-moderation-card:hover,
.photo-moderation-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.moderation-card-checkbox {
  align-self: center;
}
.moderation-card-main {
  flex-grow: 1;
  display: flex;
  gap: 1rem;
}
.tribute-moderation-card img,
.photo-moderation-card img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}
.moderation-card-content {
  flex-grow: 1;
}
.moderation-card-content p {
  margin: 0 0 0.5rem 0;
}
.moderation-card-content p:last-child {
  margin-bottom: 0;
}
.moderation-card-timestamp {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 0.5rem;
}
.tribute-moderation-actions,
.photo-moderation-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  justify-content: center;
}
.tribute-moderation-actions .button,
.photo-moderation-actions .button {
  width: 100%;
  font-size: 0.9rem;
  padding: 0.5rem 1rem;
}
.bulk-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}
/* Admin Relationships Tab */
.linked-memorial-item,
.request-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
  background: #f9fafb;
}
.request-item-actions {
  display: flex;
  gap: 0.5rem;
}
.pending-rows {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.pending-col {
  flex: 1 1 320px;
}
#relationship-preview {
  font-size: 0.9rem;
  color: var(--text-light);
}
.link-type-selector {
  display: flex;
  gap: 1.5rem;
  margin-bottom: 1rem;
}
.link-type-selector label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.link-memorial-form .button {
  margin-top: 1rem;
}

/* --- Modals, Toasts, Lightbox, etc. --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  z-index: 9000;
  overflow-y: auto;
  padding: 2rem 1rem;
}
.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  margin: 2rem auto; /* Ensure margin for scrolling */
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.8);
  position: relative; /* Context for absolute children */
}

#login-modal .modal-content {
  max-width: 400px;
  text-align: center;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
}

#login-modal h2 {
  font-size: 1.75rem;
  margin-bottom: 1.5rem;
  color: var(--theme-primary, var(--primary-gray));
}
.form-group {
  margin-bottom: 1rem;
}
.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  background-color: #f9fafb;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--theme-primary, var(--primary-gray));
  box-shadow: 0 0 0 3px rgba(102, 193, 190, 0.15);
  background-color: #ffffff;
}

.form-hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.5;
}

/* Modern switch toggles */
.switch-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0;
}
.switch-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.switch-title {
  font-weight: 600;
}
.switch-desc {
  color: var(--text-light);
  font-size: 0.9rem;
}
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 28px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  transition: 0.2s;
  border-radius: 999px;
}
.switch-slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 3px;
  top: 3px;
  background-color: white;
  transition: 0.2s;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}
.switch input:checked + .switch-slider {
  background-color: var(--theme-primary, var(--primary-teal));
}
.switch input:checked + .switch-slider:before {
  transform: translateX(20px);
}

/* (removed) Memory Book Builder styles */
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1.5rem;
}
.form-footer {
  margin-top: 1.5rem;
  text-align: center;
}
.form-footer a {
  color: var(--primary-teal);
  text-decoration: none;
  font-weight: 500;
}
.form-footer a:hover {
  text-decoration: underline;
}
.ql-editor {
  min-height: 150px;
  font-size: 1rem;
  font-family: "Poppins", sans-serif;
}
.cropper-modal-content {
  max-width: 600px;
}
#cropper-image {
  display: block;
  max-width: 100%;
}
.cropper-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: center;
  margin-top: 0.75rem;
}
.cropper-toolbar .toolbar-group {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.cropper-toolbar .toolbar-label {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-right: 0.25rem;
}
.cropper-toolbar button {
  background: #f3f4f6;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
}
.cropper-toolbar button:hover {
  background: #e5e7eb;
}
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}
.toast {
  padding: 1rem 1.5rem;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s forwards, slideOut 0.3s 2.7s forwards;
}
.toast.success {
  background-color: var(--success-green);
}
.toast.error {
  background-color: var(--error-red);
}
.toast.info {
  background-color: var(--text-dark);
}
@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(100%);
  }
}

/* --- Enhanced Cropper Modal --- */
.cropper-modal-content {
  max-width: 720px;
}
.cropper-modal-content .cropper-container {
  background: #f9fafb;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 0.5rem;
}
.file-input-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.file-input-hidden {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}
.file-input-wrapper .button {
  padding: 0.6rem 1rem;
}
.file-name-display {
  color: var(--text-light);
  font-style: italic;
}
.lightbox-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
}
.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 2rem;
  color: #fff;
  font-size: 3rem;
  cursor: pointer;
}
.lightbox-content-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 90%;
  max-height: 90%;
}
#photo-gallery-image {
  max-width: 100%;
  max-height: 75vh;
  border-radius: 8px;
}
.lightbox-details {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 2.5rem 1.5rem 1.5rem;
  color: white;
  text-align: center;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  border-radius: 0 0 8px 8px;
}
#photo-gallery-caption {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
}
.lightbox-nav {
  cursor: pointer;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  font-size: 2rem;
  background: none;
  border: none;
  padding: 1rem;
  z-index: 10;
}
.lightbox-nav.prev {
  left: 1rem;
}
.lightbox-nav.next {
  right: 1rem;
}
.theme-choice.selected {
  border-color: var(--primary-teal);
}
.theme-choice.selected::after {
  content: "✔";
  position: absolute;
  top: 5px;
  right: 5px;
  background-color: var(--primary-teal);
  color: white;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.custom-theme-settings {
  margin-top: 1.5rem;
  padding: 1.75rem;
  border-radius: 16px;
  border: 1px solid color-mix(in srgb, var(--border-color) 65%, white 35%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.65));
  box-shadow: 0 16px 38px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 1.5rem;
}

.custom-theme-header {
  display: grid;
  gap: 0.35rem;
}

.custom-theme-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.custom-theme-description {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-light);
}

.custom-theme-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.custom-theme-group {
  display: grid;
  gap: 0.75rem;
}

.custom-theme-group h4 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-dark);
}

.custom-theme-group .form-group {
  margin-bottom: 0;
}

.custom-theme-font-preview {
  margin-top: 0.5rem;
  padding: 1rem 1.1rem;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--preview-primary, #6366f1) 24%, rgba(15, 23, 42, 0.12));
  background: linear-gradient(135deg, color-mix(in srgb, var(--preview-primary, #6366f1) 14%, transparent), transparent),
    linear-gradient(
      180deg,
      color-mix(in srgb, var(--preview-background, #f8fafc) 92%, white 8%),
      var(--preview-background, #f8fafc)
    );
  box-shadow: 0 20px 35px rgba(15, 23, 42, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  display: grid;
  gap: 0.35rem;
  color: var(--preview-text, #0f172a);
  transition: background 0.25s ease, border-color 0.25s ease, color 0.25s ease;
}

.custom-theme-font-preview .font-preview-heading {
  font-size: 1.05rem;
  font-weight: 600;
}

.custom-theme-font-preview .font-preview-body {
  font-size: 0.9rem;
  opacity: 0.85;
}

.custom-theme-colour-grid {
  display: grid;
  gap: 1.1rem;
}

.custom-theme-colour-control {
  position: relative;
  border-radius: 16px;
  padding: 1rem 1.15rem 1.15rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.6)),
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.25), transparent 55%);
  border: 1px solid color-mix(in srgb, rgba(15, 23, 42, 0.12) 65%, transparent);
  box-shadow: 0 18px 32px rgba(15, 23, 42, 0.14);
  display: grid;
  gap: 0.9rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.custom-theme-colour-control::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(120deg, transparent 40%, rgba(255, 255, 255, 0.18) 100%);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.custom-theme-colour-control:hover {
  border-color: color-mix(in srgb, rgba(15, 23, 42, 0.22) 65%, transparent);
  box-shadow: 0 24px 40px rgba(15, 23, 42, 0.16);
}

.custom-theme-colour-control:hover::after,
.custom-theme-colour-control:focus-within::after {
  opacity: 1;
}

.colour-control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.colour-control-header label {
  font-weight: 600;
  color: var(--text-dark);
}

.colour-control-current {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-light);
}

.colour-control-chip {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 0.65rem;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: var(--current-colour, #000);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.colour-control-text {
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.colour-control-body {
  display: block;
}

.colour-picker-input {
  height: 48px;
  border-radius: 14px;
  border: none;
  padding: 0;
  appearance: none;
  background: none;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.16), 0 12px 24px rgba(15, 23, 42, 0.12);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.colour-picker-input:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.2), 0 18px 32px rgba(15, 23, 42, 0.18);
}

.colour-picker-input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--preview-primary, #6366f1) 35%, transparent);
  outline-offset: 3px;
}

.colour-picker-input::-webkit-color-swatch,
.colour-picker-input::-moz-color-swatch {
  border: none;
  border-radius: 12px;
}

.colour-control-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.colour-preset-btn {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: none;
  background: var(--preset-colour, #000);
  cursor: pointer;
  position: relative;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55), 0 8px 16px rgba(15, 23, 42, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.colour-preset-btn::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  border: 1px solid rgba(15, 23, 42, 0.18);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.colour-preset-btn:focus-visible,
.colour-preset-btn:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.65), 0 14px 24px rgba(15, 23, 42, 0.22);
}

.colour-preset-btn:focus-visible::after,
.colour-preset-btn:hover::after {
  opacity: 1;
}

.colour-preset-btn:focus-visible {
  outline: none;
}

/* --- Mobile Specific Fixes --- */
@media (max-width: 900px) {
  .admin-panel-layout {
    grid-template-columns: 1fr;
  }
  .admin-panel-nav {
    position: static;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }
  .header {
    padding: 0.75rem 1rem;
  }
  .hero {
    padding: clamp(4.5rem, 12vw, 5.75rem) 1.25rem clamp(2.5rem, 8vw, 3.5rem);
    min-height: auto;
  }
  .hero-content-wrapper {
    padding: 2rem 1rem;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 1.75rem;
    margin-bottom: clamp(1.75rem, 10vw, 3rem);
  }
  .hero__photo {
    width: min(60vw, 260px);
    height: min(60vw, 260px);
  }
  .hero__text {
    text-align: center;
  }
  .hero__name {
    font-size: clamp(1.9rem, 8vw, 2.3rem);
  }
  .hero__dates,
  .hero__message {
    font-size: clamp(1rem, 4.2vw, 1.1rem);
  }
  .hero-tribute-cloud {
    width: min(100%, 520px);
    padding: 0 0.5rem;
  }
  .hero-tribute-track {
    gap: clamp(0.75rem, 4vw, 1.25rem);
  }
  .hero-tribute-card {
    min-width: min(100%, 260px);
    max-width: min(100%, 320px);
    margin-inline: auto;
    margin-block: 0.35rem;
  }

  .homepage-hero {
    padding: clamp(2rem, 8vw, 2.5rem);
    text-align: center;
  }
  .homepage-hero__content {
    align-items: center;
  }
  .homepage-hero__actions {
    width: 100%;
    justify-content: center;
    gap: 0.75rem;
  }
  .homepage-hero__card {
    margin-inline: auto;
  }

  .memorial-nav {
    max-width: min(100%, 520px);
    gap: 0.45rem 0.55rem;
    margin: clamp(0.75rem, 4vw, 1.5rem) auto;
    padding: 0;
  }
  .hero-tribute-card {
    flex: 1 1 min(320px, 100%);
    width: min(100%, 320px);
    min-width: min(100%, 240px);
    max-width: min(100%, 320px);
    margin-inline: auto;
    margin-block: 0.35rem;
    transform: translateY(-6px) scale(0.97) rotate(var(--rotation, 0deg));
  }
  .hero-tribute-card--visible {
    transform: translateY(0) scale(1) rotate(var(--rotation, 0deg));
  }
  .hero-tribute-card--leaving {
    transform: translateY(-10px) scale(0.96) rotate(var(--rotation, 0deg));
  }

  .homepage-hero {
    padding: clamp(2rem, 8vw, 2.5rem);
    text-align: center;
  }
  .homepage-hero__content {
    align-items: center;
  }
  .homepage-hero__actions {
    width: 100%;
    justify-content: center;
    gap: 0.75rem;
  }
  .homepage-hero__card {
    margin-inline: auto;
  }

  .memorial-nav a {
    font-size: 0.82rem;
  }
  .memorial-section {
    padding: 1.5rem;
  }
  .modal-content {
    padding: 1.5rem;
  }
  .modal-actions {
    flex-direction: column;
    gap: 0.5rem;
  }
  .modal-actions .button {
    width: 100%;
  }

  .tribute-moderation-card,
  .photo-moderation-card {
    flex-direction: column;
    align-items: stretch;
  }
  .request-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .tribute-moderation-actions,
  .photo-moderation-actions,
  .request-item-actions {
    width: 100%;
    margin-top: 1rem;
    flex-direction: row;
  }
  .tribute-moderation-actions .button,
  .photo-moderation-actions .button,
  .request-item-actions .button {
    width: 100%;
  }
  .admin-dashboard .admin-panel__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
  .share-tools {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .memorial-nav {
    position: static;
    top: auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.4rem 0.5rem;
    padding: 0.5rem clamp(0.5rem, 4vw, 0.75rem);
    border-radius: 16px;
    box-shadow: none;
    border: 1px solid var(--border-color);
    max-width: min(100%, 520px);
    margin: 0 auto clamp(1rem, 4vw, 1.5rem);
    overflow: visible;
  }

  .memorial-nav a {
    font-size: 0.85rem;
    padding: 0.45rem 0.6rem;
    flex: initial;
    background-color: var(--card-bg);
    border-radius: 10px;
    border: 1px solid transparent;
    white-space: normal;
  }

  .memorial-nav a:hover,
  .memorial-nav a.active {
    background-color: color-mix(in srgb, var(--theme-primary, var(--primary-gray)), white 82%);
  }
}

/* ===== Relationships (explicit & directional) ===== */
.relationships-section {
  margin-top: 1.5rem;
}
.relationship-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}
.relationship-card {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: var(--card-bg, #fff);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 120ms ease, transform 120ms ease, border-color 120ms ease;
  cursor: pointer;
}
.relationship-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--theme-primary, var(--primary-teal));
  transform: translateY(-1px);
}
.relationship-names {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}
.relationship-names .name {
  max-width: 45%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.relationship-names .arrow {
  opacity: 0.7;
}
.relationship-roles {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.4rem;
  font-size: 0.92rem;
}
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--muted-bg, #f6f8f9);
  font-weight: 600;
}
.role-from {
  border-color: var(--theme-primary, var(--primary-teal));
  background: color-mix(in srgb, var(--theme-primary, #14b8a6) 12%, white);
}
.role-to {
  border-color: #adb5bd;
  background: #eef2f4;
}
.role-sep {
  color: #6c757d;
}

.role-inline {
  font-weight: 600;
  opacity: 0.85;
}

/* --- Theme Selector Grid --- */
.theme-selector-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.theme-choice {
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.theme-choice:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.theme-choice.selected {
  border-color: var(--theme-primary, var(--primary-teal));
  box-shadow: 0 0 0 3px rgba(102, 193, 190, 0.2);
}

.theme-choice img {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  display: block;
}

.theme-choice .theme-name {
  padding: 0.5rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dark);
}

/* --- Clouds Theme Fixes --- */
body.theme-glass .hero__video {
  position: absolute;
  top: 0 !important;
  left: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  z-index: 0;
  transform: none !important;
}

body.theme-glass .eulogy-image-column {
  position: sticky !important;
  top: 100px;
  height: fit-content;
}

/* --- Masonry Media Queries --- */
@media (max-width: 900px) {
  .photo-gallery-grid {
    column-count: 2;
  }
}

@media (max-width: 600px) {
  .photo-gallery-grid {
    column-count: 1;
  }
}
