:root {
  --cream: #F4EFE5;
  --paper: #FFFDF8;
  --sage: #8A9A7B;
  --sage-d: #5C6B51;
  --sage-l: #E3E8DB;
  --ink: #34362F;
  --muted: #7C7D73;
  --gold: #B8A378;
  --line: #E7E0D2;
  --serif: "Playfair Display", Georgia, serif;
  --sans: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  --script: "Dancing Script", cursive;
  --vh: 100vh;
}
@supports (height: 100svh) { :root { --vh: 100svh; } }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font: 300 16px/1.7 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; height: 100%; }
img { display: block; max-width: 100%; }
p { margin: 0; }
h1, h2 { margin: 0; font-weight: 400; }
[hidden] { display: none !important; }

.page {
  max-width: 520px;
  margin: 0 auto;
  background: var(--paper);
  overflow: hidden;
}
@media (min-width: 560px) { .page { box-shadow: 0 0 60px rgba(60, 60, 40, .08); } }

/* ---------- Phong bì ---------- */
/* Mẫu mặc định (classic). Các mẫu khác chỉ đổi biến màu, xem cuối phần này. */
.env-screen {
  --scr-bg: radial-gradient(circle at 50% 40%, rgba(255,255,255,.18), transparent 60%), var(--sage);
  --e-back: #E6DCCA; --e-pocket: #F2EBDD; --e-flap: #EAE1CF; --e-letter: var(--paper);
  --e-name: var(--sage-d); --e-shadow: rgba(30, 40, 25, .25);
  --seal-bg: radial-gradient(circle at 35% 30%, #A3B294, var(--sage-d)); --seal-ink: #F7F3EA;
  --to-ink: #fff;
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--scr-bg);
  overflow: hidden;
  cursor: pointer;
  transition: opacity .7s ease, visibility .7s;
  outline: none;
}
.env-screen.is-done { opacity: 0; visibility: hidden; }
.env-stage { position: relative; z-index: 1; text-align: center; color: var(--to-ink); padding: 0 16px; }
.env {
  position: relative;
  width: min(84vw, 340px);
  aspect-ratio: 1.45;
  margin: 0 auto 28px;
  perspective: 900px;
  filter: drop-shadow(0 18px 24px var(--e-shadow));
}
@supports not (aspect-ratio: 1) { .env { height: calc(min(84vw, 340px) / 1.45); } }
.env > div { position: absolute; inset: 0; }
.env-back { background: var(--e-back); border-radius: 6px; }
.env-letter {
  inset: 8px 14px auto 14px !important;
  height: 86%;
  background: var(--e-letter);
  border-radius: 4px;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 18px;
  color: var(--ink);
  z-index: 2;
  transition: transform 1s cubic-bezier(.2, .7, .2, 1);
}
.letter-small { font-size: 10px; letter-spacing: .25em; text-transform: uppercase; color: var(--e-name); }
.letter-names { font: 700 26px/1.3 var(--script); color: var(--e-name); margin-top: 4px; }
.env-pocket {
  background: var(--e-pocket);
  clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%);
  border-radius: 6px;
  z-index: 3;
}
.env-flap {
  background: var(--e-flap);
  clip-path: polygon(0 0, 100% 0, 50% 60%);
  transform-origin: top center;
  z-index: 4;
  transition: transform .6s ease-in, z-index 0s .3s;
  backface-visibility: visible;
}
.env-seal {
  inset: auto !important;
  left: 50% !important; top: 60% !important;
  width: 54px; height: 54px; margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: var(--seal-bg);
  color: var(--seal-ink);
  display: flex; align-items: center; justify-content: center; gap: 1px;
  font: 400 15px/1 var(--serif);
  box-shadow: 0 2px 6px rgba(0,0,0,.25), inset 0 0 0 3px rgba(255,255,255,.15);
  z-index: 5;
  transition: opacity .3s, transform .3s;
}
.env-seal i { font-size: 11px; opacity: .85; }
.env-to { font-size: 15px; opacity: .92; }
.env-to strong { display: block; font: 700 34px/1.3 var(--script); margin-top: 2px; }
.env-hint {
  margin-top: 18px; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; opacity: .85;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

.env-screen.is-opening .env-flap { transform: rotateX(180deg); z-index: 1; }
.env-screen.is-opening .env-seal { opacity: 0; transform: scale(.6); }
.env-screen.is-opening .env-hint { visibility: hidden; }
.env-screen.is-letter .env-letter { transform: translateY(-58%); }
.env-deco { display: none; position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Mẫu: floral — hoa màu nước xanh, chữ vàng */
.env--floral {
  --scr-bg: radial-gradient(ellipse at 50% 45%, #FFFFFF 0%, #F1F5FB 55%, #DCE6F4 100%);
  --e-back: #EFE9DF; --e-pocket: #FBF8F2; --e-flap: #F3EEE5; --e-letter: #FFFEFB;
  --e-name: #A9822F; --e-shadow: rgba(70, 90, 130, .22);
  --seal-bg: radial-gradient(circle at 35% 30%, #F1DE9C, #B88F3E 70%, #8E6A28); --seal-ink: #FFF9E8;
  --to-ink: #8C6A2A;
}
.env--floral .env-deco { display: block; }
.env--floral .env-hint { color: #6F86A8; }

/* Mẫu: red — phong bì đỏ truyền thống, dấu 囍 vàng */
.env--red {
  --scr-bg: radial-gradient(circle at 50% 40%, #9E2A2B, #6E1416 75%);
  --e-back: #8E1B1F; --e-pocket: #B42529; --e-flap: #C6332F; --e-letter: #FFF8EC;
  --e-name: #A11F24; --e-shadow: rgba(40, 0, 0, .4);
  --seal-bg: radial-gradient(circle at 35% 30%, #F6E3A1, #C99A3B 70%, #9C7224); --seal-ink: #A11F24;
  --to-ink: #F5DFA6;
}
.env--red .env-seal span, .env--red .env-seal i { display: none; }
.env--red .env-seal::after { content: "囍"; font: 700 26px/1 "Noto Serif SC", "PingFang SC", "Microsoft YaHei", serif; }

/* Mẫu: kraft — giấy kraft nâu, dây buộc */
.env--kraft {
  --scr-bg: radial-gradient(circle at 50% 40%, #F7F2E9, #E7DDCC 80%);
  --e-back: #A98258; --e-pocket: #C9A57A; --e-flap: #BC9568; --e-letter: #FFFDF7;
  --e-name: #6B4F33; --e-shadow: rgba(80, 55, 30, .28);
  --seal-bg: radial-gradient(circle at 35% 30%, #FFFDF6, #EFE6D3); --seal-ink: #6B4F33;
  --to-ink: #5A4632;
}
.env--kraft .env::after {
  content: ""; position: absolute; z-index: 4; top: 0; bottom: 0; left: 50%; width: 2px; margin-left: -1px;
  background: repeating-linear-gradient(to bottom, #EFE3CC 0 4px, #D9C7A6 4px 7px);
  transition: opacity .3s;
}
.env--kraft.is-opening .env::after { opacity: 0; }
.env--kraft .env-hint { color: #8A7357; }

/* ---------- Bìa ---------- */
.hero {
  position: relative;
  height: var(--vh); min-height: 520px;
  background: linear-gradient(160deg, #B8C3AC, #7D8C70);
  color: #fff;
  display: flex; align-items: flex-end; justify-content: center;
  text-align: center;
}
.hero-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,0) 45%, rgba(25,30,20,.55));
}
.hero-text { position: relative; z-index: 1; padding: 0 16px 15vh; }
.hero-names { font: 700 clamp(44px, 13vw, 60px)/1.15 var(--script); text-shadow: 0 2px 16px rgba(0,0,0,.25); }
.hero-names span { white-space: nowrap; }
.hero-names em { font-style: normal; font-size: .6em; vertical-align: middle; opacity: .9; }
.hero-date { margin-top: 10px; font: 400 17px var(--serif); letter-spacing: .3em; }
.scroll-cue {
  position: absolute; z-index: 1; bottom: 28px; left: 50%;
  width: 1px; height: 36px; background: rgba(255,255,255,.7);
  animation: cue 2s ease-in-out infinite;
}
@keyframes cue { 0% { transform: scaleY(0); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } 51% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* ---------- Khối chung ---------- */
.sec { padding: 72px 24px; text-align: center; }
.sec + .sec { border-top: 1px solid var(--line); }
.eyebrow { font-size: 11px; letter-spacing: .32em; text-transform: uppercase; color: var(--sage); font-weight: 500; }
.eyebrow.light { color: rgba(255,255,255,.9); }
h2 { font: 400 30px/1.3 var(--serif); margin: 6px 0 28px; }
.sprig { width: 120px; height: 24px; color: var(--sage); margin: 28px auto 0; display: block; }
.script-name { font: 700 32px/1.35 var(--script); color: var(--sage-d); }

/* Lời mời */
.invite { background: var(--paper); }
.invite-line { font: 400 20px/1.6 var(--serif); margin: 18px auto 14px; max-width: 26em; }
.invite-line .guest { display: block; font: 700 40px/1.3 var(--script); color: var(--sage-d); margin: 6px 0; }
.invite-sub { color: var(--muted); font-size: 15px; }

/* Cặp đôi + ngày */
.couple { background: var(--cream); }
.names-grid { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }
.role { font-size: 11px; letter-spacing: .25em; text-transform: uppercase; color: var(--muted); }
.full-name { font-size: 13px; color: var(--muted); margin-top: 2px; }
.amp { font: italic 400 30px var(--serif); color: var(--gold); }

.date-block {
  margin: 48px auto 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px;
  max-width: 340px;
}
.db-side {
  border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold);
  padding: 8px 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase;
}
.db-day { font: 400 64px/1 var(--serif); color: var(--sage-d); }
.db-year { margin-top: 10px; font: 400 18px var(--serif); letter-spacing: .4em; }
.db-lunar { margin-top: 6px; font-size: 13px; color: var(--muted); font-style: italic; }

.countdown { display: flex; justify-content: center; gap: 10px; margin-top: 36px; }
.countdown div {
  width: 68px; padding: 10px 0 8px;
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
}
.countdown b { display: block; font: 400 26px/1.1 var(--serif); color: var(--sage-d); font-variant-numeric: tabular-nums; }
.countdown span { font-size: 10px; letter-spacing: .15em; text-transform: uppercase; color: var(--muted); }
.cd-done { margin-top: 28px; font: 700 26px var(--script); color: var(--sage-d); }

/* Sự kiện */
.event {
  background: var(--cream); border-radius: 14px; padding: 28px 20px;
  border: 1px solid var(--line);
}
.event + .event { margin-top: 18px; }
.event h3 { margin: 0 0 6px; font: 400 22px var(--serif); color: var(--sage-d); }
.event-time { font-weight: 500; letter-spacing: .04em; }
.event-place { margin-top: 12px; font-weight: 500; }
.event-addr { color: var(--muted); font-size: 14px; }
.event-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 20px; }
.event-alt { display: block; margin-top: 10px; font-size: 13px; color: var(--sage-d); }

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 22px;
  border-radius: 999px; border: 1px solid var(--sage-d);
  background: var(--sage-d); color: #fff;
  font: 500 14px var(--sans); letter-spacing: .04em; text-decoration: none;
  cursor: pointer; transition: background .2s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-ghost { background: transparent; color: var(--sage-d); }
.btn[disabled] { opacity: .6; cursor: default; }

/* Album */
.gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.gallery figure { margin: 0; overflow: hidden; border-radius: 8px; background: var(--sage-l); aspect-ratio: 3 / 4; cursor: zoom-in; }
.gallery figure:first-child { grid-column: span 2; aspect-ratio: 4 / 3; }
.gallery img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s ease; }
.gallery figure:active img { transform: scale(1.03); }

.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(20, 22, 18, .94);
  display: flex; align-items: center; justify-content: center;
  touch-action: pan-y;
}
.lightbox img { max-width: 100%; max-height: 86vh; object-fit: contain; user-select: none; }
.lightbox button { position: absolute; background: none; border: 0; color: #fff; cursor: pointer; }
.lb-close { top: max(10px, env(safe-area-inset-top)); right: 10px; font-size: 38px; line-height: 1; padding: 6px 14px; }
.lb-nav { top: 50%; transform: translateY(-50%); font-size: 44px; padding: 20px 12px; opacity: .8; }
.lb-prev { left: 0; } .lb-next { right: 0; }
.lb-count { position: absolute; bottom: max(16px, env(safe-area-inset-bottom)); color: rgba(255,255,255,.7); font-size: 13px; letter-spacing: .1em; }

/* RSVP */
.rsvp { background: var(--cream); }
.rsvp-note { color: var(--muted); margin: -12px 0 28px; font-size: 15px; }
.form { text-align: left; max-width: 400px; margin: 0 auto; }
.field { display: block; margin-bottom: 22px; }
.field > span { display: block; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px;
  font: 400 16px/1.4 var(--sans); color: var(--ink); /* 16px: tránh iOS tự zoom */
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px;
  -webkit-appearance: none; appearance: none;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 50%, calc(100% - 15px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--sage-l); border-color: var(--sage); }
.seg { display: grid; gap: 8px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span {
  display: block; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); cursor: pointer; transition: all .2s;
}
.seg input:checked + span { border-color: var(--sage-d); background: var(--sage-l); color: var(--sage-d); font-weight: 500; }
.seg input:focus-visible + span { outline: 2px solid var(--sage); }
.form .btn { width: 100%; margin-top: 4px; }
.form-msg { margin-top: 12px; text-align: center; font-size: 14px; color: var(--sage-d); min-height: 1.4em; }
.form-msg.err { color: #A0524A; }
.rsvp-done p + p { margin: 8px 0 20px; color: var(--muted); }

/* Mừng cưới */
.gift-list { display: grid; gap: 18px; margin-top: 28px; }
.gift-card { background: var(--cream); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.gift-card img { width: 200px; height: 200px; object-fit: contain; margin: 12px auto; background: #fff; border-radius: 8px; }
.gift-card .acc { font: 500 18px var(--serif); letter-spacing: .05em; }
.gift-card small { display: block; color: var(--muted); }
.copy { margin-top: 10px; background: none; border: 0; color: var(--sage-d); text-decoration: underline; font: inherit; font-size: 13px; cursor: pointer; }

/* Footer */
.footer { padding-bottom: 96px; }
.footer .sprig { margin: 0 auto 22px; }
.footer-line { font: italic 400 18px/1.6 var(--serif); color: var(--muted); margin-bottom: 10px; }

/* Nút nhạc */
.music-btn {
  position: fixed; z-index: 40;
  right: 16px; bottom: max(16px, env(safe-area-inset-bottom));
  width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.6);
  background: rgba(92, 107, 81, .88); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0,0,0,.18);
  cursor: pointer;
}
.music-btn svg { width: 20px; height: 20px; }
.music-btn.playing svg { animation: spin 4s linear infinite; }
.music-btn:not(.playing)::after {
  content: ""; position: absolute; width: 26px; height: 1.5px; background: #fff; transform: rotate(-45deg);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Hiệu ứng khi cuộn */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .9s ease, transform .9s ease; }
.reveal.in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .reveal { transform: none; transition: opacity .3s; }
  .env-hint, .scroll-cue, .music-btn.playing svg { animation: none; }
}
