:root {
  color-scheme: light;
  --bg: #ffffff;
  --ink: #171717;
  --muted: #6f6f6f;
  --panel: #ffffff;
  --header: #d8d8d8;
  --line: #e4e4e4;
  --accent: #4f4f4f;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button {
  font: inherit;
}

.page-shell {
  width: 100%;
  margin: 0 auto;
  padding: 0 0 10px;
}

.site-header {
  display: flex;
  align-items: center;
  min-height: 70px;
  margin-bottom: 4px;
  padding: 18px clamp(14px, 2vw, 28px);
  background: var(--header);
}

h1 {
  margin: 0;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(1.05rem, 3vw, 1.8rem);
  font-weight: 500;
  line-height: 1.15;
  text-transform: lowercase;
}

.gallery-section {
  padding: 0 4px;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 4px;
}

.keepsake-card {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  box-shadow: none;
  cursor: pointer;
}

.keepsake-card img {
  width: 100%;
  height: 100%;
  min-height: 0;
  display: block;
  object-fit: cover;
  transition: filter 180ms ease, opacity 180ms ease;
}

.image-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 18px;
  color: var(--muted);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 1.3rem;
  text-align: center;
  background: #f4f4f4;
}

.keepsake-card.is-missing-image img {
  visibility: hidden;
}

.keepsake-card.is-missing-image .image-fallback {
  display: grid;
}

.keepsake-card:hover img,
.keepsake-card:focus-visible img {
  filter: brightness(0.92);
}

.keepsake-card:focus-visible {
  outline: 2px solid #111111;
  outline-offset: -2px;
}

.message-mark {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--accent);
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
}

.empty-state {
  max-width: 520px;
  margin: 28px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.dialog {
  width: min(720px, calc(100% - 28px));
  max-height: min(820px, calc(100vh - 28px));
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow);
}

.dialog[open] {
  animation: dialog-in 180ms ease-out;
}

.dialog::backdrop {
  background: rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(2px);
}

.dialog-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--ink);
  cursor: pointer;
}

.dialog-media-wrap {
  background: #f1f1f1;
}

.dialog-image {
  display: block;
  width: 100%;
  max-height: 56vh;
  object-fit: contain;
}

.dialog-text {
  padding: 26px;
}

.dialog-text h2 {
  margin: 0 0 12px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: clamp(1.05rem, 4vw, 1.4rem);
  font-weight: 600;
  text-transform: lowercase;
}

.dialog-text p {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
  white-space: pre-wrap;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.985);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding-bottom: 4px;
  }

  .site-header {
    min-height: 58px;
    margin-bottom: 3px;
    padding: 14px 12px;
  }

  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px;
  }

  .dialog-text {
    padding: 22px;
  }
}
