:root {
  /* Memorial colors */
  --color-cream: #faf8f5;
  --color-warm-white: #f5f2ed;
  --color-sage: #a8b5a0;
  --color-sage-dark: #6b7865;
  --color-charcoal: #3d3d3d;
  --color-soft-black: #2a2a2a;
  --color-gold: #c9a962;
  --color-gold-light: #dcc584;
  --color-border: rgba(61, 61, 61, 0.1);

  /* Typography - newspaper style with Times New Roman */
  --font-display: "Times New Roman", Times, "Noto Serif", Georgia, serif;
  --font-body: "Times New Roman", Times, "Noto Serif", Georgia, serif;

  /* Override Pico defaults */
  --pico-background-color: #faf8f5;
  --pico-color: #3d3d3d;
  --pico-font-family: "Times New Roman", Times, "Noto Serif", Georgia, serif;
  --pico-font-weight: 300;
  --pico-border-radius: 0.25rem;
  --pico-spacing: 1rem;

  /* Text size scaling for accessibility */
  --text-scale: 1;
}

/* Text Size Scaling Classes */
body.text-size-large {
  --text-scale: 1.15;
}

body.text-size-xlarge {
  --text-scale: 1.3;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  background: var(--color-cream);
  color: var(--color-charcoal);
  line-height: 1.7;
  font-weight: 300;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
}

/* Skip Navigation Link - Hidden until keyboard focus */
.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--color-soft-black);
  color: white;
  padding: 0.75rem 1.5rem;
  text-decoration: none;
  z-index: 10000;
  border-radius: 0 0 4px 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-100%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.skip-link:focus {
  top: 0;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

/* Header - Compact Design */
.header {
  background: linear-gradient(
    180deg,
    var(--color-warm-white) 0%,
    var(--color-cream) 100%
  );
  padding: 1.5rem 1rem;
  border-bottom: 1px solid var(--color-border);
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.header-compact .header-inner {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  text-align: center;
}

@media (min-width: 768px) {
  .header {
    padding: 1.5rem 2rem;
  }

  .header-compact .header-inner {
    flex-direction: row;
    text-align: left;
    gap: 2rem;
    align-items: center;
  }
}

.header-photo-wrapper {
  flex-shrink: 0;
}

.header-photo {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  border: 3px solid var(--color-gold);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  transition: transform 0.3s ease, box-shadow 0.3s ease, opacity 0.5s ease;
  opacity: 1;
  cursor: pointer;
}

.header-photo.loading {
  opacity: 0.3;
}

.header-photo:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
}

@media (min-width: 768px) {
  .header-photo {
    width: 140px;
    height: 140px;
  }
}

.header-content {
  flex: 1;
  min-width: 0;
}

.header-ornament {
  color: var(--color-gold);
  font-size: 0.875rem;
  letter-spacing: 0.3rem;
  margin-bottom: 0.25rem;
}

@media (min-width: 768px) {
  .header-ornament {
    font-size: 1rem;
  }
}

.header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 5vw, 2.5rem);
  font-weight: 300;
  color: var(--color-soft-black);
  letter-spacing: 0.03em;
  margin-bottom: 0.125rem;
  line-height: 1.2;
}

.header .dates {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--color-charcoal);
  font-style: italic;
  margin-bottom: 0.5rem;
}

.header .tribute-message {
  font-size: 0.875rem;
  color: var(--color-sage-dark);
  font-style: italic;
  margin-bottom: 0.625rem;
  line-height: 1.5;
}

/* Inline Stats */
.header-stats {
  font-size: 0.8rem;
  color: var(--color-charcoal);
  margin-bottom: 0.5rem;
}

.stat-inline {
  white-space: nowrap;
}

.stat-inline strong {
  color: var(--color-gold);
  font-weight: 600;
}

.stat-divider {
  margin: 0 0.4rem;
  color: var(--color-border);
}

/* Visitor stat - subtle styling */
.visitor-stat {
  opacity: 0.7;
  font-size: 0.75rem;
}

.visitor-stat strong {
  color: var(--color-sage-dark);
  font-weight: 500;
}

/* Header Navigation Links */
.header-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.375rem 1rem;
  font-size: 0.8rem;
}

@media (min-width: 768px) {
  .header-links {
    justify-content: flex-start;
  }
}

/* Mobile: Center the inline stats too */
@media (max-width: 767px) {
  .header-stats {
    justify-content: center;
  }
}

.header-links a {
  color: var(--color-sage-dark);
  text-decoration: none;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.header-links a:hover {
  color: var(--color-sage);
  text-decoration: underline;
}

.header-links a:focus-visible {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Legacy stats-bar styles kept for compatibility */
.stats-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}

@media (min-width: 576px) {
  .stats-bar {
    gap: 3rem;
  }
}

@media (max-width: 480px) {
  .stats-bar {
    flex-direction: column;
    gap: 1.5rem;
  }
}

.stat {
  text-align: center;
}

.stat-number {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--color-gold);
  font-weight: 500;
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-charcoal);
  font-weight: 500;
}

/* Main Content - Use PicoCSS container */
.main-content {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

@media (min-width: 768px) {
  .main-content {
    padding: 1.5rem 2rem;
  }
}

/* Form Section */
.form-section {
  background: white;
  border-radius: 4px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 100%;
}

@media (min-width: 768px) {
  .form-section {
    padding: 2.5rem;
    margin-bottom: 4rem;
  }
}

.form-section h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  color: var(--color-soft-black);
}

.form-section .subtitle {
  color: var(--color-charcoal);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

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

@media (max-width: 767px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* Fieldset styling */
fieldset {
  border: none;
  padding: 0;
  margin: 0;
}

fieldset legend {
  padding: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-charcoal);
  font-weight: 500;
  margin-bottom: 0.5rem;
}

/* Override PicoCSS form styles */
input,
textarea,
select {
  font-family: var(--font-body);
  background: var(--color-cream);
  border-color: var(--color-border);
  color: var(--color-soft-black);
  width: 100%;
  max-width: 100%;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-sage);
  background: white;
  color: var(--color-soft-black);
}

/* Ensure placeholder text is readable */
input::placeholder,
textarea::placeholder {
  color: #6b7865;
  opacity: 1;
}

textarea {
  min-height: 150px;
  resize: vertical;
  line-height: 1.8;
}

.char-count {
  font-size: 0.8rem;
  color: var(--color-charcoal);
  text-align: right;
  margin-top: 0.5rem;
}

/* Photo Upload */
.photo-upload-area {
  border: 2px dashed var(--color-border);
  border-radius: 4px;
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  background: var(--color-cream);
}

.photo-upload-area:hover {
  border-color: var(--color-sage);
  background: white;
}

.photo-upload-area.dragover {
  border-color: var(--color-gold);
  background: rgba(201, 169, 98, 0.05);
}

.upload-icon {
  font-size: 2rem;
  color: var(--color-sage);
  margin-bottom: 0.5rem;
}

.upload-text {
  color: var(--color-soft-black);
  font-size: 0.9rem;
  font-weight: 500;
}

.upload-hint {
  color: var(--color-charcoal);
  font-size: 0.8rem;
  margin-top: 0.5rem;
}

#photoInput {
  display: none;
}

.photo-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 576px) {
  .photo-preview-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1rem;
  }
}

.preview-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
}

.preview-item img,
.memory-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-width: 100%;
}

.preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 44px;
  height: 44px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease;
}

.preview-remove:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.1);
}

.preview-remove:focus {
  outline: 2px solid white;
  outline-offset: 2px;
}

/* Buttons - Override PicoCSS */
.submit-btn,
button[type="submit"] {
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  background: var(--color-soft-black);
  border-color: var(--color-soft-black);
  color: white;
  width: 100%;
  max-width: 100%;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

@media (min-width: 576px) {
  .submit-btn,
  button[type="submit"] {
    width: auto;
  }
}

.submit-btn:hover:not(:disabled),
button[type="submit"]:hover:not(:disabled) {
  background: var(--color-charcoal);
  border-color: var(--color-charcoal);
  transform: translateY(-1px);
}

.submit-btn:focus-visible,
button[type="submit"]:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

.submit-btn:disabled,
button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Focus indicators for form inputs */
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--color-sage);
  outline-offset: 2px;
}

.photo-upload-area:focus-within {
  outline: 3px solid var(--color-sage);
  outline-offset: 2px;
  border-color: var(--color-sage);
}

/* Visually hidden but accessible to screen readers */
.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;
}

/* Messages */
.message {
  padding: 1rem 1.25rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.message.success {
  background: rgba(168, 181, 160, 0.2);
  border: 1px solid var(--color-sage);
  color: var(--color-sage-dark);
}

.message.error {
  background: rgba(200, 100, 100, 0.1);
  border: 1px solid rgba(200, 100, 100, 0.3);
  color: #8b4444;
}

/* Memories Section */
.memories-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.memories-header h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
}

.export-btn,
.back-button {
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: transparent;
  color: var(--color-charcoal);
  border: 1px solid var(--color-charcoal);
  white-space: nowrap;
  transition: all 0.2s ease;
  font-weight: 500;
}

.export-btn:hover,
.back-button:hover {
  border-color: var(--color-soft-black);
  background: var(--color-soft-black);
  color: white;
}

.export-btn:focus-visible,
.back-button:focus-visible {
  outline: 3px solid var(--color-sage);
  outline-offset: 2px;
}

/* Memory Cards */
.memory-card {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 100%;
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  /* Staggered animation - delay set via JS */
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
  animation-delay: var(--animation-delay, 0ms);
}

.memory-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1), 0 4px 12px rgba(0, 0, 0, 0.05);
  border-color: var(--color-sage);
}

@media (min-width: 768px) {
  .memory-card {
    padding: 2rem;
  }
}

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

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .memory-card {
    opacity: 1;
    transform: none;
    animation: none;
  }
  .memory-card:hover {
    transform: none;
  }
}

.memory-card.featured {
  border-left: 4px solid var(--color-gold);
  background: linear-gradient(135deg, white 0%, rgba(201, 169, 98, 0.03) 100%);
}

.memory-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.memory-author {
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-soft-black);
}

.memory-relationship {
  font-size: 0.85rem;
  color: var(--color-charcoal);
  font-style: italic;
}

.memory-date {
  font-size: 0.8rem;
  color: var(--color-charcoal);
}

.memory-story {
  font-size: 1rem;
  line-height: 1.9;
  color: var(--color-charcoal);
  margin-bottom: 1.5rem;
}

.memory-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 576px) {
  .memory-photos {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
}

.memory-photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
}

.memory-photo img {
  transition: transform 0.3s ease, opacity 0.3s ease;
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

@keyframes fadeIn {
  to {
    opacity: 1;
  }
}

.memory-photo:hover img {
  transform: scale(1.05);
}

.photo-download {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  text-decoration: none;
  color: var(--color-charcoal);
  font-size: 1.1rem;
}

.memory-photo:hover .photo-download {
  opacity: 1;
}

/* Support section styles (matches your memorial aesthetic) */
.support-section {
  margin-top: 2rem;
}

@media (min-width: 768px) {
  .support-section {
    margin-top: 3rem;
  }
}

.support-card {
  background: white;
  border-radius: 4px;
  padding: 1.5rem;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--color-border);
  text-align: center;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 768px) {
  .support-card {
    padding: 2.5rem;
  }
}

.support-card h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  color: var(--color-soft-black);
}

.support-subtitle {
  color: var(--color-charcoal);
  font-size: 0.95rem;
  line-height: 1.8;
  max-width: 720px;
  margin: 0.75rem auto 1.5rem;
}

.support-btn {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  background: var(--color-sage);
  border: 1px solid var(--color-sage);
  color: white;
  text-decoration: none;
  padding: 0.85rem 1.1rem;
  border-radius: 4px;
  transition: transform 0.15s ease, background 0.15s ease,
    border-color 0.15s ease;
}

.support-btn:hover {
  background: var(--color-sage-dark);
  border-color: var(--color-sage-dark);
  transform: translateY(-1px);
}

.support-note {
  margin-top: 1.25rem;
  color: var(--color-charcoal);
  font-size: 0.85rem;
  font-style: italic;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

@media (min-width: 576px) {
  .lightbox {
    padding: 2rem;
  }
}

.lightbox.active {
  display: flex;
}

.lightbox img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  width: auto;
  height: auto;
}

.lightbox-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 44px;
  height: 44px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.lightbox-close:focus-visible {
  outline: 3px solid white;
  outline-offset: 2px;
  background: rgba(255, 255, 255, 0.15);
}

/* Photo Gallery Modal */
.photo-gallery {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 2rem 1rem;
}

.photo-gallery.active {
  display: flex;
}

.gallery-container {
  max-width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.gallery-image-wrapper {
  position: relative;
  max-width: 90vw;
  max-height: 65vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-image {
  max-width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
}

.gallery-caption {
  background: rgba(255, 255, 255, 0.95);
  padding: 1.5rem 2rem;
  border-radius: 8px;
  max-width: 600px;
  text-align: center;
}

.gallery-author {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--color-soft-black);
  margin: 0 0 0.5rem 0;
  font-weight: 500;
}

.gallery-story {
  font-size: 0.9rem;
  color: var(--color-charcoal);
  line-height: 1.6;
  font-style: italic;
}

.gallery-counter {
  color: white;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  opacity: 0.8;
}

.gallery-keyboard-hint {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  margin-top: 0.25rem;
  font-style: italic;
}

.gallery-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.5rem;
  color: var(--color-soft-black);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-nav:hover {
  background: white;
  transform: translateY(-50%) scale(1.1);
}

.gallery-nav:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

.gallery-nav.prev {
  left: -60px;
}

.gallery-nav.next {
  right: -60px;
}

@media (max-width: 768px) {
  .gallery-nav.prev {
    left: -10px;
  }

  .gallery-nav.next {
    right: -10px;
  }

  .gallery-nav {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
  }
}

.gallery-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 50px;
  height: 50px;
  background: rgba(255, 255, 255, 0.9);
  border: none;
  color: var(--color-soft-black);
  font-size: 2rem;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}

.gallery-close:hover {
  background: white;
  transform: scale(1.1);
}

.gallery-close:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

/* Loading */
.loading {
  text-align: center;
  padding: 3rem;
  color: var(--color-charcoal);
}

.spinner {
  width: 40px;
  height: 40px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-sage);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--color-charcoal);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Footer */
.footer {
  text-align: center;
  padding: 3rem 2rem;
  border-top: 1px solid var(--color-border);
  color: var(--color-charcoal);
  font-size: 0.85rem;
}

.footer-ornament {
  color: var(--color-gold);
  margin-bottom: 1rem;
}

.footer-license {
  margin-top: 1.25rem;
  font-size: 0.7rem;
  opacity: 0.5;
  letter-spacing: 0.02em;
}

.footer-license a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(0, 0, 0, 0.3);
}

.footer-license a:hover {
  opacity: 1;
  text-decoration-color: currentColor;
}

/* Articles Link */
.articles-link-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(
    135deg,
    rgba(168, 181, 160, 0.08) 0%,
    rgba(212, 175, 55, 0.06) 100%
  );
  border-radius: 12px;
  border: 1px solid rgba(168, 181, 160, 0.2);
}

.articles-link-container a.secondary {
  background: white;
  border-color: var(--color-sage);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  font-size: 0.85rem;
}

.articles-link-container a.secondary:hover {
  background: var(--color-sage);
  color: white;
  border-color: var(--color-sage);
  box-shadow: 0 4px 12px rgba(168, 181, 160, 0.3);
  transform: translateY(-1px);
}

a.secondary {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 0.875rem 2rem;
  background: transparent;
  color: var(--color-charcoal);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  font-weight: 500;
}

a.secondary:hover {
  border-color: var(--color-sage);
  color: var(--color-sage-dark);
  background: rgba(168, 181, 160, 0.05);
}

a.secondary:focus {
  outline: 2px solid var(--color-gold);
  outline-offset: 2px;
}

/* Single Memory View */
.view-single {
  display: none;
}

.view-single.active {
  display: block;
}

.view-list.hidden {
  display: none;
}

.back-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  margin-bottom: 2rem;
}

.single-memory-container {
  background: white;
  border-radius: 4px;
  padding: 1.5rem;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--color-border);
  width: 100%;
  max-width: 100%;
}

@media (min-width: 768px) {
  .single-memory-container {
    padding: 3rem;
  }
}

.single-memory-meta {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--color-border);
}

.single-memory-author {
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--color-soft-black);
  margin-bottom: 0.5rem;
}

.single-memory-relationship {
  font-size: 1.1rem;
  color: var(--color-charcoal);
  font-style: italic;
  margin-bottom: 1rem;
}

.single-memory-date {
  font-size: 0.85rem;
  color: var(--color-charcoal);
}

.single-memory-story {
  font-size: 1.1rem;
  line-height: 2;
  color: var(--color-charcoal);
  margin-bottom: 3rem;
  white-space: pre-wrap;
}

.single-memory-photos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 576px) {
  .single-memory-photos {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
  }
}

.memory-card:focus-within {
  outline: 3px solid var(--color-sage);
  outline-offset: 2px;
}

.memory-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.memory-card-link {
  display: inline-block;
  color: var(--color-sage-dark);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  transition: color 0.2s ease;
}

.memory-card-link:hover {
  color: var(--color-sage);
  text-decoration: underline;
}

.memory-card-link:focus {
  outline: 2px solid var(--color-sage);
  outline-offset: 2px;
  border-radius: 2px;
}

/* Share Button */
.share-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: var(--color-sage);
  border-color: var(--color-sage);
  color: white;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.share-btn:hover {
  background: var(--color-sage-dark);
  border-color: var(--color-sage-dark);
}

.share-btn:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

.share-btn.copied {
  background: var(--color-gold);
  border-color: var(--color-gold);
}

/* Heart Button */
.heart-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: transparent;
  border: 2px solid var(--color-sage);
  color: var(--color-sage);
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.heart-btn:hover {
  background: rgba(123, 150, 130, 0.1);
}

.heart-btn:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

.heart-btn.hearted {
  background: var(--color-sage);
  color: white;
}

.heart-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.heart-icon {
  font-size: 1.2rem;
  line-height: 1;
}

.heart-count {
  font-weight: 500;
}

/* Heart button in memory cards (list view) */
.memory-heart {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--color-charcoal);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  transition: all 0.2s ease;
  border: none;
  background: transparent;
}

.memory-heart:hover {
  background: rgba(123, 150, 130, 0.1);
}

.memory-heart.hearted .heart-icon {
  color: var(--color-sage);
}

.memory-heart:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.single-memory-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--color-border);
}

/* ========================================
   UTILITY CLASSES (Replace Inline Styles)
   ======================================== */

/* Export section styling */
.export-section {
  text-align: center;
  padding: 2rem 1rem;
}

.export-description {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--color-charcoal);
}

/* Export buttons layout */
.export-buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2rem;
}

.export-option {
  text-align: center;
}

.book-btn {
  background: linear-gradient(
    135deg,
    var(--color-sage) 0%,
    var(--color-sage-dark) 100%
  );
  border: none;
  color: white;
}

.book-btn:hover {
  background: linear-gradient(135deg, var(--color-sage-dark) 0%, #5a6a54 100%);
  color: white;
}

.book-icon {
  margin-right: 0.5rem;
}

/* ============================================
   Memory Book Modal
   ============================================ */

.book-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 1000;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.book-modal.active {
  display: flex;
}

.book-modal-content {
  background: var(--color-cream);
  border-radius: 12px;
  max-width: 580px;
  width: 100%;
  padding: 1.5rem;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.book-modal-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-charcoal);
  width: 1.75rem;
  height: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
  z-index: 1;
}

.book-modal-close:hover {
  background: rgba(0, 0, 0, 0.1);
}

/* Horizontal layout */
.book-modal-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.book-modal-fields {
  flex: 1;
  min-width: 0;
}

.book-modal-fields h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  color: var(--color-charcoal);
}

.book-modal-subtitle {
  color: var(--color-sage-dark);
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.book-form .form-group {
  margin-bottom: 0.875rem;
}

.book-form label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  margin-bottom: 0.35rem;
  color: var(--color-charcoal);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.book-form input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  background: white;
}

.book-form input:focus {
  outline: none;
  border-color: var(--color-sage);
  box-shadow: 0 0 0 3px rgba(168, 181, 160, 0.2);
}

/* Book Preview - compact */
.book-preview {
  flex-shrink: 0;
}

.book-preview-cover {
  background: linear-gradient(135deg, var(--color-cream) 0%, #f0ebe3 100%);
  border: 1.5px solid var(--color-border);
  border-radius: 3px;
  padding: 1.25rem 1rem;
  width: 150px;
  text-align: center;
  box-shadow: 3px 3px 0 0 rgba(0, 0, 0, 0.04), 6px 6px 0 0 rgba(0, 0, 0, 0.02);
}

.preview-ornament {
  color: var(--color-gold);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  margin-bottom: 0.6rem;
}

.preview-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--color-charcoal);
  margin-bottom: 0.15rem;
  line-height: 1.25;
}

.preview-subtitle {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-style: italic;
  color: var(--color-sage-dark);
  margin-bottom: 0.6rem;
  line-height: 1.35;
}

.preview-meta {
  font-size: 0.55rem;
  color: var(--color-sage-dark);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* Modal Actions */
.book-modal-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.book-modal-actions button {
  flex: 1;
  padding: 0.7rem 1rem;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
}

.book-modal-actions .secondary {
  background: transparent;
  border: 1px solid var(--color-border);
  color: var(--color-charcoal);
}

.book-modal-actions .secondary:hover {
  background: rgba(0, 0, 0, 0.05);
}

.book-generate-btn {
  background: linear-gradient(
    135deg,
    var(--color-sage) 0%,
    var(--color-sage-dark) 100%
  );
  border: none;
  color: white;
}

.book-generate-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--color-sage-dark) 0%, #5a6a54 100%);
}

.book-generate-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.spinner-small {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Progress state */
.book-progress {
  text-align: center;
  padding: 1.5rem;
}

.book-progress .spinner {
  margin: 0 auto 0.75rem;
}

.progress-hint {
  font-size: 0.8rem;
  color: var(--color-sage-dark);
  margin-top: 0.35rem;
}

/* Mobile responsive - stack vertically on small screens */
@media (max-width: 576px) {
  .export-buttons {
    flex-direction: column;
    gap: 1.5rem;
  }

  .book-modal-content {
    padding: 1.25rem;
  }

  .book-modal-layout {
    flex-direction: column;
    align-items: center;
  }

  .book-modal-fields {
    order: 2;
    width: 100%;
  }

  .book-preview {
    order: 1;
    margin-bottom: 0.5rem;
  }

  .book-preview-cover {
    width: 130px;
    padding: 1rem 0.75rem;
  }

  .book-modal-actions {
    flex-direction: column;
  }
}

/* Empty state subtitle */
.empty-state-subtitle {
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Empty state link */
.empty-state-link {
  color: var(--color-sage);
  text-decoration: underline;
}

/* ============================================
   Confirmation Modal
   ============================================ */

.confirm-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1001;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

.confirm-modal.active {
  display: flex;
}

.confirm-modal-content {
  background: var(--color-cream);
  border-radius: 12px;
  max-width: 400px;
  width: 100%;
  padding: 2rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.25s ease-out;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.confirm-modal-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.confirm-modal-content h2 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  color: var(--color-charcoal);
  margin-bottom: 0.5rem;
}

.confirm-modal-message {
  color: var(--color-sage-dark);
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 1.5rem;
}

.confirm-modal-actions {
  display: flex;
  gap: 0.75rem;
}

.confirm-modal-actions button {
  flex: 1;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
}

.confirm-modal-actions .secondary {
  background: transparent;
  border: 1px solid var(--color-sage);
  color: var(--color-sage-dark);
}

.confirm-modal-actions .secondary:hover {
  background: var(--color-sage);
  color: white;
}

.confirm-modal-actions .primary {
  background: var(--color-sage);
  color: white;
}

.confirm-modal-actions .primary:hover {
  background: var(--color-sage-dark);
}

@media (max-width: 576px) {
  .confirm-modal-content {
    padding: 1.5rem;
  }

  .confirm-modal-actions {
    flex-direction: column;
  }

  .confirm-modal-actions .secondary {
    order: 2;
  }

  .confirm-modal-actions .primary {
    order: 1;
  }
}

/* ============================================
   Text Size Control - Accessibility Feature
   ============================================ */

/* Floating text size control button */
.text-size-control {
  position: fixed;
  bottom: calc(20px + env(safe-area-inset-bottom));
  right: calc(20px + env(safe-area-inset-right));
  z-index: 1000;
  font-family: var(--font-body);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--color-soft-black);
  color: var(--color-cream);
  padding: 0.85rem 1.15rem;
  cursor: pointer;
  border: none;
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25), 0 2px 4px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
}

.text-size-control:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3), 0 3px 6px rgba(0, 0, 0, 0.2);
  background: var(--color-charcoal);
}

.text-size-control:active {
  transform: scale(0.95);
}

.text-size-control:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .text-size-control {
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: calc(16px + env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    font-size: 0.8rem;
  }
}

/* Apply text scaling to all body text (excludes large titles h1, h2, h3) */
p,
li,
td,
th,
label,
input,
textarea,
select,
button:not(.text-size-control),
figcaption,
blockquote,
.memory-story,
.single-memory-story,
.tribute-message,
.form-section .subtitle,
.gallery-story,
.memory-meta,
.single-memory-meta,
.form-help,
.photo-preview-name,
.message-text,
.empty-state p,
.export-description,
.empty-state-subtitle,
.footer p:not(.footer-license),
.nav-link,
.header-stats {
  font-size: calc(1rem * var(--text-scale));
}

/* Smaller text elements scale proportionally */
small,
.memory-date,
.single-memory-date,
.photo-count,
.form-note,
.character-count,
.stat-label {
  font-size: calc(0.85rem * var(--text-scale));
}

/* Medium-small text */
.memory-relationship {
  font-size: calc(0.9rem * var(--text-scale));
}

/* Medium emphasis text */
.memory-author {
  font-size: calc(1.15rem * var(--text-scale));
}

/* Stats numbers */
.stats-number {
  font-size: calc(1.5rem * var(--text-scale));
}

/* Links and navigation */
a:not(h1 a):not(h2 a):not(h3 a):not(.site-title) {
  font-size: calc(1rem * var(--text-scale));
}

/* Screen reader only announcement (visually hidden) */
.sr-announcement {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ============================================
   Decorative Flourishes & Dividers
   ============================================ */

.section-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 2.5rem 0;
  color: var(--color-sage);
}

.section-divider::before,
.section-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--color-border),
    transparent
  );
  max-width: 120px;
}

.section-divider .ornament {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--color-sage);
  opacity: 0.7;
}

.flourish {
  text-align: center;
  margin: 2rem 0;
  font-family: var(--font-display);
  font-size: 1.25rem;
  color: var(--color-sage);
  opacity: 0.5;
  letter-spacing: 0.5em;
}

/* ============================================
   Masonry Photo Grid
   ============================================ */

.memory-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

/* Single photo - larger display */
.memory-photos:has(.memory-photo:only-child) {
  grid-template-columns: 1fr;
  max-width: 400px;
}

/* Two photos - equal split */
.memory-photos:has(.memory-photo:nth-child(2):last-child) {
  grid-template-columns: repeat(2, 1fr);
}

/* Three+ photos - masonry-like feel */
.memory-photos:has(.memory-photo:nth-child(3)) .memory-photo:first-child {
  grid-row: span 2;
}

.memory-photo {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--color-warm-white);
}

.memory-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.memory-photo:hover img {
  transform: scale(1.05);
}

.memory-photo .photo-download {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  width: 32px;
  height: 32px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  text-decoration: none;
  color: var(--color-charcoal);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.memory-photo:hover .photo-download {
  opacity: 1;
  transform: translateY(0);
}

.memory-photo .photo-download:hover {
  background: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Single memory view - larger photos */
.single-memory-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 1.5rem;
}

.single-memory-photos .memory-photo {
  aspect-ratio: 4/3;
  border-radius: 8px;
}

/* ============================================
   Back to Top Button
   ============================================ */

.back-to-top {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  right: calc(20px + env(safe-area-inset-right));
  width: 48px;
  height: 48px;
  background: var(--color-soft-black);
  color: var(--color-cream);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s ease,
    background 0.2s ease;
  z-index: 999;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background: var(--color-charcoal);
  transform: translateY(-2px);
}

.back-to-top:focus-visible {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .back-to-top {
    bottom: calc(70px + env(safe-area-inset-bottom));
    right: calc(16px + env(safe-area-inset-right));
    width: 44px;
    height: 44px;
  }
}

/* ============================================
   Sort & Filter Controls
   ============================================ */

.memories-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.memories-count {
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--color-charcoal);
  opacity: 0.7;
}

.sort-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-label {
  font-size: 0.85rem;
  color: var(--color-charcoal);
  opacity: 0.7;
}

.sort-select {
  font-family: var(--font-body);
  font-size: 0.85rem;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  color: var(--color-charcoal);
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%233d3d3d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  min-width: 150px;
}

.sort-select:hover {
  border-color: var(--color-sage);
}

.sort-select:focus {
  outline: none;
  border-color: var(--color-sage);
  box-shadow: 0 0 0 3px rgba(168, 181, 160, 0.2);
}

@media (max-width: 480px) {
  .memories-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-controls {
    justify-content: space-between;
  }

  .sort-select {
    flex: 1;
  }
}

/* ============================================
   Standalone Photo Gallery Section
   ============================================ */

.gallery-section {
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.gallery-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.gallery-header h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--color-charcoal);
  margin: 0;
}

.gallery-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.2rem;
  background: var(--color-sage);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease;
}

.gallery-add-btn:hover {
  background: var(--color-sage-dark, #8fa388);
  transform: translateY(-1px);
}

.gallery-add-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(168, 181, 160, 0.4);
}

.gallery-helper {
  font-size: 0.9rem;
  color: var(--color-text-muted);
  margin-bottom: 1.25rem;
}

.gallery-helper a {
  color: var(--color-sage);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.gallery-helper a:hover {
  color: var(--color-sage-dark, #8fa388);
}

/* Gallery Grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.875rem;
}

@media (min-width: 576px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }
}

@media (min-width: 768px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1.25rem;
  }
}

/* Gallery Photo Item */
.gallery-photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--color-warm-white);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;

  /* Staggered animation - start visible, animation enhances the experience */
  opacity: 1;
  transform: translateY(0);
  animation: fadeInUp 0.4s ease forwards;
  animation-delay: var(--animation-delay, 0ms);
}

/* Animation starts items hidden, then animates to visible */
@supports (animation: fadeInUp 0.4s) {
  .gallery-photo-item {
    opacity: 0;
    transform: translateY(12px);
  }
}

.gallery-photo-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.gallery-photo-item:focus-within {
  outline: 3px solid var(--color-gold);
  outline-offset: 2px;
}

.gallery-photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-photo-item:hover img {
  transform: scale(1.05);
}

/* Photo Overlay with Uploader Info */
.gallery-photo-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  padding: 2rem 0.75rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.gallery-photo-item:hover .gallery-photo-overlay {
  opacity: 1;
}

.gallery-photo-uploader {
  color: white;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.3;
}

.gallery-photo-caption {
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.7rem;
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

/* Gallery photo download button */
.gallery-photo-item .photo-download {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  text-decoration: none;
  color: var(--color-charcoal);
  font-size: 1rem;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.gallery-photo-item:hover .photo-download {
  opacity: 1;
  transform: translateY(0);
}

.gallery-photo-item .photo-download:hover {
  background: white;
}

/* Gallery Form Section */
.gallery-form-section {
  background: white;
  border-radius: 8px;
  padding: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 20px rgba(0, 0, 0, 0.04);
  border: 1px solid var(--color-border);
}

@media (min-width: 768px) {
  .gallery-form-section {
    padding: 2rem;
  }
}

.gallery-form-section h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  color: var(--color-charcoal);
}

.gallery-form-section .subtitle {
  color: var(--color-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Form Actions (Cancel + Submit) */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
}

.form-actions .secondary-btn {
  flex: 0 0 auto;
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--color-charcoal);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.form-actions .secondary-btn:hover {
  background: var(--color-warm-white);
  border-color: var(--color-sage);
}

.form-actions .submit-btn {
  flex: 1;
}

@media (max-width: 576px) {
  .form-actions {
    flex-direction: column-reverse;
  }

  .form-actions .secondary-btn,
  .form-actions .submit-btn {
    width: 100%;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .gallery-photo-item {
    opacity: 1;
    transform: none;
    animation: none;
  }

  .gallery-photo-item:hover {
    transform: none;
  }

  .gallery-photo-item:hover img {
    transform: none;
  }
}
