/* ============================================================================
 * 5year.art — "I have $200 of Claude API credits" museum wall
 *
 * Layout model: <body> is a 3-row grid (header / wall / dock) that always fills
 * the viewport. The gallery engine measures the wall row with a ResizeObserver
 * and fits each frame + caption inside it, so nothing overlaps at any size.
 *
 * Sizing: the root font-size is fluid (14px on phones → 18px on big monitors),
 * so UI chrome scales in rem. Frame trim scales with the painting through
 * --fs, which the engine sets from the available wall height.
 * ============================================================================ */

:root {
  --bg-top: #1a1612;
  --bg-mid: #110f0c;
  --bg-bot: #0a0907;
  --spot: rgba(242, 210, 146, 0.13);
  --text: #f5efe4;
  --muted: #b0a698;
  --dim: #877d70;
  --gold: #d4af5a;
  --gold-bright: #f2d88f;
  --line: rgba(245, 239, 228, 0.14);
  --gold-line: rgba(212, 175, 90, 0.4);
  --panel: rgba(19, 16, 13, 0.94);
  --shadow-far: 0 44px 86px -18px rgba(0, 0, 0, 0.9);
  --shadow-near: 0 12px 26px -6px rgba(0, 0, 0, 0.74);
  --target-size: 24px;
  --gutter: max(1.75rem, 3vw);
  --dock-w: min(46rem, 100%);
}

@media (pointer: coarse) {
  :root { --target-size: 44px; }
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: clamp(14px, 0.5vmin + 10.5px, 18px);
  height: 100%;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-mid);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

h1, h2 {
  font-family: "Marcellus", "Optima", Georgia, serif;
  font-weight: 400;
  text-wrap: balance;
}

p { text-wrap: pretty; }

:where(button, select, input:not([type="checkbox"], [type="radio"]), a) {
  min-block-size: var(--target-size);
  min-inline-size: var(--target-size);
}

:where(button, select, input, a):focus-visible {
  outline: 2px solid var(--gold-bright);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
 * WALL BACKDROP (fixed, behind the grid)
 * ============================================================================ */
.wall-backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 70%, var(--bg-bot) 100%);
  pointer-events: none;
}

.wall-grain {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================================
 * ROW 1 — HEADER: story, Top/New, $200 fund meter
 * ============================================================================ */
.top-header {
  position: relative;
  z-index: 40;
  padding-top: max(1rem, env(safe-area-inset-top, 0px));
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-bottom: 0.25rem;
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
}

.header-inner {
  inline-size: min(80rem, 100%);
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title tabs"
    "fund  fund";
  align-items: center;
  column-gap: 1.25rem;
  row-gap: 0.75rem;
}

.hero-title {
  grid-area: title;
  min-inline-size: 0;
}

.hero-title h1 {
  font-size: clamp(1.25rem, 0.9rem + 1.15vw, 2rem);
  letter-spacing: 0.012em;
  line-height: 1.12;
  color: var(--text);
}

.hero-title p {
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--muted);
  margin-top: 0.3rem;
  font-weight: 300;
}

/* Fund meter */
.fund-banner {
  grid-area: fund;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-inline-size: 0;
}

.fund-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.fund-live {
  display: inline-flex;
  align-items: baseline;
  gap: 0.45rem;
  min-inline-size: 0;
}

.fund-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-bright);
  box-shadow: 0 0 11px rgba(242, 216, 143, 0.85);
  align-self: center;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes livePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.45; }
  }
  .fund-dot { animation: livePulse 2.4s ease-in-out infinite; }
}

.fund-amount {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gold-bright);
  letter-spacing: -0.01em;
}

.fund-cap {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-inline-size: 0;
}

.fund-stats {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

.fund-pct {
  font-weight: 600;
  color: var(--gold-bright);
}

progress.fund-progress {
  --progress-bar-radius: 1e5px;
  --progress-bar-track: #3a332a; /* >= 3:1 against the wall and the gold fill */
  --progress-bar-fill: linear-gradient(90deg, #a87b26 0%, #dfc06c 55%, #f8e3a1 100%);
  appearance: none;
  -webkit-appearance: none;
  border: 0 solid;
  overflow: clip;
  display: block;
  inline-size: 100%;
  block-size: 0.7rem;
  border-radius: var(--progress-bar-radius);
  background: var(--progress-bar-track);
  box-shadow:
    inset 0 2px 4px rgb(0 0 0 / 0.65),
    0 0 0 1px rgba(212, 175, 90, 0.25);
}

progress.fund-progress::-webkit-progress-bar {
  background: transparent;
}

progress.fund-progress::-webkit-progress-value {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
  box-shadow: 0 0 12px rgba(242, 216, 143, 0.35);
  transition: inline-size 0.35s ease;
}

progress.fund-progress::-moz-progress-bar {
  background: var(--progress-bar-fill);
  border-radius: var(--progress-bar-radius);
}

/* "-$0.04" floats up from the meter after each painting */
.fund-delta {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.25rem);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--gold-bright);
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes floatSpend {
    0% { opacity: 0; transform: translateY(4px); }
    20% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
  }
  .fund-delta.pop { animation: floatSpend 1.15s ease-out forwards; }
}

/* Top / New */
.sort-tabs {
  grid-area: tabs;
  align-self: start;
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(12, 10, 8, 0.78);
}

.sort-tab {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.45rem 1.1rem;
  border-radius: 999px;
  transition: color 0.16s ease, background-color 0.16s ease;
}

.sort-tab:hover { color: var(--text); }

.sort-tab.active {
  background: rgba(212, 175, 90, 0.22);
  color: var(--gold-bright);
}

/* ============================================================================
 * ROW 2 — THE WALL
 * ============================================================================ */
.stage-wrap {
  /* --hang-y / --frame-h are written by the engine after every layout pass */
  --hang-y: 50%;
  --frame-h: 50vh;
  position: relative;
  min-block-size: 0;
  overflow: hidden;
  background:
    radial-gradient(
      ellipse calc(var(--frame-h) * 1.5) calc(var(--frame-h) * 0.95) at 50% var(--hang-y),
      var(--spot),
      transparent 72%
    );
  /* where the wall meets the floor */
  border-bottom: 1px solid rgba(212, 175, 90, 0.1);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.45);
}

.gallery-stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  /* The engine reads these paddings as the wall's safe insets */
  padding-block: clamp(0.75rem, 3.2vh, 2.75rem) clamp(0.5rem, 2.4vh, 2rem);
  padding-inline: clamp(4.75rem, 8vw, 10rem);
  container-type: size;
  cursor: grab;
  touch-action: none;
  -webkit-touch-callout: none; /* no iOS "save image" menu interrupting a slow swipe */
}

.gallery-stage.dragging { cursor: grabbing; }

.gallery-bay {
  position: absolute;
  top: 0;
  left: 50%;
  /* without this, left:50% caps shrink-to-fit width at half the wall */
  width: max-content;
  display: flex;
  flex-direction: column;
  align-items: center;
  will-change: transform, opacity;
}

.gallery-bay.is-side .picture-frame { cursor: pointer; }

/* Invisible measuring copy of a bay (caption height, lamp height, frame trim) */
.gallery-bay.bay-probe {
  visibility: hidden;
  pointer-events: none;
  will-change: auto;
  transform: none;
}

/* Brass picture light above each frame */
.gallery-lamp {
  will-change: opacity; /* own layer: the fade doesn't repaint the frame */
  position: relative;
  flex: none;
  width: 40%;
  height: calc(18px * var(--fs, 1));
  margin-bottom: calc(4px * var(--fs, 1));
  pointer-events: none;
}

.gallery-lamp::before {
  content: "";
  position: absolute;
  top: calc(4px * var(--fs, 1));
  left: 0;
  right: 0;
  height: max(3px, calc(4.5px * var(--fs, 1)));
  border-radius: 3px;
  background: linear-gradient(180deg, #f5dfa0 0%, #bf963f 56%, #6a4c16 100%);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.72), 0 0 18px rgba(242, 206, 122, 0.24);
}

.gallery-lamp::after {
  content: "";
  position: absolute;
  top: calc(9px * var(--fs, 1));
  left: -45%;
  right: -45%;
  height: calc(64px * var(--fs, 1));
  background: radial-gradient(ellipse at 50% 0%, rgba(255, 232, 170, 0.22), transparent 72%);
}

/* ============================================================================
 * PICTURE FRAMES — the well gets an exact size from the engine; the frame
 * wraps it, so the painting is never cropped. Trim scales with --fs.
 * ============================================================================ */
.picture-frame {
  position: relative;
  flex: none;
  box-shadow: var(--shadow-far), var(--shadow-near);
}

.frame-mat {
  position: relative;
}

.canvas-well {
  position: relative;
  overflow: hidden;
  background: #141210;
}

.canvas-well canvas,
.canvas-well img.svg-art {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.canvas-well canvas.pixelated {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.canvas-well::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3; /* the inset shadow sits over the waiting canvas and the reveal too */
  pointer-events: none;
  box-shadow:
    inset 0 8px 16px rgba(0, 0, 0, 0.62),
    inset 0 0 0 1px rgba(0, 0, 0, 0.45),
    inset 4px 0 10px rgba(0, 0, 0, 0.34),
    inset -4px 0 10px rgba(0, 0, 0, 0.34);
}

/* ============================================================================
 * A PAINTING IN PROGRESS (paint-fx.js): a primed canvas hangs the moment a
 * prompt is sent, shimmering while Claude paints; then the frame eases into
 * the painting's shape and brush strokes paint it in.
 * ============================================================================ */
.paint-pending {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  background-color: #e8ddc6;
  background-image:
    radial-gradient(ellipse at 50% 28%, rgba(255, 249, 232, 0.6), transparent 62%),
    radial-gradient(ellipse at 50% 50%, transparent 50%, rgba(70, 50, 24, 0.34) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.3 0 0 0 0 0.23 0 0 0 0 0.15 0 0 0 0.32 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23g)'/%3E%3C/svg%3E");
  animation: pp-prime 1.1s ease-out both;
}

@keyframes pp-prime {
  from { filter: brightness(0.25) saturate(0.6); }
}

.pp-clouds {
  position: absolute;
  inset: 0;
  animation: pp-fade 2.8s ease 1.2s both;
}

@keyframes pp-fade {
  from { opacity: 0; }
}

.pp-cloud {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, var(--c) 0%, transparent 66%);
  mix-blend-mode: multiply;
  filter: blur(14px);
  translate: -50% -50%;
  opacity: 0.3;
  animation: pp-drift 8s ease-in-out var(--d) infinite alternate;
}

@keyframes pp-drift {
  0% { transform: translate(0, 0) scale(0.85); opacity: 0.16; }
  50% { opacity: 0.44; }
  100% { transform: translate(var(--dx), var(--dy)) scale(1.2); opacity: 0.26; }
}

.pp-sketch {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.pp-sketch path {
  fill: none;
  stroke: rgba(62, 50, 36, 0.62);
  stroke-width: 0.45;
  stroke-linecap: round;
  stroke-dasharray: 1 3;
  stroke-dashoffset: 1.2; /* whole path in the gap: no stray cap dot before it draws */
  animation: pp-draw 1.5s cubic-bezier(0.55, 0, 0.3, 1) forwards;
  animation-delay: calc(0.8s + var(--i) * 0.36s);
}

@keyframes pp-draw {
  to { stroke-dashoffset: 0; }
}

.pp-sheen {
  position: absolute;
  inset: -10% -80%;
  background: linear-gradient(
    102deg,
    transparent 40%,
    rgba(255, 246, 222, 0.5) 50%,
    transparent 60%
  );
  mix-blend-mode: screen;
  transform: translateX(-55%);
  animation: pp-sheen 3.2s cubic-bezier(0.45, 0, 0.25, 1) 0.5s infinite;
}

@keyframes pp-sheen {
  0% { transform: translateX(-55%); }
  62%, 100% { transform: translateX(55%); }
}

/* The frame is hung with a soft drop, then breathes a little gold light */
.gallery-bay.is-pending .picture-frame {
  animation:
    hang-in 0.9s cubic-bezier(0.2, 0.8, 0.2, 1) both,
    frame-glow 3.2s ease-in-out 0.9s infinite;
}

@keyframes hang-in {
  from { opacity: 0; transform: translateY(-18px) scale(0.97); }
}

@keyframes frame-glow {
  50% { box-shadow: var(--shadow-far), var(--shadow-near), 0 0 80px 10px rgba(242, 206, 122, 0.17); }
}

.gallery-bay.is-pending .gallery-lamp::after {
  animation: lamp-breathe 3.2s ease-in-out infinite;
}

@keyframes lamp-breathe {
  50% { filter: brightness(1.9); transform: scaleY(1.2); }
}

/* A gentle colour pulse (a background-clip:text shimmer could flash dark in Safari) */
.gallery-bay.is-pending .work-meta {
  color: var(--muted);
  animation: text-pulse 2.4s ease-in-out infinite;
}

@keyframes text-pulse {
  50% { color: var(--gold-bright); }
}

.gallery-bay.is-pending :is(.heart-btn, .save-link) {
  visibility: hidden;
}

/* The finished painting arrives: the frame eases into its shape */
.gallery-bay.is-morphing {
  transition: transform 0.6s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.gallery-bay.is-morphing .canvas-well {
  transition:
    width 0.6s cubic-bezier(0.3, 0.7, 0.2, 1),
    height 0.6s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.gallery-bay.is-morphing .gallery-lamp {
  transition: width 0.6s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.canvas-well canvas.reveal-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  transition: opacity 0.45s ease;
}

.canvas-well canvas.reveal-canvas.is-done {
  opacity: 0;
}

/* One glossy pass of varnish once the last stroke is down */
.varnish-sheen {
  position: absolute;
  inset: -10% -70%;
  z-index: 4;
  pointer-events: none;
  background: linear-gradient(110deg, transparent 42%, rgba(255, 250, 235, 0.4) 50%, transparent 58%);
  mix-blend-mode: screen;
  animation: varnish 1.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

@keyframes varnish {
  from { transform: translateX(-60%); }
  to { transform: translateX(60%); }
}

@media (prefers-reduced-motion: reduce) {
  .paint-pending,
  .pp-clouds,
  .pp-cloud,
  .pp-sheen,
  .gallery-bay.is-pending .picture-frame,
  .gallery-bay.is-pending .gallery-lamp::after,
  .gallery-bay.is-pending .work-meta {
    animation: none;
  }
  .pp-sheen { display: none; }
  .pp-sketch path { animation: none; stroke-dashoffset: 0; }
}

/* Brass nameplate, engraved per Claude model */
.frame-plate {
  position: absolute;
  left: 50%;
  bottom: calc(-10px * var(--fs, 1));
  transform: translateX(-50%);
  z-index: 6;
  pointer-events: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: calc(7px * var(--fs, 1));
  height: max(16px, calc(21px * var(--fs, 1)));
  padding: 0 max(8px, calc(13px * var(--fs, 1)));
  border-radius: 2px;
  background: linear-gradient(180deg, #2b2114 0%, #1a140c 55%, #120e08 100%);
  border: 1px solid rgba(218, 182, 102, 0.5);
  box-shadow:
    0 4px 12px rgba(0, 0, 0, 0.78),
    inset 0 1px 0 rgba(255, 240, 192, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.65);
  color: #ebd08c;
  white-space: nowrap;
  line-height: 1;
}

.frame-plate::before,
.frame-plate::after {
  content: "";
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff0be, #9e7526);
  opacity: 0.65;
  flex-shrink: 0;
}

.frame-plate.sig-fable {
  font-family: "Cinzel Decorative", Georgia, serif;
  font-size: max(7px, calc(9px * var(--fs, 1)));
  font-weight: 700;
  letter-spacing: 0.14em;
  color: #f3da94;
}

.frame-plate.sig-opus {
  font-family: "Pinyon Script", "Snell Roundhand", Georgia, cursive;
  font-size: max(12px, calc(16.5px * var(--fs, 1)));
  letter-spacing: 0.03em;
  color: #f0d796;
}

.frame-plate.sig-sonnet {
  font-family: "La Belle Aurore", Georgia, cursive;
  font-size: max(11px, calc(14px * var(--fs, 1)));
  letter-spacing: 0.03em;
  color: #e9d198;
  padding-top: 2px;
}

.frame-plate.sig-haiku {
  font-family: "Marcellus", Georgia, serif;
  font-size: max(7px, calc(9px * var(--fs, 1)));
  letter-spacing: 0.22em;
  color: #e6cf98;
}

.frame-plate.sig-sonnet46 {
  font-family: "Space Mono", ui-monospace, monospace;
  font-size: max(7px, calc(8.5px * var(--fs, 1)));
  letter-spacing: 0.14em;
  color: #ded0ad;
}

/* Frame 1: Gilded Salon Baroque */
.frame-gilded {
  padding: calc(18px * var(--fs, 1));
  border-radius: 2px;
  background: linear-gradient(158deg, #d3ac54 0%, #946c22 44%, #573b0e 100%);
  border-style: solid;
  border-width: calc(7px * var(--fs, 1));
  border-top-color: #f3dc94;
  border-left-color: #c89f44;
  border-right-color: #8c651e;
  border-bottom-color: #4f340b;
}

.frame-gilded::before {
  content: "";
  position: absolute;
  inset: calc(6px * var(--fs, 1));
  border: 1.5px solid rgba(255, 240, 184, 0.46);
  box-shadow:
    inset 0 0 0 3px rgba(52, 34, 8, 0.74),
    inset 0 0 0 4.5px rgba(235, 200, 114, 0.35),
    0 0 0 1px rgba(36, 22, 6, 0.65);
  pointer-events: none;
}

.frame-gilded .frame-mat {
  padding: calc(5px * var(--fs, 1));
  background: linear-gradient(145deg, #211a12, #0f0c08);
  box-shadow: inset 0 0 0 2px #d4af5a;
}

/* Frame 2: Dutch Ebony & Gold Fillet */
.frame-ebony {
  padding: calc(17px * var(--fs, 1));
  border-radius: 1.5px;
  background: linear-gradient(155deg, #27231f 0%, #141210 52%, #0a0908 100%);
  border-style: solid;
  border-width: calc(7px * var(--fs, 1));
  border-top-color: #413b33;
  border-left-color: #27231e;
  border-right-color: #161411;
  border-bottom-color: #080706;
}

.frame-ebony::before {
  content: "";
  position: absolute;
  inset: calc(6px * var(--fs, 1));
  border: 1px solid rgba(255, 246, 232, 0.08);
  pointer-events: none;
}

.frame-ebony .frame-mat {
  padding: calc(4px * var(--fs, 1));
  background: linear-gradient(135deg, #f2da92 0%, #ba913a 55%, #7b5919 100%);
  box-shadow: 0 0 0 2px #0b0a08;
}

/* Frame 3: American Walnut + Archival Cotton Mat */
.frame-walnut {
  padding: calc(10px * var(--fs, 1));
  border-radius: 1.5px;
  background: linear-gradient(145deg, #4e3422 0%, #2e1d12 58%, #1c110a 100%);
  border-style: solid;
  border-width: calc(6px * var(--fs, 1));
  border-top-color: #704d33;
  border-left-color: #4f3522;
  border-right-color: #301f13;
  border-bottom-color: #1b110a;
}

.frame-walnut .frame-mat {
  padding: calc(22px * var(--fs, 1));
  background: linear-gradient(160deg, #f4efe4 0%, #e7dfd0 100%);
  box-shadow: inset 0 3px 8px rgba(0, 0, 0, 0.36), inset 0 0 0 1px rgba(80, 56, 36, 0.25);
}

.frame-walnut .canvas-well {
  border-style: solid;
  border-width: 2px;
  border-top-color: #b4aa98;
  border-left-color: #c5bcac;
  border-right-color: #fbf8f1;
  border-bottom-color: #ffffff;
}

.frame-walnut .canvas-well::after {
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.26);
  background: linear-gradient(130deg, rgba(255, 255, 255, 0.055) 0%, transparent 40%);
}

/* Frame 4: Brushed Brass Floater */
.frame-floater {
  padding: calc(10px * var(--fs, 1));
  border-radius: 1px;
  background: #080706;
  border-style: solid;
  border-width: calc(4px * var(--fs, 1));
  border-top-color: #eed489;
  border-left-color: #c39d47;
  border-right-color: #967227;
  border-bottom-color: #694d17;
  box-shadow: var(--shadow-far), var(--shadow-near), inset 0 0 0 1px rgba(255, 236, 174, 0.16);
}

.frame-floater .frame-mat {
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.92);
}

/* Frame 5: Aged Florentine Bronze */
.frame-bronze {
  padding: calc(15px * var(--fs, 1));
  border-radius: 2px;
  background: linear-gradient(148deg, #473a2d 0%, #241d17 52%, #130f0c 100%);
  border-style: solid;
  border-width: calc(6px * var(--fs, 1));
  border-top-color: #725e48;
  border-left-color: #4d3f31;
  border-right-color: #2b221a;
  border-bottom-color: #16110d;
}

.frame-bronze::before {
  content: "";
  position: absolute;
  inset: calc(6px * var(--fs, 1));
  border: 1px solid rgba(206, 173, 108, 0.3);
  pointer-events: none;
}

.frame-bronze .frame-mat {
  padding: calc(5px * var(--fs, 1));
  background: #14110e;
  box-shadow: inset 0 0 0 1.5px rgba(206, 173, 108, 0.38);
}

/* ============================================================================
 * WALL LABEL (caption under the frame)
 * ============================================================================ */
.work-caption {
  /* own layer: fading the label in and out doesn't repaint the frame and painting */
  will-change: opacity;
  /* clears the nameplate that hangs below the frame */
  margin-top: calc(12px * var(--fs, 1) + 0.75rem);
  max-inline-size: min(40rem, 100cqw);
  text-align: center;
  transition: opacity 0.22s ease;
}

.work-quote {
  font-size: clamp(1.1rem, 0.85rem + 0.85vw, 1.7rem);
  line-height: 1.28;
  color: var(--text);
  margin-bottom: 0.55rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.work-sub {
  display: inline-flex;
  flex-wrap: wrap; /* narrow screens: buttons drop under the catalogue line */
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.75rem;
  max-width: 100%;
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

.work-info,
.work-actions {
  display: inline-flex;
  align-items: center;
  column-gap: inherit;
}

.work-meta {
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.work-price {
  font-family: "Space Mono", ui-monospace, monospace;
  font-weight: 700;
  font-size: 0.95em;
  color: var(--gold-bright);
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}

.heart-btn {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font: inherit;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  min-block-size: max(2.3rem, var(--target-size));
  transition: border-color 0.16s ease, color 0.16s ease, background-color 0.16s ease;
}

.heart-btn:hover {
  border-color: rgba(212, 175, 90, 0.6);
  color: var(--gold-bright);
}

.heart-btn.voted {
  border-color: var(--gold);
  background: rgba(212, 175, 90, 0.18);
  color: var(--gold-bright);
}

.save-link {
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  padding: 0.4rem 0.7rem;
  min-block-size: max(2.3rem, var(--target-size));
  transition: color 0.16s ease, border-color 0.16s ease;
}

.save-link { color: var(--muted); }

.save-link:hover {
  color: var(--gold-bright);
  border-color: var(--line);
}

/* ============================================================================
 * PREV / NEXT — hang on the same line as the paintings
 * ============================================================================ */
.nav-arrow {
  position: absolute;
  top: var(--hang-y);
  transform: translateY(-50%);
  z-index: 5;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(14, 12, 10, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.nav-arrow svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-arrow:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
}

@media (prefers-reduced-motion: no-preference) {
  .nav-arrow {
    transition: border-color 0.18s ease, color 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
  }
  .nav-arrow:hover { transform: translateY(-50%) scale(1.05); }
}

.nav-arrow.disabled {
  opacity: 0.16;
  pointer-events: none;
}

.nav-prev { left: max(1.25rem, env(safe-area-inset-left, 0px)); }
.nav-next { right: max(1.25rem, env(safe-area-inset-right, 0px)); }

/* Status toast, top of the wall */
.painting-toast {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 8;
  max-inline-size: calc(100% - 2rem);
  inline-size: max-content;
  padding: 0.6rem 1.25rem;
  border-radius: 999px;
  background: rgba(20, 17, 13, 0.95);
  border: 1px solid rgba(212, 175, 90, 0.55);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  color: var(--gold-bright);
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.painting-toast.show { opacity: 1; }

/* ============================================================================
 * ROW 3 — DOCK: prompt, model picker, scrubber, credits
 * ============================================================================ */
.bottom-dock {
  position: relative;
  z-index: 45;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  row-gap: 0.4rem;
  padding-top: 0.85rem;
  padding-right: max(var(--gutter), env(safe-area-inset-right, 0px));
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--gutter), env(safe-area-inset-left, 0px));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.18), rgba(0, 0, 0, 0.42));
}

.prompt-bar {
  position: relative;
  inline-size: var(--dock-w);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 6px 6px 6px 1.35rem;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--gold-line);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.72);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.prompt-bar:focus-within {
  border-color: var(--gold-bright);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.8), 0 0 0 3px rgba(212, 175, 90, 0.16);
}

.prompt-bar:has(input:is(:user-invalid, .user-invalid-fallback)),
.prompt-bar.has-error {
  border-color: #e06356;
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.8), 0 0 0 3px rgba(224, 99, 86, 0.18);
}

.char-counter {
  position: absolute;
  top: -10px;
  right: 26px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #15120e;
  border: 1px solid rgba(212, 175, 90, 0.3);
  font-size: 11.5px;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.16s ease, color 0.16s ease;
}

.char-counter.visible { opacity: 1; }
.char-counter.warn { color: var(--gold-bright); }
.char-counter.limit { color: #f07b6e; font-weight: 600; border-color: rgba(240, 123, 110, 0.45); }

/* Floats above the dock so showing it never pushes the layout */
.prompt-error {
  position: absolute;
  bottom: calc(100% - 0.25rem);
  left: 50%;
  transform: translateX(-50%);
  inline-size: max-content;
  max-inline-size: min(46rem, calc(100% - 2rem));
  padding: 0.45rem 0.9rem;
  border-radius: 10px;
  background: rgba(36, 16, 13, 0.96);
  border: 1px solid rgba(224, 99, 86, 0.55);
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.6);
  text-align: center;
  font-size: 0.8rem;
  color: #f8a196;
  line-height: 1.3;
  pointer-events: none;
}

.prompt-error[hidden] { display: none; }

.prompt-input {
  flex: 1;
  min-inline-size: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: max(16px, 1rem); /* >= 16px stops iOS zoom-on-focus */
  line-height: 1.35;
  user-select: text;
  -webkit-user-select: text;
}

.prompt-input:focus-visible { outline: none; }

.prompt-input::placeholder { color: #8f8576; }

.prompt-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.model-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding-left: 0.75rem;
  border-left: 1px solid rgba(245, 239, 228, 0.14);
}

.model-select {
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--gold-bright);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  min-inline-size: 7rem;
  min-block-size: 42px;
  padding: 8px 14px 8px 8px;
  letter-spacing: 0.01em;
}

.style-select { min-inline-size: 6.5rem; }
.model-select:disabled { opacity: 0.45; cursor: not-allowed; }

/* Cloudflare's bot check, only visible when it needs a click */
.turnstile-box { display: flex; justify-content: center; grid-column: 1 / -1; }
.turnstile-box:empty { display: none; }

.model-select option {
  background: #171411;
  color: #f5efe4;
}

/* Branded picker on mouse/trackpad only; touch keeps the native wheel */
@media (pointer: fine) {
  .model-select,
  .model-select::picker(select) {
    appearance: base-select;
  }

  .model-select {
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-radius: 999px;
    padding: 8px 14px;
  }

  .model-select::picker(select) {
    background: #181410;
    color: var(--text);
    border: 1px solid rgba(212, 175, 90, 0.45);
    border-radius: 14px;
    padding: 6px;
    box-shadow: 0 20px 44px rgba(0, 0, 0, 0.85);
    min-inline-size: 164px;
  }

  .model-select::picker-icon { color: var(--gold); }

  .model-select option {
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    background: transparent;
    cursor: pointer;
  }

  .model-select option:hover {
    background: rgba(212, 175, 90, 0.16);
    color: var(--gold-bright);
  }

  .model-select option::checkmark { color: var(--gold-bright); }
}

.paint-btn {
  cursor: pointer;
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.6rem;
  min-block-size: 44px;
  /* fits every label: "Paint it", "Painting…", "Wait 90s", "Fund Empty" */
  min-inline-size: 8.5rem;
  text-align: center;
  white-space: nowrap;
  background: linear-gradient(135deg, #ebd084 0%, #c79d42 100%);
  color: #120f0a;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 246, 214, 0.55), 0 6px 18px rgba(199, 157, 66, 0.22);
  transition: filter 0.15s ease;
}

.paint-btn:hover { filter: brightness(1.07); }
.paint-btn:disabled { opacity: 0.6; cursor: wait; }

@media (prefers-reduced-motion: no-preference) {
  .paint-btn { transition: transform 0.15s ease, filter 0.15s ease; }
  .paint-btn:active { transform: scale(0.97); }
}

/* Scrubber */
.scrub-row {
  inline-size: var(--dock-w);
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.scrub-count {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  min-inline-size: 5.5em;
}

.scrub-count strong {
  color: var(--gold-bright);
  font-weight: 600;
}

input[type="range"].wall-slider {
  --slider-track-size: 3px;
  --slider-thumb-size: 13px;
  --slider-track-radius: 999px;
  --slider-thumb-radius: 50%;
  --slider-track-color: #5c5347; /* >= 3:1 against the wall */
  --slider-fill-color: #e6c670;
  --slider-thumb-color: #f3da91;
  --slider-direction: to right;
  --attr-min: attr(min type(<number>), 0);
  --attr-max: attr(max type(<number>), 4999);
  --control-value: attr(value type(<number>), 0);
  --slider-progress: calc(progress(var(--control-value), var(--attr-min), var(--attr-max)) * 100%);

  appearance: none;
  -webkit-appearance: none;
  flex: 1;
  min-inline-size: 0;
  inline-size: 100%;
  block-size: 2rem;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"].wall-slider:dir(rtl) {
  --slider-direction: to left;
}

@supports not (opacity: progress(1, 0, 100)) {
  input[type="range"].wall-slider {
    --slider-progress: calc(
      (var(--control-value) - var(--attr-min)) /
      max(1, var(--attr-max) - var(--attr-min)) * 100%
    );
  }
}

input[type="range"].wall-slider::-webkit-slider-runnable-track {
  block-size: var(--slider-track-size);
  border: 0;
  border-radius: var(--slider-track-radius);
  background: linear-gradient(
    var(--slider-direction),
    var(--slider-fill-color) var(--slider-progress),
    var(--slider-track-color) var(--slider-progress)
  );
}

input[type="range"].wall-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  inline-size: var(--slider-thumb-size);
  block-size: var(--slider-thumb-size);
  margin-block-start: calc((var(--slider-track-size) - var(--slider-thumb-size)) / 2);
  border: 0;
  border-radius: var(--slider-thumb-radius);
  background: var(--slider-thumb-color);
  box-shadow: 0 0 8px rgba(242, 216, 143, 0.55);
}

input[type="range"].wall-slider::-moz-range-track {
  block-size: var(--slider-track-size);
  border: 0;
  border-radius: var(--slider-track-radius);
  background: var(--slider-track-color);
}

input[type="range"].wall-slider::-moz-range-progress {
  block-size: var(--slider-track-size);
  border-radius: var(--slider-track-radius);
  background: var(--slider-fill-color);
}

input[type="range"].wall-slider::-moz-range-thumb {
  inline-size: var(--slider-thumb-size);
  block-size: var(--slider-thumb-size);
  border: 0;
  border-radius: var(--slider-thumb-radius);
  background: var(--slider-thumb-color);
}

input[type="range"].wall-slider:focus-visible {
  outline: 2px solid var(--slider-fill-color);
  outline-offset: 4px;
}

.scrub-tip {
  font-size: 0.8rem;
  color: var(--dim);
  white-space: nowrap;
}

/* Maker credits */
.quiet-credits {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  column-gap: 0.65rem;
  font-size: 0.8rem;
  color: var(--dim);
}

.credit-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-block-size: max(24px, min(var(--target-size), 32px));
  text-decoration: none;
  color: var(--dim);
  transition: color 0.16s ease;
}

.credit-link:hover { color: var(--text); }

.credit-link strong {
  font-weight: 500;
  color: var(--muted);
  transition: color 0.16s ease;
}

.credit-link:hover strong { color: var(--gold-bright); }
.x-ico { width: 12px; height: 12px; opacity: 0.85; }
.credit-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid rgba(212, 175, 90, 0.28);
}
.credit-sep { opacity: 0.45; }

/* ============================================================================
 * NARROW (phones in portrait, small windows)
 * ============================================================================ */
@media (max-width: 640px) {
  :root { --gutter: 1rem; }

  .top-header { padding-top: max(0.8rem, env(safe-area-inset-top, 0px)); }

  .header-inner {
    column-gap: 0.75rem;
    row-gap: 0.55rem;
  }

  .hero-title p {
    font-size: 0.8rem;
    line-height: 1.35;
    margin-top: 0.25rem;
  }

  .sort-tab { padding: 0.4rem 0.8rem; font-size: 0.82rem; }

  .fund-amount { font-size: 1.1rem; }
  .fund-cap, .fund-stats { font-size: 0.78rem; }
  .fund-spent, .fund-sep { display: none; }
  progress.fund-progress { block-size: 0.6rem; }

  .gallery-stage {
    padding-block: 0.9rem 0.5rem;
    padding-inline: 1rem;
  }

  .nav-arrow { display: none; }

  .work-quote { font-size: 1.05rem; margin-bottom: 0.4rem; }
  .work-sub { gap: 0.2rem 0.4rem; font-size: 0.82rem; }
  .heart-btn { padding-inline: 0.85rem; }
  .save-link { padding-inline: 0.55rem; }

  .bottom-dock {
    padding-top: 0.6rem;
    row-gap: 0.3rem;
  }

  .scrub-tip { display: none; }
}

/* Phones: the composer stacks into two rows (prompt / model + button) */
@media (max-width: 520px) {
  .prompt-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0.6rem 0.6rem 0.6rem 0.85rem;
    border-radius: 1.25rem;
  }

  .prompt-input { padding: 0.25rem 0.2rem; }

  .char-counter { right: 18px; }

  .prompt-controls {
    justify-content: space-between;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(245, 239, 228, 0.08);
  }

  .model-wrap {
    padding-left: 0;
    border: 1px solid rgba(212, 175, 90, 0.3);
    border-radius: 999px;
    background: rgba(245, 239, 228, 0.06);
  }

  .model-select {
    min-block-size: 40px;
    padding: 6px 8px;
    min-inline-size: 0;
    inline-size: 100%;
  }

  /* Style and model pickers share the row; the button keeps its label */
  .prompt-controls { gap: 0.4rem; }
  .model-wrap { flex: 1 1 0; min-inline-size: 0; }
  .style-wrap { flex-grow: 1.25; }

  .paint-btn {
    flex: none;
    min-block-size: 42px;
    min-inline-size: 0;
    padding-block: 0.55rem;
    padding-inline: 0.95rem;
  }
}

/* Short portrait phones (iPhone SE, Safari with toolbars): give the art room */
@media (max-width: 640px) and (max-height: 700px) {
  .fund-cap { display: none; }
  .quiet-credits { font-size: 0.75rem; }
}

@media (max-width: 640px) and (max-height: 600px) {
  .hero-title p { display: none; }
  .scrub-row { display: none; }
}

/* ============================================================================
 * SQUAT (laptop windows under browser chrome, tablets in landscape)
 * ============================================================================ */
@media (min-width: 641px) and (max-height: 760px) {
  .top-header { padding-top: max(0.75rem, env(safe-area-inset-top, 0px)); }

  /* credits move up beside the scrubber; both stay aligned to the composer */
  .bottom-dock {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1.5rem;
    row-gap: 0.3rem;
    padding-top: 0.6rem;
    padding-bottom: max(0.55rem, env(safe-area-inset-bottom, 0px));
    padding-inline: max(var(--gutter), env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px), calc((100% - 46rem) / 2));
  }
  .prompt-bar { grid-column: 1 / -1; inline-size: 100%; }
  .scrub-row { inline-size: 100%; }
  .scrub-tip { display: none; }
  .quiet-credits { flex-wrap: nowrap; white-space: nowrap; justify-self: end; }
}

@media (min-width: 900px) and (max-height: 760px) {
  /* one header row: title + story | fund meter | Top/New */
  .header-inner {
    grid-template-columns: minmax(0, 1fr) minmax(17rem, 1fr) auto;
    grid-template-areas: "title fund tabs";
    column-gap: clamp(1.25rem, 3vw, 2.75rem);
  }
  .fund-spent, .fund-sep { display: none; }
  .hero-title h1 { font-size: clamp(1.2rem, 0.75rem + 0.95vw, 1.65rem); }
  .hero-title p { font-size: 0.8rem; margin-top: 0.2rem; }
  .sort-tabs { align-self: center; }
  .fund-delta { bottom: auto; top: calc(100% + 0.25rem); }
}

/* ============================================================================
 * SHORT (phones in landscape, squat windows) — everything collapses to rows
 * ============================================================================ */
@media (max-height: 540px) {
  :root { --gutter: max(1rem, 2.5vw); }

  .top-header { padding-top: max(0.55rem, env(safe-area-inset-top, 0px)); }

  .header-inner {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "title fund tabs";
    column-gap: 1.25rem;
  }

  .hero-title h1 {
    font-size: 1.05rem;
    white-space: nowrap;
  }
  .hero-title p { display: none; }

  .fund-banner { gap: 0.25rem; }
  .fund-amount { font-size: 0.95rem; }
  .fund-cap { display: none; }
  .fund-stats { font-size: 0.75rem; }
  .fund-spent, .fund-sep { display: none; }
  progress.fund-progress { block-size: 0.45rem; }
  .fund-delta { bottom: auto; top: calc(100% + 0.2rem); }

  .sort-tabs { align-self: center; padding: 3px; }
  .sort-tab { padding: 0.3rem 0.75rem; font-size: 0.8rem; min-block-size: 32px; }

  .gallery-stage {
    padding-block: 0.55rem 0.35rem;
    padding-inline: clamp(3.75rem, 8vw, 6rem);
  }

  .nav-arrow { display: flex; width: 2.6rem; height: 2.6rem; }

  .work-caption { margin-top: calc(10px * var(--fs, 1) + 0.4rem); }
  .work-quote {
    font-size: 0.98rem;
    margin-bottom: 0.25rem;
    -webkit-line-clamp: 1;
    line-clamp: 1;
  }
  .heart-btn, .save-link { min-block-size: 32px; padding-block: 0.2rem; }

  .bottom-dock {
    grid-template-columns: minmax(0, 1fr) auto;
    column-gap: 1rem;
    row-gap: 0.3rem;
    padding-top: 0.45rem;
    padding-bottom: max(0.45rem, env(safe-area-inset-bottom, 0px));
  }

  .prompt-bar {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    padding: 4px 4px 4px 1.1rem;
    border-radius: 999px;
  }
  .prompt-input { padding: 0; }
  .prompt-controls { padding-top: 0; border-top: 0; }
  .model-wrap {
    padding-left: 0.6rem;
    border: 0;
    border-left: 1px solid rgba(245, 239, 228, 0.14);
    border-radius: 0;
    background: transparent;
  }
  .model-select { min-block-size: 36px; min-inline-size: 6.25rem; padding-block: 4px; }
  .paint-btn { min-block-size: 36px; min-inline-size: 7rem; padding-block: 0.4rem; }

  .scrub-row {
    display: flex;
    inline-size: 100%;
    justify-self: stretch;
  }
  input[type="range"].wall-slider { block-size: 1.5rem; }
  .scrub-tip { display: none; }

  .quiet-credits { font-size: 0.72rem; flex-wrap: nowrap; white-space: nowrap; }
  .credit-link { min-block-size: 28px; }
}

@media (max-height: 540px) and (max-width: 700px) {
  .hero-title h1 { font-size: 0.95rem; }
  .x-ico, .credit-sep, #xHandleLink { display: none; }
}

@media (max-height: 380px) {
  .quiet-credits { display: none; }
  .bottom-dock { grid-template-columns: minmax(0, 1fr); }
}

/* ---------------------------------------------------------------------------
   Empty wall (live site before the first painting): an empty frame and an invite
   --------------------------------------------------------------------------- */
.wall-empty {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  text-align: center;
  pointer-events: none;
}

.wall-empty[hidden],
.wall-empty-sub[hidden] { display: none; }

.wall-empty-frame {
  block-size: min(38vh, 19rem);
  aspect-ratio: 4 / 5;
  margin-bottom: 1rem;
  border: 2px dashed var(--gold-line);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 0 48px rgba(0, 0, 0, 0.45), var(--shadow-near);
}

.wall-empty-title {
  font-family: "Marcellus", "Optima", Georgia, serif;
  font-size: clamp(1.25rem, 0.9rem + 1vw, 1.9rem);
  line-height: 1.25;
  color: var(--text);
}

.wall-empty-sub {
  font-size: 0.95rem;
  color: var(--muted);
}

.stage-wrap.is-empty .nav-arrow { display: none; }

/* Touch screens: the phone's own picker still opens, but with our arrow, inset from the
   pill's edge like the text is (the native arrow sat hard against the right edge) */
@media not (pointer: fine) {
  .model-select {
    appearance: none;
    -webkit-appearance: none;
    padding-inline: 14px 30px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23d4af5a' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 10px 6px;
    text-overflow: ellipsis;
  }
}

/* Others painted while you were here: one tap hangs them (New, from the start) */
.new-paintings-btn {
  position: absolute;
  top: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 90, 0.6);
  background: rgba(20, 17, 13, 0.95);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  color: var(--gold-bright);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
}

.new-paintings-btn[hidden] { display: none; }
.new-paintings-btn:hover { border-color: var(--gold-bright); }
.new-paintings-btn:disabled { opacity: 0.7; cursor: progress; }

/* Phones: the page can be pulled down for the browser's own refresh (the wall never
   scrolls the page; see the touchmove handler in gallery-engine.js) */
@media (max-width: 640px) {
  html { overflow: auto; }
  body { overscroll-behavior: auto; }
  .gallery-stage { touch-action: pan-y pinch-zoom; }
}

/* WebKit draws the filters inside an SVG image at 1x and stretches them (blurred on
   iPhones). There the picture is laid out --svg-k times larger and scaled back down, so
   the filters render at full screen resolution. app.js sets this on WebKit only. */
html.svg-hires .canvas-well img.svg-art,
html.svg-hires .lightbox-well img {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% * var(--svg-k));
  height: calc(100% * var(--svg-k));
  transform: scale(calc(1 / var(--svg-k)));
  transform-origin: 0 0;
}

/* The painting, bigger: tap the centre painting */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: max(3.75rem, calc(env(safe-area-inset-top) + 3.25rem)) 1rem max(1.5rem, env(safe-area-inset-bottom));
  background: rgba(8, 7, 6, 0.94);
  opacity: 0;
  transition: opacity 0.18s ease;
  -webkit-touch-callout: none;
}

.lightbox[hidden] { display: none; }
.lightbox.is-open { opacity: 1; }

.lightbox-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

.lightbox-well {
  position: relative;
  overflow: hidden;
  background: #141210;
  box-shadow: 0 0 0 1px rgba(212, 175, 90, 0.35), 0 24px 70px rgba(0, 0, 0, 0.7);
}

.lightbox-well img {
  display: block;
  width: 100%;
  height: 100%;
}

.lightbox-caption {
  text-align: center;
  max-width: min(40rem, 92vw);
}

.lightbox-quote {
  font-family: "Marcellus", "Optima", Georgia, serif;
  font-size: clamp(1.1rem, 0.85rem + 0.85vw, 1.6rem);
  line-height: 1.28;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.lightbox-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.25rem 0.5rem;
  font-size: 0.85rem;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}

.lightbox-close {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top));
  right: max(0.75rem, env(safe-area-inset-right));
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 90, 0.4);
  background: rgba(20, 17, 13, 0.9);
  color: var(--gold-bright);
  font: inherit;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-close:hover { border-color: var(--gold-bright); }

.gallery-bay .picture-frame { cursor: zoom-in; }
.stage-wrap .gallery-stage.dragging .picture-frame { cursor: grabbing; }
