@font-face { font-family: "EnvSerif"; src: url(/assets/env/serif.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "EnvSerif2"; src: url(/assets/env/serif2.woff2) format("woff2"); font-display: swap; }

:root {
  --colw: min(100vw, 450px);
  --accent: #790b0b;
  --page-bg: #fafafa;
  --ui-font: "Noto Sans", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: #e9e6e2;
  color: #18181b;
  font-family: var(--ui-font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.locked { overflow: hidden; height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* Nền mờ khi xem trên máy tính */
#bgBlur {
  position: fixed; inset: -40px; z-index: 0;
  background-size: cover; background-position: center;
  filter: blur(36px) saturate(1.05) brightness(.92);
  transform: scale(1.05);
}
#bgBlur::after { content: ""; position: absolute; inset: 0; background: rgba(245, 240, 236, .55); }

.col {
  position: relative; z-index: 1;
  width: var(--colw); margin: 0 auto; min-height: 100dvh;
  background: var(--page-bg);
  box-shadow: 0 0 60px rgba(0, 0, 0, .18);
}
.card { overflow: hidden; width: 100%; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
.card-inner { width: 430px; position: relative; overflow: hidden; }

/* ---------- phần tử dạng canvas ---------- */
.sec { position: relative; width: 430px; }
.el { position: absolute; }
.ea, .el-c { width: 100%; height: 100%; }
.el-text .ea, .el-text .el-c { height: auto; }
.el-text .el-c { white-space: pre-line; overflow-wrap: break-word; }
.el-img img { width: 100%; height: 100%; display: block; object-fit: cover; user-select: none; -webkit-user-drag: none; }
.el-img.contain img { object-fit: contain; }
.el-img.mask-arch .el-c { -webkit-mask: url(/assets/tpl/mask-arch.png) center / 100% 100% no-repeat; mask: url(/assets/tpl/mask-arch.png) center / 100% 100% no-repeat; }
.el-img.shadow .el-c { box-shadow: 0 0 10px rgba(0, 0, 0, .5); }
.el-img.mask-arch.shadow .el-c { box-shadow: none; }
.el-img.mask-arch.shadow .ea { filter: drop-shadow(0 0 6px rgba(0, 0, 0, .35)); }
.el-shape svg { width: 100%; height: 100%; display: block; }
.clickable { cursor: pointer; }

/* Hiệu ứng khi cuộn tới */
.ea { transition-property: opacity, transform; transition-timing-function: cubic-bezier(.22, .61, .36, 1); will-change: opacity, transform; }
.ea.pre { opacity: 0; }
.ea.pre.slide-up { transform: translateY(40px); }
.ea.pre.slide-down { transform: translateY(-40px); }
.ea.pre.slide-left { transform: translateX(50px); }
.ea.pre.slide-right { transform: translateX(-50px); }
.ea.pre.zoom-in { transform: scale(.85); }
.ea.pre.in { opacity: 1; transform: none; }

/* Hiệu ứng lặp */
.loop-wiggle { animation: wiggle 2s ease-in-out infinite; }
.loop-pulse { animation: pulse 2s ease-in-out infinite; }
.loop-rotate { animation: spin 12s linear infinite; }
.loop-wobble { animation: wobble 2s ease-in-out infinite; }
.loop-float { animation: float 3s ease-in-out infinite; }
@keyframes wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-6deg); } 75% { transform: rotate(6deg); } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes wobble { 0%, 100% { transform: translateX(0) rotate(0); } 15% { transform: translateX(-6%) rotate(-5deg); } 30% { transform: translateX(5%) rotate(3deg); } 45% { transform: translateX(-4%) rotate(-3deg); } 60% { transform: translateX(3%) rotate(2deg); } 75% { transform: translateX(-1%) rotate(-1deg); } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

/* Lịch */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); grid-auto-rows: 1fr; height: 100%; align-items: center; justify-items: center; font-family: Arial, Helvetica, sans-serif; }
.cal span { position: relative; display: grid; place-items: center; width: 100%; height: 100%; }
.cal .on { font-weight: 700; }
.cal .on svg { position: absolute; width: 32px; height: 32px; left: 50%; top: 50%; margin: -17px 0 0 -16px; animation: pulse 1.6s ease-in-out infinite; }

/* Đếm ngược */
.cd { display: flex; height: 100%; font-family: Arial, Helvetica, sans-serif; }
.cd div { flex: 1; border-radius: 4px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.35; }
.cd b { font-size: 16px; font-weight: 400; }
.cd small { font-size: 14px; }

/* Bản đồ */
.map { width: 100%; height: 100%; border: 1px solid; position: relative; background: #eee; }
.map iframe { width: 100%; height: 100%; border: 0; display: block; }
.map a { position: absolute; right: 6px; bottom: 6px; background: #fff; color: #1a73e8; font: 600 11px var(--ui-font); padding: 5px 9px; border-radius: 4px; text-decoration: none; box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* Khối RSVP */
.rsvp-box { text-align: center; font-family: var(--ui-font); color: #333; padding: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; }
.rsvp-box .k { letter-spacing: .25em; font-size: 11px; color: #888; font-weight: 600; }
.rsvp-box h3 { margin: 6px 0 12px; font-size: 19px; font-weight: 700; color: #18181b; }
.rsvp-box p { margin: 0 0 18px; font-size: 13.5px; line-height: 1.55; color: #555; }
.pill-btn { display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 999px; padding: 10px 20px; font-weight: 600; font-size: 14px; }
.pill-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Timeline ---------- */
.tl { position: relative; width: 430px; padding: 26px 0 36px; display: flex; flex-direction: column; align-items: center; }
.tl > .ea { height: auto; display: flex; flex-direction: column; align-items: center; }
.tl-title { margin: 0 0 14px; text-align: center; font-size: 46px; line-height: 1.1; font-weight: 400; }
.tl-card { position: relative; overflow: hidden; width: 300px; border-radius: 72px; padding: 36px 26px 64px; border: 1px solid; text-align: center; }
.tl-card::after { content: ""; position: absolute; width: 170px; height: 170px; border-radius: 50%; border: 1.2px solid currentColor; right: -52px; bottom: -96px; opacity: .8; pointer-events: none; }
.tl-item { display: flex; flex-direction: column; align-items: center; }
.tl-item svg { display: block; }
.tl-ic { width: 84px; height: 84px; }
.tl-time { font-family: "PlayfairDisplay", Georgia, serif; font-size: 30px; font-weight: 700; line-height: 1.15; letter-spacing: .5px; }
.tl-text { font-family: "Quicksand", var(--ui-font); font-size: 20px; line-height: 1.32; text-transform: uppercase; white-space: pre-line; font-weight: 500; }
.tl-item.center .tl-time { margin-top: 10px; margin-bottom: 4px; }
.tl-extra { display: flex; gap: 26px; margin-top: 14px; }
.tl-extra svg { width: 64px; height: 64px; }
.tl-item.row { flex-direction: row; justify-content: center; gap: 20px; text-align: center; }
.tl-item.row .tl-ic { width: 76px; height: 76px; flex: none; }
.tl-item.row .tl-body { min-width: 104px; }
.tl-sep { display: flex; align-items: center; gap: 8px; margin: 18px 0; }
.tl-sep i { flex: 1; border-top: 2px dotted currentColor; opacity: .5; }
.tl-sep svg { width: 18px; height: 18px; fill: currentColor; }

/* ---------- Phong bì ---------- */
.env { position: fixed; inset: 0; z-index: 1000; background: #d9d2c5; }
.env-page { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; container-type: size; cursor: pointer; }
.env-bg { position: absolute; inset: 0; background: url(/assets/env/bg.webp) top / cover; }
.env-stage { position: relative; flex-shrink: 0; width: min(160cqw, 143.78cqh); aspect-ratio: 934 / 734; container-type: inline-size; user-select: none; }
.env-img { position: absolute; }
.env-img img { width: 100%; height: 100%; display: block; }
.env-floral-l { left: 16.7%; top: 19.9%; width: 25.4%; height: 58.5%; }
.env-floral-l img, .env-floral-rb img { transform: scaleX(-1); }
.env-envelope { left: 22.9%; top: 23.5%; width: 52.7%; height: 56.9%; }
.env-floral-ra { left: 62%; top: 26.8%; width: 20.4%; height: 46.9%; }
.env-floral-rb { left: 60.8%; top: 26.8%; width: 18.7%; height: 41.6%; }
.env-seal { left: 43.5%; top: 48.4%; width: 11.4%; height: 15%; }
.env-seal span { position: absolute; font-family: "EnvSerif", Georgia, serif; font-style: italic; font-size: 3.34cqw; line-height: 1; color: rgba(150, 150, 150, .9); text-shadow: 0 1px 0 rgba(255, 255, 255, .6); }
.env-seal .seal-a { left: 31%; top: 27%; }
.env-seal .seal-b { left: 42%; top: 38%; }
.env-stage p { position: absolute; left: 10%; right: 10%; margin: 0; text-align: center; color: #2b2724; transform: translateY(-50%); line-height: 1.2; }
.env-word { top: 14.6%; font-family: "Noto Serif", Georgia, serif; font-size: 2.65cqw; }
.env-name { top: 23.4%; font-size: 3.9cqw; }
.env-cta { top: 79.6%; font-family: "Noto Serif", Georgia, serif; font-size: 2.05cqw; letter-spacing: .04em; }
.env-cta { animation: ctaPulse 2.2s ease-in-out 1.6s infinite; }
@keyframes ctaPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.env .ev-in { animation: envRise .9s cubic-bezier(.22, .61, .36, 1) both; animation-delay: var(--d, 0s); }
.env .env-bg.ev-in { animation: envFade .7s ease both; }
.env.exiting .ev-in:not(.env-bg) { animation: envAway .7s cubic-bezier(.22, .61, .36, 1) both; animation-delay: calc(var(--d, 0s) * .42); }
.env.exiting .env-cta { animation: envAway .7s cubic-bezier(.22, .61, .36, 1) both; }
.env.exiting { background: transparent; transition: background .35s ease-out .55s; }
.env.exiting .env-bg { animation: envFadeOut .4s ease-out .74s both; }
@keyframes envFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes envFadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes envRise { from { opacity: 0; transform: translateY(34px); } to { opacity: 1; transform: none; } }
@keyframes envAway { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-34px); } }
.env-stage p.ev-in { animation-name: envRiseC; }
.env.exiting .env-stage p.ev-in { animation-name: envAwayC; }
@keyframes envRiseC { from { opacity: 0; transform: translateY(calc(-50% + 34px)); } to { opacity: 1; transform: translateY(-50%); } }
@keyframes envAwayC { from { opacity: 1; transform: translateY(-50%); } to { opacity: 0; transform: translateY(calc(-50% - 34px)); } }

/* ---------- UI nổi ---------- */
.ui { position: fixed; left: 50%; transform: translateX(-50%); width: var(--colw); top: 0; bottom: 0; pointer-events: none; z-index: 50; }
.ui > * { pointer-events: auto; }
.music-btn { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; width: 44px; height: 28px; border-radius: 999px; border: 0; background: rgba(60, 60, 60, .45); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; }
.bars { display: flex; gap: 2.5px; align-items: center; height: 12px; }
.bars i { width: 2.5px; height: 4px; background: #fff; border-radius: 2px; }
.music-btn.playing .bars i { animation: eq .9s ease-in-out infinite; }
.music-btn.playing .bars i:nth-child(2) { animation-delay: .2s; }
.music-btn.playing .bars i:nth-child(3) { animation-delay: .4s; }
.music-btn.playing .bars i:nth-child(4) { animation-delay: .1s; }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }

.toolbar { position: absolute; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: center; transition: transform .35s ease, opacity .35s ease; }
.tb-wish { flex: 1; min-width: 0; height: 38px; border-radius: 999px; border: 0; background: rgba(40, 40, 40, .42); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #fff; font-size: 14px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px 0 18px; }
.tb-wish span { flex: 1; text-align: center; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-wish svg, .tb-round svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.tb-round { width: 38px; height: 38px; flex: none; border-radius: 50%; border: 0; background: rgba(40, 40, 40, .42); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: grid; place-items: center; }
.toggle-ui { position: absolute; right: 10px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 50px); width: 38px; height: 38px; border-radius: 50%; border: 0; background: linear-gradient(160deg, #ff8fa3, #ff5277); box-shadow: 0 4px 14px rgba(255, 82, 119, .4); display: grid; place-items: center; }
.toggle-ui svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2.2; stroke-linecap: round; }
.toggle-ui .ic-heart { display: none; fill: #fff; stroke: none; }
.ui.collapsed .toggle-ui { bottom: max(10px, env(safe-area-inset-bottom)); }
.ui.collapsed .toggle-ui .ic-x { display: none; }
.ui.collapsed .toggle-ui .ic-heart { display: block; }
.ui.collapsed .toolbar { transform: translateY(80px); opacity: 0; pointer-events: none; }
.ui.collapsed .live-wishes { opacity: 0; }

.live-wishes { position: absolute; left: 12px; right: 64px; bottom: calc(max(10px, env(safe-area-inset-bottom)) + 52px); display: flex; flex-direction: column; align-items: flex-start; gap: 6px; pointer-events: none; transition: opacity .3s; }
.chip { max-width: 100%; font-size: 13px; line-height: 1.35; padding: 6px 12px; border-radius: 8px; animation: chipIn .45s ease both; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.chip b { font-weight: 700; }
.chip.out { animation: chipOut .5s ease both; }
@keyframes chipIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes chipOut { to { opacity: 0; transform: translateY(-10px); } }

/* ---------- Bottom sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 200; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .4); animation: envFade .25s ease both; }
.sheet-panel { position: absolute; left: 50%; bottom: 0; transform: translateX(-50%); width: var(--colw); max-height: 92dvh; background: #fff; border-radius: 18px 18px 0 0; display: flex; flex-direction: column; animation: sheetUp .32s cubic-bezier(.22, .61, .36, 1) both; }
@keyframes sheetUp { from { transform: translate(-50%, 100%); } to { transform: translate(-50%, 0); } }
.sheet-head { display: flex; align-items: center; justify-content: center; position: relative; padding: 16px 48px 10px; }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; text-align: center; }
.sheet-x { position: absolute; right: 8px; top: 8px; width: 36px; height: 36px; border: 0; background: none; display: grid; place-items: center; border-radius: 50%; }
.sheet-x:hover { background: #f3f3f3; }
.sheet-x svg { width: 18px; height: 18px; fill: none; stroke: #333; stroke-width: 2; stroke-linecap: round; }
.sheet-body { overflow-y: auto; padding: 4px 20px calc(20px + env(safe-area-inset-bottom)); }
.sheet-desc { text-align: center; color: #666; font-size: 13px; line-height: 1.55; margin: 2px 0 16px; }

.f { display: block; margin-bottom: 14px; }
.f > span { display: block; font-size: 12px; color: #555; margin-bottom: 4px; font-weight: 500; }
.f input, .f textarea, .f select { width: 100%; font: inherit; font-size: 15px; border: 0; border-bottom: 1px solid #d4d4d8; padding: 8px 0; background: transparent; outline: none; border-radius: 0; color: #18181b; }
.f textarea { resize: vertical; min-height: 70px; border: 1px solid #d4d4d8; border-radius: 8px; padding: 10px; }
.f input:focus, .f textarea:focus, .f select:focus { border-color: var(--accent); }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; }
.choice label { border: 1px solid #e4e4e7; border-radius: 10px; padding: 10px 12px; display: flex; align-items: center; gap: 8px; font-size: 13.5px; cursor: pointer; background: #fafafa; }
.choice input { accent-color: var(--accent); margin: 0 0 0 auto; width: 18px; height: 18px; flex: none; }
.choice label:has(input:checked) { border-color: var(--accent); background: #fff; box-shadow: 0 0 0 1px var(--accent) inset; }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; border: 1px solid #e4e4e7; border-radius: 8px; padding: 8px; text-align: center; font-size: 14px; cursor: pointer; }
.seg input { display: none; }
.seg label:has(input:checked) { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.submit { width: 100%; border: 0; border-radius: 10px; padding: 13px; font-weight: 600; font-size: 15px; background: var(--accent); color: #fff; margin-top: 4px; }
.submit:disabled { opacity: .45; }
.done { text-align: center; padding: 18px 6px 10px; }
.done svg { width: 54px; height: 54px; fill: var(--accent); }
.done p { color: #555; line-height: 1.6; }

.gift-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.gift-tabs button { flex: none; border: 1px solid #e4e4e7; background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.gift-tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.gift-acc { text-align: center; }
.gift-acc img { width: min(260px, 100%); aspect-ratio: 1; object-fit: contain; border-radius: 12px; border: 1px solid #eee; background: #fff; }
.gift-acc dl { margin: 14px 0 0; display: grid; gap: 8px; text-align: left; background: #fafafa; border-radius: 10px; padding: 12px 14px; }
.gift-acc dl div { display: flex; justify-content: space-between; gap: 10px; align-items: center; font-size: 14px; }
.gift-acc dt { color: #777; flex: none; }
.gift-acc dd { margin: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.copy { border: 1px solid #ddd; background: #fff; border-radius: 6px; font-size: 12px; padding: 3px 8px; margin-left: 6px; font-weight: 500; }
.empty { text-align: center; color: #777; font-size: 14px; padding: 30px 0; }

.toast { position: fixed; left: 50%; bottom: 90px; transform: translate(-50%, 20px); background: rgba(24, 24, 27, .9); color: #fff; font-size: 14px; padding: 9px 16px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; z-index: 300; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.qr-desk { position: fixed; right: 28px; bottom: 28px; z-index: 40; background: #fff; border-radius: 12px; padding: 10px 10px 8px; box-shadow: 0 6px 24px rgba(0, 0, 0, .15); text-align: center; width: 128px; }
.qr-desk #qrBox img, .qr-desk #qrBox canvas { width: 108px !important; height: 108px !important; display: block; margin: 0 auto; }
.qr-desk p { margin: 6px 0 0; font-size: 10.5px; color: #555; line-height: 1.35; }
@media (max-width: 899px) { .qr-desk { display: none !important; } #bgBlur { display: none; } }

@media (prefers-reduced-motion: reduce) {
  .ea { transition: none !important; }
  [class*="loop-"], .env-cta { animation: none !important; }
}
