:root {
  color-scheme: light;
  --paper: #eeede9;
  --aperture: min(26.5625vw, calc((100svh - 330px) * .75), 408px);
  --rim: calc(var(--aperture) * .07353);
  --window-width: calc(var(--aperture) + var(--rim) * 2);
  --window-height: calc(var(--aperture) * 4 / 3 + var(--rim) * 2);
  --display-width: calc(var(--aperture) * .652);
  --gap: calc(var(--aperture) * .157);
  --shutter-size: calc(var(--aperture) * .314);
  font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  background: var(--paper);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-width: 280px; min-height: 100%; }
body { background: var(--paper); }
button { -webkit-tap-highlight-color: transparent; }
.workspace {
  display: grid;
  place-items: center;
  min-height: 100svh;
  padding: 44px 24px;
  overflow: hidden;
}
.instrument {
  display: grid;
  grid-template-columns: var(--window-width) var(--display-width);
  gap: var(--gap);
  align-items: start;
  transform: translateX(min(3.125vw, 48px));
}
.camera { display: flex; flex-direction: column; align-items: center; }
.window-frame {
  width: var(--window-width);
  padding: var(--rim);
  border-radius: 24% / 18.6%;
  background: linear-gradient(137deg, #bcbab3 0%, #d0cec7 26%, #e6e4dd 56%, #f7f6f2 88%);
  box-shadow: -2px -2px 4px #d1cfc844, 2px 2px 3px #ffffffbd, inset 1px 1px 3px #ffffff8c;
  position: relative;
}
.window-frame::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  box-shadow: inset 1px 2px 4px #eeede9d9, inset -1px -1px 3px #ffffff99;
  pointer-events: none;
}
.window-bevel {
  border-radius: 21% / 15.75%;
  box-shadow: 0 -1px 2px #5f5e574d, 0 1px 2px #ffffffc9;
}
.aperture {
  width: var(--aperture);
  aspect-ratio: 3 / 4;
  border-radius: inherit;
  overflow: hidden;
  position: relative;
  isolation: isolate;
  background: radial-gradient(ellipse at 57% 65%, #53524e, #494844 70%, #3d3c38);
  box-shadow: inset 0 4px 15px #1e1d1a7a;
}
.aperture::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 3px 8px #1615116b, inset 1px 0 2px #24231f55;
  pointer-events: none;
  z-index: 5;
}
#viewfinder, #photograph {
  position: absolute;
  width: 100%; height: 100%;
  inset: 0;
  object-fit: cover;
  transform: scaleX(-1);
}
#viewfinder { opacity: 0; transition: opacity 320ms ease; }
[data-state="live"] #viewfinder { opacity: 1; }
#photograph { z-index: 1; }
#dither {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 2; transform: scaleX(-1); image-rendering: pixelated;
  clip-path: inset(calc((1 - var(--scan-progress, 0)) * 100%) 0 0 0);
  opacity: 1;
}
.is-reading .aperture::before {
  content: ""; position: absolute; left: 0; right: 0;
  top: calc((1 - var(--scan-progress, 0)) * 100%);
  height: 2px; z-index: 3; pointer-events: none;
  background: #c6df9b99; box-shadow: 0 0 10px #b2d17a66;
}
[hidden] { display: none !important; }
.window-shade { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 36px #1b1a172b; z-index: 2; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; z-index: 4; pointer-events: none; }
.flash.exposed { animation: exposure 330ms ease-out; }
@keyframes exposure { 0% { opacity: .85; } 100% { opacity: 0; } }
#camera-message {
  position: absolute; inset: 0; z-index: 3;
  display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  padding: 24px; color: #e0ded6; font-size: 12px; line-height: 1.85;
  font-weight: 400; text-align: center;
}
#camera-message-text { white-space: pre-line; }
#camera-open-page {
  color: #e0ded6; text-decoration: underline; text-underline-offset: 4px;
  padding: 8px 4px;
}
#camera-open-page:hover { color: #fffef8; }
#camera-open-page:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; border-radius: 2px; }
.shutter {
  --shutter-line: 3px;
  --shutter-ink: #8c9b70;
  width: var(--shutter-size);
  height: var(--shutter-size);
  min-width: 66px; min-height: 66px;
  margin-top: calc(var(--aperture) * .078);
  position: relative;
  border: 0;
  border-radius: 50%; padding: 9px;
  background: transparent;
  box-shadow: none;
  cursor: pointer; touch-action: manipulation;
}
.shutter::before {
  content: "";
  position: absolute; inset: 0;
  border: var(--shutter-line) solid var(--shutter-ink);
  border-radius: inherit;
  pointer-events: none;
}
.shutter-seam {
  display: block; width: 100%; height: 100%; padding: 1.5px;
  border-radius: 50%;
  background: #cbc7bd;
  box-shadow: inset 0 0 1.5px #817a6d66;
}
.shutter-surface {
  display: grid; place-items: center; width: 100%; height: 100%; border-radius: 50%;
  border: 0;
  background: radial-gradient(ellipse at 43% 31%, #faf9f5 0%, #f0efe9 49%, #dedbd2 100%);
  box-shadow: inset 0 1px 2px #ffffffd9, inset 0 -1px 2px #8a83752b;
  transition: transform 130ms ease, box-shadow 130ms ease, background 130ms ease;
}
.retake-icon {
  width: 62%; height: 62%; color: var(--shutter-ink); opacity: 0;
  stroke-width: var(--shutter-line);
  transition: opacity 180ms ease;
}
[data-state="captured"] .retake-icon { opacity: 1; }
.shutter:active .shutter-surface {
  transform: translateY(1px) scale(.985);
  background: linear-gradient(165deg, #e3e1d9, #efeee8);
  box-shadow: inset 0 2px 4px #77705d38, inset 0 -1px 1px #ffffffb3;
}
.shutter:focus-visible { outline: 2px solid #777e69; outline-offset: 8px; }
.shutter:disabled { cursor: wait; }
.readout { padding-top: calc((var(--window-height) - var(--display-width) * .59) / 2 + var(--aperture) * .10); }
.display-frame {
  width: var(--display-width);
  aspect-ratio: 1.7;
  padding: 12px 15px;
  border-radius: 17px;
  border: 1px solid #44443e;
  background: linear-gradient(135deg, #696963 0%, #575751 55%, #4e4e48 100%);
  box-shadow: 0 1px 2px #ffffff, 0 -1px 3px #5a58502e, inset 0 1px 2px #b9b9af, inset 0 0 0 3px #62625b, inset 0 -2px 3px #2729226b;
}
.display-glass {
  position: relative;
  width: 100%; height: 100%; overflow: hidden;
  border-radius: 11px;
  border: 2px solid #3d4236;
  background: #929a88;
  box-shadow: 0 1px 2px #c0c2b333, inset 0 3px 5px #252a2580;
}
.display-glass::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(130deg, #f8ffe611, transparent 55%, #2936250b);
  box-shadow: inset 0 2px 6px #25322140;
}
#pixels { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}
@media (max-width: 600px) {
  :root {
    --aperture: min(52vw, 240px, calc((100svh - 220px) * .75));
    --display-width: calc(var(--aperture) * .52);
    --gap: 16px;
    --shutter-size: 72px;
  }
  .workspace { padding: 32px 16px; }
  .instrument { transform: none; }
  .display-frame { padding: 6px; border-radius: 9px; }
  .display-glass { border-width: 1px; border-radius: 5px; }
  .shutter { --shutter-line: 2px; margin-top: 28px; padding: 5px; }
  #camera-message { padding: 16px; font-size: 11px; }
}
@media (max-width: 600px) and (orientation: portrait) {
  :root {
    --aperture: min(69vw, 300px, calc((100svh - 290px) * .67));
    --display-width: 150px;
  }
  .instrument { grid-template-columns: var(--window-width); row-gap: 30px; }
  .readout { grid-row: 1; justify-self: center; padding-top: 0; }
  .camera { grid-row: 2; }
  .display-frame { padding: 8px 10px; border-radius: 12px; }
  .display-glass { border-radius: 7px; }
}
@media (max-height: 520px) and (min-width: 601px) {
  :root { --aperture: calc((100svh - 170px) * .75); --shutter-size: 66px; }
  .workspace { padding-block: 24px; }
  .shutter { padding: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
