:root {
  --night: #14213a;
  --night-2: #1c2f52;
  --ink: #1d1b18;
  --muted: #5f5a52;
  --cream: #fbf5e9;
  --paper: #f4e9d2;
  --line: #e2d3b5;
  --red: #b4432e;
  --red-dark: #8f3221;
  --gold: #e8b955;
  --green: #2e5b4b;
  --green-dark: #1f3f34;
  --focus: #ffd166;
  --radius: 14px;
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  line-height: 1.5;
  color: var(--cream);
  background-color: var(--night);
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #ffffffb0 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 62%, #ffffff90 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 12%, #ffffffa0 50%, transparent 51%),
    radial-gradient(1px 1px at 66% 40%, #ffffff80 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 84% 22%, #ffffffb0 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 70%, #ffffff80 50%, transparent 51%),
    radial-gradient(ellipse at 50% -10%, var(--night-2), var(--night) 60%);
  background-attachment: fixed;
  min-height: 100vh;
}

h1, h2 { font-family: var(--serif); line-height: 1.15; margin: 0 0 .5rem; font-weight: 700; }
h2 { font-size: 1.5rem; }
p { margin: 0 0 .75rem; }
a { color: var(--gold); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.skip-link { position: absolute; left: -999px; top: .5rem; background: var(--cream); color: var(--ink); padding: .5rem 1rem; border-radius: 8px; z-index: 20; }
.skip-link:focus { left: .5rem; }

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

/* ---------- mockup bar ---------- */
.demo-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem .9rem;
  padding: .5rem 1rem; font-size: .85rem;
  background: #00000080; border-bottom: 1px dashed #ffffff30;
}
.demo-bar strong { background: var(--gold); color: var(--ink); padding: .1rem .5rem; border-radius: 6px; }
.demo-bar select { font: inherit; padding: .25rem .4rem; border-radius: 6px; border: 0; }
.demo-link { background: none; border: 0; color: var(--cream); text-decoration: underline; font: inherit; cursor: pointer; padding: .25rem; }

/* ---------- layout ---------- */
.site-header, main, .site-footer { max-width: 980px; margin: 0 auto; padding-left: 1rem; padding-right: 1rem; }
.site-header { padding-top: 1rem; padding-bottom: .5rem; }
.logo { font-family: var(--serif); font-size: 1.5rem; font-weight: 700; color: var(--cream); text-decoration: none; }
.logo span { color: var(--gold); }
main { padding-bottom: 3rem; }
main:focus, main:focus-visible { outline: none; }
.site-footer { display: flex; flex-wrap: wrap; gap: .4rem .6rem; justify-content: center; padding-bottom: 2rem; font-size: .85rem; color: #cfc6b4; }
.site-footer a { color: #cfc6b4; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .6rem 1.15rem; border-radius: 999px;
  border: 2px solid currentColor; background: transparent; color: inherit;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background .15s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost:hover { background: #00000010; }
.btn-lg { font-size: 1.1rem; padding: .8rem 1.6rem; }
.link { background: none; border: 0; color: var(--gold); text-decoration: underline; font: inherit; cursor: pointer; padding: .5rem; }

.card { background: var(--cream); color: var(--ink); border-radius: var(--radius); padding: 1.5rem; box-shadow: 0 12px 34px #0007; }
.card a:not(.btn) { color: var(--red-dark); }

label, legend { display: block; font-weight: 600; margin-bottom: .35rem; }
fieldset { border: 0; padding: 0; margin: 0; }
input, textarea, select { color: var(--ink); }
input:not([type=file]), textarea {
  font: inherit; width: 100%; padding: .7rem .85rem;
  border: 2px solid var(--line); border-radius: 10px; background: #fff;
}
input:focus, textarea:focus { border-color: var(--green); outline: none; box-shadow: 0 0 0 3px #2e5b4b40; }
input[aria-invalid="true"] { border-color: var(--red); }
textarea { resize: vertical; }
.field { margin-bottom: 1.1rem; }
.field-error { color: var(--red-dark); font-size: .9rem; font-weight: 500; margin: .35rem 0 0; }
.hint { color: var(--muted); font-size: .9rem; margin: .35rem 0 0; }
.hint.light { color: #d9d0bf; }
.center { text-align: center; }
.req { color: var(--red); }
.optional { font-weight: 400; color: var(--muted); }
.counter { font-size: .8rem; color: var(--muted); text-align: right; margin: .25rem 0 0; }

/* ---------- start ---------- */
.hero { text-align: center; padding: 2rem 0 1.5rem; }
.hero h1 { font-size: clamp(2rem, 5.5vw, 3.3rem); max-width: 17ch; margin: 0 auto .9rem; }
.lead { max-width: 58ch; margin: 0 auto 1.75rem; color: #e9e1d1; font-size: 1.1rem; }
.create-form { max-width: 460px; margin: 0 auto 1.25rem; text-align: left; }
.create-form .btn-primary { width: 100%; margin-top: 1rem; }
.how { margin-top: 2rem; }
.how h2 { text-align: center; }
.steps { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; counter-reset: s; }
.steps li { align-content: start; counter-increment: s; background: #ffffff0d; border: 1px solid #ffffff1f; border-radius: var(--radius); padding: 1.1rem; display: grid; gap: .25rem; }
.steps li::before { content: counter(s); font-family: var(--serif); font-size: 1.7rem; color: var(--gold); line-height: 1; }
.steps span { color: #d9d0bf; font-size: .95rem; }

/* ---------- created / share ---------- */
.created { max-width: 600px; margin: 1.5rem auto; }
.created h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
.eyebrow { text-transform: uppercase; letter-spacing: .12em; font-size: .8rem; font-weight: 600; color: var(--gold); margin: 0 0 .25rem; }
.eyebrow.dark { color: var(--green); }
.share-box { margin: 1rem 0; }
.copy-row { display: flex; gap: .5rem; }
.copy-row input { flex: 1; min-width: 0; font-size: .95rem; }
.btn-row { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: center; margin-top: .9rem; }
.btn-row.left { justify-content: flex-start; }
.code-box { background: var(--paper); border-radius: 12px; padding: 1rem 1.1rem; margin: 1.25rem 0; }
.code-label { font-weight: 600; margin: 0; }
.code { font-family: var(--serif); font-size: 2.3rem; letter-spacing: .12em; margin: .1rem 0 .4rem; color: var(--red-dark); }

/* ---------- calendar ---------- */
.cal-head { text-align: center; padding: 1.25rem 0 1.5rem; }
.cal-head h1 { font-size: clamp(2.2rem, 7vw, 3.6rem); }
.cal-summary { color: #e9e1d1; max-width: 52ch; margin: 0 auto 1.1rem; }

.house { position: relative; margin: 1rem auto 2rem; max-width: 860px; }
/* Fairy lights hanging over the top edge of the calendar */
.lights { position: relative; margin: 0 1.5% -26px; z-index: 2; pointer-events: none; }
.lights svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.lights path { fill: none; stroke: #4a4337; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.bulb {
  position: absolute; width: 11px; height: 16px; margin-left: -5.5px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 40% 35%, #fffbe6 0 18%, #ffe27a 40%, #f5b82e 100%);
  transform: rotate(var(--tilt)); transform-origin: 50% 0;
  box-shadow: 0 0 6px 2px #ffd86680, 0 0 18px 6px #ffc94040;
  animation: twinkle 2.6s ease-in-out infinite; animation-delay: var(--d);
}
.bulb::before { /* socket */
  content: ""; position: absolute; left: 2.5px; top: -4px; width: 6px; height: 5px;
  border-radius: 1px; background: #3a342b;
}
@media (max-width: 640px) { .bulb:nth-of-type(2n) { display: none; } }
@keyframes twinkle {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px 2px #ffd866a0, 0 0 22px 8px #ffc94060; }
  50% { opacity: .5; box-shadow: 0 0 2px 0 #ffd86640, 0 0 6px 1px #ffc94020; filter: saturate(.7); }
}
.doors {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: clamp(.4rem, 1.5vw, .9rem);
  padding: clamp(.6rem, 2vw, 1.25rem);
  background: linear-gradient(180deg, var(--green), var(--green-dark));
  padding-top: clamp(1.6rem, 4vw, 2.2rem);
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 6px #ffffff10, 0 20px 40px #0007;
}
@media (max-width: 640px) { .doors { grid-template-columns: repeat(4, 1fr); } }

.door {
  position: relative; aspect-ratio: 3 / 4;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
  padding: .3rem; border: 0; border-radius: 10px;
  background: var(--paper); color: var(--ink); font: inherit; cursor: pointer;
  box-shadow: inset 0 0 0 3px #ffffff90, 0 3px 0 #0004;
  transition: transform .15s ease;
  transform-origin: left center;
}
.door:nth-child(3n+1) { background: #f6e2c4; }
.door:nth-child(4n+2) { background: #efd9b5; }
.door:nth-child(5n) { background: #f8eedd; }
.door[data-n="24"] { background: var(--red); }
.door[data-n="24"] .door-num, .door[data-n="24"] .door-count { color: #fff; }
.door:hover:not([aria-disabled="true"]) { transform: translateY(-3px); }
.door-num { font-family: var(--serif); font-weight: 700; font-size: clamp(1.3rem, 4vw, 2.2rem); color: var(--red-dark); line-height: 1; }
.door-num.small { font-size: .85rem; position: absolute; top: .3rem; left: .45rem; }
.door-count { font-size: clamp(.8rem, 2.2vw, 1.05rem); color: var(--muted); min-height: 1.2em; letter-spacing: -.1em; }

.door.locked { cursor: default; filter: saturate(.75); }
.door.locked::after { content: "🔒"; position: absolute; top: .3rem; right: .4rem; font-size: .7rem; opacity: .7; }
.door.filled { background: #fffaf0; box-shadow: inset 0 0 0 2px #e8b955, 0 3px 0 #0004; }
.door.filled .door-num { opacity: .7; }
.door[data-n="24"].filled .door-num { opacity: 1; }
.door.filled[aria-disabled="true"] { cursor: not-allowed; }
.door.filled[aria-disabled="true"]:hover { transform: none; }
.door[data-n="24"].filled { background: #c9604a; }
.door.opened-empty .door-peek { filter: drop-shadow(0 0 6px #e8b955); }
.door.ready { box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 3px #e8b95560, 0 0 18px #e8b955a0; animation: glow 2.2s ease-in-out infinite; }
.door.opened { background: #fff; }
.door-peek { font-size: clamp(1.6rem, 5vw, 2.6rem); line-height: 1; }
.door-thumb { width: 78%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.door.opening { animation: swing .55s ease-in forwards; }

@keyframes glow { 50% { box-shadow: inset 0 0 0 3px var(--gold), 0 0 0 4px #e8b95590, 0 0 26px #e8b955d0; } }
@keyframes swing { to { transform: perspective(700px) rotateY(-80deg); } }

.gift-list { max-width: 640px; margin: 0 auto; }
.gift-list h2 { text-align: center; }
.gift-list ul { list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: .5rem; }
.gift-list li { display: flex; gap: .8rem; align-items: center; background: #ffffff0d; border: 1px solid #ffffff1c; border-radius: 12px; padding: .7rem 1rem; }
.door-badge { font-family: var(--serif); font-weight: 700; background: var(--paper); color: var(--red-dark); border-radius: 8px; min-width: 2.4rem; text-align: center; padding: .15rem .4rem; flex: none; }
.cal-foot { display: flex; flex-wrap: wrap; gap: .5rem 1.5rem; justify-content: center; align-items: center; margin-top: 2rem; }
.invite { max-width: 640px; margin: 0 auto; }

/* ---------- dialog ---------- */
dialog {
  border: 0; padding: 0; border-radius: 18px;
  width: min(560px, calc(100% - 1.5rem)); max-height: calc(100dvh - 2rem); overflow: auto;
  background: var(--cream); color: var(--ink); box-shadow: 0 30px 80px #000a;
}
dialog::backdrop { background: #0a1222cc; backdrop-filter: blur(3px); }
.dlg-inner { padding: 1.25rem 1.25rem 1.5rem; }
.dlg-head { display: flex; align-items: flex-start; gap: 1rem; margin-bottom: .75rem; }
.dlg-head > :first-child { flex: 1; }
.dlg-head h2 { outline: none; }
.dlg-close { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 0; background: #0000000f; font-size: 1.6rem; line-height: 1; cursor: pointer; color: var(--ink); }
.dlg-close:hover { background: #0000001c; }
.step-ind { font-size: .78rem; font-weight: 600; color: var(--muted); margin: 0 0 .2rem; text-transform: uppercase; letter-spacing: .08em; }
.progress { display: flex; gap: .35rem; margin-bottom: 1.1rem; }
.progress span { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.progress span.on { background: var(--red); }
.dlg-foot {
  display: flex; justify-content: space-between; gap: .75rem;
  position: sticky; bottom: -1.5rem; margin: 1.25rem -1.25rem -1.5rem; padding: .9rem 1.25rem 1.25rem;
  background: linear-gradient(180deg, #fbf5e900, var(--cream) 30%);
}

.type-grid { display: grid; gap: .75rem; }
.type-card {
  display: grid; grid-template-columns: auto 1fr; column-gap: 1rem; align-items: center;
  text-align: left; padding: 1rem 1.1rem; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; font: inherit; color: var(--ink);
}
.type-card:hover, .type-card.chosen { border-color: var(--red); }
.type-ico { grid-row: span 2; font-size: 2.1rem; }
.type-title { font-weight: 700; font-size: 1.1rem; }
.type-desc { color: var(--muted); font-size: .9rem; }

.sym-group h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 1rem 0 .4rem; }
.sym-group:first-child h3 { margin-top: 0; }
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: .4rem; }
.sym { font-size: 1.6rem; height: 52px; border: 2px solid transparent; border-radius: 12px; background: #fff; cursor: pointer; }
.sym:hover { border-color: var(--line); }
.sym[aria-pressed="true"] { border-color: var(--red); background: #fbe7e1; }

.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: .3rem;
  padding: 2.2rem 1rem; border: 2px dashed var(--line); border-radius: 14px;
  background: #fff; cursor: pointer; text-align: center; font-weight: 400;
}
.dropzone:hover, .dropzone.drag { border-color: var(--green); background: #eef5f1; }
.dropzone:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }
.dz-ico { font-size: 2.2rem; }
.photo-preview { margin: 0 0 .75rem; }
.photo-preview img { display: block; width: 100%; max-height: 320px; object-fit: contain; border-radius: 12px; background: #0000000d; }

.song-ok { color: var(--green); font-weight: 600; margin: 0 0 .5rem; }
.embed-consent { background: var(--paper); border-radius: 12px; padding: 1rem; text-align: center; }
.embed-title { font-weight: 600; }
.embed iframe { display: block; width: 100%; border: 0; border-radius: 12px; }
.embed-video { aspect-ratio: 16 / 9; }
.embed-video iframe { height: 100%; }

.door-picker { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
.door-pick { height: 44px; border: 2px solid var(--line); background: #fff; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); }
.door-pick:hover { border-color: var(--red); }
.door-pick[aria-pressed="true"] { background: var(--red); border-color: var(--red); color: #fff; }
.door-pick { position: relative; }
.door-pick.filled { background: #f3ead8; border-style: dashed; }
.door-pick:disabled { color: #9b9284; cursor: not-allowed; }
.door-pick:disabled:hover { border-color: var(--line); }
.pick-gift { position: absolute; top: -6px; right: -4px; font-size: .75rem; }
.pick-legend { margin: 0 0 .5rem; }
.gift-empty .gift-msg { font-size: 1.15rem; }
.star-glow { filter: drop-shadow(0 0 14px #e8b955); }

.success { text-align: center; padding: .5rem 0 1rem; }
.success-ico { font-size: 3.8rem; }
.success h2 { font-size: 2rem; outline: none; }

.gift-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 1.25rem; margin-bottom: 1rem; text-align: center; }
.gift-sym { font-size: 5rem; line-height: 1.1; }
.gift-photo { display: block; width: 100%; border-radius: 10px; }
.gift-msg { font-family: var(--serif); font-size: 1.25rem; margin: .9rem 0 .25rem; white-space: pre-line; }
.gift-from { color: var(--muted); margin: 0; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 1.25rem; z-index: 30;
  transform: translate(-50%, 200%); max-width: calc(100% - 2rem);
  background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: 12px;
  box-shadow: 0 10px 30px #0008; transition: transform .25s ease, opacity .25s ease, visibility .25s;
  opacity: 0; visibility: hidden;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
dialog a:not(.btn) { color: var(--red-dark); }

/* ---------- legal pages ---------- */
.legal { max-width: 680px; margin: 1.5rem auto; }
.legal h2 { font-size: 1.2rem; margin-top: 1.5rem; }
.legal-list { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 1rem 0; }
.legal-list dt { font-weight: 600; }
.legal-list dd { margin: 0; }
.missing { background: #fde7a8; color: #6b4b00; border-radius: 4px; padding: 0 .35rem; font-size: .9rem; }
@media (max-width: 520px) { .legal-list { grid-template-columns: 1fr; } .legal-list dd { margin-bottom: .5rem; } }

.legal h2 { scroll-margin-top: 1rem; }
.legal h2:focus { outline: none; }
.legal ul { padding-left: 1.2rem; }
.legal li { margin-bottom: .35rem; }
.toc { background: var(--paper); border-radius: 12px; padding: .9rem 1.1rem; margin: 1rem 0 1.5rem; }
.toc ol { margin: 0; padding-left: 1.3rem; columns: 2; column-gap: 2rem; }
.toc li { margin: 0 0 .25rem; break-inside: avoid; }
@media (max-width: 520px) { .toc ol { columns: 1; } }

/* ---------- save your calendar / own calendars ---------- */
.part-title { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; margin-top: 1.75rem; }
.part-no { display: inline-grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--red); color: #fff; font-family: var(--sans); font-size: .95rem; flex: none; }
.save-box.highlight { border: 2px solid var(--gold); background: #fff8e6; border-radius: 12px; padding: 1rem 1.1rem; margin: .75rem 0 1rem; }
.save-box.highlight h2 { font-size: 1.15rem; }
.save-steps { margin-top: .9rem; }
.save-now { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .75rem .9rem; margin: 0; }
.save-device { display: block; font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--green); margin-bottom: .2rem; }
.other-devices { margin-top: .75rem; }
.other-devices summary, details.save-box > summary { cursor: pointer; font-weight: 600; }
.other-devices ul { padding-left: 1.2rem; margin: .5rem 0 0; }
.other-devices li { margin-bottom: .4rem; }
details.save-box { max-width: 640px; margin: 0 auto 1rem; }
details.save-box > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; }
details.save-box > summary::-webkit-details-marker { display: none; }
details.save-box > summary::after { content: "▾"; font-size: 1.2rem; transition: transform .2s; }
details.save-box[open] > summary::after { transform: rotate(180deg); }
details.save-box > summary h2 { margin: 0; font-size: 1.3rem; }
details.save-box[open] > summary { margin-bottom: .75rem; }
kbd { font-family: var(--sans); font-size: .85em; background: #fff; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 .35em; }
.my-cals { max-width: 460px; margin: 1.25rem auto 0; text-align: center; }
.my-cals h2 { font-size: 1.2rem; }
.my-cals ul { list-style: none; padding: 0; margin: .75rem 0 0; display: grid; gap: .5rem; }
.my-cals .btn { width: 100%; }

/* ---------- states of the connected app ---------- */
.save-box.highlight { color: var(--ink); }
.form-alert { scroll-margin-bottom: 7rem; }
.demo-bar[hidden], .offline-bar[hidden] { display: none; }
.offline-bar { background: var(--paper); color: var(--ink); text-align: center; padding: .5rem 1rem; font-weight: 500; }
textarea[aria-invalid="true"] { border-color: var(--red); }
.form-alert { background: var(--paper); color: var(--red-dark); border-left: 4px solid var(--red); border-radius: 8px; padding: .75rem 1rem; font-weight: 500; }
.appeal { display: block; color: var(--muted); font-weight: 400; }
.btn[aria-disabled="true"] { opacity: .75; cursor: progress; }
.door.skeleton { background: var(--paper); opacity: .35; cursor: default; }
.photo-slot.loading { aspect-ratio: 4 / 3; background: var(--paper); border-radius: 12px; }
.gift-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .5rem; }
.link.quiet { color: var(--muted); font-size: .9rem; min-height: 44px; min-width: 44px; }
