:root{color-scheme:dark;--paper:#141414;--ink:#ecebe5;--app-font:"EB Garamond",Garamond,"Times New Roman",serif;--app-font-size:13px}*{box-sizing:border-box}body{margin:0;background:var(--paper);color:var(--ink);font:400 var(--app-font-size)/1.25 var(--app-font);letter-spacing:-.01em;font-kerning:normal;overflow:hidden}button{font:inherit;cursor:pointer;border:0;color:inherit}button:focus-visible,.lens:focus-visible{outline:1px solid #fff8;outline-offset:-3px}button:disabled{cursor:wait;opacity:.35}[hidden]{display:none!important}.sr-only{position:absolute!important;width:1px!important;height:1px!important;padding:0!important;margin:-1px!important;overflow:hidden!important;clip:rect(0,0,0,0)!important;white-space:nowrap!important;border:0!important}canvas{display:block}
#stage{position:fixed;inset:0;touch-action:none}#stage.behind-camera{visibility:hidden}
#capture{position:fixed;inset:0;z-index:5;overflow:hidden;background:var(--paper);background-image:var(--camera-paper,none);background-size:100% 100%;transform:translate3d(0,0,0);touch-action:manipulation}
.camera-shell{position:relative;width:100%;height:100%;display:grid;grid-template-rows:minmax(0,1fr) clamp(150px,21svh,210px);overflow:hidden;background:transparent}
.lens{position:relative;min-height:0;width:100%;height:100%;overflow:hidden;cursor:crosshair;touch-action:manipulation;background:#151d18}
.finder-image{position:absolute;inset:0;width:100%!important;height:100%!important}.raw-feed{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.finder-markers{display:grid;place-items:center;position:absolute;inset:0;z-index:3;pointer-events:none;color:#f5f3df;opacity:.7}.finder-markers:before,.finder-markers:after{content:"";position:absolute;background:#e9e9d2;opacity:.24}.finder-markers:before{left:0;right:0;top:50%;height:.75px;transform:translateY(-50%)}.finder-markers:after{top:0;bottom:0;left:50%;width:.75px;transform:translateX(-50%)}.finder-markers svg{position:static;width:24px;height:24px;transform:none;transform-origin:50% 50%;transform-box:view-box;stroke-width:1}
#preview{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;z-index:1}
.camera-panel{position:relative;min-height:0;background:transparent;padding:clamp(22px,3svh,30px) 24px max(40px,calc(env(safe-area-inset-bottom) + 12px));display:flex;flex-direction:column;justify-content:space-between}
.camera-heading{display:flex;justify-content:space-between;gap:20px;pointer-events:none}.camera-heading p{margin:0;text-transform:none;font-family:inherit;font-weight:400;font-size:var(--app-font-size);line-height:1.25;letter-spacing:inherit;color:#e5e5df}.camera-heading p:last-child{text-align:right;font-variant-numeric:tabular-nums}
.shutter-deck{display:grid;grid-template-columns:repeat(3,44px);align-items:center;justify-content:space-between;margin:0 -10px -4px;min-height:44px}.shutter-deck button{width:44px;height:44px;display:grid;place-items:center;padding:11px;background:transparent;touch-action:manipulation}.shutter-deck svg{width:22px;height:22px;stroke-width:.9;stroke-linecap:butt;stroke-linejoin:miter}.shutter-deck button:active{opacity:.55}
#capture.capture-frozen .shutter-deck{opacity:0;pointer-events:none;transition:opacity .2s}#capture.capture-frozen .shutter-deck button{pointer-events:none}#capture.flipped,#capture.capture-bridging{pointer-events:none}
#stage.memory-transition,.colour-decode{will-change:transform}
.colour-decode{position:absolute;inset:0;z-index:3;pointer-events:none;overflow:hidden}
.colour-decode canvas{position:absolute;inset:0;width:100%;height:100%}
.capture-decoding #preview,.capture-decoding .finder-markers,.capture-decoding .finder-image{visibility:hidden}
.capture-decoding .lens{background:transparent}
.capture-revealing .finder-image{visibility:hidden}
body:has(#stage.memory-transition) #soundToggle,.capture-decoding #aboutButton{visibility:hidden}
#carpetScroll{position:fixed;inset:0;overflow-y:auto;overflow-x:hidden;overscroll-behavior:contain;scrollbar-width:thin;scrollbar-color:#666 var(--paper);background:var(--paper);touch-action:pan-y}#carpetLength{width:1px;pointer-events:none}#carpetScroll #stage,#stage canvas{touch-action:none}body:has(#capture:not([hidden])) #carpetScroll{overflow:hidden;pointer-events:none}
#firstFloor{display:none;position:fixed;right:calc(env(safe-area-inset-right) + 28px);top:calc(env(safe-area-inset-top) + 32px);z-index:4;width:44px;height:44px;place-items:center;background:#0005;color:var(--ink)}#firstFloor svg{width:20px;height:20px;stroke-width:1}body:has(#capture[hidden]) #firstFloor{display:grid}
@media(max-height:500px) and (orientation:landscape){.camera-shell{grid-template-rows:minmax(0,1fr) 110px}.camera-panel{padding:12px max(24px,env(safe-area-inset-right)) 8px max(24px,env(safe-area-inset-left))}}
@media(prefers-reduced-motion:reduce){*{scroll-behavior:auto!important}}

.app-name{font:inherit;letter-spacing:inherit}

#aboutButton,#aboutClose{position:absolute;top:calc(env(safe-area-inset-top) + 16px);right:calc(env(safe-area-inset-right) + 16px);width:44px;height:44px;display:grid;place-items:center;padding:12px;background:transparent;color:var(--ink);z-index:8;touch-action:manipulation}
#aboutButton svg,#aboutClose svg{width:20px;height:20px}
#capture.capture-frozen #aboutButton{visibility:hidden;pointer-events:none}
#aboutDialog{position:fixed;inset:0;width:min(300px,calc(100vw - 64px));height:fit-content;max-width:none;max-height:calc(100dvh - 96px);margin:auto;border:0;border-radius:0;padding:0;overflow:auto;background:var(--paper);background-image:var(--camera-paper,none);background-size:cover;color:var(--ink);font:inherit}
#aboutDialog::backdrop{background:#0009}
#aboutDialog #aboutClose{top:14px;right:12px;width:36px;height:36px;padding:10px;background:none;border:0;box-shadow:none;border-radius:0;outline:none}#aboutDialog #aboutClose svg{width:16px;height:16px}#aboutDialog #aboutClose:focus-visible{outline:1px solid #fff8;outline-offset:-5px}
#aboutDialog article{padding:24px 20px;overflow-y:auto;overscroll-behavior:contain;text-align:left;text-transform:none}
#aboutDialog h1{font-style:italic;padding-right:36px;outline:none;font-size:var(--app-font-size);font-weight:400;letter-spacing:inherit;margin:0 0 14px}
#aboutDialog article>p{text-align:justify;text-justify:inter-word;font-size:var(--app-font-size);line-height:1.25;letter-spacing:inherit;margin:0 0 8px}

#aboutDialog article>p:last-of-type{margin-bottom:0}

#soundToggle,#aboutButton{top:calc(env(safe-area-inset-top) + 32px);width:44px;height:44px;display:grid;place-items:center;border:0;background:#0005;color:var(--ink);padding:12px;cursor:pointer}#soundToggle{position:fixed;z-index:40;left:calc(env(safe-area-inset-left) + 28px)}#aboutButton{right:calc(env(safe-area-inset-right) + 28px)}#soundToggle svg,#aboutButton svg{width:20px;height:20px;stroke-width:1}#soundToggle[data-enabled="true"] .sound-off{display:none}#soundToggle:focus-visible,#aboutButton:focus-visible{outline:1px solid #fff8;outline-offset:-3px}

#privacyNote{opacity:.72}#storageNotice{position:fixed;z-index:50;bottom:0;left:0;right:0;margin:0;padding:12px max(24px,env(safe-area-inset-right)) max(12px,env(safe-area-inset-bottom)) max(24px,env(safe-area-inset-left));background:var(--paper);color:var(--ink);font-size:var(--app-font-size);line-height:1.25;text-align:center;pointer-events:none}

/* Native scrolling owns all touches; the rug is a fixed, non-interactive surface. */
#carpetScroll #stage{pointer-events:none}

#postcardDialog{outline:none;width:min(380px,calc(100vw - 48px),calc((100dvh - 96px)*.5625));max-height:calc(100dvh - 64px);padding:0;margin:auto;border:1px solid #ecebe580;border-radius:0;box-shadow:none;background:transparent;color:var(--ink);font:inherit;overflow:auto}#postcardDialog::backdrop{background:var(--paper);background-image:var(--camera-paper,none);background-size:100vw 100vh}.postcard-actions{position:absolute;top:8px;left:8px;right:8px;z-index:1;display:flex;justify-content:space-between;padding:4px 8px}.postcard-actions button{display:grid;place-items:center;width:32px;height:32px;padding:8px;background:transparent;border:0;outline:none}.postcard-actions button:focus-visible{outline:none}.postcard-actions button:focus-visible svg{stroke-width:1.5}.postcard-actions svg{width:16px;height:16px}#postcardPreview{display:block;width:100%;height:auto}#postcardStatus{margin:20px;text-align:center}

.about-credit{display:flex;align-items:center;gap:5px;margin-top:16px;font:inherit;color:var(--ink)}.woven-heart{display:block;width:18px;height:16px;flex:none}

.scan-status{position:absolute;left:24px;bottom:max(40px,calc(env(safe-area-inset-bottom) + 12px));z-index:4;margin:0;font:inherit;color:var(--ink);pointer-events:none}

#aboutDialog h2{font:inherit;font-style:italic;margin:16px 0 8px}

/* Four completed-print controls; no footer strip or cloth interaction. */
#regenerateMemory,#firstFloor,#downloadMemory,#saveMemory{position:fixed;z-index:4;display:grid;place-items:center;width:44px;height:44px;padding:12px;border:0;background:#0005;color:var(--ink)}
#regenerateMemory svg,#firstFloor svg,#downloadMemory svg,#saveMemory svg{width:20px;height:20px;stroke-width:1}
#regenerateMemory{left:calc(env(safe-area-inset-left) + 28px);top:calc(env(safe-area-inset-top) + 32px)}
#firstFloor{right:calc(env(safe-area-inset-right) + 28px);top:calc(env(safe-area-inset-top) + 32px)}
#downloadMemory{left:calc(env(safe-area-inset-left) + 28px);bottom:calc(env(safe-area-inset-bottom) + 32px)}
#saveMemory{right:calc(env(safe-area-inset-right) + 28px);bottom:calc(env(safe-area-inset-bottom) + 32px)}
#rugFlip{position:fixed;z-index:2;border:0;padding:0;background:transparent;cursor:pointer;touch-action:manipulation}
#rugFlip:focus-visible{outline:1px solid var(--ink);outline-offset:5px}
body:has(#capture[hidden]) #soundToggle{display:none}
body:has(#storageNotice:not([hidden])) #downloadMemory,body:has(#storageNotice:not([hidden])) #saveMemory{bottom:96px}

#galleryDialog{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:calc(env(safe-area-inset-top) + 24px) 28px calc(env(safe-area-inset-bottom) + 36px);border:0;color:var(--ink);background:var(--paper) var(--camera-paper,none) center/cover;overflow-y:auto;overscroll-behavior:contain}
#galleryDialog::backdrop{background:var(--paper)}
.gallery-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:32px}
.gallery-heading h1{margin:0;font:inherit}
.gallery-heading button{display:grid;place-items:center;width:44px;height:44px;padding:12px;background:#0005}
.gallery-heading svg{width:20px;height:20px}
#galleryGrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(120px,1fr));gap:32px 24px;max-width:880px;margin:0 auto}
#galleryGrid figure{margin:0;display:flex;flex-direction:column;align-items:center;gap:12px}
.gallery-rug{width:100%;max-width:144px;aspect-ratio:1.536/3.8;display:grid;place-items:center;font:inherit}
.gallery-rug canvas{display:block;width:100%;height:100%}
#galleryGrid figcaption{font:inherit}
#galleryStatus{margin:24px 0;font:inherit}
#galleryRetry{padding:10px 16px;border:.75px solid #ecebe54d;background:transparent}

#galleryTitle:focus{outline:none}
button.gallery-rug{padding:0;border:0;background:transparent;color:var(--ink);cursor:pointer}

#postcardDialog:has(#memoryDetail:not([hidden])){height:calc(100dvh - 64px);overflow:hidden}
#memoryDetail{height:100%;padding:56px 24px 28px;background:var(--paper) var(--camera-paper,none) center/cover}
.memory-detail-column{width:min(100%,260px);height:100%;margin:auto;display:grid;grid-template-rows:minmax(0,1fr) auto;gap:28px}
#memoryDetailFlip{display:block;place-self:center;height:100%;width:auto;max-width:100%;aspect-ratio:1.536/3.8;min-height:0;padding:0;border:0;background:transparent;cursor:pointer}
#memoryDetailFlip:disabled{opacity:1}
#memoryDetailFlip canvas{width:100%!important;height:100%!important;pointer-events:none}
#memoryDetailCopy{height:100%;display:flex;flex-direction:column;align-self:stretch;min-width:0;font:inherit;text-wrap:pretty}
#memoryDetailCopy p{flex:none;margin:0 0 4px}
#memoryDetailCopy p:first-child{margin-bottom:10px}
#memoryDetailCopy footer{display:flex;justify-content:space-between;gap:12px;margin-top:24px;padding-top:0;font:inherit}
@media(max-height:600px) and (min-aspect-ratio:1/1){
 #postcardDialog:has(#memoryDetail:not([hidden])){width:min(720px,calc(100vw - 32px));height:calc(100dvh - 32px);max-height:calc(100dvh - 32px)}
 #memoryDetail{padding:48px 24px 16px}
 .memory-detail-column{width:100%;grid-template-columns:minmax(0,1fr) minmax(180px,1.4fr);grid-template-rows:minmax(0,1fr);gap:24px}
 #memoryDetailCopy{height:auto;align-self:center}
}
