:root {
  color-scheme: dark;
  --paper: #f5f2e5;
  --panel: #142522;
  --ink: #edf1e7;
  --muted: #b6c6bb;
  --line: #3b4f46;
  --accent: #c8e2ac;
  --sans: "DM Sans", "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", "Baskerville", Georgia, serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  --edge: clamp(1.125rem, 3vw, 3.25rem);
  font-family: var(--sans);
  color: var(--ink);
  background: var(--panel);
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
h1, h2, h3, p { margin: 0; }
button, input, select, summary { font: inherit; }
button, summary, select { cursor: pointer; }
button { color: inherit; }
a { color: inherit; text-underline-offset: .23em; }
button:disabled { cursor: default; opacity: .5; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid #f7d197; outline-offset: 3px; }
.sr-only, .symbols { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.icon { display: block; width: 19px; height: 19px; flex: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; fill: none; }

.gallery { position: relative; overflow: hidden; height: 100vh; height: 100dvh; display: grid; grid-template-rows: minmax(0, 1fr) auto; }
.stage { position: relative; isolation: isolate; z-index: 1; min-height: 0; min-width: 0; background: #24555c; color: var(--paper); }
.picture, .art { position: absolute; inset: 0; overflow: clip; background: #10201e; }
.art canvas, .poster { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: var(--fit, cover); object-position: var(--focus, center); image-rendering: pixelated; }
.picture.whole { --matte-position: center; }
.art canvas, .poster { object-position: var(--matte-position, var(--focus, center)); }
#restore { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 3; background: transparent; border: 0; cursor: none; }
#restore:focus { outline: none; }
.gallery.accompanying .stage::after { display: none; }
.art canvas { visibility: hidden; }
.picture.ready canvas { visibility: visible; }
.picture.ready .poster { visibility: hidden; }
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to bottom, rgba(8,24,24,.32), transparent min(23%, 10rem)),
              linear-gradient(to top, rgba(7,22,23,.55), rgba(7,22,23,.14) min(12%, 6rem), transparent min(29%, 14rem));
}
.topbar, .caption { position: absolute; z-index: 1; left: max(var(--edge), env(safe-area-inset-left)); right: max(var(--edge), env(safe-area-inset-right)); display: flex; justify-content: space-between; align-items: center; gap: 1rem; pointer-events: none; }
.topbar { z-index: 2; top: max(var(--edge), env(safe-area-inset-top)); align-items: center; }
.caption { bottom: max(var(--edge), env(safe-area-inset-bottom)); align-items: end; }
.brand { display: inline-flex; align-items: center; gap: .57rem; color: #fffbed; font-size: clamp(1.05rem, 1.65vw, 1.32rem); font-weight: 650; letter-spacing: -.05em; text-shadow: 0 1px 6px #16241f95; user-select: none; }
.tide-mark { width: 28px; height: 25px; stroke-width: 2.1; stroke-linecap: square; stroke-linejoin: miter; }
h1 { font: 400 clamp(3rem, 6.4vw, 6.45rem)/.97 var(--serif); letter-spacing: -.056em; text-wrap: balance; text-shadow: 0 2px 15px #10252466; }
h1 em { font-weight: 400; }
.actions, .scene-picker { pointer-events: auto; }
.actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.overlay-button { display: inline-flex; align-items: center; justify-content: center; gap: .52rem; min-height: 44px; padding: 0 1.04rem; border: 1px solid #f0f6e852; border-radius: 2rem; background: #152b29c9; color: #f8f7ee; font-size: .94rem; font-weight: 560; line-height: 1; white-space: nowrap; -webkit-tap-highlight-color: transparent; }
@supports (backdrop-filter: blur(8px)) { .overlay-button { backdrop-filter: blur(8px); } }
.round { width: 44px; padding: 0; }
.details-toggle { background: var(--paper); border-color: var(--paper); color: #20382e; }
.details-toggle[aria-expanded="true"] { background: #172b28; color: var(--paper); border-color: #c9dbc082; }
@media (hover: hover) {
  .overlay-button:hover { background: #233d36; }
  .details-toggle:not([aria-expanded="true"]):hover { background: white; }
}
.scene-picker { position: relative; }
.scene-picker summary { list-style: none; }
.scene-picker summary::-webkit-details-marker { display: none; }
.scene-switch { position: absolute; top: calc(100% + .5rem); right: 0; width: min(17.5rem, calc(100vw - 2 * var(--edge))); max-height: calc(100vh - 6.5rem); max-height: calc(100dvh - 6.5rem); overflow-y: auto; padding: .34rem; border: 1px solid #96ac9966; border-radius: 14px; background: #152722; color: var(--ink); box-shadow: 0 10px 34px #0b1e2640; }
.scene-switch a { display: grid; grid-template-columns: 52px 1fr 17px; align-items: center; gap: .74rem; min-height: 52px; padding: .35rem .6rem .35rem .34rem; border-radius: 9px; text-decoration: none; font-size: .96rem; }
.scene-switch a:focus-visible { outline-offset: -2px; }
.scene-switch a:hover, .scene-switch a[aria-current="page"] { background: #2b4137; }
.thumbnail { width: 52px; height: 34px; border-radius: 4px; background-color: #384c41; background-position: center 0; background-size: auto 400%; image-rendering: pixelated; }
.current-mark { width: 17px; height: 17px; color: var(--accent); visibility: hidden; }
[aria-current="page"] .current-mark { visibility: visible; }
.status { position: absolute; z-index: 2; top: 50%; left: 50%; width: max-content; max-width: 85%; transform: translate(-50%, -50%); padding: .7rem 1rem; background: var(--panel); color: var(--paper); border-radius: 6px; text-align: center; }

.sheet { min-width: 0; max-height: 48vh; max-height: 48dvh; overscroll-behavior: contain; overflow: auto; background: var(--panel); border-top: 1px solid #9cae963f; scrollbar-color: #607768 var(--panel); scrollbar-width: thin; }
.sheet-inner { display: grid; grid-template-columns: minmax(0, 1fr); max-width: 58rem; margin-inline: auto; padding: clamp(1.3rem, 2.5vw, 2.2rem) max(var(--edge), env(safe-area-inset-right)) max(1.45rem, env(safe-area-inset-bottom)) max(var(--edge), env(safe-area-inset-left)); }
.sheet h2 { font: 400 clamp(1.65rem, 2.1vw, 2.1rem)/1.1 var(--serif); letter-spacing: -.035em; color: var(--paper); }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.text-button { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; font-size: .9rem; text-decoration: none; }
.text-button { background: transparent; border: 0; color: var(--muted); }
.text-button { min-height: 38px; padding: 0 .2rem; }
.text-button .icon { width: 16px; height: 16px; }
.text-button:hover { color: white; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.knobs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(1rem, 2.3vw, 2.4rem); margin: .9rem 0 .8rem; }
.knob-title { display: flex; justify-content: space-between; gap: .5rem; align-items: center; font-size: .93rem; }
.knob output { font: .8rem var(--mono); font-variant-numeric: tabular-nums; color: var(--accent); }
.knob input { appearance: none; -webkit-appearance: none; display: block; width: 100%; height: 28px; margin: 1px 0 0; background: transparent; cursor: pointer; }
.knob input::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--progress, 33%), var(--line) var(--progress, 33%)); }
.knob input::-moz-range-track { height: 3px; border-radius: 3px; background: var(--line); }
.knob input::-moz-range-progress { height: 3px; background: var(--accent); }
.knob input::-webkit-slider-thumb { appearance: none; margin-top: -6px; width: 15px; height: 15px; background: var(--accent); border: 2px solid var(--panel); outline: 1px solid var(--accent); border-radius: 50%; }
.knob input::-moz-range-thumb { width: 12px; height: 12px; background: var(--accent); border: 2px solid var(--panel); outline: 1px solid var(--accent); border-radius: 50%; }
.knob input:disabled { opacity: .4; cursor: default; }
@media (max-width: 560px) {
  .caption { align-items: start; flex-direction: column; gap: .85rem; }
  h1 { font-size: clamp(2.7rem, 10.5vw, 3.8rem); }
  .actions { gap: .48rem; }
  .overlay-button { font-size: .9rem; }
  .knob input { height: 37px; }
  .text-button { min-height: 42px; }
}
@media (max-height: 520px) {
  :root { --edge: 1rem; }
  .topbar { top: max(.55rem, env(safe-area-inset-top)); }
  .caption { bottom: max(.7rem, env(safe-area-inset-bottom)); flex-direction: row; align-items: end; }
  h1 { font-size: clamp(2.05rem, 5.4vw, 3.2rem); }
  .sheet { max-height: 52vh; max-height: 52dvh; }
}

.framing { display: flex; align-items: center; gap: .7rem; font-size: .93rem; }
.framing select { color: var(--paper); background: var(--panel); border: 1px solid var(--line); padding: .4rem .5rem; border-radius: 6px; }
@media (max-height: 510px) and (min-width: 480px) {
  .scene-switch { width: min(32rem, 92vw); display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); }
  .scene-switch a { min-height: 42px; }
  .sheet-inner { padding-block: .45rem; }
  .knobs { margin-block: .2rem; }
}
@media (max-width: 479px) and (max-height: 520px) {
  .caption { flex-direction: column; gap: .25rem; align-items: start; }
  .sheet-inner { padding-block: .25rem; }
  .knobs { margin: 0; }
}
@media (max-width: 360px) {
  .actions .overlay-button:not(.round) { padding-inline: .65rem; }
  .actions { gap: .32rem; }
}
