.photo-gallery {
  gap: clamp(16px, 2vw, 24px) !important;
  grid-auto-rows: auto !important;
  align-items: stretch;
  transition: opacity 0.22s ease;
}

.photo-gallery > .gallery-img {
  width: 100%;
  height: auto !important;
  max-width: none;
  max-height: none;
  aspect-ratio: 4 / 3;
  box-sizing: border-box;
  padding: 6px;
  object-fit: cover !important;
  object-position: center;
  grid-column: auto !important;
  grid-row: auto !important;
  border: 1px solid rgba(73, 51, 58, 0.1) !important;
  border-radius: 6px !important;
  background: #fff !important;
  box-shadow:
    0 14px 30px rgba(54, 35, 42, 0.13),
    0 3px 8px rgba(54, 35, 42, 0.07) !important;
  filter: saturate(1.02) contrast(1.015);
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease !important;
}

.photo-gallery > .gallery-img:hover {
  z-index: 2;
  transform: translateY(-5px) scale(1.012) !important;
  box-shadow:
    0 22px 42px rgba(54, 35, 42, 0.17),
    0 5px 12px rgba(54, 35, 42, 0.09) !important;
  filter: saturate(1.06) contrast(1.025);
}

.photo-gallery .gallery-frame {
  position: relative;
  isolation: isolate;
  appearance: none;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  box-sizing: border-box;
  padding: 6px;
  overflow: hidden;
  border: 1px solid rgba(222, 151, 171, 0.32);
  border-radius: 6px;
  background: #fff6f8;
  box-shadow:
    0 14px 30px rgba(117, 64, 83, 0.12),
    0 3px 8px rgba(117, 64, 83, 0.06);
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.photo-gallery .gallery-frame::before {
  content: '';
  position: absolute;
  z-index: -2;
  inset: -22px;
  background-image: var(--photo-image);
  background-position: center;
  background-size: cover;
  filter: blur(20px) saturate(1.3) brightness(1.2);
  opacity: 0.14;
  transform: scale(1.08);
}

.photo-gallery .gallery-frame::after {
  content: '';
  position: absolute;
  z-index: -1;
  inset: 0;
  background: linear-gradient(145deg, rgba(255, 253, 251, 0.82), rgba(255, 238, 243, 0.7));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.88);
  pointer-events: none;
}

.photo-gallery .gallery-frame .gallery-img {
  display: block;
  width: 100%;
  height: 100% !important;
  max-width: none;
  max-height: none;
  box-sizing: border-box;
  padding: 0;
  object-fit: contain !important;
  object-position: center;
  border: 0 !important;
  border-radius: 3px !important;
  background: transparent !important;
  box-shadow: none !important;
  filter: drop-shadow(0 5px 12px rgba(39, 24, 29, 0.17)) saturate(1.025) contrast(1.015);
  cursor: inherit;
  transition: transform 0.35s ease, filter 0.35s ease !important;
}

.photo-gallery .gallery-frame:hover {
  z-index: 2;
  transform: translateY(-5px);
  box-shadow:
    0 22px 42px rgba(117, 64, 83, 0.16),
    0 5px 12px rgba(117, 64, 83, 0.08);
}

.photo-gallery .gallery-frame:hover .gallery-img {
  transform: scale(1.012) !important;
  filter: drop-shadow(0 7px 15px rgba(39, 24, 29, 0.19)) saturate(1.055) contrast(1.025);
}

.photo-gallery .gallery-frame:focus-visible {
  outline: 3px solid currentColor;
  outline-offset: 3px;
}

.photo-gallery .gallery-frame:active {
  transform: translateY(-2px) scale(0.995);
}

.timeline-img {
  box-sizing: border-box;
  padding: 5px;
  object-fit: contain !important;
  object-position: center;
  border: 1px solid rgba(73, 51, 58, 0.1) !important;
  border-radius: 6px !important;
  background: #fff !important;
  box-shadow:
    0 12px 26px rgba(54, 35, 42, 0.12),
    0 2px 7px rgba(54, 35, 42, 0.07) !important;
  filter: saturate(1.025) contrast(1.015);
  cursor: zoom-in;
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease !important;
}

.timeline-img:hover {
  box-shadow:
    0 18px 34px rgba(54, 35, 42, 0.16),
    0 4px 10px rgba(54, 35, 42, 0.08) !important;
  filter: saturate(1.055) contrast(1.025);
}

.native-icon {
  display: inline-flex;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  color: currentColor;
  font-family: Arial, "Segoe UI Symbol", sans-serif;
  font-style: normal;
  font-weight: 700;
  line-height: 1;
  vertical-align: -0.12em;
}

.native-icon-clock,
.native-icon-camera {
  position: relative;
  box-sizing: border-box;
}

.native-icon-clock {
  border: 0.08em solid currentColor;
  border-radius: 50%;
}

.native-icon-clock::before {
  content: "";
  position: absolute;
  top: 0.18em;
  left: 0.46em;
  width: 0.22em;
  height: 0.3em;
  box-sizing: border-box;
  border-left: 0.08em solid currentColor;
  border-bottom: 0.08em solid currentColor;
}

.native-icon-camera {
  height: 0.72em;
  margin-top: 0.14em;
  border: 0.08em solid currentColor;
  border-radius: 0.1em;
}

.native-icon-camera::before {
  content: "";
  position: absolute;
  top: -0.2em;
  left: 0.14em;
  width: 0.38em;
  height: 0.16em;
  border-radius: 0.06em 0.06em 0 0;
  background: currentColor;
}

.native-icon-camera::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.3em;
  height: 0.3em;
  box-sizing: border-box;
  border: 0.07em solid currentColor;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.image-error {
  opacity: 0.45;
}

.shared-home-return {
  position: fixed;
  z-index: 1100;
  left: max(16px, env(safe-area-inset-left));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex;
  height: 42px;
  align-items: center;
  gap: 7px;
  box-sizing: border-box;
  padding: 0 14px 0 10px;
  border: 1px solid rgba(147, 76, 99, 0.16);
  border-radius: 8px;
  color: #703e50;
  background: rgba(255, 252, 250, 0.94);
  box-shadow: 0 10px 28px rgba(73, 40, 52, 0.16);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font: 600 13px/1 'Noto Serif SC', serif;
  letter-spacing: 0;
  text-decoration: none !important;
  white-space: nowrap;
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.shared-home-return::before {
  content: '⌂';
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  color: #c64f75;
  background: #ffe5ec;
  font: 700 18px/1 Georgia, serif;
}

.shared-home-return--stacked {
  bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
}

.shared-home-return:hover {
  background: #fff;
  box-shadow: 0 13px 32px rgba(73, 40, 52, 0.2);
  transform: translateY(-2px);
}

.shared-home-return:focus-visible {
  outline: 3px solid #ff8eac;
  outline-offset: 3px;
}

.reveal-pending {
  opacity: 0 !important;
  transform: translate3d(var(--reveal-x, 0), var(--reveal-y, 24px), 0) !important;
  transition: opacity 0.55s ease, transform 0.55s ease !important;
}

.reveal-pending.is-revealed {
  opacity: 1 !important;
  transform: translate3d(0, 0, 0) !important;
}

.shared-image-viewer {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.86);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.shared-image-viewer.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.shared-image-viewer__image {
  display: block;
  max-width: min(94vw, 1600px);
  max-height: 90vh;
  box-sizing: border-box;
  padding: 8px;
  object-fit: contain;
  border-radius: 4px;
  background: #fff;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

.shared-image-viewer__close {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  right: max(16px, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: 32px/1 Arial, sans-serif;
  cursor: pointer;
}

@media (max-width: 480px) {
  .photo-gallery > .gallery-img,
  .photo-gallery .gallery-frame {
    padding: 4px;
  }

  .shared-image-viewer {
    padding: 12px;
  }
}

@media (max-width: 768px) {
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .timeline-scroll {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .navbar .container {
    gap: 12px;
  }

  .navbar .back-link {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .navbar .page-title {
    min-width: 0;
    font-size: 1.35rem !important;
    line-height: 1.35;
    text-align: right;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reveal-pending,
  .shared-image-viewer,
  .photo-gallery {
    transition: none !important;
  }
}
