:root {
  color-scheme: light;
  --bg: #f7f3ea;
  --ink: #20201d;
  --muted: #776f63;
  --line: #ded4c3;
  --paper: #fffaf1;
  --accent: #0f766e;
  --accent-ink: #f4fffb;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font: inherit;
}

.shell {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(26px, env(safe-area-inset-bottom));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(18px);
}

.kicker,
.summary p,
.empty p,
.tile time,
#viewerCaption {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

h1 {
  margin: 2px 0 0;
  font-size: clamp(30px, 9vw, 54px);
  line-height: .96;
  letter-spacing: 0;
}

.icon-button,
.viewer-close {
  display: grid;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 250, 241, .86);
  box-shadow: 0 10px 28px rgba(55, 46, 30, .08);
}

.icon-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  margin: 8px 0 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.summary strong {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.3;
}

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

.tile {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: #e9dfcf;
  color: inherit;
  text-align: left;
  aspect-ratio: 3 / 4;
}

.tile:nth-child(5n + 1) {
  grid-row: span 2;
  aspect-ratio: 3 / 5;
}

.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 180ms ease, transform 240ms ease;
}

.tile img.is-loaded {
  opacity: 1;
  transform: scale(1);
}

.tile time {
  position: absolute;
  left: 8px;
  bottom: 8px;
  max-width: calc(100% - 16px);
  padding: 4px 7px;
  border-radius: 999px;
  color: #fff;
  background: rgba(0, 0, 0, .45);
  backdrop-filter: blur(8px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty {
  margin: 34px 0;
  padding: 26px 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.viewer {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  padding: max(14px, env(safe-area-inset-top)) 12px max(18px, env(safe-area-inset-bottom));
  background: rgba(17, 16, 14, .94);
}

.viewer[hidden],
[hidden] {
  display: none !important;
}

.viewer img {
  max-width: 100%;
  max-height: calc(100vh - 96px);
  border-radius: 8px;
  object-fit: contain;
}

.viewer-close {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  border-color: rgba(255, 255, 255, .18);
  color: #fff;
  background: rgba(0, 0, 0, .45);
  font-size: 28px;
  line-height: 1;
}

#viewerCaption {
  min-height: 24px;
  margin-top: 12px;
  color: rgba(255, 255, 255, .76);
}

@media (min-width: 600px) {
  .gallery {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
  }
}
