/* Social-post album: responsive layout, progressive feed, and lightbox. */
:root {
  color-scheme: light;
  --ink: #342c30;
  --muted: #82747a;
  --paper: #faf6f5;
  --surface: #fff;
  --line: #eee4e3;
  --rose: #c97d91;
  --rose-dark: #8f5266;
  --shadow: 0 10px 32px rgb(62 40 48 / 7%);
}
* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input { font: inherit; }
button { color: inherit; }
.site-header {
  position: sticky;
  z-index: 5;
  top: 0;
  width: 100%;
  padding: 15px clamp(16px, 4vw, 60px);
  background: rgb(255 253 252 / 94%);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}
.site-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
}
.site-brand h1 {
  margin: 0;
  color: var(--rose-dark);
  font-size: clamp(1.35rem, 2.2vw, 1.8rem);
  line-height: 1.2;
  letter-spacing: -.04em;
}
.header-tools { width: min(440px, 48vw); }
.search-input {
  width: 100%;
  min-width: 0;
  padding: 10px 14px;
  border: 1px solid #e5d9da;
  border-radius: 999px;
  background: #fbf8f7;
  color: var(--ink);
  outline: none;
}
.search-input:focus-visible { border-color: var(--rose); box-shadow: 0 0 0 3px rgb(201 125 145 / 18%); }
.search-input:disabled { opacity: .65; }
.page-shell { max-width: 1440px; margin: 0 auto; padding: 18px clamp(14px, 3vw, 36px) 56px; }
.gallery-status { min-height: 1.5em; margin: 0 2px 16px; color: var(--muted); font-size: .88rem; }
.gallery-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; gap: 24px; }
.image-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  scroll-margin-top: 90px;
}
.post-header { display: flex; align-items: center; gap: 11px; min-height: 64px; padding: 11px 14px; }
.post-avatar, .lightbox-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: linear-gradient(145deg, #eab3c0, #9c6577);
  box-shadow: 0 0 0 2px #e7c4cc;
  color: #fff;
  font-weight: 750;
}
.post-profile { display: grid; min-width: 0; line-height: 1.25; }
.post-profile strong { font-size: .94rem; }
.post-profile span { color: var(--muted); font-size: .72rem; }
.post-media { display: block; overflow: hidden; background: #f1e8e7; line-height: 0; }
.post-image { display: block; width: 100%; height: auto; aspect-ratio: 2 / 3; object-fit: cover; }
.post-actions { display: flex; align-items: center; gap: 6px; padding: 7px 12px 0; }
.post-action {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 8px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color .16s ease, color .16s ease, transform .16s ease;
}
.post-action:hover { background: #f8eeee; color: var(--rose-dark); }
.post-action:active { transform: scale(.92); }
.post-action:focus-visible, .load-more:focus-visible, .lightbox-close:focus-visible { outline: 3px solid #bc7187; outline-offset: 2px; }
.post-action svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.post-save { margin-left: auto; }
.post-save.is-saved { color: var(--rose-dark); }
.post-save.is-saved svg { fill: #d995a8; }
.post-body { padding: 1px 15px 16px; }
.generation-time { display: block; margin: 0 0 5px; color: var(--muted); font-size: .74rem; font-variant-numeric: tabular-nums; letter-spacing: .025em; }
.post-caption { margin: 0 0 12px; font-size: .96rem; line-height: 1.45; overflow-wrap: anywhere; }
.caption-account { margin-right: 4px; color: #4d333d; }
.tag-list { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { padding: 3px 8px; border-radius: 999px; background: #f7f1f0; color: #705d63; font-size: .72rem; line-height: 1.4; overflow-wrap: anywhere; }
.no-results, .load-error { margin: 26px 2px; color: var(--muted); }
.infinite-sentinel { width: 100%; height: 1px; }
.load-more {
  display: block;
  min-height: 46px;
  margin: 4px auto 12px;
  padding: 10px 22px;
  border: 1px solid #e1cbd1;
  border-radius: 999px;
  background: #fff;
  color: var(--rose-dark);
  font-weight: 650;
  cursor: pointer;
}
.load-more:hover { background: #fbf0f3; }
.load-more[hidden] { display: none; }
.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; }
.lightbox {
  width: min(96vw, 1040px);
  max-width: 96vw;
  max-height: 96dvh;
  padding: 0;
  overflow: visible;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: #fff;
}
.lightbox::backdrop { background: rgb(24 17 20 / 78%); backdrop-filter: blur(5px); }
.lightbox-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 96dvh;
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 18%);
  border-radius: 18px;
  background: #211a1d;
  box-shadow: 0 24px 90px rgb(0 0 0 / 35%);
}
.lightbox-close {
  position: absolute;
  z-index: 2;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0 0 4px;
  border: 1px solid rgb(255 255 255 / 50%);
  border-radius: 50%;
  background: rgb(24 17 20 / 72%);
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
}
.lightbox-close:hover { background: #fff; color: #2d2428; }
.lightbox-media { display: grid; min-height: 0; flex: 1 1 auto; place-items: center; background: #171214; }
.lightbox-image { display: block; width: auto; height: auto; max-width: 96vw; max-height: calc(96dvh - 88px); object-fit: contain; }
.lightbox-caption { display: flex; flex: 0 0 auto; align-items: center; gap: 11px; min-height: 66px; padding: 9px 16px; background: #211a1d; }
.lightbox-caption > div { display: grid; gap: 2px; }
.lightbox-caption time { color: #d9cbd0; font-size: .8rem; font-variant-numeric: tabular-nums; }
@media (max-width: 1020px) { .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; } }
@media (max-width: 700px) {
  html { scroll-snap-type: y proximity; }
  .site-header { padding: 12px 14px; }
  .site-brand { align-items: stretch; flex-direction: column; gap: 10px; }
  .header-tools { width: 100%; }
  .search-input { min-height: 44px; }
  .page-shell { padding: 14px 10px 36px; }
  .gallery-status { margin: 0 5px 11px; }
  .gallery-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .image-card { width: min(100%, 560px); margin: 0 auto; border-radius: 16px; scroll-snap-align: start; scroll-snap-stop: normal; }
  .post-header { min-height: 60px; }
  .post-body { padding: 1px 14px 15px; }
  .tag-chip { font-size: .71rem; }
  .lightbox { width: 100vw; max-width: 100vw; max-height: 100dvh; border-radius: 0; }
  .lightbox-panel { max-height: 100dvh; min-height: 100dvh; border: 0; border-radius: 0; }
  .lightbox-image { max-width: 100vw; max-height: calc(100dvh - 82px); }
  .lightbox-close { top: max(12px, env(safe-area-inset-top)); right: 14px; width: 52px; height: 52px; }
  .lightbox-caption { padding: 10px 18px max(10px, env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
