/* ===== Ghép ảnh vào frame: dùng chung cho trang quản lý và trang khách =====
   Tên lớp đều có tiền tố fr- để không đụng kiểu sẵn có của hai trang. */

/* Hộp hỏi của thư viện phải nổi trên khung ghép frame (khung ghép nằm trên album) */
.swal2-container { z-index: 5000 !important; }

.fr-modal { position: fixed; inset: 0; background: #fafafa; z-index: 3200; display: flex; flex-direction: column; font-family: 'Inter', sans-serif; color: #111; }
.fr-head { display: flex; align-items: center; gap: 8px; padding: 16px 16px; background: #fff; border-bottom: 1px solid #e5e5e5; flex: none; }
.fr-head h3 { flex: 1; margin: 0; font-size: 14px; font-weight: 700; }
.fr-x { background: none; border: none; font-size: 28px; line-height: 1; color: #666; cursor: pointer; padding: 4px 12px; min-width: 44px; min-height: 44px; font-family: 'Inter', sans-serif; }
.fr-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.fr-wrap { max-width: 980px; margin: 0 auto; padding: 16px; box-sizing: border-box; }

.fr-card { background: #fff; border: 1px solid #e5e5e5; border-radius: 16px; padding: 16px; margin-bottom: 16px; }
.fr-card h4 { font-size: 12px; margin: 0 0 12px; }
.fr-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fr-btn { padding: 8px 16px; border-radius: 10px; border: 1px solid #e5e5e5; background: #fff; font: 600 12px 'Inter', sans-serif; cursor: pointer; color: #111; white-space: nowrap; box-sizing: border-box; }
/* Nút dạng label (chọn file): căn chữ giữa như nút thật khi nút cao 44px trên điện thoại */
label.fr-btn { display: inline-flex; align-items: center; justify-content: center; }
.fr-btn.solid { background: #111; color: #fff; border-color: #111; }
.fr-btn.danger { color: #dc2626; border-color: #e5e5e5; }
.fr-btn:disabled { opacity: .45; cursor: not-allowed; }
.fr-big { width: 100%; padding: 16px; font-size: 14px; }
.fr-hint { font-size: 12px; color: #666; line-height: 1.6; margin: 8px 0 0; }
.fr-card input[type=text], .fr-card input[type=number] { padding: 8px 8px; border: 1px solid #e5e5e5; border-radius: 10px; font: 13px 'Inter', sans-serif; width: 100%; box-sizing: border-box; }
.fr-label { font-size: 12px; font-weight: 600; color: #666; display: block; margin-bottom: 4px; }
.fr-grid5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
/* Nút bật/tắt cơ sở: dùng nút thay ô tích vì trang khách có kiểu chung cho mọi
   ô nhập (đệm 14px, cách dưới 15px), ô tích dính kiểu đó là lệch hẳn */
.fr-chip.on { background: #111; color: #fff; border-color: #111; }
.fr-chip.on::before { content: '✓ '; }
/* Gỡ kiểu ô nhập chung của trang khách khỏi thanh phóng to */
.fr-modal input[type=range] { padding: 0; margin: 0; border: none; box-shadow: none; height: auto; background: none; }

/* Danh sách frame */
.fr-flist { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.fk-trong { grid-column: 1 / -1; margin: 24px 8px; text-align: center; font: 600 14px/1.5 "Inter", sans-serif; color: #18181b; }
.fk-trong span { font-weight: 400; font-size: 14px; color: #71717a; }
.fr-fwrap { position: relative; }
.fr-fitem { width: 100%; border: 1px solid #e5e5e5; border-radius: 10px; padding: 8px; background: #fff; cursor: pointer; text-align: left; font-family: 'Inter', sans-serif; color: #111; display: block; box-sizing: border-box; }
.fr-fitem .fr-fimg { display: block; width: 100%; aspect-ratio: 3/2; border-radius: 10px; overflow: hidden;
                     background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/16px 16px; }
/* isolation: các lớp ảnh chỉ xếp chồng với nhau trong khung, không đè lên nút ✕ / ⠿ */
.fr-fitem .fr-fimg { position: relative; isolation: isolate; }
.fr-fdel { z-index: 5; }
/* Frame cao cấp: nhãn bên admin, khoá bên khách */
.fr-cao { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 6px; background: #111; color: #fff; font-size: 12px; font-weight: 700; vertical-align: middle; }
.fr-fitem.khoa { cursor: default; }
.fr-fitem.khoa .fr-fimg img { opacity: .45; }
.fr-lock { position: absolute; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; }
/* Ổ khoá co theo ảnh thu nhỏ: khoảng 1/5 bề ngang, không quá to trên điện thoại nhỏ */
.fr-lock svg { width: clamp(26px, 20%, 44px); height: auto; aspect-ratio: 1; padding: clamp(8px, 4%, 8px); box-sizing: border-box; border-radius: 50%; background: rgba(17,17,17,.82); stroke: #fff; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.fr-fitem .fr-fimg img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.fr-fitem .fr-fimg svg.fr-o { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.fr-fitem.khoa .fr-fimg svg.fr-o { opacity: .45; }
/* Kéo ⠿ để xếp thứ tự frame khách thấy */
.fr-fgrip { position: absolute; top: 6px; left: 6px; z-index: 3; width: 30px; height: 30px; border-radius: 10px; border: 1px solid #e5e5e5; background: #fff;
            display: flex; align-items: center; justify-content: center; font-size: 16px; color: #666; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
.fr-fwrap.drag .fr-fitem { border-color: #111; box-shadow: 0 6px 18px rgba(0,0,0,.15); }
.fr-fitem b { display: block; font-size: 12px; margin-top: 8px; }
.fr-fitem span.fr-meta { display: block; font-size: 12px; color: #666; }
.fr-fitem.off { opacity: .5; }
.fr-fdel { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 1px solid #e5e5e5; background: #fff;
           color: #dc2626; font: 700 16px 'Inter', sans-serif; cursor: pointer; line-height: 1; }

/* Khung làm việc: chặn cuộn trang khi kéo trên khung */
.fr-stage { position: relative; width: 100%; touch-action: none; user-select: none; -webkit-user-select: none;
            background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/20px 20px; border-radius: 10px; overflow: hidden; }
.fr-stage img.fr-frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Ô bên quản lý: ảnh giả (để thấy frame nằm trên hay dưới ảnh), frame, khung điều khiển */
.fr-efill { position: absolute; background: repeating-linear-gradient(45deg, #a1a1aa 0 14px, #d4d4d8 14px 28px); }
.fr-eslot { position: absolute; border: 2px solid rgba(24,24,27,.4); cursor: move; --hs: 16px; box-sizing: border-box; }
/* Ô đang chọn nổi lên trên: ô to ra chạm ô bên cạnh thì chấm kéo không bị che */
.fr-eslot.sel { border: 3px solid #18181b; z-index: 2; }
.fr-eslot .fr-num { position: absolute; left: 4px; top: 4px; background: #18181b; color: #fff; font: 700 12px 'Inter', sans-serif; padding: 2px 8px; border-radius: 6px; }
/* Ô lấy ảnh ô khác / có hiệu ứng: nhãn nhỏ dưới số ô */
.fr-eslot .fr-lk { position: absolute; left: 4px; top: 26px; right: 4px; background: rgba(24,24,27,.82); color: #fff; font: 600 12px 'Inter', sans-serif; padding: 2px 8px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fr-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fa-lk { margin-top: 12px; }
.fa-lk select, .fa-hu select { width: 100%; max-width: none; height: 38px; border: 1px solid #d4d4d8; border-radius: 10px; padding: 0 8px; font: 500 14px 'Inter', sans-serif; background: #fff; color: #111; }
@media (max-width: 560px) { .fr-grid2 { grid-template-columns: 1fr; } }
.fa-hu { margin-top: 8px; }
.fa-hu input[type=color] { width: 100%; height: 38px; padding: 2px; border: 1px solid #d4d4d8; border-radius: 10px; background: #fff; }
canvas.fr-hu { display: block; }
/* Mặt lưng trong màn sửa frame */
.fa-ix-hai { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
.fa-ix-hai figure { margin: 0; flex: 1 1 220px; max-width: 360px; }
.fa-ix-hai canvas { display: block; width: 100%; height: auto; border: 1px solid #d4d4d8; border-radius: 6px; background: repeating-conic-gradient(#f4f4f5 0% 25%, #fff 0% 50%) 0 0 / 16px 16px; }
.fa-ix-hai figcaption { margin-top: 4px; font-size: 12px; color: #71717a; }
.fa-chia { text-align: left; font-size: 14px; }
.fa-chia-nhanh { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.fa-chia-so { display: flex; flex-wrap: wrap; gap: 8px; }
.fa-chia-so label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.fa-chia-so input { width: 110px; height: 36px; border: 1px solid #d4d4d8; border-radius: 10px; padding: 0 8px; font: 600 14px 'Inter', sans-serif; }
.fa-instax { margin-top: 8px; padding: 8px 12px; border: 1px solid #e4e4e7; border-radius: 10px; background: #fafafa; font-size: 12px; line-height: 1.5; color: #3f3f46; }
.fa-instax p { margin: 0 0 8px; }
.fa-instax p:last-child { margin: 0; }
.fa-instax .fa-ok { color: #18181b; font-weight: 600; }
.fa-instax .fa-do { color: #dc2626; font-weight: 600; }
.fa-lung { margin: 0 0 12px; }
.fa-lung-o { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; padding: 8px; border: 1px solid #e4e4e7; border-radius: 10px; background: #fff; }
.fa-lung-h { display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: 12px; color: #71717a; }
.fa-lung-h canvas { max-width: 240px; max-height: 300px; border-radius: 6px; box-shadow: 0 0 0 1px #e4e4e7; }
#fa-lung-xem { cursor: crosshair; }
.fa-lung-ct { flex: 1; min-width: 220px; }
.fa-lung-ct select { width: 100%; height: 38px; border: 1px solid #d4d4d8; border-radius: 10px; padding: 0 8px; font: 500 14px 'Inter', sans-serif; background: #fff; }
/* Thử như khách: hàng nút thêm ảnh thử trên bảng phải */
#thu-hang { margin: 0; padding: 12px 16px 4px; }
#thu-hang .fr-hint { margin: 8px 0 0; }
#thu-hang .thu-nut { display: block; width: 100%; text-align: center; padding: 12px; font-size: 14px; }
/* Chấm kéo như Canva: 4 góc đổi cả hai chiều, 4 cạnh chỉ đổi một chiều */
.fr-h { position: absolute; width: var(--hs); height: var(--hs); background: #fff; border: 2px solid #18181b; border-radius: 50%;
        margin: calc(var(--hs) / -2) 0 0 calc(var(--hs) / -2); touch-action: none; box-sizing: border-box; }
.fr-h.side { border-radius: 6px; }
.fr-h.n, .fr-h.s { width: calc(var(--hs) * 1.6); margin-left: calc(var(--hs) * -0.8); }
.fr-h.e, .fr-h.w { height: calc(var(--hs) * 1.6); margin-top: calc(var(--hs) * -0.8); }
.fr-h.rt { cursor: grab; background: #18181b; }
.fr-h.rt::before { content: ''; position: absolute; left: 50%; bottom: 100%; width: 2px; height: 14px; margin-left: -1px; background: #18181b; }

/* Ô bên khách: không viền, ô trống có nền xám và dấu cộng */
.fr-cslot { position: absolute; overflow: hidden; background: #e5e5e5; box-sizing: border-box; }
.fr-cslot img { position: absolute; left: 50%; top: 50%; max-width: none; pointer-events: none; }
.fr-cmark { position: absolute; pointer-events: none; display: flex; align-items: center; justify-content: center; }
.fr-plus { color: #777; font-family: 'Inter', sans-serif; font-weight: 200; line-height: 1; display: flex; align-items: center; justify-content: center; }

.fr-tool { display: none; margin-top: 12px; }
.fr-tool.on { display: block; }
.fr-modal input[type=range] { width: 100%; accent-color: #111; }

/* Bảng chọn ảnh trong lượt chụp */
.fr-pk { position: fixed; inset: 0; background: #fff; z-index: 3300; display: flex; flex-direction: column; font-family: 'Inter', sans-serif; color: #111; }
/* Frame thu nhỏ có số ô: chỉ hiện khi đang chọn ảnh, để khách biết số nào là ô nào */
.fr-mini { position: relative; width: min(100%, 300px); margin: 8px auto 0; border-radius: 6px; overflow: hidden; flex: none;
           background: repeating-conic-gradient(#eee 0 25%, #fff 0 50%) 0 0/12px 12px; }
.fr-mini img { position: absolute; inset: 0; width: 100%; height: 100%; }
.fr-mini .fr-mslot { position: absolute; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.fr-mini .fr-mslot b { background: #fff; color: #111; border: 1px solid #111; font: 700 12px/1 'Inter', sans-serif; min-width: 20px; height: 20px; padding: 0 4px;
                       border-radius: 10px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
/* Ô đang chọn: chỉ vòng số chuyển đen, không tô tối cả ô */
.fr-mini .fr-mslot.co { align-items: flex-start; justify-content: flex-start; padding: 4px; }   /* ô có ảnh: số lên góc, khỏi che mặt */
.fr-mini .fr-mslot.on b { background: #111; color: #fff; }
.fr-pk-grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: grid; grid-template-columns: repeat(3, 1fr);
              grid-auto-rows: max-content; gap: 8px; padding: 12px; align-content: start; }
@media (min-width: 560px) { .fr-pk-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .fr-pk-grid { grid-template-columns: repeat(5, 1fr); } }
/* Ô ảnh không tự cắt phần thừa: bảng bị ép vừa chiều cao màn hình, ô có cắt
   thừa thì trình duyệt được bóp hàng lại, ảnh chồng lên nhau và chạm ảnh này
   trúng ảnh kia. Phần cắt để cho khung ảnh bên trong. */
.fr-pk-item { position: relative; display: block; width: 100%; padding: 0; border: 2px solid transparent; border-radius: 10px; background: #fafafa; cursor: pointer; }
.fr-pk-ph { display: block; width: 100%; aspect-ratio: 3/2; border-radius: 10px; overflow: hidden; }
.fr-pk-ph img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Ảnh đã chọn: chỉ vòng số ô chuyển đen, không viền đen quanh ảnh */
.fr-pk-tick { position: absolute; top: 6px; right: 6px; min-width: 26px; height: 26px; padding: 0 8px; border-radius: 10px; border: 2px solid #fff; box-sizing: border-box;
              background: rgba(0,0,0,.25); color: #fff; font: 700 12px/22px 'Inter', sans-serif; text-align: center; }
.fr-pk-item.on .fr-pk-tick { background: #111; }
.fr-pk-used { position: absolute; left: 6px; bottom: 6px; background: #111; color: #fff; font: 700 12px 'Inter', sans-serif; padding: 4px 8px; border-radius: 10px; }
/* Hai nguồn ảnh: lượt chụp và ảnh trong máy */
.fr-tabs { display: flex; gap: 8px; padding: 8px 12px 0; flex: none; }
.fr-tab { flex: 1; padding: 8px; border: 1px solid #e5e5e5; border-radius: 10px; background: #fff; font: 600 12px 'Inter', sans-serif; color: #111; cursor: pointer; min-height: 44px; }
.fr-tab.on { background: #111; color: #fff; border-color: #111; }
.fr-pk-add { border: 2px dashed #d4d4d8; cursor: pointer; }
.fr-pk-add .fr-pk-ph { display: flex; align-items: center; justify-content: center; font: 600 14px 'Inter', sans-serif; color: #111; }
.fr-pk-foot { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-top: 1px solid #e5e5e5; }
.fr-pk-foot span { flex: 1; font-size: 14px; color: #666; }

.fr-res img { width: 100%; border-radius: 10px; border: 1px solid #e5e5e5; display: block; }
.fr-bar { height: 8px; background: #f4f4f5; border-radius: 6px; overflow: hidden; margin-top: 8px; }
.fr-bar span { display: block; height: 100%; width: 0; background: #111; transition: width .3s; }
.fr-hidden { display: none !important; }

/* Bảng lớp của frame (admin): trên cùng ở đầu danh sách, kéo ⠿ để đổi thứ tự */
.fa-layers { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.fa-lrow { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #e5e5e5; border-radius: 10px; padding: 8px 8px; }
.fa-lrow.drag { border-color: #111; box-shadow: 0 4px 14px rgba(0,0,0,.12); }
.fa-lh { cursor: grab; touch-action: none; font-size: 20px; color: #71717a; padding: 8px 4px; user-select: none; -webkit-user-select: none; }
.fa-lthumb { width: 46px; height: 34px; border-radius: 6px; flex: none; overflow: hidden; display: flex; align-items: center; justify-content: center;
             background: repeating-conic-gradient(#e5e5e5 0 25%, #fff 0 50%) 0 0 / 10px 10px; }
.fa-lthumb img { width: 100%; height: 100%; object-fit: contain; }
.fa-lthumb.ph { background: repeating-linear-gradient(45deg, #a1a1aa 0 6px, #d4d4d8 6px 12px); }
.fa-lname { flex: 1; min-width: 60px; font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fa-layers input.fa-lop { width: 90px; flex: none; accent-color: #111; }
.fa-lpct { font-size: 12px; color: #666; width: 34px; text-align: right; }
.fa-lbtn { padding: 8px 8px; font-size: 12px; }
/* Điện thoại: thanh độ đậm + nút lên/xuống xuống dòng 2 (nút 44px không còn tràn khỏi hàng) */
@media (max-width: 560px) {
    .fa-lrow { flex-wrap: wrap; row-gap: 4px; }
    .fa-lname { flex: 1 1 0; }
    .fa-layers input.fa-lop { flex: 1 1 80px; width: auto; }
}

/* ===== Màn ghép bên khách: dồn chỗ cho frame trên điện thoại ===== */
.fk-hbtn { padding: 8px 12px; font-size: 12px; }
#fk-modal[data-step=comp] .fr-wrap { padding: 8px 8px 0; }
.fk-comp { padding: 0 !important; border: 0 !important; background: transparent !important; margin: 0 !important; }
.fk-comp .fr-stage { margin: 0 auto; touch-action: manipulation; }
.fk-tip { text-align: center; margin: 8px 0 0; }
.fk-rot { text-align: center; font-size: 12px; font-weight: 600; color: #111; background: #fff; border: 1px dashed #d4d4d8; border-radius: 10px; padding: 8px; margin-bottom: 8px; }
/* Thanh dưới luôn hiện: tiến độ + Ghép xong, không phải cuộn tìm nút */
/* Thanh dưới dính sát đáy màn hình */
.fk-foot { position: fixed; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 12px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: #fff; border-top: 1px solid #e5e5e5; z-index: 6; }
#fk-modal[data-step=comp] .fr-body { padding-bottom: 90px; }
.fk-foot span { flex: 1; font-size: 14px; font-weight: 600; color: #444; }
.fk-foot .fr-btn { padding: 16px 24px; font-size: 14px; }

/* Màn chỉnh một ô: ô to giữa màn, frame xung quanh mờ đi */
.fk-ed { position: fixed; inset: 0; z-index: 3250; background: #fafafa; display: none; flex-direction: column; font-family: 'Inter', sans-serif; color: #111; }
.fk-ed.on { display: flex; }
.fk-nav { padding: 8px 16px; font-size: 20px; line-height: 1; }
.fk-ed-view { flex: 1; position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: #e5e5e5; min-height: 200px; }
.fk-ed-in { position: absolute; }
.fk-ed-in .fr-frame { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.fk-ed-tools { flex: none; background: #fff; border-top: 1px solid #e5e5e5; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }
.fk-ed-tools input[type=range] { width: 100%; accent-color: #111; }
/* Xoay ngang: công cụ sang bên phải, ô ảnh chiếm phần còn lại */
@media (orientation: landscape) and (max-height: 520px) {
    .fk-ed.on { display: grid; grid-template-columns: 1fr 260px; grid-template-rows: auto 1fr; }
    .fk-ed .fr-head { grid-column: 1 / -1; padding: 8px 12px; }
    .fk-ed-tools { border-top: 0; border-left: 1px solid #e5e5e5; overflow-y: auto; }
    /* Màn ghép xoay ngang: thanh đầu gọn, frame bên trái cao hết cỡ, nút bên phải */
    #fk-modal .fr-head { padding: 8px 12px; }
    #fk-modal[data-step=comp] .fr-wrap { max-width: none; padding: 8px 8px 0; }
    #fk-modal[data-step=comp] .fk-comp { display: flex; align-items: flex-start; gap: 8px; }
    .fk-comp .fr-stage { margin: 0; flex: none; }
    #fk-modal[data-step=comp] .fr-body { padding-bottom: 0; }
    .fk-foot { position: static; flex-direction: column; align-items: stretch; width: 160px; flex: none; margin: 0; border: 1px solid #e5e5e5; border-radius: 10px; padding: 12px; }
    .fk-tip, .fk-rot { display: none !important; }
}

/* Bộ lọc màu (admin) */
.fr-select { height: 38px; border: 1px solid #d4d4d8; border-radius: 10px; padding: 0 8px; font: 500 14px 'Inter', sans-serif; background: #fff; max-width: 180px; }
.ft-prev { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.ft-prev canvas { width: 100%; height: auto; border-radius: 10px; display: block; background: #e5e5e5; }
.ft-sl { margin-bottom: 8px; }
.ft-sl input[type=range] { width: 100%; }
@media (max-width: 600px) { .ft-prev { grid-template-columns: 1fr; } }

/* Bên khách: chỗ trong suốt của frame hiện nền xám trơn thay cho ô lưới.
   Ô lưới chỉ có ích cho quản lý nhìn chỗ nào trong suốt; khách nhìn rối mắt. */
#fk-modal .fr-fimg, #fk-modal .fr-stage, #fk-pk .fr-mini { background: #e5e5e5; }

@media (hover: none) and (pointer: coarse) {
    .fr-btn { min-height: 44px; }
    .fr-card input[type=text], .fr-card input[type=number] { font-size: 16px; min-height: 44px; }
    .fr-eslot { --hs: 26px; }
}
@media (max-width: 560px) { .fr-grid5 { grid-template-columns: repeat(3, 1fr); } }

/* Danh sách frame phía khách (V9): lưới 2 cột ngay trên nền, không bọc thêm khung; ảnh frame to */
#fk-pick.fr-card { background: none; border: none; padding: 0; }
#fk-list.fr-flist { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { #fk-list.fr-flist { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
#fk-list .fr-fitem .fr-fimg { aspect-ratio: 1 / 1; }
#fk-list .fr-fitem b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fk-list .fr-fitem span.fr-meta { color: #71717a; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Lọc frame theo nhóm: một hàng nút trượt ngang */
.fk-locs { grid-column: 1 / -1; display: flex; gap: 8px; overflow-x: auto; padding: 0 0 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.fk-locs::-webkit-scrollbar { display: none; }
.fk-loc { flex: none; min-height: 44px; padding: 0 16px; border: 1px solid #e5e5e5; border-radius: 22px; background: #fff; color: #111; font: 600 14px 'Inter', sans-serif; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.fk-loc span { font-weight: 500; color: #71717a; }
.fk-loc.on { background: #111; border-color: #111; color: #fff; }
.fk-loc.on span { color: #a1a1aa; }
/* Màn xem lại ảnh ghép (V3): một lớp, ảnh căn giữa, câu nhắc căn giữa */
#fk-res.fr-card { background: none; border: none; padding: 0; }
#fk-res img { border: none; border-radius: 6px; max-height: 62vh; width: auto; max-width: 100%; margin: 0 auto; box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#fk-res-info { text-align: center; margin: 12px 0 0; }
/* Ô tự lấy ảnh của ô khác (V11) */
.fk-tu span { background: rgba(255,255,255,.92); color: #18181b; font: 600 12px/1 'Inter', sans-serif; padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
/* Chọn ảnh từ máy (V2): nút rộng cùng lề lưới ảnh */
.fr-pk-addbtn { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; border: 1px solid #d4d4d8; border-radius: 10px;
                background: #fff; font: 600 14px 'Inter', sans-serif; color: #111; cursor: pointer; box-sizing: border-box; }
.fr-pk-addbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.fk-may-trong { grid-column: 1 / -1; text-align: center; margin: 16px 0 0; }
#fk-pk-count.canh { color: #dc2626; }

/* Tiêu đề nhóm frame trong danh sách khách chọn */
.fr-nhom-ti { grid-column: 1 / -1; font: 700 12px 'Inter', sans-serif; color: #111; margin: 8px 0 -2px; }
.fr-nhom-ti span { font-weight: 500; text-transform: none; letter-spacing: 0; color: #71717a; }

/* Đang ghép frame: không cho chụm phóng cả trang (frame-khach.js fkKhoaPhong) */
body.fk-mo, body.fk-mo .fr-modal, body.fk-mo .fk-ed, body.fk-mo .fr-pk { touch-action: pan-x pan-y; }

/* Bảng "Ghép ảnh của lượt nào?" (khách chụp nhiều lượt): mỗi lượt một ô to, dễ chạm */
.swal2-radio.fk-chon-luot { display: flex !important; flex-direction: column; align-items: stretch; gap: 8px; padding: 0 8px; }
.swal2-radio.fk-chon-luot label { margin: 0 !important; display: flex; align-items: center; gap: 12px; padding: 16px 16px; border: 1.5px solid #d4d4d8; border-radius: 10px; font-size: 16px; font-weight: 600; color: #111; cursor: pointer; }
.swal2-radio.fk-chon-luot label:has(input:checked) { border-color: #111; box-shadow: 0 0 0 1px #111; }
.swal2-radio.fk-chon-luot input { accent-color: #111; width: 18px; height: 18px; margin: 0; }

/* ===== Màn sửa frame: 4 thẻ ===== */
.fa-dau { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.fa-dau img { width: 46px; height: 62px; object-fit: contain; background: #f4f4f5; border-radius: 6px; box-shadow: 0 0 0 1px #e4e4e7; }
.fa-dau-ten { display: flex; flex-direction: column; gap: 2px; min-width: 200px; flex: 1; }
.fa-dau-ten input { font: 800 20px 'Inter', sans-serif; border: 1px solid transparent; border-radius: 10px; padding: 4px 8px; margin-left: -8px; background: transparent; color: #111; }
.fa-dau-ten input:hover, .fa-dau-ten input:focus { border-color: #d4d4d8; background: #fff; outline: none; }
#fa-dau-phu { font-size: 12px; color: #71717a; }
.fa-tt { font: 700 12px 'Inter', sans-serif; letter-spacing: .4px; padding: 4px 12px; border-radius: 999px; border: 1px solid #18181b; color: #18181b; background: #fff; }
.fa-tt.dung { background: #18181b; color: #fff; }
.fa-con-viec { margin-left: auto; font-size: 14px; color: #52525b; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fa-con-viec b { color: #111; }
.fa-lam { border: none; background: none; padding: 0; font: 700 14px 'Inter', sans-serif; color: #111; border-bottom: 1.5px solid #111; cursor: pointer; }
.fa-thes { display: flex; gap: 2px; margin: 16px -4px 16px; border-bottom: 1px solid #e4e4e7; overflow-x: auto; }
.fa-the-nut { border: none; background: none; padding: 12px 16px; font: 700 14px 'Inter', sans-serif; color: #71717a; border-bottom: 3px solid transparent; cursor: pointer; white-space: nowrap; display: flex; align-items: center; }
.fa-the-nut b { display: inline-flex; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 50%; background: #e4e4e7; color: #3f3f46; font-size: 12px; margin-right: 8px; }
.fa-the-nut.on { color: #111; border-bottom-color: #111; }
.fa-the-nut.on b { background: #111; color: #fff; }
.fa-the-nut i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-left: 8px; background: #a1a1aa; }
.fa-the-nut i.do { background: #ef4444; }
.fa-the { display: none; }
.fa-the.on { display: block; }
.fa-hai { display: flex; gap: 16px; align-items: flex-start; }
.fa-trai { flex: 1.15; min-width: 0; display: flex; flex-direction: column; align-items: center; }
.fa-phai { flex: 1; min-width: 300px; display: flex; flex-direction: column; gap: 12px; }
.fa-hai-deu > * { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.fa-hai-deu > .fa-hop { display: block; }
.fa-hop { background: #fff; border: 1px solid #e4e4e7; border-radius: 10px; padding: 16px 16px; }
.fa-hop h5 { margin: 0 0 8px; font: 700 12px 'Inter', sans-serif; color: #111; }
.fa-h5-phu { font-weight: 500; text-transform: none; color: #71717a; letter-spacing: 0; }
.fa-hep { max-width: 640px; margin-bottom: 12px; }
.fa-keo { margin: 8px 0 0; text-align: center; }
.fa-vt { margin-top: 16px; padding-top: 12px; border-top: 1px dashed #e4e4e7; }
.fa-kiem { list-style: none; margin: 8px 0 0; padding: 0; }
.fa-kiem li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid #f4f4f5; font-size: 14px; }
.fa-kiem .fa-v { flex: none; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font: 700 12px 'Inter', sans-serif; }
.fa-kiem li.ok .fa-v { background: #111; color: #fff; }
.fa-kiem li.thieu .fa-v { border: 2px solid #ef4444; color: #dc2626; }
.fa-kiem li.nen .fa-v { border: 1.5px solid #a1a1aa; color: #71717a; }
.fa-kiem-chu { flex: 1; }
.fa-kiem small { color: #71717a; font-size: 12px; }
.fa-kiem .fa-lam { font-size: 12px; }
.fa-kiem li.nen .fa-lam { color: #71717a; border-bottom-color: #a1a1aa; font-weight: 600; }
#fa-cho-dung:disabled { opacity: .35; cursor: not-allowed; }
.fa-chan { display: flex; align-items: center; gap: 8px; margin-top: 16px; padding-top: 16px; border-top: 1px solid #e4e4e7; }
#fa-luu-ghi { color: #dc2626; font-weight: 600; }
@media (max-width: 900px) { .fa-hai { flex-direction: column; } .fa-phai { min-width: 0; width: 100%; } .fa-con-viec { margin-left: 0; width: 100%; } }
/* Màn sửa frame rộng hơn (2 cột ở thẻ Ô ảnh); tên frame ở thanh đầu trông như chữ, bấm mới thành ô nhập */
#fa-modal .fr-wrap { max-width: 1240px; }
#fa-edit .fa-dau-ten input[type=text] { font: 800 20px 'Inter', sans-serif; border: 1px solid transparent; border-radius: 10px; padding: 4px 8px; margin-left: -8px; background: transparent; width: 100%; max-width: 420px; }
#fa-edit .fa-dau-ten input[type=text]:hover, #fa-edit .fa-dau-ten input[type=text]:focus { border-color: #d4d4d8; background: #fff; outline: none; }
#fa-edit .fa-hu.fr-grid5 { grid-template-columns: repeat(3, 1fr); }

/* Thẻ ② Màu: xem trước trước / sau */
.fa-mau-xem { display: flex; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.fa-mau-xem > div { flex: 1; min-width: 200px; }
.fa-mau-xem canvas { display: block; width: 100%; height: auto; border-radius: 10px; box-shadow: 0 0 0 1px #e4e4e7; background: #f4f4f5; }

/* Danh sách frame (quản lý): một hàng cuộn ngang, thẻ cùng cỡ, chữ dài cắt gọn */
#fa-list.fr-flist { display: flex; gap: 8px; overflow-x: auto; overflow-y: hidden; padding: 2px 2px 12px; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
#fa-list .fr-fwrap { flex: 0 0 168px; scroll-snap-align: start; }
#fa-list .fr-fitem { height: 100%; }
#fa-list .fr-fitem b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fa-list .fr-fitem span.fr-meta { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
#fa-list .fr-tt { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; border: 1px solid #18181b; color: #18181b; margin-right: 2px; }
#fa-list .fr-tt.dung { background: #18181b; color: #fff; }
#fa-list .fr-fwrap.mo .fr-fitem { border: 2px solid #111; padding: 8px; }
/* Chưa mở frame nào: lưới như danh sách frame bên khách (2 cột điện thoại, 3-4 cột máy tính) + hàng nút lọc */
#fa-list.luoi { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; overflow: visible; padding: 2px; }
@media (min-width: 640px) { #fa-list.luoi { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { #fa-list.luoi { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
#fa-list.luoi .fr-fwrap { flex: none; min-width: 0; }
#fa-list.luoi .fr-fitem .fr-fimg { aspect-ratio: 1 / 1; }
#fa-list.luoi .fr-fitem b { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#fa-list .fk-locs { grid-column: 1 / -1; }
#fa-list:not(.luoi) .fk-locs { display: none; }
#fa-list::-webkit-scrollbar { height: 8px; }
#fa-list::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 6px; }
/* Nút xoá frame đủ 44px để chạm trên điện thoại (nghiệm thu iPhone 24/10/2026) */
@media (hover: none) and (pointer: coarse) { .fr-fdel { width: 44px; height: 44px; top: 2px; right: 2px; } }

/* Lưới quản lý frame: nút xoá nhỏ, nhạt (vùng chạm vẫn 44px) để không lấn ảnh frame */
#fa-list.luoi .fr-fdel { width: 32px; height: 32px; top: 4px; right: 4px; font-size: 14px; color: #71717a; border-color: #e4e4e7; background: rgba(255,255,255,.92); }
@media (hover: none) and (pointer: coarse) {
    #fa-list.luoi .fr-fdel { width: 44px; height: 44px; top: 0; right: 0; border: none; background: none; }
    #fa-list.luoi .fr-fdel::before { content: ''; position: absolute; inset: 8px; border-radius: 50%; background: rgba(255,255,255,.92); border: 1px solid #e4e4e7; z-index: -1; }
}

/* Video Instax: công tắc trong phần Instax của màn sửa frame */
.fa-ix-video { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; padding: 12px; border: 1px solid #e4e4e7; border-radius: 10px; background: #fafafa; }
.fa-ix-video label { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; line-height: 1.4; cursor: pointer; }
.fa-ix-video input { width: 20px; height: 20px; flex: none; accent-color: #111; margin-top: 1px; }

/* Màn Xem lại frame Instax có video: tấm in + ảnh trang trí (trái), video (phải) */
.fk-res-hai { display: flex; gap: 12px; align-items: flex-start; justify-content: center; }
.fk-res-in { flex: 1; min-width: 0; text-align: center; }
.fk-nhan { display: block; font-size: 12px; color: #52525b; margin: 0 0 4px; text-align: center; }
.fk-vid { flex: none; width: 34%; max-width: 200px; text-align: center; }
/* Có video: video bên trái to, cao ngang mép dưới ảnh trang trí; tấm in + ảnh trang trí thu nhỏ bên phải (vkCanVideo tính bề rộng) */
.fk-res-hai.co-vid .fk-vid { order: -1; max-width: none; }
.fk-res-hai.co-vid .fk-res-in { flex: 1 1 0; min-width: 0; }
.fk-res-hai.co-vid #fk-res-img { width: 100%; height: auto; max-height: none; }
.fk-vid-than { aspect-ratio: 9 / 16; background: #18181b; border-radius: 6px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 0; }
.fk-vid-than video { width: 100%; height: 100%; object-fit: cover; display: block; }
.fk-vid-tt { color: #e4e4e7; font-size: 12px; margin: 0 8px; text-align: center; }
.fk-vid-than .fr-bar { width: 80%; }
.fk-vid-sua { width: 100%; margin-top: 8px; font-size: 12px; min-height: 44px; }
a.nv-chip { text-decoration: none; color: inherit; }
.fk-tt { margin-top: 10px; }
.fk-tt img { width: 100%; display: block; border-radius: 6px; box-shadow: 0 1px 4px rgba(0,0,0,.12); }

/* Ghép frame cho khách (trang nhân viên, frame-nv.js nvGhepMoi): lưới chọn frame */
.nv-fchon { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; max-height: 60vh; overflow-y: auto; text-align: left; }
.nv-fchon button { display: flex; flex-direction: column; gap: 4px; padding: 8px; border: 1px solid #e4e4e7; border-radius: 10px; background: #fff; cursor: pointer; font-family: inherit; }
.nv-fchon button:hover { border-color: #18181b; }
.nv-fchon img { width: 100%; aspect-ratio: 3 / 4; object-fit: contain; background: #f4f4f5; border-radius: 6px; }
.nv-fchon b { font-size: 14px; color: #18181b; }
.nv-fchon small { font-size: 12px; color: #71717a; }
