/* Layout: the lamp fills the whole window; one toolbar floats at the bottom and opens one small card at a time above it.
   Single dark look on purpose: the night or day sky is part of the 3D scene, the controls stay navy glass on both. */
:root {
  color-scheme: dark;
  --bg: #0A0D1F;
  --glass: rgba(16, 21, 46, .9);
  --field: #1B2244;
  --line: rgba(226, 176, 78, .35);
  --line-soft: #2C3562;
  --ink: #F8EEDC;
  --muted: #B3B4CC;
  --gold: #E7B04C;
  --gold-hi: #F2C266;
  --red: #B3202F;
  --cream: #F6ECD9;
  --navy-ink: #141A3C;
  --display: "Abril Fatface", Georgia, "Times New Roman", serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", "Segoe Print", "Bradley Hand", cursive;
  --paper: #F7EEDC;
  --paper-ink: #3A2A2E;
  --paper-rule: rgba(179, 32, 47, .16);
}
[hidden] { display: none !important; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px; line-height: 1.45; overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.stage { position: fixed; inset: 0; overflow: hidden; background: #121A42; }
#lampCanvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#lampCanvas.is-dragging { cursor: grabbing; }
.webgl-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.6; }

/* loading screen */
.loading { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: var(--bg); transition: opacity .6s ease; }
.loading.is-done { opacity: 0; pointer-events: none; }
.loading-in { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 24px; text-align: center; }
.loading-in h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 34px; line-height: 1.1; color: var(--ink); }
.loading-in p { margin: 0; color: var(--muted); font-size: 13.5px; }
.load-track { width: 180px; height: 3px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.load-bar { height: 100%; background: var(--gold); transform: scaleX(.04); transform-origin: left; transition: transform .3s ease; }

/* credits, bottom left */
.credits { position: absolute; left: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); max-width: 300px; margin: 0; font-size: 11.5px; line-height: 1.5; color: rgba(179, 180, 204, .8); text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.credits a { color: inherit; text-decoration: underline; text-decoration-color: rgba(179, 180, 204, .45); text-underline-offset: 2px; }
.credits a:hover { color: var(--ink); }
.stage[data-room="day"] .credits { color: rgba(58, 36, 64, .78); text-shadow: none; }
.stage[data-room="day"] .credits a { text-decoration-color: rgba(58, 36, 64, .4); }
.stage[data-room="day"] .credits a:hover { color: #3A2440; }

/* top-left title */
.brand { position: absolute; top: calc(22px + env(safe-area-inset-top, 0px)); left: 24px; display: flex; flex-direction: column; gap: 2px; pointer-events: none; }
.brand h1 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1.1; color: var(--ink); text-shadow: 0 2px 12px rgba(0, 0, 0, .45); }
.brand p { margin: 0; font-size: 13px; color: var(--muted); text-shadow: 0 1px 8px rgba(0, 0, 0, .5); }
.stage[data-room="day"] .brand h1 { color: #3A2440; text-shadow: none; }
.stage[data-room="day"] .brand p { color: #5D4D6E; text-shadow: none; }

.rec-badge {
  position: absolute; top: calc(22px + env(safe-area-inset-top, 0px)); right: 24px; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px; background: rgba(24, 18, 44, .75); color: #FFEAF3;
  font-size: 12.5px; font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .04em;
}
.rec-badge::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: #FF6F91; animation: recblink 1s steps(2) infinite; }
@keyframes recblink { 50% { opacity: .2; } }

/* bottom toolbar */
.toolbar {
  position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; gap: 4px; padding: 7px; border-radius: 999px;
  background: rgba(16, 21, 46, .92); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  max-width: calc(100vw - 32px);
}
.tool {
  display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border: 0; border-radius: 999px;
  background: transparent; color: var(--ink); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.tool svg { flex: none; }
.tool:hover { background: rgba(255, 255, 255, .07); }
.tool[aria-expanded="true"] { background: var(--gold); color: var(--navy-ink); font-weight: 600; }
.tool.is-recording { color: #FF8FA8; }
.tool { position: relative; }
.soon-dot { position: absolute; top: 9px; right: 10px; width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 2px rgba(16, 21, 46, .92); }
.soon { margin-left: 6px; padding: 2px 8px; border-radius: 999px; font: 700 10.5px var(--body); letter-spacing: .08em; text-transform: uppercase; vertical-align: middle; background: rgba(231, 176, 76, .18); color: var(--gold); }

/* inspect: the camera is close to one polaroid; the toolbar makes way for a small photo bar */
.inspect-bar {
  position: absolute; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px; padding: 7px; border-radius: 999px;
  background: rgba(16, 21, 46, .92); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  font-variant-numeric: tabular-nums; white-space: nowrap; animation: inrise .35s ease;
}
@keyframes inrise { from { opacity: 0; transform: translate(-50%, 10px); } }
.inspect-bar #inspectCount { min-width: 104px; text-align: center; color: var(--ink); font-weight: 500; }
.in-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.in-btn:hover { background: rgba(255, 255, 255, .07); }
.in-back { height: 44px; padding: 0 18px; margin-left: 4px; border-radius: 999px; border: 0; background: var(--gold); color: var(--navy-ink); font-weight: 600; cursor: pointer; }
.in-back:hover { background: var(--gold-hi); }
.stage.is-inspecting .toolbar, .stage.is-inspecting .credits { display: none; }

/* one card above the toolbar */
.card {
  position: absolute; right: 24px; bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  width: min(var(--w, 340px), calc(100vw - 32px)); max-height: calc(100% - 190px); overflow-y: auto; box-sizing: border-box;
  padding: 20px 22px 22px; border-radius: 20px; background: var(--glass); border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45);
  display: flex; flex-direction: column; gap: 16px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.card-head h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; line-height: 1.2; }
.x-btn { width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--line-soft); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.x-btn:hover { color: var(--ink); border-color: var(--muted); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.note { margin: 0; color: var(--muted); font-size: 12.5px; text-wrap: pretty; }

.seg { display: inline-flex; background: var(--field); border: 1px solid var(--line-soft); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; min-width: 44px; padding: 6px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-variant-numeric: tabular-nums; }
.seg button[aria-pressed="true"] { background: var(--gold); color: var(--navy-ink); font-weight: 600; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; max-height: 300px; overflow-y: auto; padding: 4px 2px 6px; }
.tile { position: relative; border: 0; padding: 0; background: none; cursor: pointer; border-radius: 3px; transition: transform .15s ease; }
.tile canvas { display: block; width: 100%; height: auto; border-radius: 2px; box-shadow: 0 2px 8px rgba(0, 0, 0, .35); }
.tile:hover { transform: translateY(-2px) rotate(-1.5deg); }
.tile.is-drop { outline: 2px dashed var(--gold); outline-offset: 3px; }
.tile.is-focus { outline: 2px solid var(--gold); outline-offset: 3px; box-shadow: 0 0 18px rgba(231, 176, 76, .55); border-radius: 3px; }
.tile-num { position: absolute; left: 6px; bottom: 4px; font-size: 10.5px; color: #8E829C; font-variant-numeric: tabular-nums; pointer-events: none; }

.btn { border: 1px solid var(--line-soft); background: var(--field); padding: 9px 16px; border-radius: 999px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn-main { background: var(--gold); color: var(--navy-ink); border-color: var(--gold); font-weight: 600; }
.btn-main:hover { background: var(--gold-hi); border-color: var(--gold-hi); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.btn-wide { width: 100%; height: 48px; font-size: 15px; }

.switch { position: relative; width: 44px; height: 26px; border-radius: 999px; border: 1px solid var(--line-soft); background: var(--field); cursor: pointer; padding: 0; flex: none; }
.switch::after { content: ""; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .2s ease, background .2s ease; }
.switch[aria-checked="true"] { background: #4A3A1E; border-color: var(--gold); }
.switch[aria-checked="true"]::after { transform: translateX(18px); background: var(--gold); }
input[type="range"] { width: 150px; accent-color: var(--gold); }
.speed-wrap { display: inline-flex; align-items: center; gap: 10px; }
#speedVal { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--gold); font-weight: 600; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.field input, .field textarea { box-sizing: border-box; width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-soft); background: var(--field); color: var(--ink); }
.field textarea { resize: none; height: 72px; line-height: 1.4; }
.field input::placeholder, .field textarea::placeholder { color: #7E80A0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.count { align-self: flex-end; font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* recording button at the top */
.rec-badge { border: 0; cursor: pointer; }
.rec-stop { margin-left: 4px; padding: 2px 9px; border-radius: 999px; background: #FF6F91; color: #2A0E18; font-weight: 700; letter-spacing: .02em; }

/* music list */
.songs { display: flex; flex-direction: column; gap: 4px; max-height: 340px; overflow-y: auto; padding-right: 4px; }
.song { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 9px 12px; border-radius: 12px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.song:hover { background: rgba(255, 255, 255, .05); }
.song[aria-checked="true"] { background: rgba(231, 176, 76, .14); border-color: var(--line); }
.song .dot { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--line-soft); color: var(--muted); }
.song[aria-checked="true"] .dot { background: var(--gold); border-color: var(--gold); color: var(--navy-ink); }
.song .st { display: flex; flex-direction: column; min-width: 0; }
.song .st b { font-weight: 600; }
.song .st small { color: var(--muted); font-size: 12px; }

/* gift card: a sheet of letter paper */
.paper {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 18px 20px 14px; border-radius: 6px;
  background: var(--paper); color: var(--paper-ink); box-shadow: 0 6px 18px rgba(0, 0, 0, .35); transform: rotate(-.6deg);
}
.p-line { display: flex; align-items: baseline; gap: 8px; font-family: var(--hand); font-size: 24px; line-height: 1.2; }
.p-line label { color: var(--paper-ink); }
.p-line input { flex: 1; min-width: 0; border: 0; border-bottom: 1.5px dashed rgba(58, 42, 46, .35); background: transparent; padding: 0 2px 2px; font: 600 24px var(--hand); color: var(--red); }
.p-line input::placeholder, .paper textarea::placeholder { color: rgba(58, 42, 46, .38); }
.p-sign { justify-content: flex-end; }
.p-sign input { flex: 0 1 150px; }
.paper textarea {
  border: 0; resize: none; background: transparent; padding: 0 2px; color: var(--paper-ink);
  font: 500 22px/30px var(--hand); background-image: repeating-linear-gradient(to bottom, transparent 0 29px, var(--paper-rule) 29px 30px); height: 92px;
}
.paper input:focus-visible, .paper textarea:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; border-radius: 2px; }
.paper .count { color: rgba(58, 42, 46, .55); }

/* gift pop-up: letter on the left, live envelope on the right */
.gift-scrim { position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; padding: 16px; background: rgba(8, 10, 28, .66); overflow-y: auto; }
.gmodal { width: min(900px, 100%); box-sizing: border-box; padding: 22px 24px 24px; border-radius: 22px; background: var(--glass); border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0, 0, 0, .5); display: flex; flex-direction: column; gap: 18px; animation: grise .3s cubic-bezier(.2, .8, .2, 1); }
@keyframes grise { from { opacity: 0; transform: translateY(14px) scale(.98); } }
.gsplit { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 22px; align-items: center; }
.gleft { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.gleft .row { flex-wrap: wrap; }
.lbl { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); }
.swatches { display: flex; gap: 8px; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; box-shadow: inset 0 0 0 3px rgba(0, 0, 0, .15); }
.sw[aria-checked="true"] { border-color: var(--ink); }
.sw:disabled { cursor: default; opacity: .6; }
.gactions { display: flex; justify-content: flex-end; align-items: center; gap: 12px; flex-wrap: wrap; }
.gactions .note { color: #FF9AAE; }
.gdone { display: flex; flex-direction: column; gap: 10px; animation: grise .3s ease; }
.gdone .row { justify-content: flex-start; flex-wrap: wrap; }
.grow { flex: 1; }
.linkbox { display: flex; gap: 8px; align-items: center; padding: 6px 6px 6px 14px; border-radius: 999px; background: var(--field); border: 1px solid var(--line-soft); }
.linkbox code { flex: 1; min-width: 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.gpreview { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 14px 12px 16px; border-radius: 16px; background: rgba(255, 255, 255, .04); border: 1px dashed var(--line-soft); }
.gpreview .tag { align-self: flex-start; margin-bottom: 110px; }
.menv { --seal: #9E1C2A; position: relative; width: min(340px, 100%); aspect-ratio: 440 / 290; max-width: 100%; perspective: 1200px; }
.menv-back { position: absolute; inset: 0; border-radius: 8px; background: #1F2A5C; background-image: radial-gradient(circle at 20% 30%, rgba(231, 176, 76, .28) 0 2px, transparent 3px); background-size: 40px 40px; }
.menv-letter { position: absolute; left: 7%; right: 7%; top: 7%; height: 86%; border-radius: 4px; background: var(--paper); z-index: 2; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); transition: transform .7s cubic-bezier(.3, .7, .2, 1); padding: 10px 14px; box-sizing: border-box; color: var(--paper-ink); font: 500 18px/1.2 var(--hand); overflow: hidden; }
.menv-letter p { margin: 0; overflow-wrap: anywhere; }
.menv-letter .sig { text-align: right; color: var(--red); }
.menv-front { position: absolute; inset: 0; z-index: 3; border-radius: 8px; background: linear-gradient(180deg, #F1E3C7, #E8D5B2); clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 7%; }
.menv-to { font-family: var(--display); font-size: 22px; color: #4A2A30; }
.menv-flap { position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 1; transform-origin: top center; transform: rotateX(180deg); background: linear-gradient(180deg, #F4E8D0, #E3CDA6); clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 8px 8px 0 0; transition: transform .55s ease, z-index 0s .27s; }
.menv[data-flap="closed"] .menv-flap { transform: rotateX(0deg); z-index: 4; }
.menv[data-letter="peek"] .menv-letter { transform: translateY(-30%); }
.menv[data-letter="in"] .menv-letter { transform: translateY(0); }
.menv-seal { position: absolute; left: 50%; top: 58%; z-index: 5; width: 17%; aspect-ratio: 1; margin: -8.5% 0 0 -8.5%; }
.wax { width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--seal) 70%, white), var(--seal) 60%, color-mix(in srgb, var(--seal) 75%, black)); box-shadow: 0 4px 12px rgba(0, 0, 0, .4), inset 0 0 0 4px rgba(0, 0, 0, .12); }
.wax svg { width: 42%; height: 42%; }
.menv-seal { border: 0; padding: 0; background: transparent; border-radius: 50%; display: grid; cursor: default; }
.menv-seal.spot { cursor: pointer; animation: sealpulse 1.4s ease-in-out infinite; }
.menv-seal.spot .wax { background: rgba(247, 238, 220, .35); box-shadow: none; border: 2px dashed rgba(74, 42, 48, .6); }
.menv-seal.spot .wax svg { opacity: .35; }
.menv-seal.spot:hover .wax { border-color: var(--seal); background: rgba(247, 238, 220, .6); }
.menv-seal.spot::after { content: "Press to seal"; position: absolute; left: 50%; bottom: 112%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 700; color: #4A2A30; background: rgba(247, 238, 220, .95); padding: 3px 9px; border-radius: 999px; }
.menv-seal:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
@keyframes sealpulse { 50% { transform: scale(1.08); } }
.menv-seal.stamped .wax { animation: stamp .45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes stamp { 0% { transform: scale(1.9); opacity: 0; } 60% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1); } }
.paper input:read-only, .paper textarea:read-only { cursor: default; }

/* clip dialog */
.modal { position: fixed; inset: 0; background: rgba(10, 7, 20, .72); display: grid; place-items: center; padding: 16px; z-index: 10; }
.modal-card { width: min(640px, 100%); background: #10152E; border: 1px solid var(--line); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.modal-card h2 { margin: 0; font-family: var(--display); font-weight: 400; font-size: 20px; }
.adjust-card { width: min(480px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; box-sizing: border-box; gap: 14px; }
#adjCanvas { display: block; align-self: center; width: min(280px, 64vw, calc((100vh - 290px) * 460 / 585)); min-width: 160px; height: auto; cursor: grab; touch-action: none; border-radius: 10px; box-shadow: 0 14px 34px rgba(0, 0, 0, .45); }
#adjCanvas.is-dragging { cursor: grabbing; }
.adj-zoom { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.adj-zoom input[type="range"] { flex: 1; width: auto; }
.adj-note { text-align: center; }
.adj-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.modal-card video { width: 100%; border-radius: 8px; background: #000; max-height: 60vh; }

/* gift view: what the friend sees */
.gift-seal { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(12, 14, 38, .72); z-index: 5; overflow-y: auto; }
.env-wrap { display: flex; flex-direction: column; align-items: center; gap: 18px; width: min(460px, 100%); }
.env-lead { margin: 0; font-family: var(--display); font-size: 28px; line-height: 1.15; text-align: center; color: var(--ink); text-wrap: balance; text-shadow: 0 2px 14px rgba(0, 0, 0, .5); }
.env-hint { margin: 0; color: var(--muted); font-size: 13.5px; text-align: center; }
.envelope { position: relative; width: 100%; aspect-ratio: 440 / 290; max-width: 100%; perspective: 1200px; }
.env-back { position: absolute; inset: 0; border-radius: 8px; background: #1F2A5C; background-image: radial-gradient(circle at 20% 30%, rgba(231, 176, 76, .25) 0 2px, transparent 3px), radial-gradient(circle at 70% 20%, rgba(231, 176, 76, .25) 0 2px, transparent 3px); background-size: 46px 46px; }
.letter {
  position: absolute; left: 6%; right: 6%; top: 6%; height: 88%; box-sizing: border-box; padding: 16px 22px 18px; border-radius: 4px;
  background: var(--paper); color: var(--paper-ink); display: flex; flex-direction: column; align-items: flex-start; gap: 4px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25); z-index: 2; transition: transform .8s cubic-bezier(.3, .7, .2, 1);
}
.letter p { margin: 0; }
.l-dear, .l-sign { font: 600 24px/1.2 var(--hand); }
.l-msg { font: 500 22px/1.3 var(--hand); overflow-wrap: anywhere; }
.l-sign { align-self: flex-end; color: var(--red); }
.letter .btn-red { align-self: center; margin-top: auto; height: 46px; font-size: 15px; }
.env-front {
  position: absolute; inset: 0; z-index: 3; border-radius: 8px; background: linear-gradient(180deg, #F1E3C7, #E8D5B2);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 7%;
  box-shadow: inset 0 0 0 2px rgba(179, 32, 47, .12);
}
.env-to { font-family: var(--display); font-size: 26px; color: #4A2A30; }
.env-flap {
  position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 4; transform-origin: top center; transform: rotateX(0deg);
  background: linear-gradient(180deg, #F4E8D0, #E3CDA6); clip-path: polygon(0 0, 100% 0, 50% 100%); border-radius: 8px 8px 0 0;
  transition: transform .6s ease, z-index 0s .3s;
}
.seal {
  position: absolute; left: 50%; top: 58%; z-index: 5; width: 64px; height: 64px; margin: -32px 0 0 -32px; border: 0; border-radius: 50%; cursor: pointer;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--seal, #9E1C2A) 70%, white), var(--seal, #9E1C2A) 60%, color-mix(in srgb, var(--seal, #9E1C2A) 75%, black)); box-shadow: 0 4px 12px rgba(0, 0, 0, .4), inset 0 0 0 4px rgba(0, 0, 0, .12);
  display: grid; place-items: center; transition: transform .3s ease, opacity .3s ease;
}
.seal:hover { transform: scale(1.06); }
.seal:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.envelope:not([data-state="closed"]) .seal { opacity: 0; transform: scale(.6); pointer-events: none; }
.envelope:not([data-state="closed"]) .env-flap { transform: rotateX(180deg); z-index: 1; }
.envelope[data-state="out"] .letter { transform: translateY(-62%); }
.envelope[data-state="read"] .letter { z-index: 6; transform: translateY(-10%) scale(1.05); }
.gift-seal { transition: opacity .6s ease; }
.gift-seal.is-leaving { opacity: 0; }
.btn-red { height: 52px; padding: 0 30px; border-radius: 999px; border: 0; background: var(--red); color: #FFF6E8; font-weight: 600; font-size: 16px; cursor: pointer; }
.btn-red:hover { background: #C62A3A; }
.btn-red:focus-visible { outline-color: var(--red); }

.gift-note {
  position: absolute; top: calc(24px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  width: min(460px, calc(100vw - 32px)); box-sizing: border-box; padding: 16px 22px; border-radius: 18px;
  background: rgba(246, 236, 217, .95); color: #2A1E24; text-align: center; box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
  display: flex; flex-direction: column; gap: 6px;
}
.gift-note .who { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--red); }
.gift-note .msg { font-family: var(--hand); font-size: 24px; line-height: 1.25; overflow-wrap: anywhere; }
.gift-bar { position: absolute; left: 24px; right: 24px; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; pointer-events: none; flex-wrap: wrap; }
.gift-bar > * { pointer-events: auto; }
.gift-left { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 999px; border: 1px solid var(--line); background: rgba(20, 24, 58, .85); color: var(--ink); cursor: pointer; font-weight: 500; }
.chip-hint { cursor: default; color: var(--muted); font-size: 13px; background: rgba(20, 24, 58, .6); }
.btn-own { height: 46px; padding: 0 22px; border-radius: 999px; border: 0; background: var(--gold); color: var(--navy-ink); font-weight: 600; font-size: 15px; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
.preview-tag { position: absolute; top: calc(24px + env(safe-area-inset-top, 0px)); right: 24px; display: flex; align-items: center; gap: 10px; padding: 6px 6px 6px 14px; border-radius: 999px; background: rgba(20, 24, 58, .85); border: 1px solid var(--line); font-size: 12.5px; color: var(--muted); z-index: 6; }
.preview-tag button { border: 0; border-radius: 999px; padding: 6px 12px; background: var(--field); color: var(--ink); cursor: pointer; }

.photo-view { position: fixed; inset: 0; z-index: 8; background: rgba(10, 12, 32, .82); display: grid; place-items: center; padding: 16px; }
.photo-view canvas { width: min(420px, 80vw, calc((100vh - 120px) * 460 / 585)); height: auto; transform: rotate(-2deg); box-shadow: 0 30px 70px rgba(0, 0, 0, .55); border-radius: 6px; }
.photo-view .pv-count { position: absolute; top: calc(38px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%); color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pv-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; border: 1px solid rgba(246, 236, 217, .35); background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.pv-prev { left: 24px; } .pv-next { right: 24px; }
.pv-close { position: absolute; top: calc(24px + env(safe-area-inset-top, 0px)); right: 24px; width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(246, 236, 217, .4); background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 760px) {
  .gsplit { grid-template-columns: 1fr; }
}
@media (max-width: 1000px) {
  .credits { bottom: auto; top: calc(78px + env(safe-area-inset-top, 0px)); max-width: 240px; }
}
@media (max-width: 640px) {
  .tool span { display: none; }
  .tool { padding: 0 13px; }
  .brand h1 { font-size: 20px; }
  .card { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .loading, .load-bar, .tile, .switch::after, .tool, .letter, .env-flap, .seal, .gift-seal, .menv-letter, .menv-flap { transition: none; }
  .inspect-bar, .gmodal, .gdone, .menv-seal.stamped .wax, .menv-seal.spot { animation: none; }
}
