:root {
  --muc: #40262a; --phu: #75585c; --nhan: #a51a2b; --nen: #fffaf5; --the: #fff; --vien: #e2cdc6; --loi: #b3261e;
  --duoi: calc(68px + env(safe-area-inset-bottom));
}
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: calc(var(--duoi) + 16px); }
body { background: var(--nen); color: var(--muc); font: 400 1.0625rem/1.5 'Be Vietnam Pro', system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
button { min-height: 46px; padding: 8px 16px; border: 1.5px solid var(--vien); border-radius: 14px; background: var(--the); font-weight: 500; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.chinh { border-color: var(--nhan); background: var(--nhan); color: #fff; }
:focus-visible { outline: 3px solid var(--nhan); outline-offset: 2px; }
h1:focus, h2:focus { outline: none; }
h1 { font: 600 2rem/1.25 'EB Garamond', Georgia, serif; text-wrap: balance; }
h2 { font-size: 1.125rem; font-weight: 600; }
img { display: block; max-width: 100%; }

/* Chọn loại */
#chon-loai { max-width: 1040px; margin: 0 auto; padding: calc(24px + env(safe-area-inset-top)) 16px 48px; }
.ten-trang { display: block; width: max-content; margin-bottom: 20px; }
.ten-trang img { width: 148px; height: auto; }
/* Khi soạn trên điện thoại, chỉ hiện chữ I của logo để đủ chỗ cho các nút. */
.thanh-tren .ten-trang { flex: none; width: 27px; height: 45px; margin: 0; overflow: hidden; }
.thanh-tren button { padding-inline: 12px; white-space: nowrap; }
.thanh-tren .ten-trang img { max-width: none; }
@media (min-width: 700px) { .thanh-tren .ten-trang { width: auto; } }
/* Trang bắt đầu: chọn dịp */
.dau-chon { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 28px; }
.dau-chon .ten-trang { margin: 0; }
.dau-chon .nut { min-height: 44px; }
.ba-buoc { display: flex; flex-wrap: wrap; gap: 8px 6px; margin: 0 0 18px; padding: 0; list-style: none; color: var(--phu); font-size: .9375rem; }
.ba-buoc li { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 999px; background: #f6ebe6; }
.ba-buoc li + li::before { content: ""; width: 14px; height: 1.5px; margin-left: -12px; margin-right: 2px; background: #d9c3bb; }
.ba-buoc b { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: #fff; font-size: .8125rem; }
.ba-buoc [aria-current] { background: var(--nhan); color: #fff; font-weight: 600; }
.ba-buoc [aria-current] b { color: var(--nhan); }
/* Điện thoại: 3 bước chia đều một hàng, số ở trên, chữ ở dưới. */
@media (max-width: 759px) {
  .ba-buoc { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: .8125rem; text-align: center; }
  .ba-buoc li { flex-direction: column; justify-content: center; gap: 4px; padding: 8px 4px; border-radius: 14px; line-height: 1.25; }
  .ba-buoc li + li::before { display: none; }
}
#chon-loai h1 { font-size: clamp(2rem, 6vw, 2.75rem); }
.phu-chon { max-width: 40em; margin: 8px 0 26px; color: var(--phu); }
#cac-loai { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.loai { display: flex; flex-direction: column; align-items: stretch; gap: 0; min-height: 0; padding: 0; overflow: hidden; border: 1px solid #efdfd8; border-radius: 22px; background: var(--the); text-align: left; box-shadow: 0 8px 22px rgb(80 30 30 / .06); transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease; }
.anh-loai { position: relative; display: block; overflow: hidden; aspect-ratio: 1 / 1; }
.loai img { width: 100%; height: 100%; border-radius: 0; object-fit: cover; transition: transform .6s ease; }
.so-mau { position: absolute; left: 10px; bottom: 10px; padding: 2px 10px; border-radius: 999px; background: rgb(255 250 245 / .92); color: var(--muc); font-size: .8125rem; font-weight: 600; }
.chu-loai { display: grid; gap: 4px; padding: 12px 14px 14px; }
.chu-loai b { font-size: 1.0625rem; font-weight: 600; }
.chu-loai > span { color: var(--phu); font-size: .9375rem; font-weight: 400; line-height: 1.4; }
.chu-loai .di-tiep { display: none; margin-top: 6px; color: var(--nhan); font-weight: 600; }
@media (hover: hover) {
  .loai:hover { transform: translateY(-4px); border-color: #e2c4bb; box-shadow: 0 18px 36px rgb(80 30 30 / .12); }
  .loai:hover img { transform: scale(1.06); }
}
.loai:focus-visible { outline: 3px solid var(--nhan); outline-offset: 3px; }
@media (min-width: 760px) {
  #cac-loai { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; }
  .anh-loai { aspect-ratio: 4 / 3; }
  .chu-loai { padding: 16px 18px 18px; }
  .chu-loai b { font-size: 1.25rem; }
  .chu-loai .di-tiep { display: block; }
}
@media (prefers-reduced-motion: reduce) { .loai, .loai img { transition: none; } }

.nhan-phi { position: absolute; top: 16px; left: 16px; padding: 2px 10px; border-radius: 999px; background: #f0cf7d; color: #40262a; font-size: .875rem; font-weight: 600; }

/* Soạn */
.thanh-tren { display: flex; align-items: center; justify-content: space-between; gap: 9px; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.thanh-tren p { flex: 1; color: var(--phu); font-size: .9375rem; text-align: right; }
#loi-luu { padding: 0 16px 12px; }
.cot-soan { padding: 0 16px calc(var(--duoi) + 24px); min-width: 0; }
#cac-buoc { display: flex; gap: 8px; margin: 0 -16px 20px; padding: 4px 16px; overflow-x: auto; scrollbar-width: none; }
#cac-buoc button { flex: none; border-radius: 999px; font-size: .9375rem; }
#cac-buoc [aria-current] { border-color: var(--nhan); background: var(--nhan); color: #fff; }
#cac-buoc .co-loi:not([aria-current]) { border-color: var(--loi); color: var(--loi); }
#ten-buoc { margin-bottom: 18px; scroll-margin-top: 16px; }
#o-nhap { display: grid; gap: 18px; }
#o-nhap h2 { margin-top: 8px; }
.o { display: grid; gap: 6px; min-width: 0; }
.o > label, .o > .nhan { font-weight: 600; }
.o input, .o textarea, .o select { display: block; width: 100%; min-width: 0; min-height: 50px; padding: 10px 14px; border: 1.5px solid var(--vien); border-radius: 14px; background: var(--the); -webkit-appearance: none; appearance: none; text-align: left; }
.o input::-webkit-date-and-time-value { text-align: left; }
.o select { background: var(--the) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%2375585c' stroke-width='2'/%3E%3C/svg%3E") no-repeat right 16px center; }
.o textarea { min-height: 104px; resize: vertical; }
.o [aria-invalid=true] { border-color: var(--loi); }
.goi-y { color: var(--phu); font-size: .9375rem; }
.loi { color: var(--loi); font-size: .9375rem; font-weight: 500; }
.goi-y:empty, .loi:empty { display: none; }

.bat { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 50px; padding: 8px 14px; border-radius: 14px; background: var(--the); cursor: pointer; }
.bat input { position: relative; flex: none; width: 52px; height: 32px; margin: 0; border-radius: 999px; background: #cdbab5; -webkit-appearance: none; appearance: none; transition: background .2s; cursor: pointer; }
.bat input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform .2s; }
.bat input:checked { background: var(--nhan); }
.bat input:checked::after { transform: translateX(20px); }

.kem-goi-y { display: grid; gap: 6px; }

.ds { display: grid; gap: 14px; }
.dong { display: grid; gap: 12px; padding: 14px; border: 0; border-radius: 18px; background: #f8ece6; min-width: 0; }
.dong legend { float: left; width: 100%; padding: 0; font-weight: 600; }
.dong .xoa { justify-self: start; }
.xoa { color: var(--loi); }
.them { justify-self: start; }

.cac-anh { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.cac-anh:empty { display: none; }
.cac-anh div { display: grid; gap: 6px; }
.cac-anh img { width: 100%; aspect-ratio: 4 / 5; border-radius: 14px; object-fit: cover; }
.cac-anh .ca-hinh { background: #fff; object-fit: contain; }
.chon-anh { position: relative; display: grid; place-items: center; min-height: 64px; border: 1.5px dashed var(--nhan); border-radius: 14px; color: var(--nhan); font-weight: 600; }
.chon-anh input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; opacity: 0; cursor: pointer; }
.chon-anh:focus-within { outline: 3px solid var(--nhan); outline-offset: 2px; }
.chon-anh:has(input:disabled) { opacity: .5; }

.cac-mau { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mau { position: relative; padding: 10px; border: 2px solid var(--vien); border-radius: 18px; background: var(--the); font-weight: 600; text-align: center; }
.mau input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.mau img { width: 100%; aspect-ratio: 3 / 4; margin-bottom: 8px; border-radius: 12px; object-fit: cover; }
.mau:has(:checked) { border-color: var(--nhan); color: var(--nhan); }
.mau:focus-within { outline: 3px solid var(--nhan); outline-offset: 2px; }

.ket-qua { display: grid; gap: 14px; }
.ket-qua ul { display: grid; gap: 10px; padding: 0; list-style: none; }
.ket-qua li { padding: 14px; border-radius: 18px; background: var(--the); }
.ket-qua li button { margin-top: 10px; }
.ket-qua .nhac li { display: grid; gap: 2px; overflow-wrap: anywhere; }
.ket-qua .nhac span { color: var(--phu); font-size: .9375rem; }
.link-khach { display: grid; gap: 10px; padding: 14px; border-radius: 18px; background: #f8ece6; }
.link-khach div { display: flex; flex-wrap: wrap; gap: 8px; }
.link-khach a, .nut { display: grid; place-items: center; min-height: 46px; padding: 8px 16px; border: 1.5px solid var(--vien); border-radius: 14px; background: var(--the); color: inherit; font-weight: 500; text-decoration: none; }

.thanh-duoi { position: fixed; z-index: 3; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: auto 1fr 1fr; gap: 8px; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--nen); box-shadow: 0 -6px 20px rgb(80 30 30 / .1); }
.thanh-duoi button { padding-inline: 8px; white-space: nowrap; }

/* Xem trước: điện thoại phủ kín, máy tính nằm bên phải */
.cot-xem { display: none; position: fixed; z-index: 2; inset: 0 0 var(--duoi); padding: env(safe-area-inset-top) 0 0; background: var(--nen); flex-direction: column; }
.dang-xem .cot-xem { display: flex; }
.dang-xem { overflow: hidden; }
.khung-xem { flex: 1; min-height: 0; }
iframe { display: block; width: 100%; height: 100%; border: 0; background: #fff; }
#xem-khach { margin: 8px 16px; }
dialog { width: 100vw; max-width: none; height: 100dvh; max-height: none; padding: 0; border: 0; background: #fff; }
#dong-khach, #dong-dang-nhap { position: absolute; z-index: 1; top: calc(10px + env(safe-area-inset-top)); left: 12px; box-shadow: 0 4px 14px rgb(80 30 30 / .25); }
#dong-dang-nhap { right: 12px; left: auto; }
#hop-khach[open] { display: grid; grid-template-rows: auto minmax(0, 1fr); }
#khung-khach { grid-row: 2; }
#bao-mau { padding: calc(10px + env(safe-area-inset-top)) 16px 10px 104px; background: #f8ece6; font-size: .9375rem; line-height: 1.4; }
#hop-khach:has(#bao-mau:not([hidden])) #dong-khach { top: calc(8px + env(safe-area-inset-top)); }

#hop-nang-cap { width: min(420px, calc(100vw - 32px)); height: max-content; margin: auto; padding: 24px; border: 0; border-radius: 24px; background: #fffaf5; color: #40262a; }
#hop-nang-cap[open] { display: grid; gap: 12px; }
#hop-nang-cap::backdrop { background: rgb(40 12 18 / .55); }
#hop-nang-cap div { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.nut.chinh { border-color: var(--nhan); background: var(--nhan); color: #fff; }

@media (min-width: 900px) {
  .hai-cot { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 32px; max-width: 1140px; margin: 0 auto; padding: 0 16px; }
  .cot-xem { position: sticky; z-index: 0; inset: auto; top: 12px; display: flex; align-self: start; height: calc(100dvh - var(--duoi) - 84px); }
  .khung-xem { overflow: hidden; border: 8px solid #40262a; border-radius: 34px; }
  #xem { display: none; }
  .thanh-duoi { grid-template-columns: auto auto; justify-content: center; }
  .thanh-duoi button { min-width: 160px; }
  dialog { width: 440px; height: min(900px, 94dvh); margin: auto; border-radius: 28px; overflow: hidden; }
}

/* Phân trang danh sách mẫu. Khi đã chạy mã, trang đầu chỉ hiện 20 mẫu để không bị nhảy. */
.ngoai-trang { display: none !important; }
.co-js .cac-mau:not(.da-chia) > :nth-child(n+21) { display: none; }
.phan-trang { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin-top: 24px; }
.phan-trang[hidden] { display: none; }
.phan-trang button { min-width: 46px; min-height: 46px; padding: 0 12px; border: 1.5px solid var(--vien); border-radius: 999px; background: #fff; color: var(--muc); font: inherit; font-weight: 600; cursor: pointer; }
.phan-trang [aria-current=page] { border-color: var(--nhan); background: var(--nhan); color: #fff; }
.phan-trang button:disabled { opacity: .4; cursor: default; }

/* Nhãn HOT, Mới, Nổi bật: xếp dọc ở góc phải trên của thẻ mẫu (Trả phí ở góc trái). */
.mau .cac-nhan { position: absolute; top: 16px; right: 16px; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; pointer-events: none; }
.mau .cac-nhan > span { position: static; padding: 2px 10px; border-radius: 999px; color: #fff; font-size: .8125rem; font-weight: 700; line-height: 1.5; letter-spacing: .02em; box-shadow: 0 4px 10px rgb(60 10 20 / .22); }
.mau .cac-nhan .nhan-hot { background: linear-gradient(135deg, #ff7a18, #e0244b); }
.mau .cac-nhan .nhan-moi { background: #2f7d4f; }
.mau .cac-nhan .nhan-noi-bat { background: #a51a2b; }

/* ---------- Bố cục soạn thiệp mới ---------- */
.thanh-tren { border-bottom: 1px solid #f0e2dc; background: #fffdfb; }
#ten-thiep { display: none; overflow: hidden; font: 600 1.25rem/1.2 'EB Garamond', Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
#trang-thai.da-luu { color: #2f7d4f; }
#xem-that { min-height: 44px; white-space: nowrap; }
#den-cuoi { display: none; }
#so-buoc { margin: 16px 0 2px; color: var(--nhan); font: italic 500 1rem 'EB Garamond', Georgia, serif; }
#mo-ta-buoc { margin: -10px 0 20px; color: var(--phu); }
#mo-ta-buoc:empty { display: none; }
#cac-buoc .so { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 8px; border-radius: 50%; background: #f3e6e1; color: var(--phu); font-size: .8125rem; font-weight: 700; }
#cac-buoc [aria-current] .so { background: #fff; color: var(--nhan); }
#cac-buoc .da-xong .so { background: #2f7d4f; color: #fff; }
#cac-buoc button { display: inline-flex; align-items: center; }
.hai-cot > #cac-buoc { margin: 8px 0 0; }
.nhom-o { display: grid; align-items: start; gap: 16px; padding: 18px 16px; border: 1px solid #f0e2dc; border-radius: 22px; background: var(--the); box-shadow: 0 6px 18px rgb(80 30 30 / .04); }
.nhom-o > h2 { margin: 0; }
.nhom-o .bat { padding-inline: 0; }
@media (min-width: 700px) {
  #ten-thiep { display: block; flex: 1; min-width: 0; }
  .thanh-tren p { flex: none; }
  #den-cuoi { display: inline-flex; }
  .nhom-o { grid-template-columns: 1fr 1fr; padding: 22px 24px; }
  .nhom-o > h2, .nhom-o > .rong { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  .hai-cot { grid-template-columns: minmax(0, 1fr) 420px; }
  .hai-cot > #cac-buoc { grid-column: 1 / -1; }
}
/* Màn hình rộng: các bước thành cột dọc bên trái, giống mục lục. */
@media (min-width: 1180px) {
  .hai-cot { grid-template-columns: 230px minmax(0, 1fr) 420px; max-width: 1400px; gap: 28px; }
  .hai-cot > #cac-buoc { grid-column: auto; position: sticky; top: 12px; align-self: start; flex-direction: column; gap: 4px; margin: 16px 0 0; padding: 0; overflow: visible; }
  #cac-buoc button { justify-content: flex-start; min-height: 46px; padding: 8px 12px; border: 0; border-radius: 14px; background: transparent; text-align: left; white-space: normal; }
  #cac-buoc button:hover { background: #f8ece6; }
  #cac-buoc [aria-current] { background: #f8ece6; color: var(--nhan); font-weight: 600; }
  #cac-buoc [aria-current] .so { background: var(--nhan); color: #fff; }
  #cac-buoc .co-loi:not([aria-current]) { color: var(--loi); }
}

/* Hộp tạo video */
.hop-video { width: min(440px, calc(100vw - 32px)); height: max-content; margin: auto; padding: 24px; border: 0; border-radius: 24px; background: #fffaf5; color: #40262a; }
.hop-video[open] { display: grid; gap: 12px; }
.hop-video::backdrop { background: rgb(40 12 18 / .55); }
.hop-video progress { width: 100%; height: 10px; accent-color: #a51a2b; }
.hop-video .chu-video { font-weight: 500; }
.nut-video { justify-self: start; }
