.page-shell {
  background: #fff;
  min-height: 100vh;
  padding: 100px 40px 60px;
}

/* Pages with a real backdrop effect (others, work, writing) need a
   transparent shell so the fixed .backdrop shows through, with the dark
   fallback color living on <html> (same reasoning as the homepage fix). */
html:has(body.dark-bg) {
  background: #060608;
}
body.dark-bg .page-shell {
  background: transparent;
}

/* Persistent instagram-link + audio-toggle bar, present on every page of
   the original site (found on a second SingleFile cross-check - see
   README). Two color variants depending on the page's background. */
.site-icons {
  position: absolute;
  top: 74px;
  left: 24px;
  right: 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 60;
  pointer-events: none;
}
.site-icons a, .site-icons button { pointer-events: auto; }
.site-icons .instagram-link {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.site-icons .instagram-link svg { width: 18px; height: 18px; fill: currentColor; }
.site-icons .audio-toggle {
  background: none;
  border: 1px solid currentColor;
  border-radius: 16px;
  padding: 6px 16px;
  font-family: var(--font-sans);
  font-size: 14px;
  cursor: pointer;
  color: inherit;
}
.site-icons.theme-dark { color: rgba(255, 255, 255, 0.85); }
.site-icons.theme-light { color: rgba(0, 0, 0, 0.75); }

/* Pinned "back to top" button, present on all 5 real mobile page duplicates
   but not their desktop counterparts (see README) - shown only under the
   mobile breakpoint via the display:flex override in the media query below. */
.scroll-to-top {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 60;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid currentColor;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.scroll-to-top svg { width: 18px; height: 18px; fill: currentColor; }
.scroll-to-top.theme-light { background: rgba(255, 255, 255, 0.85); color: rgba(0, 0, 0, 0.75); }

.page-footer-note {
  max-width: 1400px;
  margin: 40px auto 0;
  text-align: center;
  color: rgba(0, 0, 0, 0.6);
  font-family: var(--font-serif);
  font-size: 16px;
}

.page-nav {
  position: fixed;
  top: 20px;
  left: 40px;
  z-index: 100;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 16px;
}
.page-nav a {
  background: #111;
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
}

.gallery {
  max-width: 1400px;
  margin: 0 auto;
}

/* --- columnized (masonry) ---
   CSS column-count is a fallback if JS fails to run - it fills one column
   completely before starting the next. js/masonry.js replaces this with
   true shortest-column-first placement (matching the live site's actual
   behavior) once images load, at which point .masonry-ready switches to a
   flex row of real column divs. */
.gallery-columnized {
  column-count: 3;
  column-gap: 16px;
}
.gallery-columnized .col-item {
  break-inside: avoid;
  margin-bottom: 16px;
}
.gallery-columnized img,
.gallery-columnized video {
  width: 100%;
  border-radius: 2px;
}
.gallery-columnized.masonry-ready {
  display: flex;
  align-items: flex-start;
  column-count: unset;
  gap: 16px;
}
.gallery-columnized.masonry-ready .col {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.gallery-columnized.masonry-ready .col-item {
  margin-bottom: 16px;
}

/* --- freeform (scattered canvas) ---
   Positioned in pixels against a fixed design width (see gen-gallery.mjs)
   then scaled to fit the viewport by js/stage.js - same technique as the
   homepage. Width/height are set inline per-page; only reset defaults here. */
.gallery-freeform {
  position: relative;
  margin: 0 auto;
}
/* Position/size/rotation/z-index come from --dt-* custom properties set
   inline per item by gen-gallery.mjs (not literal left/top/width anymore -
   needed once items could carry a second, mobile-specific position too). */
.freeform-item {
  position: absolute;
  cursor: zoom-in;
  left: var(--dt-left);
  top: var(--dt-top);
  width: var(--dt-w);
  z-index: var(--dt-z);
  transform: rotate(var(--dt-rot));
}
.freeform-item img,
.freeform-item video {
  width: 100%;
  border-radius: 2px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}

/* --- justify (justified rows) --- */
.gallery-justify {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.justify-item {
  flex: 1 1 260px;
  max-width: 900px;
  cursor: zoom-in;
}
/* `row-end` marks where Cargo's real justified-packing algorithm (an
   aspect-ratio-based computation this rebuild doesn't reproduce) ended a
   row. Two different bugs have existed here at different times: an early
   version collapsed row-end ITEMS to height:0, silently hiding real
   images/videos/iframes; a later "fix" rendered the item normally but
   dropped the line-break entirely, so two side-by-side full-width videos
   that should each get their own row instead packed together (caught by
   comparing rendered desktop screenshots against the live site - see
   README). gen-gallery.mjs now emits a separate zero-size `.row-break`
   spacer right after each row-end item, forcing the wrap without touching
   the item's own content. */
.row-break {
  flex-basis: 100%;
  width: 0;
  height: 0;
  margin: 0;
  padding: 0;
}
/* Row height is a per-page CSS custom property set inline by
   gen-gallery.mjs's generateJustify (--row-h / --mobile-row-h), calibrated
   by rendering and comparing against each page's real live scrollHeight
   (desktop and mobile each have their own real row-height/mobile-row-height
   percentage in Cargo's markup, but deriving the exact formula wasn't worth
   it for a single CSS number - see gen-gallery.mjs). Replaces an earlier
   one-off .tall-rows class that only worked for a single page; two pages
   now need distinct values, and mobile needs a third and fourth. */
.justify-item img,
.justify-item video {
  width: 100%;
  height: var(--row-h, 1130px);
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

/* --- slideshow --- */
.gallery-slideshow {
  position: relative;
  max-width: 900px;
  margin: 0 auto;
}
.slides {
  position: relative;
  min-height: 60vh;
}
.slide {
  display: none;
}
.slide.active {
  display: block;
}
.slide img,
.slide video {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
}
.slide-prev, .slide-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 18px;
  cursor: pointer;
}
.slide-prev { left: -10px; }
.slide-next { right: -10px; }

/* --- lightbox (zoom) --- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
}
.lightbox-overlay img,
.lightbox-overlay video {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
}
.lightbox-overlay[hidden] {
  display: none;
}

/* --- external video embeds section (video/work pages) --- */
.external-videos {
  max-width: 1400px;
  margin: 60px auto 0;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.external-videos iframe {
  width: 400px;
  height: 225px;
  border: 0;
}

/* --- responsive: the site really does have separate mobile-specific page
   duplicates in Cargo (work/video-2/drawings-2/others-copy-1/writing-2 -
   see README), not the empty "-mob" stubs an earlier pass mistook for them.
   Rather than ship duplicate HTML files, one file per page is kept and
   resolved at this single breakpoint: 3 of the 5 pairs are content-
   identical (video/work/writing), so CSS is enough for them; the 2 with
   real per-item differences (drawings' image swap, others' repositioned
   freeform layout) carry real per-item mobile data baked in by
   gen-gallery.mjs (data-viewport, --mb-* custom properties), consumed here
   and by masonry.js/stage.js's matchMedia checks. --- */
@media (max-width: 720px) {
  .page-shell { padding: 90px 16px 40px; }
  .gallery-columnized { column-count: 1; }
  .gallery-columnized [data-viewport="desktop-only"] { display: none; }
  .gallery-justify { flex-direction: column; }
  /* .justify-item's desktop flex-basis (260px) applies to WIDTH in a row
     layout but to HEIGHT once flex-direction switches to column here -
     without resetting it, every item was stuck at a 260px-tall minimum
     regardless of the calibrated --mobile-row-h on its image. */
  .justify-item { max-width: 100%; flex-basis: auto; }
  .justify-item img,
  .justify-item video { height: var(--mobile-row-h, var(--row-h, 1130px)); }
  /* .gallery-freeform's own height is set directly as an inline style by
     js/stage.js (from data-mobile-height), not via CSS - no rule needed here. */
  .freeform-item {
    left: var(--mb-left, var(--dt-left));
    top: var(--mb-top, var(--dt-top));
    width: var(--mb-w, var(--dt-w));
    z-index: var(--mb-z, var(--dt-z));
    transform: rotate(var(--mb-rot, var(--dt-rot)));
  }
  .scroll-to-top { display: flex; }
}
@media (min-width: 721px) {
  .gallery-columnized [data-viewport="mobile-only"] { display: none; }
  .external-videos iframe { width: 100%; height: 56vw; }
}
