/* Trang tạo / sửa thiệp (phong cách trắng đen tối giản, như trang chủ): form bên trái, điện thoại xem trước bên phải (trên điện thoại: nút "Xem trước" mở toàn màn hình). */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 44px; align-items: start; padding-block: 28px 140px; }
.editor-form { display: grid; gap: 18px; min-width: 0; }
.ed-intro { display: grid; gap: 8px; margin-bottom: 6px; }
.ed-intro h1 { font-size: clamp(26px, 3vw, 38px); font-weight: 300; }
.ed-intro h1 em { color: inherit; }
.ed-sec { background: var(--surface); border: 1px solid var(--line); border-radius: 2px; padding: 30px; display: grid; gap: 18px; scroll-margin-top: 84px; transition: border-color .2s, box-shadow .2s; }
.ed-sec.active { border-color: var(--line-strong); box-shadow: var(--shadow); }
.ed-sec > h2 { display: flex; align-items: baseline; gap: 16px; font-family: var(--display); font-size: 19px; font-weight: 400; line-height: 1.3; }
.ed-sec > h2 span.n { font-family: var(--display); font-weight: 500; font-size: 11px; letter-spacing: .14em; color: var(--muted); flex: none; min-width: 22px; }
.ed-sec > p.muted { margin-top: -8px; font-size: 13.5px; }
@media (max-width: 520px) { .ed-sec { padding: 18px 16px; } }

.tpl-pick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 720px) { .tpl-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tpl-opt { position: relative; border: 1px solid transparent; border-radius: 2px; padding: 0 0 12px; cursor: pointer; display: grid; gap: 10px; background: var(--surface); transition: border-color .15s, transform .15s; }
.tpl-opt:hover .tpl-swatch { background-size: auto 108%; }
.tpl-opt b, .tpl-opt small { padding-inline: 2px; }
.tpl-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tpl-opt:has(input:checked) .tpl-swatch { box-shadow: inset 0 0 0 1px var(--ink); }
.tpl-opt:has(input:checked) b { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 1px; }
.tpl-opt:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.tpl-swatch { aspect-ratio: 4 / 5; border-radius: 0; display: block; position: relative; overflow: hidden; font-size: 0 !important; color: transparent !important; box-shadow: none !important; background: var(--tile) center / auto 86% no-repeat !important; transition: background-size .6s cubic-bezier(.2,.7,.2,1); }
.tpl-swatch * { display: none; }
.tpl-swatch.kim { background-image: url(/static/img/mau/kim-mo.webp) !important; }
.tpl-swatch.do { background-image: url(/static/img/mau/do-mo.webp) !important; }
.tpl-swatch.hong { background-image: url(/static/img/mau/hong-mo.webp) !important; }
.tpl-swatch.la { background-image: url(/static/img/mau/la-mo.webp) !important; }
.tpl-swatch.hong { background: radial-gradient(circle at 50% 0, #f7dfe2, #fbf2f1 70%); color: #a84a60; font-family: 'Great Vibes', cursive; font-size: 34px; }
.tpl-swatch.do { background: #8a1b1e; color: #ecc874; font-family: 'Songti SC', 'Noto Serif SC', serif; font-size: 40px; box-shadow: inset 0 0 0 6px #8a1b1e, inset 0 0 0 7px rgba(236,200,116,.5); }
.tpl-swatch.la { background: #eef3e9; color: #2f5c3f; font-family: 'Dancing Script', cursive; font-size: 32px; }
.tpl-swatch.kim { background: radial-gradient(circle at 50% 30%, #2a241c, #12100e 70%); font-family: 'Cormorant Garamond', serif; font-style: italic; font-weight: 300; font-size: 36px; box-shadow: inset 0 0 0 6px #12100e, inset 0 0 0 7px rgba(214,180,110,.5); }
.tpl-opt b { font-family: var(--display); font-size: 13.5px; font-weight: 500; }
.tpl-opt small { display: block; color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.tpl-opt .tick { position: absolute; top: 16px; right: 16px; width: 24px; height: 24px; border-radius: 50%; background: var(--ink); color: #fff; display: none; place-items: center; }
.tpl-opt .tick svg { width: 14px; height: 14px; }
.tpl-opt:has(input:checked) .tick { display: grid; }

.events-ed { display: grid; gap: 12px; }
.event-ed { border: 1px solid var(--line); border-radius: 2px; padding: 18px; display: grid; gap: 12px; background: var(--tile); }
.event-ed .head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.event-ed .head b { font-size: 14px; }
.event-ed details summary { cursor: pointer; font-size: 13px; color: var(--ink); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; }
.event-ed details[open] summary { margin-bottom: 8px; }
.lunar-hint { font-size: 12.5px; color: var(--accent); font-weight: 500; }

.drop { display: grid; place-items: center; gap: 6px; text-align: center; padding: 30px 16px; border: 1px dashed var(--line-strong); border-radius: 2px; background: var(--tile); cursor: pointer; transition: border-color .15s, background .15s; }
.drop:hover, .drop.over { border-color: var(--ink); }
.drop svg { width: 28px; height: 28px; color: var(--ink); }
.drop b { font-size: 14px; font-weight: 500; }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .thumbs { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.thumb { position: relative; aspect-ratio: 1; border-radius: 3px; overflow: hidden; background: var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .tag { position: absolute; left: 6px; top: 6px; background: var(--ink); color: #fff; font-size: 10.5px; font-weight: 500; padding: 2px 8px; border-radius: 999px; }
.thumb .tools { position: absolute; inset: auto 0 0; display: flex; justify-content: space-between; padding: 5px; background: linear-gradient(transparent, rgba(0,0,0,.55)); }
.thumb .tools button { width: 28px; height: 28px; border-radius: 8px; border: 0; background: rgba(255,255,255,.92); color: var(--ink); display: grid; place-items: center; cursor: pointer; }
.thumb .tools button svg { width: 15px; height: 15px; }
.thumb .tools button:disabled { opacity: .35; cursor: default; }
.thumb.loading { display: grid; place-items: center; color: var(--muted); }

.gift-fields { display: grid; gap: 12px; padding: 18px; border-radius: 2px; background: var(--tile); border: 0; }
.gift-fields h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .16em; color: var(--ink); font-weight: 500; }
.qr-up { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.qr-up img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }

.ed-submit { position: sticky; bottom: calc(env(safe-area-inset-bottom, 0px) + 12px); z-index: 5; background: rgba(255,255,255,.97); color: var(--ink); border: 1px solid var(--line); border-radius: 2px; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; box-shadow: var(--shadow); }
.ed-submit .total { display: grid; line-height: 1.3; }
.ed-submit .total b { font-family: var(--display); font-size: 24px; font-weight: 300; color: var(--ink); line-height: 1.1; }
.ed-submit .total small { color: var(--muted); font-size: 12px; }
.ed-submit .form-error { color: var(--bad); }
.ed-submit .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.form-error { color: var(--bad); font-size: 14px; font-weight: 500; width: 100%; }

.ed-preview { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 84px); display: grid; gap: 10px; justify-items: center; }
.ed-preview .phone { height: min(740px, calc(100vh - 140px)); width: auto; max-width: none; aspect-ratio: 9 / 18.5; }
.ed-preview .cap { font-size: 12.5px; color: var(--muted); text-align: center; }
.ed-preview .close-preview { display: none; }

.mobile-preview-btn { display: none; }
@media (max-width: 980px) {
  .editor { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .ed-preview { position: fixed; inset: 0; z-index: 60; background: rgba(255, 255, 255, .97); padding: calc(env(safe-area-inset-top, 0px) + 56px) 16px calc(env(safe-area-inset-bottom, 0px) + 16px); align-content: center; visibility: hidden; opacity: 0; transition: opacity .2s, visibility 0s linear .2s; }
  .ed-preview.show { visibility: visible; opacity: 1; transition: opacity .2s; }
  .ed-preview .phone { height: min(720px, calc(100vh - 110px)); }
  .ed-preview .close-preview { display: inline-flex; position: absolute; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 16px; }
  .mobile-preview-btn { display: inline-flex; }
}

/* Chế độ quản lý thiệp */
.manage-head { display: grid; gap: 14px; padding-top: 26px; }
.manage-head .row1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.manage-head h1 { font-size: clamp(26px, 3vw, 36px); font-weight: 300; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button { border: 0; background: none; padding: 14px 16px; font-weight: 500; color: var(--muted); cursor: pointer; border-bottom: 1px solid transparent; margin-bottom: -1px; white-space: nowrap; font-size: 12.5px; letter-spacing: .02em; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .count { font-size: 11px; letter-spacing: 0; background: var(--tile); color: var(--ink); border-radius: 999px; padding: 1px 7px; margin-left: 4px; }
.tab-body { padding-block: 26px 80px; display: grid; gap: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.stat { background: var(--tile); border: 0; border-radius: 2px; padding: 20px 22px; }
.stat small { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .16em; font-weight: 500; }
.stat b { font-family: var(--display); font-size: 34px; font-weight: 300; line-height: 1.1; font-variant-numeric: lining-nums tabular-nums; }
.wish-row { display: flex; justify-content: space-between; gap: 14px; padding: 14px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.wish-row:first-child { border-top: 0; }
.wish-row p { overflow-wrap: anywhere; }
.wish-row.hidden-wish { opacity: .5; }
.share-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; }
@media (max-width: 820px) { .share-grid { grid-template-columns: 1fr; } }
.linkbox { display: flex; gap: 8px; align-items: center; border: 1px solid var(--line-strong); border-radius: 4px; padding: 6px 6px 6px 12px; background: var(--bg); min-width: 0; }
.linkbox code { flex: 1; min-width: 0; font-size: 14px; overflow-wrap: anywhere; font-family: var(--ui); }
.qr-box { display: grid; justify-items: center; gap: 10px; }
.qr-box canvas, .qr-box img { width: 200px; height: 200px; image-rendering: pixelated; border-radius: 4px; border: 1px solid var(--line); background: #fff; padding: 8px; }

/* Chọn loại thiệp và dịp */
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .seg { grid-template-columns: 1fr; } }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; gap: 3px; padding: 16px 18px; border: 1px solid var(--line-strong); border-radius: 2px; transition: border-color .2s, background .2s; height: 100%; }
.seg b { font-size: 14px; font-weight: 500; }
.seg small { font-size: 12px; color: var(--muted); }
.seg label:has(input:checked) span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--tile); }
.seg label:has(input:focus-visible) span { outline: 1px solid var(--ink); outline-offset: 3px; }
.occ-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-ed { position: relative; cursor: pointer; }
.chip-ed input { position: absolute; opacity: 0; pointer-events: none; }
.chip-ed span { display: inline-block; border: 1px solid var(--line-strong); border-radius: 999px; padding: 8px 16px; font-size: 13px; transition: background .2s, color .2s, border-color .2s; }
.chip-ed:has(input:checked) span { background: var(--ink); border-color: var(--ink); color: #fff; }
.chip-ed:has(input:focus-visible) span { outline: 1px solid var(--ink); outline-offset: 3px; }
.tpl-swatch.xuan { background-image: url(/static/img/mau/xuan-mo.webp) !important; }
.tpl-swatch.dong { background-image: url(/static/img/mau/dong-mo.webp) !important; }
@media (min-width: 721px) { .tpl-pick { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* Link riêng hàng loạt */
.bulk { display: grid; gap: 10px; }
.bulk-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--line); border-radius: 2px; }
.bulk-row { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.6fr) auto; gap: 10px; align-items: center; padding: 8px 10px; border-top: 1px solid var(--line); font-size: 13px; }
.bulk-row:first-child { border-top: 0; }
.bulk-row code { font-family: var(--ui); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.bulk-row b { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
