/* ===== Nền tảng chung cho trang soạn thiệp & quản lý ===== */
/* Bọc @layer để CSS tay này luôn nhường ưu tiên cho Tailwind (global.css) khi
   cả hai cùng nạp trên một trang (trang chủ dùng <Header> Tailwind + base.css) —
   base.css nạp trước nên nếu không có @layer, rule không-layer của nó (vd `a{color}`)
   sẽ thắng mọi utility class có layer bất kể specificity, đè màu chữ header. */
/* QUAN TRỌNG: phải chốt thứ tự layer TRƯỚC, vì base.css nạp trước bundle Tailwind.
   Không có dòng này, `legacy` bị xếp DƯỚI mọi layer Tailwind → preflight
   (`* { margin:0 }`, `h1 { font-size:inherit }` trong layer `base`) đè sạch
   toàn bộ style ở đây (mất căn giữa .wrap, mất cỡ chữ heading…).
   `legacy` đứng sau `base` (thắng preflight) nhưng trước `utilities`
   (utility của Header vẫn thắng — giữ đúng ý đồ ban đầu của việc bọc layer). */
@layer properties, theme, base, components, legacy, utilities;
@layer legacy {
:root {
  --ink: #2b2320;
  --wd-muted: #6d6058; /* ≥4.5:1 trên nền paper/trắng (AA text nhỏ) */
  --line: #e7ddd3;
  --paper: #fbf7f1;
  --paper-2: #ffffff;
  --gold: #c2a14d;
  --gold-deep: #7d641f; /* ≥4.5:1 trên trắng — dùng được cho link/chữ nhỏ */
  --red: #b5232a;
  --shadow: 0 18px 50px -20px rgba(70, 50, 30, .35);
  --wd-radius: 18px;
  --font-body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Playfair Display", Georgia, "Times New Roman", serif;
  --font-script: "Great Vibes", "Brush Script MT", cursive;
}

* { box-sizing: border-box; }

/* a11y: viền focus rõ khi dùng bàn phím */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--gold-deep); outline-offset: 2px; border-radius: 4px;
}

/* a11y: skip link — ẩn tới khi nhận focus bàn phím */
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 10px 10px;
  font-weight: 600; text-decoration: none; transition: top .15s;
}
.skip-link:focus-visible { top: 0; color: #fff; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, #fbeede 0, transparent 60%),
    radial-gradient(900px 500px at -10% 110%, #f6e7e0 0, transparent 55%),
    var(--paper);
  line-height: 1.6;
}

a { color: var(--gold-deep); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 22px; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0; gap: 16px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); }
.brand .sigil {
  width: 44px; height: 44px; display: grid; place-items: center;
  border-radius: 50%; background: linear-gradient(145deg, var(--red), #8c171d);
  color: #ffe9b8; font-size: 22px; box-shadow: var(--shadow);
}
.brand b { font-family: var(--font-display); font-size: 22px; letter-spacing: .3px; }
.brand small { display: block; color: var(--wd-muted); font-size: 12px; letter-spacing: 2px; text-transform: uppercase; }

/* Hero intro */
@keyframes heroIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: none; }
}
.hero {
  text-align: center; padding: 26px 0 10px;
}
.hero .eyebrow {
  letter-spacing: 4px; text-transform: uppercase; font-size: 12.5px;
  color: var(--gold-deep); font-weight: 600;
  animation: heroIn .4s ease both; animation-delay: .05s;
}
.hero h1 {
  font-family: var(--font-display); font-weight: 800;
  font-size: clamp(30px, 5vw, 50px); margin: 8px 0 6px; line-height: 1.1;
  animation: heroIn .4s ease both; animation-delay: .15s;
}
.hero p { color: var(--wd-muted); max-width: 620px; margin: 0 auto; font-size: 16px; animation: heroIn .4s ease both; animation-delay: .26s; }
.hero-cta { animation: heroIn .4s ease both; animation-delay: .36s; }
.hero-trust { display: flex; gap: 8px 20px; justify-content: center; flex-wrap: wrap; margin-top: 16px; color: var(--wd-muted); font-size: 13px; animation: heroIn .4s ease both; animation-delay: .46s; }
.hero-trust span { white-space: nowrap; }
@media (prefers-reduced-motion: reduce) {
  .hero .eyebrow, .hero h1, .hero p, .hero-cta, .hero-trust { animation: none; }
}

/* Editor layout */
.editor {
  /* minmax(0,…) để min-content của form (ô datetime…) không ép cột tràn viewport */
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 30px;
  align-items: start; padding: 24px 0 70px;
}
@media (max-width: 940px) { .editor { grid-template-columns: minmax(0, 1fr); } }

.card {
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--wd-radius); box-shadow: var(--shadow); padding: 26px;
}
.card h2 {
  font-family: var(--font-display); font-size: 22px; margin: 0 0 4px;
}
.card .hint { color: var(--wd-muted); font-size: 13.5px; margin: 0 0 18px; }

.section-label {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; letter-spacing: 2px; text-transform: uppercase;
  color: var(--gold-deep); font-weight: 700; margin: 26px 0 12px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 11px 13px; border: 1px solid var(--line);
  border-radius: 11px; font: inherit; color: var(--ink); background: #fffdfa;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(194,161,77,.18);
}
.field textarea { resize: vertical; min-height: 70px; }
/* iOS tự phóng to trang khi focus input <16px — các ô thêm dòng (kỷ niệm, lịch trình,
   FAQ, lưu trú, sự kiện) dùng text-sm 14px nên ép ≥16px riêng trên mobile. */
@media (max-width: 940px) {
  .editor input[type="text"], .editor input[type="url"], .editor textarea { font-size: 16px; }
}
.suggest-btn { margin-top: 6px; border: 1px solid var(--line); background: #fffdfa; color: var(--gold-deep); cursor: pointer; font: inherit; font-size: 13px; font-weight: 600; padding: 10px 15px; min-height: 44px; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; }
.suggest-btn svg { flex: none; }
.suggest-btn:hover { background: #fbf2dc; }
.suggest-list { display: grid; gap: 6px; margin-top: 8px; }
.suggest-item { text-align: left; cursor: pointer; font: inherit; font-size: 13px; line-height: 1.5; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.suggest-item:hover { border-color: var(--gold); background: #fffdf6; }
.gallery-thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
/* Không dùng overflow:hidden — nó cắt cụt vùng chạm mở rộng của .gthumb-x; bo góc chuyển cho img. */
.gthumb { position: relative; width: 66px; height: 66px; border-radius: 10px; border: 1px solid var(--line); background: #f3ece2; cursor: grab; }
.gthumb.dragging { opacity: .45; }
.gthumb:active { cursor: grabbing; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.gthumb.broken { display: none; }
.gthumb-x { position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%; border: none; background: rgba(0,0,0,.62); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; display: grid; place-items: center; padding: 0; }
/* Vùng chạm hiệu dụng ~44px (26 + 2×9) — hình vẽ giữ nguyên để không che ảnh. */
.gthumb-x::before { content: ''; position: absolute; inset: -9px; }
.gthumb-x:hover { background: var(--red); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }

/* Template picker */
.templates { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 520px) { .templates { grid-template-columns: 1fr; } }
.tpl {
  cursor: pointer; border: 2px solid var(--line); border-radius: 14px;
  overflow: hidden; background: #fff; text-align: center; transition: transform .12s, border-color .15s, box-shadow .15s;
}
.tpl:hover { transform: translateY(-2px); }
.tpl.active { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(194,161,77,.2); }
/* radio ẩn kiểu sr-only vẫn nhận focus — hiện viền trên thẻ mẫu khi điều hướng bàn phím */
.tpl:has(input:focus-visible) { outline: 2px solid var(--gold-deep); outline-offset: 2px; }
/* Bộ chọn mẫu hiển thị ảnh preview thật (gradient t-* làm nền chờ ảnh tải) */
.tpl .swatch { aspect-ratio: 3 / 4; display: block; overflow: hidden; position: relative; font-family: var(--font-script); font-size: 24px; }
.tpl.active .swatch::after {
  content: "✓"; position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--gold-deep); color: #fff;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; font-family: var(--font-body);
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.tpl .swatch img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; transition: transform .25s ease; }
.tpl:hover .swatch img { transform: scale(1.04); }
@media (prefers-reduced-motion: reduce) { .tpl:hover .swatch img { transform: none; } }
.tpl .swatch.t-truyen-thong { background: linear-gradient(135deg,#b5232a,#7c1418); color: #ffd87a; }
.tpl .swatch.t-hien-dai { background: linear-gradient(135deg,#f5f2ec,#e7ddd0); color: #3a342e; }
.tpl .swatch.t-pastel { background: linear-gradient(135deg,#fbe6ec,#e4f0ea); color: #b06b86; }
.tpl .swatch.t-hoang-gia { background: linear-gradient(135deg,#26304f,#0f1629); color: #d4af37; }
.tpl .swatch.t-xanh-la { background: linear-gradient(135deg,#e8f1e6,#cfe3c7); color: #5b8c5a; }
.tpl .swatch.t-do-ruou { background: linear-gradient(135deg,#a83a48,#7c2630); color: #fbe6ec; }
.tpl .swatch.t-anh-dao { background: linear-gradient(135deg,#fbe3ec,#f3c3d4); color: #c75b7a; }
.tpl .swatch.t-long-phung { background: linear-gradient(135deg,#6e0f15,#3c070a); color: #f1c75a; }
.tpl .swatch.t-mai-trang { background: linear-gradient(135deg,#fffdf7,#f3ecdc); color: #b08f3e; }
.tpl .swatch.t-lam-ngoc { background: linear-gradient(135deg,#d7e6ea,#56a0b6); color: #1f5263; }
.tpl .swatch.t-hong-kim { background: linear-gradient(135deg,#fdeef0,#d49aa1); color: #9c5560; }
.tpl .swatch.t-luc-bao { background: linear-gradient(135deg,#114a38,#061d16); color: #e8c66a; }
.tpl span { display: block; padding: 8px 6px; font-size: 12.5px; font-weight: 600; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; font: inherit; font-weight: 700;
  padding: 13px 22px; border-radius: 12px; text-decoration: none;
  transition: transform .12s, box-shadow .15s, opacity .15s;
}
.btn:active { transform: translateY(1px); }
/* CTA chính = đỏ thương hiệu (đồng bộ với hero, nút Starwind & theme-color) */
.btn-primary { background: var(--red); color: #fff; box-shadow: 0 12px 26px -10px rgba(181,35,42,.5); }
.btn-primary:hover { background: #9c171d; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* Live preview pane */
.preview-pane { position: sticky; top: 18px; }
.preview-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.preview-tabs .ptab {
  flex: 1; cursor: pointer; font: inherit; font-size: 13px; font-weight: 600;
  padding: 12px 10px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--wd-muted); transition: .15s;
}
.preview-tabs .ptab.active { background: var(--gold-deep); color: #fff; border-color: var(--gold-deep); }
.preview-frame {
  border: 1px solid var(--line); border-radius: var(--wd-radius); overflow: hidden;
  box-shadow: var(--shadow); background: #fff; height: 640px;
}
.preview-frame iframe { width: 100%; height: 100%; border: 0; display: block; transition: opacity .15s ease; }
.preview-frame iframe.pf-fading { opacity: 0; }
@media (prefers-reduced-motion: reduce) { .preview-frame iframe { transition: none; } }
.preview-caption { text-align: center; color: var(--wd-muted); font-size: 12.5px; margin-top: 10px; }

/* Result modal */
.overlay {
  position: fixed; inset: 0; background: rgba(40,28,18,.55); backdrop-filter: blur(3px);
  display: none; align-items: center; justify-content: center; padding: 22px; z-index: 50;
}
.overlay.open { display: flex; }
/* Modal mở → khoá cuộn nền (editor.js toggle class này cùng lúc với .overlay.open) */
body.modal-open { overflow: hidden; }
.modal {
  background: var(--paper-2); border-radius: 20px; max-width: 460px; width: 100%;
  padding: 30px; text-align: center; box-shadow: var(--shadow);
}
.modal h3 { font-family: var(--font-display); font-size: 26px; margin: 6px 0 4px; }
.modal p { color: var(--wd-muted); margin: 0 0 18px; }
#qrbox { display: grid; place-items: center; margin: 6px auto 16px; }
#qrbox img, #qrbox canvas { width: 168px; height: 168px; border-radius: 12px; border: 1px solid var(--line); padding: 8px; background: #fff; }
.linkrow { display: flex; gap: 8px; margin-bottom: 10px; }
.linkrow input { flex: 1; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; background: #fffdfa; }
.linkrow .btn { padding: 10px 14px; }
.modal .note { font-size: 12.5px; color: var(--wd-muted); }
.share-row { display: flex; gap: 8px; margin: 4px 0 6px; }
.share-btn { flex: 1; padding: 11px 12px; }
.share-fb { background: #1877f2; color: #fff; border-color: #1877f2; font-weight: 700; }
.share-fb:hover { opacity: .92; }
.modal .danger { color: var(--red); font-weight: 600; }

.toast {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  opacity: 0; transition: .25s; z-index: 60; font-size: 14px;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Công tắc bật/tắt + hộp mừng cưới (editor) */
.switch-row {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; background: #fffdfa;
}
.switch-row span:first-child { flex: 1; }
.switch-row b { display: block; font-size: 14.5px; }
.switch-row small { display: block; color: var(--wd-muted); font-size: 12.5px; margin-top: 3px; line-height: 1.45; }
.switch-row input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { width: 46px; height: 26px; border-radius: 999px; background: #d9cdbf; position: relative; flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch-row input:checked ~ .switch { background: var(--gold-deep); }
.switch-row input:checked ~ .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible ~ .switch { box-shadow: 0 0 0 3px rgba(194,161,77,.3); }
.gift-side { border: 1px dashed var(--line); border-radius: 12px; padding: 14px; margin-top: 12px; }
.gift-side-title { font-size: 13px; font-weight: 700; color: var(--gold-deep); margin-bottom: 8px; }

.site-footer { text-align: center; color: var(--wd-muted); font-size: 13px; padding: 30px 0 40px; }
.err-inline { color: var(--red); font-size: 13px; margin-top: 6px; min-height: 1px; }

/* ── Thanh cuộn "chỉ vàng" — đồng bộ với global.css (trang chủ + /manage) ── */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
  border: 3px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
  background-image: linear-gradient(180deg, #d9c188, #ab8438);
  min-height: 44px;
}
::-webkit-scrollbar-thumb:hover { background-image: linear-gradient(180deg, #caa75f, #8a6a2a); }
::-webkit-scrollbar-thumb:active { background-image: linear-gradient(180deg, #c04046, #8f1b21); }
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: #b08a3e transparent; }
}
} /* /@layer legacy */
