:root{
  --cream:#f7f2ea;
  --ivory:#fbf8f2;
  --ink:#2f3227;
  --sage:#7f8b6b;
  --sage-deep:#5c6a4c;
  --gold:#c2a05a;
  --gold-soft:#d8c290;
  --line:rgba(92,106,76,.18);
  --shadow:0 10px 30px rgba(47,50,39,.14);
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --safe-left:env(safe-area-inset-left,0px);
  --safe-right:env(safe-area-inset-right,0px);
  --dock-w:96px;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;height:100%;overflow:hidden}
body{
  font-family:"Inter",-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;
  background:var(--cream);color:var(--ink);
  -webkit-font-smoothing:antialiased;
  overscroll-behavior:none;
  user-select:none;
}
.hidden{display:none !important}

/* ---------- closed splash (guest app not open yet) ---------- */
.closed-splash{position:fixed;inset:0;z-index:30;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(120% 90% at 50% 0%,#fbf8f2,#f2ead9);padding:28px;text-align:center}
.cs-card{max-width:420px}
.cs-mono{width:76px;height:76px;margin:0 auto 22px;font-size:40px;border-color:var(--gold)!important;color:var(--ink)}
.cs-mono span{color:var(--gold)}
.cs-couple{font-family:"Cormorant Garamond",serif;font-weight:600;font-size:52px;line-height:1;color:var(--ink);margin:0}
.cs-date{font-size:14px;letter-spacing:.22em;text-transform:uppercase;color:var(--sage);margin-top:10px}
.cs-heart{font-size:34px;color:var(--gold-soft);margin:26px 0 16px}
.cs-msg{font-family:"Cormorant Garamond",serif;font-size:24px;line-height:1.5;color:var(--sage-deep);margin:0}

/* ---------- views ---------- */
.view{position:fixed;inset:0;display:none;flex-direction:column}
.view.is-active{display:flex}

/* ---------- camera ---------- */
.topbar{
  position:absolute;top:0;left:0;right:0;z-index:6;
  display:flex;align-items:center;gap:12px;
  padding:calc(var(--safe-top) + 14px) 18px 14px;
  background:linear-gradient(180deg,rgba(20,22,16,.55),rgba(20,22,16,0));
  color:#fff;pointer-events:none;
}
.monogram{
  font-family:"Cormorant Garamond",serif;font-weight:600;font-size:26px;line-height:1;
  border:1.5px solid rgba(255,255,255,.7);border-radius:50%;
  width:46px;height:46px;display:flex;align-items:center;justify-content:center;
  letter-spacing:.5px;backdrop-filter:blur(3px);
}
.monogram span{font-size:15px;margin:0 1px;color:var(--gold-soft)}
.titles .couple{font-family:"Cormorant Garamond",serif;font-size:24px;font-weight:600;line-height:1.05}
.titles .subtitle{font-size:12px;opacity:.85;letter-spacing:.14em;text-transform:uppercase;margin-top:2px}

.camera-stage{position:relative;flex:1;overflow:hidden;background:#14140f}
#preview{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;transform-origin:center center;background:#14140f}

.flash{position:absolute;inset:0;background:#fff;opacity:0;pointer-events:none;z-index:7}
.flash.fire{animation:flash .32s ease-out}
@keyframes flash{0%{opacity:.85}100%{opacity:0}}

.camera-fallback{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;
  background:radial-gradient(120% 90% at 50% 0%,#20241a,#14140f);padding:24px;z-index:5}
.fallback-card{text-align:center;color:#f7f2ea}
.fallback-heart{font-size:44px;color:var(--gold-soft);margin-bottom:10px}
.fallback-card p{margin:0 0 18px;opacity:.9}
.btn-primary{
  display:inline-block;background:var(--gold);color:#2a2416;font-weight:600;
  padding:14px 26px;border-radius:999px;box-shadow:var(--shadow);cursor:pointer;
}

.zoom-wrap{position:absolute;left:50%;transform:translateX(-50%);bottom:18px;z-index:6;
  display:flex;align-items:center;gap:12px;background:rgba(20,22,16,.42);
  padding:8px 16px;border-radius:999px;backdrop-filter:blur(8px)}
.zoom-wrap .zoom-ico{color:#fff;font-size:16px;width:14px;text-align:center;opacity:.85}
#zoom{-webkit-appearance:none;appearance:none;width:44vw;max-width:230px;height:3px;border-radius:3px;
  background:rgba(255,255,255,.5)}
#zoom::-webkit-slider-thumb{-webkit-appearance:none;width:22px;height:22px;border-radius:50%;
  background:#fff;box-shadow:0 2px 6px rgba(0,0,0,.4)}
#zoom::-moz-range-thumb{width:22px;height:22px;border:none;border-radius:50%;background:#fff}

.flip-btn{position:absolute;right:16px;top:calc(var(--safe-top) + 74px);z-index:6;
  width:44px;height:44px;border-radius:50%;border:none;background:rgba(20,22,16,.4);
  backdrop-filter:blur(6px);display:flex;align-items:center;justify-content:center}
.flip-btn svg{width:24px;height:24px;fill:#fff}

.toast{position:absolute;left:50%;top:calc(var(--safe-top) + 70px);transform:translate(-50%,-14px);
  background:rgba(20,22,16,.82);color:#fff;padding:9px 18px;border-radius:999px;font-size:14px;
  opacity:0;transition:.28s;z-index:8;pointer-events:none;white-space:nowrap}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* dock */
.dock{
  position:relative;z-index:6;display:flex;flex-direction:column;align-items:center;gap:12px;
  padding:12px 26px calc(var(--safe-bottom) + 16px);
  background:linear-gradient(0deg,var(--ivory),var(--ivory) 74%,rgba(251,248,242,0));
}
.dock-row{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;width:100%}

/* Foto / Video segmented toggle */
.mode-toggle{display:inline-flex;background:rgba(92,106,76,.12);border-radius:999px;padding:3px}
.mode-opt{border:none;background:transparent;color:var(--sage-deep);font-family:"Inter",sans-serif;
  font-size:13px;font-weight:600;letter-spacing:.03em;padding:7px 20px;border-radius:999px;transition:.18s}
.mode-opt.is-active{background:#fff;color:var(--ink);box-shadow:0 2px 6px rgba(47,50,39,.14)}

.dock-btn{display:flex;flex-direction:column;align-items:center;gap:3px;background:none;border:none;
  color:var(--sage-deep);font-size:11px;font-weight:500;position:relative;justify-self:center}
.dock-btn svg{width:26px;height:26px;fill:var(--sage-deep)}
.dock-btn:active{opacity:.6}
.badge{position:absolute;top:-4px;right:6px;min-width:18px;height:18px;padding:0 5px;border-radius:999px;
  background:var(--gold);color:#fff;font-size:11px;font-weight:600;display:flex;align-items:center;justify-content:center}

.shutter{width:76px;height:76px;border-radius:50%;border:none;background:transparent;position:relative;
  display:flex;align-items:center;justify-content:center}
.shutter-ring{position:absolute;inset:0;border-radius:50%;border:3px solid var(--sage-deep)}
.shutter-core{width:60px;height:60px;border-radius:50%;
  background:radial-gradient(circle at 35% 30%,#fff,#efe7d6);box-shadow:inset 0 0 0 2px var(--gold-soft)}
.shutter:active .shutter-core{transform:scale(.9);transition:.1s}
/* video mode: red record button; while recording: rounded stop-square */
body.mode-video .shutter-ring{border-color:#c0433b}
body.mode-video .shutter-core{background:radial-gradient(circle at 35% 30%,#e8564c,#c0433b);box-shadow:inset 0 0 0 2px rgba(255,255,255,.35)}
body.recording .shutter-core{width:30px;height:30px;border-radius:8px;transition:.2s}

/* camera-stage control buttons (res + torch), stacked under flip */
.ctl-btn{position:absolute;right:16px;z-index:6;border:none;background:rgba(20,22,16,.4);
  backdrop-filter:blur(6px);color:#fff;display:flex;align-items:center;justify-content:center}
.ctl-btn:active{opacity:.7}
.ctl-btn[hidden]{display:none}
.res-btn{height:34px;padding:0 14px;border-radius:999px;top:calc(var(--safe-top) + 126px);
  font-family:"Inter",sans-serif;font-size:12px;font-weight:600;letter-spacing:.04em}
.res-btn.is-high{background:var(--gold);color:#2a2416}
.torch-btn{width:44px;height:44px;border-radius:50%;top:calc(var(--safe-top) + 170px)}
.torch-btn svg{width:22px;height:22px;fill:#fff}
.torch-btn.is-on{background:var(--gold);box-shadow:0 0 0 2px var(--gold-soft),0 0 14px rgba(194,160,90,.7)}
.torch-btn.is-on svg{fill:#2a2416}

/* recording badge */
.rec-badge{position:absolute;left:50%;top:calc(var(--safe-top) + 16px);transform:translateX(-50%);z-index:8;
  display:flex;align-items:center;gap:8px;background:rgba(20,22,16,.72);color:#fff;
  padding:7px 14px;border-radius:999px;font-size:14px;font-weight:600;font-variant-numeric:tabular-nums}
.rec-badge.hidden{display:none}
.rec-dot{width:10px;height:10px;border-radius:50%;background:#e8564c;animation:recpulse 1s infinite}
@keyframes recpulse{50%{opacity:.35}}
.rec-progress{position:absolute;left:12px;right:12px;bottom:3px;height:2px;background:rgba(255,255,255,.25);border-radius:2px;overflow:hidden}
.rec-progress i{display:block;height:100%;width:0;background:var(--gold-soft)}

/* video tile play badge */
.tile-play{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:42px;height:42px;
  border-radius:50%;background:rgba(92,106,76,.82);display:flex;align-items:center;justify-content:center;pointer-events:none}
.tile-play svg{width:22px;height:22px;fill:#fff;margin-left:2px}

.upload-status{position:absolute;left:50%;transform:translateX(-50%);
  bottom:calc(var(--safe-bottom) + 118px);z-index:7;
  background:rgba(92,106,76,.94);color:#fff;padding:7px 16px;border-radius:999px;font-size:13px;
  box-shadow:var(--shadow);display:flex;align-items:center;gap:8px}
.upload-status .spin{width:13px;height:13px;border:2px solid rgba(255,255,255,.4);border-top-color:#fff;
  border-radius:50%;animation:spin .7s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- album ---------- */
#albumView{background:var(--cream)}
.album-top{display:flex;align-items:center;gap:12px;
  padding:calc(var(--safe-top) + 14px) 16px 12px;border-bottom:1px solid var(--line);
  background:var(--ivory)}
.back-btn,.camera-jump{width:42px;height:42px;border-radius:50%;border:1px solid var(--line);
  background:#fff;display:flex;align-items:center;justify-content:center;flex:0 0 auto}
.back-btn svg,.camera-jump svg{width:22px;height:22px;fill:var(--sage-deep)}
.camera-jump{background:var(--sage-deep);border-color:var(--sage-deep)}
.camera-jump svg{fill:#fff}
.album-title{flex:1;text-align:center}
.album-title .couple{font-family:"Cormorant Garamond",serif;font-size:22px;font-weight:600;line-height:1}
.album-title .subtitle{font-size:12px;color:var(--sage);letter-spacing:.1em;margin-top:2px}

.gallery{flex:1;overflow-y:auto;-webkit-overflow-scrolling:touch;
  display:grid;grid-template-columns:repeat(3,1fr);gap:3px;padding:3px;
  padding-bottom:calc(var(--safe-bottom) + 16px);content-visibility:auto}
@media (min-width:620px){.gallery{grid-template-columns:repeat(4,1fr)}}
@media (min-width:900px){.gallery{grid-template-columns:repeat(6,1fr)}}
.tile{position:relative;aspect-ratio:1;overflow:hidden;background:#e9e2d4;border-radius:4px}
.tile img{width:100%;height:100%;object-fit:cover;display:block;opacity:0;transition:opacity .4s}
.tile img.loaded{opacity:1}
.tile.pending::after{content:"";position:absolute;inset:0;
  background:linear-gradient(110deg,#e9e2d4 30%,#f2ecdf 50%,#e9e2d4 70%);
  background-size:200% 100%;animation:shimmer 1.3s infinite}
@keyframes shimmer{to{background-position:-200% 0}}
.tile.new{animation:pop .5s ease}
@keyframes pop{0%{transform:scale(.6);opacity:0}100%{transform:scale(1);opacity:1}}

.gallery-empty{position:absolute;inset:0;top:80px;display:none;flex-direction:column;
  align-items:center;justify-content:center;text-align:center;color:var(--sage);gap:6px}
.gallery-empty.show{display:flex}
.empty-heart{font-size:52px;color:var(--gold-soft)}
.gallery-empty p{font-family:"Cormorant Garamond",serif;font-size:22px;line-height:1.4}

/* ---------- viewer ---------- */
.viewer{position:fixed;inset:0;z-index:20;background:rgba(16,17,12,.97);
  display:flex;align-items:center;justify-content:center;touch-action:none}
.viewer.hidden{display:none}
.viewer-stage{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;overflow:hidden}
#viewerImg{max-width:100%;max-height:100%;object-fit:contain;will-change:transform;
  transform:translate(0,0) scale(1);transition:transform .05s linear}
#viewerImg.hidden{display:none}
#viewerVideo{max-width:100%;max-height:100%;object-fit:contain;background:#000}
#viewerVideo.hidden{display:none}
.viewer-msg{position:absolute;left:24px;right:24px;bottom:18%;text-align:center;color:#fff;
  background:rgba(20,22,16,.75);padding:14px 16px;border-radius:14px;font-size:14px;line-height:1.4}
.viewer-msg.hidden{display:none}
.viewer-close,.viewer-download{position:absolute;top:calc(var(--safe-top) + 12px);z-index:22;
  width:44px;height:44px;border-radius:50%;border:none;background:rgba(255,255,255,.14);
  color:#fff;font-size:20px;display:flex;align-items:center;justify-content:center;backdrop-filter:blur(6px)}
.viewer-close{right:14px}
.viewer-download{left:14px;text-decoration:none}
.viewer-download svg{width:22px;height:22px;fill:#fff}
.viewer-hint{position:absolute;bottom:calc(var(--safe-bottom) + 22px);left:0;right:0;text-align:center;
  color:rgba(255,255,255,.7);font-size:12.5px;letter-spacing:.03em;transition:opacity .5s;z-index:21}
.viewer-hint.fade{opacity:0}

/* ---------- install FAB (header) + compact bottom sheet ---------- */
.install-fab{flex:0 0 auto;margin-left:auto;width:40px;height:40px;border-radius:50%;
  border:1px solid rgba(255,255,255,.55);background:rgba(20,22,16,.28);backdrop-filter:blur(6px);
  display:flex;align-items:center;justify-content:center;pointer-events:auto;-webkit-tap-highlight-color:transparent}
.install-fab[hidden]{display:none}
.install-fab svg{width:20px;height:20px;fill:#fff}
.install-fab:active{opacity:.6}
.album-top .install-fab{border-color:var(--line);background:#fff}
.album-top .install-fab svg{fill:var(--sage-deep)}

.sheet{position:fixed;inset:0;z-index:24;display:block}
.sheet.hidden{display:none}
.sheet-backdrop{position:absolute;inset:0;background:rgba(16,17,12,.42);opacity:0;transition:opacity .28s ease}
.sheet.show .sheet-backdrop{opacity:1}
.sheet-panel{position:absolute;left:0;right:0;bottom:0;max-height:42vh;background:var(--ivory);color:var(--ink);
  border-radius:20px 20px 0 0;box-shadow:0 -10px 30px rgba(47,50,39,.22);
  padding:10px 22px calc(var(--safe-bottom) + 22px);transform:translateY(100%);
  transition:transform .32s cubic-bezier(.22,.61,.36,1);overflow-y:auto;-webkit-overflow-scrolling:touch;touch-action:pan-y}
.sheet.show .sheet-panel{transform:translateY(0)}
.sheet-panel.dragging{transition:none}
.sheet-grip{width:40px;height:5px;border-radius:3px;background:var(--line);margin:2px auto 12px}
.sheet-x{position:absolute;top:10px;right:14px;width:34px;height:34px;border:none;background:transparent;color:var(--sage);font-size:17px;line-height:1}
.sheet-head{display:flex;align-items:center;gap:10px;margin-bottom:8px}
.sheet-ico{font-size:22px}
.sheet-title{font-family:"Cormorant Garamond",serif;font-weight:600;font-size:24px;margin:0}
.sheet-lede{font-size:14px;line-height:1.45;color:var(--sage-deep);margin:0 0 16px}
.sheet-lede b,.sheet-steps b{color:var(--sage-deep);font-weight:600}
.sheet-cta{display:block;width:100%;background:var(--gold);color:#2a2416;border:none;border-radius:999px;
  padding:15px;font-size:16px;font-weight:600;box-shadow:var(--shadow)}
.sheet-cta:active{transform:scale(.98)}
.sheet-steps{margin:0;padding-left:20px;display:flex;flex-direction:column;gap:11px;font-size:14px;line-height:1.4}
.sheet-steps .inl{width:18px;height:18px;vertical-align:-4px;fill:var(--sage-deep);margin:0 2px}
@media (prefers-reduced-motion:reduce){.sheet-backdrop,.sheet-panel{transition:none}}

/* ============================================================
   LANDSCAPE — camera view relayouts to [ preview | right dock ]
   ============================================================ */
body.landscape #cameraView{flex-direction:row}
body.landscape .camera-stage{flex:1 1 auto;min-width:0;height:100%}
body.landscape .dock{flex:0 0 auto;flex-direction:column;justify-content:center;gap:16px;
  width:calc(var(--dock-w) + var(--safe-right));height:100%;
  padding:calc(var(--safe-top) + 10px) calc(var(--safe-right) + 8px) calc(var(--safe-bottom) + 10px) 8px;
  background:linear-gradient(270deg,var(--ivory),var(--ivory) 68%,rgba(251,248,242,0))}
body.landscape .dock-row{display:flex;flex-direction:column;align-items:center;gap:22px;width:auto}
body.landscape .shutter{width:66px;height:66px}
body.landscape .shutter-core{width:52px;height:52px}
/* stack Foto/Video vertically so it fits the narrow landscape dock column (no overflow over the feed) */
body.landscape .mode-toggle{flex-direction:column;transform:none;gap:2px;padding:3px}
body.landscape .mode-opt{width:70px;padding:6px 0;text-align:center;font-size:12.5px}
body.landscape .badge{right:2px}
body.landscape .topbar{padding:calc(var(--safe-top) + 8px) 16px 10px calc(var(--safe-left) + 16px)}
/* flip/res/torch are children of .camera-stage, which in landscape is the preview
   area (excludes the dock) — so their default right:16px already sits them at the
   preview's right edge next to the dock. Only the vertical spacing needs tightening. */
body.landscape .flip-btn{top:calc(var(--safe-top) + 8px)}
body.landscape .res-btn{top:calc(var(--safe-top) + 52px)}
body.landscape .torch-btn{top:calc(var(--safe-top) + 96px)}
body.landscape .zoom-wrap{bottom:calc(var(--safe-bottom) + 12px)}
body.landscape #zoom{width:200px;max-width:34vw}
