/* Lightbox — a screen used as a light box.
   Ground stays lit; every control is glass floating over it. */

:root {
  --ink:        #14161a;
  --ink-2:      rgba(20, 22, 26, .64);
  --ink-3:      rgba(20, 22, 26, .40);
  --accent:     #0071e3;
  --accent-2:   #005fc4;

  --glass-fill: linear-gradient(180deg, rgba(255,255,255,.76), rgba(255,255,255,.56));
  --glass-blur: blur(30px) saturate(190%);
  --glass-cast: 0 1px 2px rgba(16,18,22,.05), 0 16px 36px -14px rgba(16,18,22,.30);

  --dock-h:     44px;
  --ease:       cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}

body {
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(168deg, #f2f4f7 0%, #e6eaef 46%, #d9dee5 100%) fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  touch-action: none;
}

.lamp {
  position: fixed;
  inset: -10%;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(58% 52% at 50% 44%,
              #ffffff 0%, rgba(255,255,255,.86) 38%, rgba(255,255,255,0) 74%);
  opacity: .38;
  transition: opacity 1100ms var(--ease);
}
body.lit .lamp { opacity: 1; }

/* ── Icons ──────────────────────────────────────────────────────────────── */

.sprite { display: none; }

svg:not(.mark):not(.chip__mark) {
  width: 20px;
  height: 20px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
svg .solid { fill: currentColor; stroke: none; }
svg .solid-edge { fill: currentColor; }

/* ── Glass material ─────────────────────────────────────────────────────── */

.glass {
  position: relative;
  background: var(--glass-fill);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--glass-cast);
  isolation: isolate;
}

/* Specular rim: bright at the light-facing edge, near-nothing opposite it.
   A masked gradient border, not a flat hairline. */
.glass::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(155deg,
              rgba(255,255,255,.98) 0%,
              rgba(255,255,255,.34) 32%,
              rgba(20,22,26,.10) 66%,
              rgba(255,255,255,.62) 100%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
          mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
          mask-composite: exclude;
  pointer-events: none;
  z-index: 2;
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass { background: linear-gradient(180deg, rgba(255,255,255,.94), rgba(255,255,255,.88)); }
}

/* ── Intro ──────────────────────────────────────────────────────────────── */

.intro {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 32px 24px calc(32px + env(safe-area-inset-bottom));
  overflow-y: auto;
  touch-action: pan-y;
  transition: opacity 420ms var(--ease), filter 420ms var(--ease);
}
.intro.is-leaving {
  opacity: 0;
  filter: blur(6px);
  pointer-events: none;
}

.intro__inner {
  width: min(600px, 100%);
  text-align: center;
  animation: rise 640ms var(--ease);
}
.intro__inner .drop { width: min(560px, 100%); margin-inline: auto; }

.mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 22px;
  color: var(--ink);
  display: block;
}

.wordmark {
  margin: 0;
  font-size: clamp(2.5rem, 7.5vw, 3.75rem);
  font-weight: 600;
  letter-spacing: -.035em;
  line-height: 1.02;
}

.lede {
  margin: 14px auto 34px;
  max-width: 43ch;
  font-size: 1.0625rem;
  line-height: 1.52;
  color: var(--ink-2);
  text-wrap: balance;
}

.drop {
  display: block;
  padding: 40px 28px 34px;
  border-radius: 24px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.72));
  box-shadow: 0 1px 2px rgba(16,18,22,.06), 0 26px 52px -18px rgba(16,18,22,.34);
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease);
}
.drop::after {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 16px;
  border: 1.5px dashed rgba(20,22,26,.2);
  transition: border-color 200ms var(--ease);
  pointer-events: none;
}
.drop:hover,
.drop:focus-within { transform: translateY(-2px); box-shadow: 0 1px 2px rgba(16,18,22,.06), 0 34px 62px -18px rgba(16,18,22,.4); }
.drop:hover::after,
.drop:focus-within::after { border-color: rgba(0,113,227,.42); }
.drop.is-over { transform: scale(1.015); }
.drop.is-over::after { border-color: var(--accent); border-style: solid; }

.drop__icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  margin: 0 auto 16px;
  border-radius: 15px;
  color: var(--accent);
  background: rgba(0,113,227,.10);
}
.drop__icon svg { width: 26px; height: 26px; stroke-width: 1.5; }

.drop__title {
  display: block;
  font-size: 1.125rem;
  font-weight: 600;
  letter-spacing: -.018em;
}
.drop__sub {
  display: block;
  margin-top: 7px;
  font-size: .875rem;
  color: var(--ink-2);
}
.link { color: var(--accent); font-weight: 500; }

.fineprint {
  margin: 26px auto 0;
  max-width: 46ch;
  font-size: .8125rem;
  line-height: 1.55;
  color: var(--ink-2);
  text-wrap: balance;
}

kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 1px 5px;
  margin: 0 1px;
  font: inherit;
  font-size: .78em;
  font-weight: 500;
  line-height: 1.5;
  text-align: center;
  color: var(--ink-2);
  background: rgba(255,255,255,.7);
  border-radius: 5px;
  box-shadow: 0 0 0 .5px rgba(20,22,26,.16), 0 1px 0 rgba(20,22,26,.06);
}

/* ── Gallery ────────────────────────────────────────────────────────────── */

/* With saved traces the intro stops being a centred hero and becomes a page. */
.intro.has-gallery { place-items: start stretch; padding: 0; }

/* Full bleed, not a centred column. The traces are the content — a measure
   cap belongs on prose, and boxing a grid into 1120px just manufactures dead
   margin on a wide screen. */
.gallery {
  width: 100%;
  padding: 26px 40px calc(64px + env(safe-area-inset-bottom));
  animation: rise 520ms var(--ease);
}

.gallery__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.gallery__id { display: flex; align-items: center; gap: 10px; }
.gallery__id h1 {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -.022em;
}
.mark--sm { width: 24px; height: 24px; margin: 0; }

.grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 22px 18px;
  grid-template-columns: repeat(auto-fill, minmax(208px, 1fr));
}

.card { position: relative; min-width: 0; }

.card__open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: 14px;
}
.card__thumb {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.7));
  box-shadow: 0 0 0 .5px rgba(20,22,26,.1), 0 10px 24px -13px rgba(16,18,22,.4);
  transition: transform 260ms var(--ease), box-shadow 260ms var(--ease);
}
.card__thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;   /* show the whole reference — you recognise it by shape */
}
.card:hover .card__thumb,
.card__open:focus-visible .card__thumb {
  transform: translateY(-3px);
  box-shadow: 0 0 0 .5px rgba(20,22,26,.12), 0 20px 38px -16px rgba(16,18,22,.48);
}

.card__foot {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 10px 4px 0;
  min-width: 0;
}
.card__name {
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: -.008em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card__meta {
  font-size: .75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.card__more {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255,255,255,.76);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  box-shadow: 0 0 0 .5px rgba(20,22,26,.1), 0 4px 12px -6px rgba(16,18,22,.4);
  cursor: pointer;
  opacity: 0;
  transition: opacity 200ms var(--ease);
}
.card__more svg { width: 16px; height: 16px; }
.card:hover .card__more,
.card.is-open .card__more,
.card__more:focus-visible { opacity: 1; }
@media (pointer: coarse) { .card__more { opacity: 1; } }

.card__rename {
  width: 100%;
  font: inherit;
  font-size: .8125rem;
  font-weight: 500;
  padding: 1px 6px;
  margin: -1px -6px;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 0 0 2px var(--accent);
  outline: none;
}

.gallery__foot {
  margin: 30px 4px 0;
  font-size: .75rem;
  color: var(--ink-3);
}

/* ── Menu ───────────────────────────────────────────────────────────────── */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 176px;
  padding: 5px;
  border-radius: 14px;
  animation: rise 180ms var(--ease);
}
.menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  font: inherit;
  font-size: .8125rem;
  font-weight: 500;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: background 140ms var(--ease);
}
.menu button svg { width: 16px; height: 16px; flex: none; }
.menu button:hover { background: rgba(20,22,26,.07); }
.menu .danger { color: #c1232b; }
.menu .danger:hover { background: rgba(193,35,43,.1); }
.menu__ask {
  padding: 7px 10px 4px;
  font-size: .75rem;
  line-height: 1.4;
  color: var(--ink-2);
}

/* ── Stage ──────────────────────────────────────────────────────────────── */

/* The image is never fenced in by the viewport: pan it fully off any edge and
   the stage simply crops it. No bounds, at any zoom. */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  cursor: grab;
  touch-action: none;
  overflow: hidden;
  contain: layout paint;
}
.stage.is-dragging { cursor: grabbing; }
.stage.is-spinning { cursor: crosshair; }

.pan {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
}
#art {
  display: block;
  transform-origin: 50% 50%;
  user-select: none;
  -webkit-user-drag: none;
  image-rendering: auto;
}
body.grayscale #art { filter: grayscale(1); }

/* ── Top bar ────────────────────────────────────────────────────────────── */

.topbar {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top));
  left: 16px;
  right: 16px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
}
.topbar > * { pointer-events: auto; }
.topbar__left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* A quiet mark that the position is being written to this device as you work. */
.chip__saved {
  width: 5px;
  height: 5px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  opacity: .5;
  transition: opacity 240ms var(--ease), transform 240ms var(--ease);
}
.chip__saved.is-writing { opacity: 1; transform: scale(1.5); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: -.005em;
  color: var(--ink);
  max-width: min(48vw, 320px);
}
.chip__mark { width: 17px; height: 17px; flex: none; }
.chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink-2);
}
.chip--btn {
  border: 0;
  font-family: inherit;
  cursor: pointer;
  transition: background 180ms var(--ease);
}
.chip--btn svg { width: 16px; height: 16px; }
.chip--btn:hover { background: linear-gradient(180deg, rgba(255,255,255,.9), rgba(255,255,255,.7)); }
.chip--btn:active { transform: scale(.97); }

/* ── Dock ───────────────────────────────────────────────────────────────── */

.dock {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  /* No fill-mode: a filled animation outranks the declarations below it and
     would pin the dock visible once locked. */
  transform: translate(-50%, 0);
  opacity: 1;
  animation: dock-in 620ms var(--ease);
  transition: opacity 320ms var(--ease), transform 320ms var(--ease);
  max-width: calc(100vw - 24px);
}

.seg { display: flex; align-items: center; gap: 2px; }
.seg--opacity { gap: 6px; padding: 0 4px 0 8px; }
.seg__icon { width: 17px; height: 17px; color: var(--ink-3); flex: none; }

.rule {
  width: 1px;
  height: 22px;
  margin: 0 5px;
  background: rgba(20,22,26,.12);
  flex: none;
}

.btn {
  display: grid;
  place-items: center;
  width: var(--dock-h);
  height: var(--dock-h);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease), transform 120ms var(--ease);
}
.btn:hover { background: rgba(20,22,26,.07); }
.btn:active { transform: scale(.92); background: rgba(20,22,26,.11); }
.btn[aria-pressed="true"] { background: rgba(0,113,227,.14); color: var(--accent); }
/* Nothing left to undo reads as a dimmed, inert control. */
.btn:disabled { cursor: default; color: var(--ink-3); opacity: .4; }
.btn:disabled:hover { background: transparent; }
.btn:disabled:active { transform: none; }
/* Upscaling runs for seconds, so that one control says so rather than going
   dead — a busy button and an unavailable button must not look alike. */
#enhance:disabled { cursor: progress; opacity: 1; }
#enhance:disabled svg { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.btn--sm { width: 28px; height: 28px; }
.btn--sm svg { width: 16px; height: 16px; }

.readout {
  min-width: 56px;
  height: var(--dock-h);
  padding: 0 6px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: .8125rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
  color: var(--ink-2);
  cursor: pointer;
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.readout:hover { background: rgba(20,22,26,.07); color: var(--ink); }
/* Wide enough for "359.5°" so the dock never reflows mid-rotation. */
.readout--sm { min-width: 56px; }
/* The angle is a knob, not just a number — drag it anywhere you like. */
.readout--knob { cursor: ew-resize; touch-action: none; }
.readout--knob.is-scrubbing { background: rgba(0,113,227,.14); color: var(--accent); }
.readout--static {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 44px;
  cursor: default;
  padding-right: 2px;
}
.readout--static:hover { background: transparent; color: var(--ink-2); }

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 104px;
  height: 22px;
  background: transparent;
  cursor: pointer;
  --pct: 100%;
}
.slider::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) var(--pct), rgba(20,22,26,.17) var(--pct));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 .5px rgba(20,22,26,.2), 0 1px 3px rgba(16,18,22,.32);
}
.slider::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgba(20,22,26,.17);
}
.slider::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border: 0;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 .5px rgba(20,22,26,.2), 0 1px 3px rgba(16,18,22,.32);
}

.lock, .primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: var(--dock-h);
  padding: 0 17px 0 14px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: .875rem;
  font-weight: 590;
  letter-spacing: -.012em;
  color: #fff;
  background: linear-gradient(180deg, #1a8bff, var(--accent));
  box-shadow: 0 1px 1px rgba(255,255,255,.5) inset,
              0 1px 2px rgba(0,60,130,.24), 0 6px 16px -6px rgba(0,90,190,.6);
  cursor: pointer;
  transition: filter 160ms var(--ease), transform 120ms var(--ease);
}
.lock:hover, .primary:hover { filter: brightness(1.06); }
.lock:active, .primary:active { transform: scale(.96); }
.lock svg, .primary svg { width: 17px; height: 17px; stroke-width: 1.9; }
.primary { height: 38px; }

/* ── Help ───────────────────────────────────────────────────────────────── */

.helpbtn {
  position: fixed;
  right: 16px;
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 20;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 999px;
  color: var(--ink-2);
  cursor: pointer;
  transition: color 160ms var(--ease), opacity 320ms var(--ease), transform 320ms var(--ease);
}
.helpbtn:hover { color: var(--ink); }

.help {
  position: fixed;
  right: 16px;
  bottom: calc(66px + env(safe-area-inset-bottom));
  z-index: 21;
  width: 296px;
  padding: 14px 16px 16px;
  border-radius: 18px;
  opacity: 1;
  animation: rise 300ms var(--ease);
}
.help__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.help__head h2 {
  margin: 0;
  font-size: .8125rem;
  font-weight: 600;
  letter-spacing: .01em;
  color: var(--ink-2);
}
.help__list { margin: 0; font-size: .8125rem; }
.help__list > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  border-top: 1px solid rgba(20,22,26,.07);
}
.help__list > div:first-child { border-top: 0; }
.help__list dt { color: var(--ink); font-weight: 500; flex: none; }
.help__list dd { margin: 0; color: var(--ink-2); text-align: right; }

/* ── Locked ─────────────────────────────────────────────────────────────── */

body.locked .stage { pointer-events: none; cursor: default; }
/* Kill the long-press callout and any text selection while locked — a palm on
   the glass should do nothing at all. */
body.locked {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
body.locked .dock,
body.locked .topbar,
body.locked .helpbtn,
body.locked .help {
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) translateX(var(--tx, 0));
}
body.locked .dock { --tx: -50%; }

.release {
  position: fixed;
  right: calc(14px + env(safe-area-inset-right));
  bottom: calc(14px + env(safe-area-inset-bottom));
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 13px 0 11px;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-size: .8125rem;
  font-weight: 500;
  color: rgba(20,22,26,.8);
  background: rgba(255,255,255,.62);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 0 0 .5px rgba(20,22,26,.1), 0 8px 20px -10px rgba(16,18,22,.4);
  cursor: pointer;
  opacity: .16;
  transition: opacity 400ms var(--ease);
}
.release:hover, .release:focus-visible { opacity: 1; }
.release svg { width: 15px; height: 15px; }

/* Touch has no hover and no Esc key, so the way out has to stay visible. */
@media (pointer: coarse) { .release { opacity: .6; } }

/* Fullscreen defaults to a black backdrop; the light box must stay lit. */
:fullscreen { background: linear-gradient(168deg, #f2f4f7 0%, #e6eaef 46%, #d9dee5 100%); }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  left: 50%;
  z-index: 40;
  display: flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: .8125rem;
  font-weight: 500;
  letter-spacing: -.006em;
  color: rgba(255,255,255,.96);
  background: rgba(24,26,30,.76);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  box-shadow: 0 8px 26px -10px rgba(16,18,22,.6);
  transform: translate(-50%, -14px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms var(--ease), transform 380ms var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast kbd {
  color: rgba(255,255,255,.94);
  background: rgba(255,255,255,.16);
  box-shadow: none;
}

/* ── Focus ──────────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 999px;
}
.drop:focus-within { outline: none; }

/* ── Motion ─────────────────────────────────────────────────────────────── */

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
}
@keyframes dock-in {
  from { opacity: 0; transform: translate(-50%, 22px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ── Narrow ─────────────────────────────────────────────────────────────── */

@media (max-width: 860px) {
  .gallery { padding: 24px 24px calc(60px + env(safe-area-inset-bottom)); }
  .dock {
    flex-wrap: wrap;
    justify-content: center;
    border-radius: 26px;
    padding: 6px 8px;
    row-gap: 2px;
  }
  .rule { display: none; }
  .seg { padding: 0 2px; }
  .seg--opacity { padding: 0 2px 0 6px; }
  .slider { width: 88px; }
  .lock { margin-left: 4px; }
}

@media (max-width: 560px) {
  :root { --dock-h: 40px; }
  .dock { bottom: calc(12px + env(safe-area-inset-bottom)); max-width: calc(100vw - 16px); }
  .helpbtn { bottom: auto; top: calc(16px + env(safe-area-inset-top)); right: 16px; }
  .help { bottom: auto; top: calc(62px + env(safe-area-inset-top)); right: 12px; width: min(296px, calc(100vw - 24px)); }
  .topbar { right: 62px; }
  .chip { max-width: 60vw; }
  /* Back and New both have to fit; the filename is already in the gallery. */
  .chip--name { display: none; }
  .drop { padding: 32px 20px 28px; }
  .gallery { padding: 20px 16px calc(56px + env(safe-area-inset-bottom)); }
  .grid { gap: 18px 14px; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); }
  .gallery__head { margin-bottom: 18px; }
  .readout { min-width: 50px; }
  /* One full-width row: the thing you reach for last should be the easiest hit. */
  .lock { flex: 1 0 100%; justify-content: center; margin: 4px 0 0; }
  .slider { flex: 1; width: auto; min-width: 90px; }
  .seg--opacity { flex: 1 1 100%; }
}
