/* Layout: a single gallery wall (paint colour chosen by the viewer) hung with framed pieces and museum placards; UI chrome floats over it in theme colours. */
:root {
  --ui-bg: #fbfaf8;
  --ui-fg: #1d1c1a;
  --ui-muted: #6c6862;
  --ui-line: #e3dfd8;
  --ui-raise: #ffffff;
  --accent: #2f5bd3;          /* primary-crayon blue */
  --accent-fg: #ffffff;
  --danger: #b4302a;
  --placard-bg: #fdfcfa;
  --placard-fg: #24221f;
  --placard-muted: #6f6a63;
  --scrim: rgba(18, 17, 15, .45);

  --wall: #f1efea;
  --on-wall: #1d1c1a;
  --on-wall-muted: rgba(29, 28, 26, .62);

  --f-display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", sans-serif;
  --f-body: "Instrument Sans", "Helvetica Neue", Arial, sans-serif;
  --f-label: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ui-bg: #1a1918; --ui-fg: #efece7; --ui-muted: #a19c95; --ui-line: #34312e; --ui-raise: #242220;
    --accent: #7f9cff; --accent-fg: #0f1630; --danger: #ef7a72; --scrim: rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ui-bg: #1a1918; --ui-fg: #efece7; --ui-muted: #a19c95; --ui-line: #34312e; --ui-raise: #242220;
  --accent: #7f9cff; --accent-fg: #0f1630; --danger: #ef7a72; --scrim: rgba(0,0,0,.6);
  color-scheme: dark;
}

html, body { min-height: 100%; }
body {
  background: var(--wall);
  color: var(--on-wall);
  font-family: var(--f-body);
  font-size: 15px;
  line-height: 1.5;
  transition: background-color .5s ease;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- Wall ---------- */
.wall {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 28px 96px;
  max-width: 1320px;
  margin: 0 auto;
}
.masthead {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 16px 24px;
  margin-bottom: clamp(28px, 6vw, 64px);
}
.masthead h1 {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(40px, 8vw, 84px);
  line-height: .92;
  letter-spacing: -.03em;
  margin: 0;
  text-wrap: balance;
  position: relative;
  display: inline-block;
}
.masthead h1 .scribble {
  display: block;
  height: 14px;
  margin-top: 6px;
  width: 100%;
}
.masthead .sub {
  margin: 10px 0 0;
  font-family: var(--f-label);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--on-wall-muted);
  font-variant-numeric: tabular-nums;
}
.tools { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--ui-line);
  background: var(--ui-raise);
  color: var(--ui-fg);
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
.btn:hover { border-color: var(--ui-muted); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.notice {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--ui-raise); color: var(--ui-fg);
  border: 1px dashed var(--ui-muted);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 36px;
  font-size: 14px;
}
.notice strong { font-weight: 600; }

.hang {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: clamp(40px, 6vw, 72px) clamp(28px, 4vw, 56px);
  align-items: center;
}
.work {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  margin: 0;
  min-width: 0;
}
.work .hit {
  border: 0; padding: 0; background: none; display: block; max-width: 100%;
  border-radius: 2px;
  transition: transform .25s ease;
}
.work .hit:hover { transform: translateY(-3px); }
.work img { display: block; max-height: 320px; max-width: 100%; width: auto; height: auto; }
.work.missing .frame { min-width: 200px; min-height: 160px; }

.placard {
  background: var(--placard-bg);
  color: var(--placard-fg);
  padding: 10px 14px 11px;
  width: min(100%, 240px);
  box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 3px 10px rgba(0,0,0,.06);
  font-size: 13px;
  line-height: 1.35;
  align-self: center;
}
.placard .t { font-weight: 600; font-size: 14px; margin: 0; overflow-wrap: anywhere; }
.placard .t.untitled { font-style: italic; font-weight: 500; color: var(--placard-muted); }
.placard .m { margin: 2px 0 0; color: var(--placard-muted); }
.placard .tag {
  display: inline-block; margin-top: 6px;
  font-family: var(--f-label); font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--placard-muted);
}

/* ---------- Frames (applied to .frame) ---------- */
.frame { position: relative; display: inline-block; max-width: 100%; line-height: 0; }
.frame .mat { display: block; line-height: 0; }
.mat-on .frame .mat { background: #fbfaf7; padding: clamp(14px, 9%, 34px); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06), inset 0 2px 5px rgba(0,0,0,.08); }
.mat-on .frame .mat img { box-shadow: 0 0 0 1px rgba(0,0,0,.08); }

.fr-black .frame { padding: 10px; background: #151413; box-shadow: 0 2px 4px rgba(0,0,0,.25), 0 16px 32px -12px rgba(0,0,0,.45); }
.fr-oak .frame {
  padding: 16px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.08), rgba(255,255,255,.08) 30%, rgba(0,0,0,.06) 70%, rgba(255,255,255,.05)),
    repeating-linear-gradient(92deg, #b88a57 0 3px, #a8794a 3px 5px, #c39565 5px 9px, #ad7f4f 9px 12px);
  box-shadow: inset 0 0 0 1px rgba(60,35,10,.4), inset 2px 2px 0 rgba(255,235,200,.25), inset -2px -2px 0 rgba(60,35,10,.3), 0 18px 34px -14px rgba(0,0,0,.5);
}
.fr-gilt .frame {
  padding: 22px;
  background:
    radial-gradient(circle at 30% 20%, rgba(255,250,210,.7), transparent 40%),
    linear-gradient(135deg, #8a6a1f, #e7c96b 22%, #a8801f 40%, #f4dc86 58%, #8f6b1a 78%, #d9b553);
  box-shadow:
    inset 0 0 0 3px #6e5214, inset 0 0 0 6px #e8cd77, inset 0 0 0 8px #7a5c18,
    inset 0 0 0 14px rgba(255,240,180,.35), inset 0 0 0 16px #6b4f12,
    0 22px 40px -14px rgba(0,0,0,.6);
}
.fr-white .frame { padding: 12px; background: #f7f6f2; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08), 0 2px 3px rgba(0,0,0,.12), 0 18px 30px -16px rgba(0,0,0,.4); }
.fr-float .frame { padding: 0; box-shadow: 0 1px 1px rgba(0,0,0,.1), 14px 18px 30px -12px rgba(0,0,0,.42); }
.fr-tape .frame { padding: 0; box-shadow: 0 1px 2px rgba(0,0,0,.2), 0 8px 18px -10px rgba(0,0,0,.35); transform: rotate(-1deg); }
.fr-tape .work:nth-child(2n) .frame { transform: rotate(1.2deg); }
.fr-tape .frame::before, .fr-tape .frame::after {
  content: ""; position: absolute; top: -12px; width: 78px; height: 26px; z-index: 2;
  background: rgba(244, 233, 196, .78);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
  clip-path: polygon(3% 8%, 97% 0, 100% 90%, 1% 100%);
}
.fr-tape .frame::before { left: -14px; transform: rotate(-32deg); }
.fr-tape .frame::after { right: -14px; transform: rotate(30deg); }
.fr-magnet .frame { padding: 0; box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 6px 14px -8px rgba(0,0,0,.35); }
.fr-magnet .frame::before {
  content: ""; position: absolute; top: -10px; left: 50%; width: 30px; height: 30px; margin-left: -15px; border-radius: 50%; z-index: 2;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.65), transparent 35%), var(--magnet, #e0402f);
  box-shadow: 0 3px 5px rgba(0,0,0,.35);
}
.fr-magnet .work:nth-child(4n+2) .frame { --magnet: #2f6fe0; }
.fr-magnet .work:nth-child(4n+3) .frame { --magnet: #f2b51c; }
.fr-magnet .work:nth-child(4n+4) .frame { --magnet: #2e9e58; }

/* ---------- Sheets & panels ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  background: var(--scrim);
  display: flex; align-items: flex-end; justify-content: center;
  padding-top: max(16px, env(safe-area-inset-top, 0px));
}
@media (min-width: 720px) { .overlay { align-items: center; padding: 24px; } }
.sheet {
  background: var(--ui-bg); color: var(--ui-fg);
  width: min(100%, 560px);
  max-height: 100%;
  overflow: auto;
  border-radius: 18px 18px 0 0;
  padding-block: 20px max(20px, env(safe-area-inset-bottom, 0px));
  padding-left: max(20px, env(safe-area-inset-left, 0px));
  padding-right: max(20px, env(safe-area-inset-right, 0px));
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
}
@media (min-width: 720px) { .sheet { border-radius: 18px; padding: 26px; } }
.sheet h2 { font-family: var(--f-display); font-weight: 800; font-size: 26px; letter-spacing: -.02em; margin: 0; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--ui-line);
  background: var(--ui-raise); color: var(--ui-fg); display: grid; place-items: center; flex: none;
}
.icon-btn svg { width: 20px; height: 20px; }
.section-label { font-family: var(--f-label); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--ui-muted); margin: 20px 0 10px; }
.section-label:first-of-type { margin-top: 0; }

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 10px; }
.swatch {
  border: 2px solid transparent; border-radius: 12px; padding: 0; background: var(--ui-raise);
  overflow: hidden; text-align: left;
  box-shadow: 0 0 0 1px var(--ui-line);
}
.swatch .chip { display: block; height: 46px; }
.swatch .nm { display: block; padding: 6px 8px; font-size: 12px; font-weight: 500; }
.swatch[aria-pressed="true"] { border-color: var(--accent); box-shadow: none; }

.frames { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.frame-opt {
  border: 2px solid transparent; border-radius: 12px; background: var(--ui-raise);
  box-shadow: 0 0 0 1px var(--ui-line);
  padding: 12px 8px 8px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 500;
}
.frame-opt[aria-pressed="true"] { border-color: var(--accent); box-shadow: none; }
.frame-opt .mini { width: 52px; height: 40px; display: block; }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-top: 1px solid var(--ui-line); margin-top: 18px; }
.switch-row .lbl { font-weight: 600; }
.switch-row .hint { color: var(--ui-muted); font-size: 13px; }
.toggle { position: relative; width: 48px; height: 28px; flex: none; }
.toggle input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.toggle span { position: absolute; inset: 0; border-radius: 999px; background: var(--ui-line); transition: background .2s; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(20px); }
.toggle input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.save-note { font-size: 13px; color: var(--ui-muted); margin: 14px 0 0; }

/* add / edit form */
.drop {
  border: 2px dashed var(--ui-line); border-radius: 14px; padding: 22px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center;
  color: var(--ui-muted);
}
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, transparent); }
.drop .row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.preview-wrap { display: grid; gap: 10px; }
.preview-wrap canvas { width: 100%; height: auto; max-height: 300px; object-fit: contain; background: repeating-conic-gradient(var(--ui-line) 0 25%, transparent 0 50%) 0 0/16px 16px; border-radius: 8px; }
.preview-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.field { display: grid; gap: 6px; margin-top: 14px; }
.field label { font-weight: 600; font-size: 13px; }
.field .opt { font-weight: 400; color: var(--ui-muted); }
.field input, .field textarea {
  width: 100%; border: 1px solid var(--ui-line); background: var(--ui-raise); border-radius: 10px; padding: 10px 12px;
}
.field textarea { min-height: 84px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row .field { min-width: 0; }
.actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 22px; }
.actions .spacer { flex: 1; }
.err { color: var(--danger); font-size: 13px; margin: 10px 0 0; }
.batch-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; margin-top: 4px; }
.batch-list img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; max-width: 100%; }
.progress { height: 6px; border-radius: 99px; background: var(--ui-line); overflow: hidden; margin-top: 14px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
#addForm { width: min(100%, 640px); }
.choose { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: flex-start; gap: 14px; text-align: left;
  border: 1px solid var(--ui-line); background: var(--ui-raise); color: var(--ui-fg);
  border-radius: 14px; padding: 14px 16px; cursor: pointer;
}
.choice:hover { border-color: var(--ui-muted); }
.choice svg { width: 28px; height: 28px; flex: none; margin-top: 2px; color: var(--accent); }
.choice span { display: grid; gap: 2px; min-width: 0; }
.choice strong { font-size: 15px; }
.choice small { color: var(--ui-muted); font-size: 13px; line-height: 1.4; }
.choice.primary-choice { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.scan-help { margin: 0 0 12px; color: var(--ui-muted); font-size: 14px; }
.scan-help.warn { color: var(--danger); }
.ed-stage { display: grid; place-items: center; background: color-mix(in srgb, var(--ui-fg) 6%, transparent); border-radius: 12px; padding: 18px; }
.ed-frame { position: relative; line-height: 0; max-width: 100%; touch-action: none; }
.ed-frame canvas#edCanvas { display: block; max-width: 100%; max-height: 52vh; width: auto; height: auto; }
.ed-svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.ed-svg polygon { fill: rgba(47, 91, 211, .14); stroke: #2f5bd3; stroke-width: 2; vector-effect: non-scaling-stroke; }
.handle {
  position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; padding: 0;
  border: 0; background: none; touch-action: none; cursor: grab; z-index: 2;
}
.handle::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border-radius: 50%; background: #fff; border: 3px solid #2f5bd3; box-shadow: 0 1px 4px rgba(0,0,0,.4);
}
.handle.active::after { background: #2f5bd3; }
.handle:focus-visible { outline: none; }
.handle:focus-visible::after { box-shadow: 0 0 0 4px var(--accent); }
.loupe { position: absolute; top: 8px; width: 132px; height: 132px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 16px rgba(0,0,0,.45); z-index: 3; pointer-events: none; background: #000; }
.loupe.left { left: 8px; } .loupe.right { right: 8px; }
.seg { display: inline-flex; border: 1px solid var(--ui-line); border-radius: 999px; overflow: hidden; background: var(--ui-raise); }
.seg button { border: 0; background: none; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--ui-muted); }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.angle-guide { margin: 0 0 14px; padding-left: 22px; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 2px 16px; font-size: 13px; color: var(--ui-muted); }
.angle-guide li.next { color: var(--ui-fg); font-weight: 600; }
.angle-guide li.taken { text-decoration: line-through; }
.angle-guide em { font-style: normal; opacity: .7; }
.shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-bottom: 14px; }
.shots:empty { display: none; }
.shot { position: relative; border: 1px solid var(--ui-line); border-radius: 10px; background: var(--ui-raise); padding: 0; overflow: hidden; aspect-ratio: 1; max-width: 100%; }
.shot canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot .n { position: absolute; left: 6px; top: 6px; background: var(--ui-fg); color: var(--ui-bg); font: 600 11px/1 var(--f-label); padding: 4px 6px; border-radius: 6px; }
.shot .flag { position: absolute; left: 6px; bottom: 6px; right: 6px; background: var(--danger); color: #fff; font-size: 11px; line-height: 1.2; padding: 3px 6px; border-radius: 6px; }
.shot .rm { position: absolute; right: 4px; top: 4px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; display: grid; place-items: center; }
.shot .rm svg { width: 14px; height: 14px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.aligner { font-size: 13px; color: var(--ui-muted); margin: 12px 0 0; min-height: 1em; }
.working { display: grid; justify-items: center; gap: 12px; padding: 40px 0; color: var(--ui-muted); }
.working p { margin: 0; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--ui-line); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.confirm-box { margin-top: 16px; padding: 14px; border-radius: 12px; border: 1px solid var(--danger); display: grid; gap: 10px; }

/* ---------- Viewer ---------- */
.viewer {
  position: fixed; inset: 0; z-index: 30;
  background: var(--wall);
  color: var(--on-wall);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.viewer-bar {
  display: flex; align-items: center; gap: 8px;
  padding-block: 10px;
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
}
.viewer-bar .count { font-family: var(--f-label); font-size: 12px; letter-spacing: .08em; color: var(--on-wall-muted); font-variant-numeric: tabular-nums; margin-right: auto; padding-left: 6px; }
.viewer .icon-btn { background: color-mix(in srgb, var(--ui-raise) 88%, transparent); }
.stage {
  position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  min-height: 0;
}
.track { position: absolute; inset: 0; display: flex; will-change: transform; }
.slide { flex: 0 0 100%; height: 100%; display: grid; place-items: center; padding: 28px 20px; }
.slide .zoomer { transform-origin: 0 0; will-change: transform; }
.slide .work-in { display: grid; place-items: center; }
.slide img { max-width: min(86vw, 1100px); max-height: calc(100vh - 290px); width: auto; height: auto; display: block; -webkit-user-drag: none; pointer-events: none; }
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%); z-index: 2;
  width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--ui-line);
  background: color-mix(in srgb, var(--ui-raise) 88%, transparent); color: var(--ui-fg);
  display: grid; place-items: center;
}
.nav-arrow svg { width: 22px; height: 22px; }
.nav-arrow.prev { left: max(12px, env(safe-area-inset-left, 0px)); }
.nav-arrow.next { right: max(12px, env(safe-area-inset-right, 0px)); }
@media (hover: none) { .nav-arrow { display: none; } }
.viewer-card {
  justify-self: center;
  width: min(calc(100% - 32px), 620px);
  margin-bottom: 14px;
  background: var(--placard-bg); color: var(--placard-fg);
  padding: 14px 18px 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.18), 0 6px 22px rgba(0,0,0,.1);
  max-height: 32vh; overflow: auto;
}
.viewer-card .t { font-family: var(--f-display); font-weight: 800; font-size: 22px; letter-spacing: -.01em; margin: 0; line-height: 1.15; overflow-wrap: anywhere; }
.viewer-card .t.untitled { font-family: var(--f-body); font-style: italic; font-weight: 500; color: var(--placard-muted); font-size: 18px; }
.viewer-card .m { margin: 4px 0 0; color: var(--placard-muted); font-size: 13px; }
.viewer-card .c { margin: 10px 0 0; font-size: 15px; max-width: 62ch; white-space: pre-wrap; overflow-wrap: anywhere; }
.viewer-card .edit-row { display: flex; gap: 8px; margin-top: 12px; }
.zoom-hint { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); font-family: var(--f-label); font-size: 11px; letter-spacing: .08em; color: var(--on-wall-muted); pointer-events: none; white-space: nowrap; }
.play-on { background: var(--accent) !important; color: var(--accent-fg) !important; border-color: transparent !important; }

.toast {
  position: fixed; left: 50%; bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 16px)); transform: translateX(-50%);
  z-index: 60; background: var(--ui-fg); color: var(--ui-bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  max-width: calc(100% - 32px);
}

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .slide { padding: 16px 12px; }
  .slide img { max-width: 84vw; max-height: calc(100vh - 300px); }
  .work img { max-height: 280px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---------- standalone app ---------- */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; -webkit-tap-highlight-color: transparent; }
img { max-width: 100%; }
.wall { padding-top: max(28px, calc(env(safe-area-inset-top, 0px) + 16px)); }
.footer {
  margin-top: 72px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center;
  font-size: 13px; color: var(--on-wall-muted);
}
.linkbtn { border: 0; background: none; padding: 0; color: inherit; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; cursor: pointer; }
.offline-pill {
  display: inline-flex; align-items: center; gap: 6px; font-family: var(--f-label); font-size: 11px; letter-spacing: .08em;
  text-transform: uppercase; padding: 4px 10px; border-radius: 999px; background: var(--ui-raise); color: var(--ui-fg); border: 1px solid var(--ui-line);
}

/* password screen */
.gate {
  min-height: 100vh; min-height: 100dvh; display: grid; place-items: center;
  padding: max(24px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(24px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.gate-card { width: min(100%, 380px); display: grid; gap: 14px; }
.gate-card h1 { font-family: var(--f-display); font-weight: 800; font-size: clamp(40px, 12vw, 56px); line-height: .95; letter-spacing: -.03em; margin: 0; }
.gate-card p { margin: 0; color: var(--on-wall-muted); }
.gate-card input { width: 100%; border: 1px solid var(--ui-line); background: var(--ui-raise); color: var(--ui-fg); border-radius: 12px; padding: 14px; font-size: 16px; }

/* ---------- live camera ---------- */
.camera {
  position: fixed; inset: 0; z-index: 50; background: #000; color: #fff;
  display: grid; grid-template-rows: auto 1fr auto;
}
.cam-top, .cam-bottom {
  display: flex; align-items: center; gap: 10px; z-index: 2;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
}
.cam-top { padding-top: max(12px, env(safe-area-inset-top, 0px)); padding-bottom: 10px; }
.cam-bottom { padding-top: 14px; padding-bottom: max(20px, calc(env(safe-area-inset-bottom, 0px) + 10px)); justify-content: space-between; }
.cam-msg { flex: 1; font-size: 15px; font-weight: 600; text-align: center; text-wrap: balance; min-height: 1.4em; }
.cam-view { position: relative; overflow: hidden; min-height: 0; }
.cam-view video, .cam-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.cam-btn {
  width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff;
  display: grid; place-items: center;
}
.cam-btn svg { width: 22px; height: 22px; }
.cam-side { width: 96px; display: flex; justify-content: center; }
.shutter {
  width: 76px; height: 76px; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 0;
  display: grid; place-items: center; position: relative;
}
.shutter::after { content: ""; width: 60px; height: 60px; border-radius: 50%; background: #fff; transition: transform .12s; }
.shutter:active::after { transform: scale(.88); }
.shutter .ring { position: absolute; inset: -4px; width: 76px; height: 76px; transform: rotate(-90deg); pointer-events: none; }
.shutter .ring circle { fill: none; stroke: #f2b51c; stroke-width: 4; stroke-dasharray: 226; stroke-dashoffset: 226; }
.auto-toggle { border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; border-radius: 999px; padding: 8px 12px; font-size: 13px; font-weight: 600; }
.auto-toggle[aria-pressed="true"] { background: #fff; color: #000; }
.cam-count { font-family: var(--f-label); font-size: 12px; letter-spacing: .08em; }
.cam-thumbs { display: flex; gap: 6px; }
.cam-thumbs canvas { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; border: 2px solid #fff; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .25s; }
.flash.on { opacity: .85; transition: none; }

/* viewer share */
.viewer-card .edit-row { flex-wrap: wrap; }
