/* =========================================================
   TRÌNH TỰ THIẾT KẾ — /thiet-ke (mẫu, ai cũng dùng được) và /thiet-ke/<slug> (thiệp thật)
   Máy tính: bảng chỉnh bên trái, điện thoại xem trước bên phải.
   Điện thoại: xem trước ghim ở trên, bảng chỉnh cuộn bên dưới.
   ========================================================= */
.dz { --view-w: 400px; }
.dz-main { display: grid; grid-template-columns: minmax(0, 1fr) var(--view-w); gap: 28px; max-width: 1180px; margin: 0 auto; padding: 18px 20px 120px; align-items: start; }
.dz-view { grid-column: 2; grid-row: 1; position: sticky; top: 76px; }
.dz-panel { grid-column: 1; grid-row: 1; min-width: 0; }

/* xem trước */
.dz-tools { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px; }
.dz-hist { display: inline-flex; gap: 4px; }
.tool { min-height: 36px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.tool:disabled { opacity: .4; cursor: default; }
.tool[aria-pressed="true"] { background: var(--wine); border-color: var(--wine); color: #fff; }
.dz-phone { position: relative; height: min(780px, calc(100svh - 150px)); border-radius: 34px; padding: 9px; background: #1d1719; box-shadow: 0 18px 40px -18px rgba(42,29,31,.45); }
.dz-phone iframe { position: absolute; inset: 9px; width: calc(100% - 18px); height: calc(100% - 18px); border: 0; border-radius: 26px; background: #fff; opacity: 0; pointer-events: none; transition: opacity .18s; }
.dz-phone iframe.on { opacity: 1; pointer-events: auto; }

/* mẫu gốc */
.dz-base { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 18px; background: var(--card); border: 1px solid var(--line); margin-bottom: 12px; }
.dz-base img { width: 64px; height: 80px; object-fit: cover; border-radius: 12px; flex: none; }
.dz-base div { flex: 1; min-width: 0; }
.dz-base b { display: block; font: 500 19px/1.25 var(--serif); }
.dz-base small { color: var(--muted); }
.dz-base .btn { flex: none; }

/* nhóm lựa chọn (gập / mở) */
.grp { background: var(--card); border: 1px solid var(--line); border-radius: 18px; margin-bottom: 10px; }
.grp > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 600; }
.grp > summary::-webkit-details-marker { display: none; }
.grp > summary::after { content: ""; margin-left: auto; width: 9px; height: 9px; border: solid var(--muted); border-width: 0 2px 2px 0; rotate: 45deg; translate: 0 -3px; transition: rotate .2s; }
.grp[open] > summary::after { rotate: 225deg; translate: 0 2px; }
.grp > summary .cur { font-weight: 400; color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grp .in { padding: 0 16px 16px; }
.grp h2 { margin: 14px 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.grp h2:first-child { margin-top: 0; }

/* nút lựa chọn */
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opt { position: relative; min-height: 40px; padding: 0 14px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink); font-size: 14px; }
.opt:hover { border-color: var(--rose); }
.opt[aria-pressed="true"] { border-color: var(--wine); background: var(--wine); color: #fff; }
.opt .def { font-size: 11px; opacity: .75; margin-left: 4px; }
.opt .lock { font-size: 11px; margin-left: 4px; }
.opts--pic .opt { width: 112px; padding: 8px; display: grid; gap: 6px; justify-items: center; font-size: 13px; line-height: 1.25; text-align: center; }
.opts--pic .opt svg { width: 72px; height: 54px; }
.opts--pic .opt[aria-pressed="true"] svg { color: #fff; }

/* bảng màu */
.pals { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.pal { display: grid; gap: 6px; padding: 8px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; font-size: 12.5px; text-align: left; color: var(--ink); }
.pal i { display: flex; height: 26px; border-radius: 7px; overflow: hidden; box-shadow: inset 0 0 0 1px rgba(0,0,0,.08); }
.pal i b { flex: 1; }
.pal[aria-pressed="true"] { border-color: var(--wine); box-shadow: 0 0 0 2px var(--wine); }
.mood { margin: 12px 0 6px; font-size: 12px; color: var(--muted); }
.tune { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tune label { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; }
.tune input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: 10px; flex: none; }
.tune .btn--text { min-height: 30px; padding: 0 6px; font-size: 12px; }

/* font */
.fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; }
.fnt { padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; text-align: left; color: var(--ink); display: grid; gap: 2px; }
.fnt .s { font-size: 26px; line-height: 1.2; }
.fnt .d { font-size: 16px; }
.fnt small { color: var(--muted); font-size: 11.5px; }
.fnt[aria-pressed="true"] { border-color: var(--wine); box-shadow: 0 0 0 2px var(--wine); }

/* thứ tự các phần */
.secs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.secs li { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.secs li.off span { color: var(--muted); text-decoration: line-through; }
.secs li span { flex: 1; }
.secs button { width: 36px; height: 36px; border: 0; border-radius: 10px; background: var(--soft); color: var(--ink); }
.secs button:disabled { opacity: .35; cursor: default; }
.secs .eye { width: auto; padding: 0 10px; font-size: 13px; }

/* ảnh (thiệp thật) */
.slots-dz { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.sl { border: 1px solid var(--line); border-radius: 14px; padding: 8px; background: #fff; display: grid; gap: 6px; }
.sl img { width: 100%; aspect-ratio: 4/5; object-fit: cover; border-radius: 10px; }
.sl b { font-size: 13px; }
.sl .acts { display: flex; flex-wrap: wrap; gap: 4px; }
.sl .btn { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
.stock { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.stock button { padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: none; }
.stock button:hover, .stock button:focus-visible { border-color: var(--wine); }
.stock img { width: 100%; aspect-ratio: 4/5; object-fit: cover; }

/* hộp thoại */
.dz-dlg { border: 0; border-radius: 22px; padding: 24px 20px 20px; width: min(760px, calc(100vw - 24px)); max-height: calc(100svh - 24px); overflow: auto; background: var(--card); color: var(--ink); }
.dz-dlg::backdrop { background: rgba(42,29,31,.55); }
.dz-dlg h2 { font: 500 24px var(--serif); margin: 0 40px 4px 0; }
.dz-dlg .dlg-x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--soft); font-size: 22px; }
#premDlg { width: min(420px, calc(100vw - 24px)); }
#premDlg .row2 { margin-top: 14px; display: grid; gap: 8px; }
.dz-dlg .tpl-grid { max-height: 60svh; overflow: auto; }

.dz-save { gap: 8px; }
.dz-save #saveState { font-size: 13px; }

/* ---------- Điện thoại / máy tính bảng dọc ---------- */
@media (max-width: 900px) {
  .dz-main { display: block; padding: 0 0 110px; }
  .dz-view { position: sticky; top: 61px; z-index: 10; background: var(--bg); padding: 8px 12px 10px; border-bottom: 1px solid var(--line); }
  .dz-tools { margin-bottom: 6px; }
  .dz-phone { height: 46svh; border-radius: 20px; padding: 5px; max-width: 460px; margin: 0 auto; }
  .dz-phone iframe { inset: 5px; width: calc(100% - 10px); height: calc(100% - 10px); border-radius: 16px; }
  .dz-panel { padding: 12px; }
  .dz-save { left: 12px; right: 12px; translate: none; justify-content: flex-end; }
  .dz-save #saveState { margin-right: auto; }
}
@media (max-width: 420px) {
  .opts--pic .opt { width: calc(33.333% - 6px); }
  .opts--pic .opt svg { width: 100%; height: 44px; }
  .dz-save #saveState { display: none; }
  .tune { grid-template-columns: 1fr; }
}
.dz-save .btn--line { color: inherit; border-color: currentColor; opacity: .85; }
.dz-save .btn--line:hover { background: rgba(255,255,255,.1); }
.top-title h1 { margin: 0; font: 500 18px var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
