:root {
  --bg: #0f1013;
  --fg: #ececec;
  --muted: rgba(255, 255, 255, .62);
  --gap: 6px;
  --radius: 6px;
  --pill-bg: rgba(22, 23, 27, .55);
  --pill-border: rgba(255, 255, 255, .08);
  --tile-ratio: 4 / 5;
  --cols: 5;
  --pill-h: 44px;
  color-scheme: dark;
}
@media (max-width: 1100px) { :root { --cols: 3; } }
@media (max-width: 640px)  { :root { --cols: 2; } }

* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  gap: var(--gap);
  padding: calc(var(--pill-h) + 20px) var(--gap) 96px;
}
.tile {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius);
  aspect-ratio: var(--tile-ratio);
  background: #16171b;
  outline-offset: 2px;
}
.tile img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .45s ease;
}
.tile img.is-loaded { opacity: 1; }

.tile-meta {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 3px;
  padding: 14px;
  background: linear-gradient(to top, rgba(0, 0, 0, .68), rgba(0, 0, 0, .18) 55%, transparent);
  opacity: 0;
  transition: opacity .25s ease;
  pointer-events: none;
}
.tile:hover .tile-meta,
.tile:focus-visible .tile-meta { opacity: 1; }
.tile-title {
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: .14em;
  text-transform: uppercase;
}
.tile-date { font-size: 11px; color: var(--muted); letter-spacing: .06em; }
@media (hover: none) { .tile-meta { display: none; } }

@media (prefers-reduced-motion: no-preference) {
  .tile {
    animation: tileIn .32s ease both;
    animation-delay: min(calc(var(--i, 0) * 14ms), 300ms);
  }
  @keyframes tileIn { from { opacity: 0; transform: scale(.97); } }
}

.empty {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .14em;
  text-transform: uppercase;
  pointer-events: none;
}
.empty[hidden] { display: none; } /* our display:grid must not beat the hidden attribute */

/* ---------- floating glass pills ---------- */
.pill {
  position: fixed;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .35);
}
.pill--top {
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 24px);
  height: var(--pill-h);
}
.brand {
  padding: 0 8px 0 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  white-space: nowrap;
}
.filters {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-left: 6px;
  border-left: 1px solid var(--pill-border);
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  transition: background .2s, color .2s;
}
.chip:hover { color: var(--fg); }
.chip[aria-pressed="true"] { background: #fff; color: #0f1013; }

.pill--profile {
  left: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  padding-right: 6px;
}
.avatar { display: block; width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.profile-name {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .14em;
  text-transform: uppercase;
  white-space: nowrap;
  padding-right: 4px;
}
.icon-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--muted);
  transition: background .2s, color .2s;
}
.icon-btn:hover { background: rgba(255, 255, 255, .1); color: var(--fg); }
@media (max-width: 640px) {
  .profile-name { display: none; }
  .brand { padding-left: 8px; }
}

/* ---------- lightbox ---------- */
.lightbox {
  border: 0;
  padding: 0;
  margin: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  background: transparent;
  color: var(--fg);
  overflow: hidden;
}
.lightbox::backdrop {
  background: rgba(10, 10, 12, .94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
html.lb-open { overflow: hidden; }

.lb-figure {
  margin: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 56px 16px 24px;
  pointer-events: none; /* empty space passes clicks to the dialog = close */
}
#lb-img {
  max-width: min(96vw, 1800px);
  max-height: 82vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 4px;
  pointer-events: auto;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 14px;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  pointer-events: auto;
}
.lb-date, .lb-original { color: var(--muted); }
.lb-original:hover { color: var(--fg); text-decoration: underline; }

.lb-btn {
  position: absolute;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  color: var(--fg);
  font-size: 26px;
  line-height: 1;
  transition: background .2s;
}
.lb-btn:hover { background: rgba(255, 255, 255, .16); }
.lb-btn:disabled { opacity: .25; cursor: default; }
.lb-close { top: 14px; right: 14px; font-size: 22px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
@media (max-width: 640px) {
  .lb-prev, .lb-next { display: none; } /* swipe instead */
  #lb-img { max-height: 76vh; }
}
