/* Multi-template invitation library */
.template-sheet-open { overflow: hidden; }
.template-launcher {
  position: fixed;
  right: 18px;
  bottom: calc(214px + env(safe-area-inset-bottom));
  z-index: 61;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 46px;
  border: 1px solid rgba(255, 253, 248, 0.5);
  border-radius: 999px;
  padding: 6px 15px 6px 7px;
  color: var(--pearl);
  background: rgba(111, 35, 51, 0.9);
  box-shadow: 0 16px 38px rgba(72, 38, 31, 0.24);
  backdrop-filter: blur(12px);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 800;
}

.template-launcher:hover { background: var(--gold); transform: translateY(-3px); }
.template-launcher__icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--burgundy);
  background: var(--pearl);
  font-size: 1rem;
}

.template-sheet {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: max(18px, env(safe-area-inset-top)) 18px max(18px, env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 240ms ease, visibility 240ms ease;
}
.template-sheet.is-open { opacity: 1; visibility: visible; pointer-events: auto; }
.template-sheet__backdrop { position: absolute; inset: 0; background: rgba(36, 16, 23, 0.62); backdrop-filter: blur(16px); }
.template-sheet__panel {
  position: relative;
  width: min(1120px, 100%);
  max-height: min(860px, calc(100dvh - 36px));
  overflow: auto;
  border: 1px solid rgba(199, 155, 85, 0.34);
  border-radius: 30px;
  padding: clamp(24px, 4vw, 46px);
  color: var(--ink);
  background: radial-gradient(circle at 88% 0%, rgba(242, 214, 209, 0.5), transparent 28%), linear-gradient(145deg, rgba(255, 253, 248, 0.98), rgba(251, 246, 237, 0.98));
  box-shadow: 0 42px 130px rgba(26, 10, 16, 0.4);
  transform: translateY(18px) scale(0.98);
  transition: transform 300ms cubic-bezier(0.23, 1, 0.32, 1);
}
.template-sheet.is-open .template-sheet__panel { transform: translateY(0) scale(1); }
.template-sheet__handle { display: none; width: 44px; height: 4px; margin: 0 auto 20px; border-radius: 999px; background: rgba(111, 35, 51, 0.22); }
.template-sheet__header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.template-sheet__header h2 { max-width: 660px; margin: 0; color: var(--burgundy); font-family: "Playfair Display", serif; font-size: clamp(2rem, 5vw, 4rem); line-height: 0.98; }
.template-sheet__intro { max-width: 640px; margin: 14px 0 0; color: var(--muted); line-height: 1.7; }
.template-sheet__close {
  display: grid; flex: 0 0 auto; place-items: center; width: 42px; height: 42px;
  border: 1px solid rgba(111, 35, 51, 0.16); border-radius: 50%; color: var(--burgundy);
  background: rgba(255, 255, 255, 0.62); cursor: pointer; font-size: 1.45rem;
}
.template-sheet__close:hover { color: var(--pearl); background: var(--burgundy); transform: rotate(6deg); }
.template-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.template-card {
  position: relative; display: grid; gap: 13px; min-width: 0; border: 1px solid rgba(111, 35, 51, 0.13);
  border-radius: 22px; padding: 10px; color: var(--ink); background: rgba(255, 255, 255, 0.64);
  cursor: pointer; text-align: left;
}
.template-card:hover { border-color: rgba(199, 155, 85, 0.74); box-shadow: 0 18px 44px rgba(72, 38, 31, 0.12); transform: translateY(-4px); }
.template-card.is-active { border-color: var(--burgundy); box-shadow: 0 0 0 3px rgba(111, 35, 51, 0.1), 0 18px 44px rgba(72, 38, 31, 0.14); }
.template-card__preview { position: relative; display: grid; place-items: center; min-height: 188px; overflow: hidden; border-radius: 16px; background: var(--preview-bg); isolation: isolate; }
.template-card__preview::before { content: ""; position: absolute; inset: 14px; border: 1px solid var(--preview-line); border-radius: 10px; }
.template-card__preview::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 70% 14%, var(--preview-glow), transparent 28%); }
.template-card__visual-orb { position: absolute; right: -28px; bottom: -36px; width: 122px; aspect-ratio: 1; border-radius: 50%; background: var(--preview-orb); opacity: 0.56; }
.template-card__visual-title { position: relative; z-index: 2; color: var(--preview-title); font-family: "Allura", cursive; font-size: clamp(2.5rem, 5vw, 4.1rem); line-height: 0.9; text-shadow: 0 8px 24px var(--preview-shadow); }
.template-card__visual-line { position: absolute; z-index: 2; width: 54%; height: 1px; bottom: 28px; background: var(--preview-line); }
.template-card__visual-chip { position: absolute; z-index: 2; top: 22px; left: 24px; color: var(--preview-accent); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; }
.template-card__info { min-width: 0; padding: 0 5px 5px; }
.template-card__name { display: block; color: var(--burgundy); font-family: "Playfair Display", serif; font-size: 1.08rem; line-height: 1.15; }
.template-card__description { display: block; min-height: 2.7em; margin-top: 5px; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.template-card__check { position: absolute; top: 18px; right: 18px; display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(255, 253, 248, 0.6); border-radius: 50%; color: var(--pearl); background: var(--burgundy); box-shadow: 0 6px 16px rgba(36, 16, 23, 0.16); font-size: 0.8rem; opacity: 0; transform: scale(0.8); }
.template-card.is-active .template-card__check { opacity: 1; transform: scale(1); }
.template-sheet__footer { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 24px; padding-top: 18px; border-top: 1px solid rgba(111, 35, 51, 0.12); color: var(--muted); font-size: 0.86rem; font-weight: 700; }
.template-sheet__done { min-height: 44px; border: 0; border-radius: 999px; padding: 0 20px; color: var(--pearl); background: var(--burgundy); cursor: pointer; font-weight: 800; }
.template-sheet__done:hover { background: var(--gold); transform: translateY(-2px); }

.template-card[data-template="editorial"] .template-card__preview { --preview-bg: linear-gradient(145deg, #fffdf8, #f2d6d1); --preview-title: #6f2333; --preview-accent: #a97832; --preview-line: rgba(111,35,51,.26); --preview-glow: rgba(255,226,190,.9); --preview-orb: #d49c9c; --preview-shadow: rgba(111,35,51,.12); }
.template-card[data-template="midnight"] .template-card__preview { --preview-bg: linear-gradient(145deg, #171927, #3a2949); --preview-title: #f5d9b3; --preview-accent: #dcb36c; --preview-line: rgba(245,217,179,.3); --preview-glow: rgba(100,82,147,.72); --preview-orb: #8065a5; --preview-shadow: rgba(8,7,16,.42); }
.template-card[data-template="garden"] .template-card__preview { --preview-bg: linear-gradient(145deg, #f5f7ed, #d9e5d2); --preview-title: #456355; --preview-accent: #849a72; --preview-line: rgba(69,99,85,.28); --preview-glow: rgba(255,215,209,.7); --preview-orb: #b3c9a7; --preview-shadow: rgba(69,99,85,.1); }
.template-card[data-template="mono"] .template-card__preview { --preview-bg: linear-gradient(145deg, #f5f4ee, #bcbdb7); --preview-title: #1b1b1a; --preview-accent: #555650; --preview-line: rgba(27,27,26,.28); --preview-glow: rgba(255,255,255,.78); --preview-orb: #80817c; --preview-shadow: rgba(27,27,26,.1); }
.template-card[data-template="terracotta"] .template-card__preview { --preview-bg: linear-gradient(145deg, #ffe5d1, #ba684c); --preview-title: #fff9ef; --preview-accent: #ffe0b4; --preview-line: rgba(255,249,239,.48); --preview-glow: rgba(255,206,140,.82); --preview-orb: #e99a6a; --preview-shadow: rgba(94,39,35,.2); }
.template-card[data-template="sakura"] .template-card__preview { --preview-bg: linear-gradient(145deg, #fffdfd, #f6dbe4); --preview-title: #8d4c61; --preview-accent: #b58280; --preview-line: rgba(141,76,97,.24); --preview-glow: rgba(255,255,255,.9); --preview-orb: #e9b9c9; --preview-shadow: rgba(141,76,97,.1); }

body[data-template="midnight"] { --ivory:#131521; --pearl:#202132; --champagne:#dcb36c; --gold:#c99b58; --blush:#5a425e; --rose:#d987a0; --burgundy:#f1d5ae; --ink:#f4eadf; --muted:#c1b5bd; background:#131521; }
body[data-template="garden"] { --ivory:#f1f5ec; --pearl:#fcfdf6; --champagne:#b39a5f; --gold:#7e936c; --blush:#e9c9c3; --rose:#c98998; --burgundy:#456355; --ink:#27362f; --muted:#63736a; }
body[data-template="mono"] { --ivory:#ecebe5; --pearl:#f8f7f2; --champagne:#8f9088; --gold:#565751; --blush:#d7d7d0; --rose:#7e7f78; --burgundy:#1b1b1a; --ink:#1c1c1a; --muted:#686862; }
body[data-template="terracotta"] { --ivory:#fff1e5; --pearl:#fffaf1; --champagne:#d5a461; --gold:#b06a39; --blush:#ffd6c0; --rose:#dc8264; --burgundy:#9b443b; --ink:#3e2a27; --muted:#856e65; }
body[data-template="sakura"] { --ivory:#fff7f8; --pearl:#fffdfd; --champagne:#caa477; --gold:#a47b62; --blush:#f7dce3; --rose:#d79aac; --burgundy:#8d4c61; --ink:#3c2b30; --muted:#89747d; }

body[data-template="midnight"] .gate { background: linear-gradient(135deg, rgba(10,9,20,.84), rgba(51,31,68,.6)), url("assets/photos/hero.jpg") center/cover; }
body[data-template="midnight"] .gate__panel, body[data-template="midnight"] .music-prompt__panel, body[data-template="midnight"] .template-sheet__panel { color:var(--ink); background:linear-gradient(145deg,rgba(31,30,48,.98),rgba(24,25,39,.98)); border-color:rgba(220,179,108,.38); }
body[data-template="midnight"] .section-nav { background:rgba(19,21,33,.88); border-color:rgba(220,179,108,.22); }
body[data-template="midnight"] .section-nav a, body[data-template="midnight"] .template-sheet__header h2, body[data-template="midnight"] .template-card__name { color:var(--burgundy) !important; }
body[data-template="midnight"] .opening-invitation { color:var(--ink); background:radial-gradient(circle at 90% 18%,rgba(102,74,134,.42),transparent 30%),linear-gradient(180deg,#1a1b2b,#28243a 55%,#151922); }
body[data-template="midnight"] .opening__title, body[data-template="midnight"] .opening__invite, body[data-template="midnight"] .opening__hint, body[data-template="midnight"] .opening__phrase { color:var(--burgundy); }
body[data-template="midnight"] .section-band, body[data-template="midnight"] .section-band--light, body[data-template="midnight"] .event-details, body[data-template="midnight"] .gift-support, body[data-template="midnight"] .editorial-album { color:var(--ink); background:linear-gradient(145deg,#171825,#242338); }
body[data-template="midnight"] .section-band--deep, body[data-template="midnight"] .showcase { background:linear-gradient(145deg,#0d0d17,#292039 58%,#12131d); }
body[data-template="midnight"] .event-card, body[data-template="midnight"] .gift-support__intro, body[data-template="midnight"] .gift-support__panel, body[data-template="midnight"] .person, body[data-template="midnight"] .invite__card, body[data-template="midnight"] .quote-shell, body[data-template="midnight"] .wedding-qr-card { border-color:rgba(241,213,174,.18); background:rgba(32,33,50,.78); box-shadow:0 28px 80px rgba(0,0,0,.22); }
body[data-template="midnight"] .hero__veil { background:linear-gradient(180deg,rgba(15,14,28,.12),rgba(20,15,31,.66)),linear-gradient(90deg,rgba(20,15,31,.24),rgba(20,15,31,.62)); }
body[data-template="midnight"] .closing { background:linear-gradient(rgba(15,9,22,.68),rgba(15,9,22,.9)),url("assets/photos/closing.jpg") center/cover; }

body[data-template="garden"] .opening-invitation { background:radial-gradient(circle at 10% 12%,rgba(255,222,202,.42),transparent 24%),radial-gradient(circle at 88% 36%,rgba(192,216,185,.5),transparent 28%),linear-gradient(180deg,#fcfdf7,#f0f5ea); }
body[data-template="garden"] .section-band, body[data-template="garden"] .section-band--light, body[data-template="garden"] .event-details, body[data-template="garden"] .gift-support, body[data-template="garden"] .editorial-album { background:linear-gradient(145deg,#fcfdf7,#edf4e9); }
body[data-template="garden"] .section-band--deep, body[data-template="garden"] .showcase { background:linear-gradient(145deg,#304c40,#55725a 60%,#23392f); }
body[data-template="garden"] .hero__veil { background:linear-gradient(180deg,rgba(238,246,231,.12),rgba(69,99,85,.34)),linear-gradient(90deg,rgba(255,253,248,.2),rgba(233,244,226,.45)); }

body[data-template="mono"] .opening-invitation, body[data-template="mono"] .section-band, body[data-template="mono"] .section-band--light, body[data-template="mono"] .event-details, body[data-template="mono"] .gift-support, body[data-template="mono"] .editorial-album { background:linear-gradient(145deg,#f8f7f2,#deded8); }
body[data-template="mono"] .section-band--deep, body[data-template="mono"] .showcase { background:linear-gradient(145deg,#171716,#4e4f4a 60%,#20201e); }
body[data-template="mono"] .hero__veil { background:linear-gradient(180deg,rgba(248,247,242,.12),rgba(20,20,18,.34)),linear-gradient(90deg,rgba(248,247,242,.18),rgba(248,247,242,.5)); }

body[data-template="terracotta"] .opening-invitation { background:radial-gradient(circle at 10% 16%,rgba(255,204,148,.44),transparent 25%),radial-gradient(circle at 90% 32%,rgba(255,181,159,.48),transparent 26%),linear-gradient(180deg,#fffaf1,#fff0e4); }
body[data-template="terracotta"] .section-band, body[data-template="terracotta"] .section-band--light, body[data-template="terracotta"] .event-details, body[data-template="terracotta"] .gift-support, body[data-template="terracotta"] .editorial-album { background:linear-gradient(145deg,#fffaf1,#ffe8d6); }
body[data-template="terracotta"] .section-band--deep, body[data-template="terracotta"] .showcase { background:linear-gradient(145deg,#71362f,#a95243 60%,#432423); }
body[data-template="terracotta"] .hero__veil { background:linear-gradient(180deg,rgba(255,241,229,.14),rgba(155,68,59,.36)),linear-gradient(90deg,rgba(255,243,228,.18),rgba(255,228,205,.52)); }

body[data-template="sakura"] .opening-invitation { background:radial-gradient(circle at 10% 14%,rgba(255,227,234,.5),transparent 24%),radial-gradient(circle at 88% 28%,rgba(255,248,239,.9),transparent 28%),linear-gradient(180deg,#fffdfd,#fff1f5); }
body[data-template="sakura"] .section-band, body[data-template="sakura"] .section-band--light, body[data-template="sakura"] .event-details, body[data-template="sakura"] .gift-support, body[data-template="sakura"] .editorial-album { background:linear-gradient(145deg,#fffdfd,#fff0f4); }
body[data-template="sakura"] .section-band--deep, body[data-template="sakura"] .showcase { background:linear-gradient(145deg,#713b50,#a45e75 60%,#48283a); }
body[data-template="sakura"] .hero__veil { background:linear-gradient(180deg,rgba(255,253,253,.14),rgba(141,76,97,.3)),linear-gradient(90deg,rgba(255,253,253,.22),rgba(255,238,245,.48)); }

@media (max-width: 820px) {
  .template-launcher { right: 10px; bottom: calc(172px + env(safe-area-inset-bottom)); min-height: 42px; padding-right: 12px; }
  .template-launcher__icon { width: 29px; height: 29px; }
  .template-launcher__label { font-size: 0.74rem; }
  .template-sheet { place-items: end center; padding: 0; }
  .template-sheet__panel { width: 100%; max-height: min(760px, calc(100dvh - 16px)); border-radius: 28px 28px 0 0; padding: 18px 16px max(18px, env(safe-area-inset-bottom)); transform: translateY(24px); }
  .template-sheet__handle { display: block; }
  .template-sheet__header { margin-bottom: 20px; }
  .template-sheet__header h2 { font-size: clamp(1.8rem, 8vw, 2.8rem); }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .template-card { border-radius: 16px; padding: 7px; }
  .template-card__preview { min-height: 128px; border-radius: 11px; }
  .template-card__visual-title { font-size: 2.7rem; }
  .template-card__description { min-height: 3.4em; font-size: 0.72rem; }
  .template-card__name { font-size: 0.92rem; }
  .template-card__check { top: 12px; right: 12px; width: 24px; height: 24px; }
  .template-sheet__footer { align-items: stretch; flex-direction: column; gap: 10px; }
  .template-sheet__done { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .template-sheet__panel, .template-card, .template-launcher, .template-sheet__close, .template-sheet__done { transition: none; }
}
