/* Chế độ beta / khách, nhãn Free / Pro, thư viện ảnh, vương miện. */
/* Chế độ thử nghiệm (Beta) */
.beta { font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; color: #fff; background: var(--brand); border-radius: 999px; padding: 2px 7px; }
.beta-note { margin: 0 0 18px; padding: 8px 12px; border: 1px dashed var(--brand); border-radius: 10px; color: var(--muted); font-size: 13px; background: rgba(109,91,255,.08); }

/* Khách (chưa đăng nhập) / đã đăng nhập */
body:not(.authed) [data-auth], body.authed [data-guest] { display: none !important; }

/* Nhãn Free / Pro trên thẻ bản mẫu */
.tbadge { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; vertical-align: middle; }
.tbadge.free { background: rgba(34,197,94,.18); color: #4ade80; }
.tbadge.pro { background: rgba(109,91,255,.22); color: #b3a8ff; }

/* Tên project chỉ đọc (demo) */
.name[readonly], .name[readonly]:hover, .name[readonly]:focus { border-color: transparent; background: transparent; cursor: default; color: var(--text); }
.dlg label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.dlg label.check input { width: 16px; height: 16px; accent-color: var(--brand); flex: none; }

/* Ảnh mẫu của bản mẫu trong hộp thoại chọn: thanh cuộn nằm trong khung ảnh, cả hộp thoại không cuộn */
#dlgNew, #dlgTemplate { overflow: hidden; width: min(640px, calc(100vw - 32px)); }
#dlgNew .dlg, #dlgTemplate .dlg { max-height: calc(100vh - 48px); }
#dlgNew .dlg .field { flex: 1 1 auto; min-height: 0; }
#dlgNew .dlg .checks { flex: 1 1 auto; min-height: 90px; max-height: none; overflow-y: auto; }
.tplscroll { flex: none; overflow-x: auto; overflow-y: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.tplprev { display: block; width: 100%; min-width: 480px; height: auto; } /* đủ 5 màn hình theo bề ngang hộp thoại; màn hình hẹp thì cuộn ngang */

/* Thư viện ảnh */
#dlgLibrary { width: min(640px, calc(100vw - 32px)); }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; max-height: 55vh; overflow-y: auto; padding: 2px; }
.dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; width: 100%; min-height: 170px; padding: 20px; border: 2px dashed var(--line); border-radius: 12px; background: var(--panel-2); color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; text-align: center; }
.dropzone b { color: var(--text); font-size: 14px; }
.dropzone:hover, .dropzone.over { border-color: var(--brand); color: var(--text); }
#dlgImage .libgrid { max-height: 46vh; overflow-y: auto; }
.libitem { position: relative; line-height: 0; }
.libpick { width: 100%; padding: 0; border: 2px solid transparent; border-radius: 10px; background: var(--panel-2); cursor: pointer; overflow: hidden; }
.libpick.sel { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.dropzone { min-height: 120px; }
.dropzone.busy { pointer-events: none; }
.spinner { width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#dlgImage .libgrid { max-height: 34vh; }
.libpick:hover { border-color: var(--brand); }
.libhead { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 8px; }
.libsort { display: flex; align-items: center; gap: 6px; }
.libsort label { display: flex; flex-direction: row; align-items: center; white-space: nowrap; gap: 8px; color: var(--muted); font-size: 12px; }
.libsort select { width: 100px; max-width: 100%; flex: none; }
.libdir { padding: 4px 10px; }
.libpick img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; display: block; }
.libcap { display: flex; flex-direction: column; gap: 1px; margin-top: 4px; line-height: 1.25; font-size: 11px; min-width: 0; }
.libname { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.libdim { color: var(--muted); }

body.in-editor #btnDemo { display: none; }

/* Biểu tượng Pro (vương miện) */
.crown { width: 14px; height: 14px; fill: #fbbf24; flex: none; }
.btn.proable { display: inline-flex; align-items: center; gap: 6px; }
.probadge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; background: rgba(251,191,36,.14); color: #fbbf24; font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; white-space: nowrap; flex: none; }
.pcard { position: relative; }
.card-crown { position: absolute; top: 18px; right: 18px; width: 28px; height: 28px; border-radius: 50%; background: rgba(15,17,21,.78); display: grid; place-items: center; pointer-events: none; box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.card-crown .crown { width: 16px; height: 16px; }
.tplwrap { position: relative; flex: none; }
.card-crown.prevcrown { top: 8px; right: 8px; }
.ssel-item .crown, .ssel-btn .crown { margin-left: 6px; vertical-align: -2px; }
#dlgNew .ssel-btn, #dlgTemplate .ssel-btn { font-size: 14px; padding: 8px 28px 8px 10px; }
