:root { --bg-main: #fafafa; --card-bg: #fff; --text-main: #111; --text-muted: #666; --border-color: #f0f0f0; --btn-bg: #111; }
/* Màn chính (V4): thẻ việc */
.viec { margin-top: 24px; text-align: left; }
.viec-nhom { margin: 0 0 8px; font-size: 14px; font-weight: 600; color: #111; }
.viec-the { display: block; width: 100%; box-sizing: border-box; background: #fff; border: 1px solid #e5e5e5; border-radius: 16px; padding: 16px; margin: 0 0 8px; text-align: left; font-family: 'Inter', sans-serif; color: #111; }
.viec-dau { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.viec-icon { width: 24px; height: 24px; flex: none; fill: none; stroke: #111; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; margin-top: 2px; }
.viec-chu { flex: 1; min-width: 0; display: block; }
.viec-chu b { display: block; font-size: 16px; font-weight: 600; }
.viec-chu > span { display: block; font-size: 14px; color: #71717a; margin-top: 2px; line-height: 1.4; }
.viec-chon { display: flex; gap: 8px; margin-bottom: 12px; border: 1px solid #e5e5e5; padding: 8px 12px; border-radius: 10px; align-items: center; background: #fafafa; }
.viec-nut { display: flex; align-items: center; gap: 12px; cursor: pointer; min-height: 72px; }
.viec-nut:disabled { opacity: .6; cursor: default; }
.viec-mui { width: 20px; height: 20px; flex: none; fill: none; stroke: #a1a1aa; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (hover: hover) { .viec-nut:hover { border-color: #111; } }

/* Xoay ngang iPhone không tự phóng to chữ (V8) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.br-qr { margin: 0 0 4px; font: 600 16px 'Inter', sans-serif; color: #111; }
.form-loi { color: #71717a; font-size: 14px; margin: 0 0 24px; font-weight: 500; }
.name-hint { margin: 0 0 8px; text-align: left; font-size: 14px; color: #18181b; }
/* Điện thoại xoay ngang (màn thấp): thẻ sát trên, logo nhỏ, khỏi phải cuộn mới thấy ô số điện thoại */
@media (orientation: landscape) and (max-height: 520px) {
    body { align-items: flex-start; }
    .logo { width: 56px; height: 56px; margin-bottom: 8px; }
    .form-loi { margin-bottom: 12px; }
}
body { font-family: 'Inter', sans-serif; background: var(--bg-main); color: var(--text-main); display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; padding: 16px; box-sizing: border-box; }
.card { background: var(--card-bg); padding: 32px 32px; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.04); width: 100%; max-width: 400px; text-align: center; border: 1px solid #e5e5e5; box-sizing: border-box;}
.logo { width: 90px; height: 90px; object-fit: cover; border-radius: 50%; border: 1px solid #e5e5e5; padding: 2px; margin-bottom: 16px;}

input, select { width: 100%; padding: 16px; margin-bottom: 16px; border: 1px solid #e5e5e5; border-radius: 10px; box-sizing: border-box; font-size: 14px; font-family: 'Inter', sans-serif; outline: none; transition: 0.2s;}
input:focus, select:focus { border-color: #111; box-shadow: 0 0 0 3px rgba(17,17,17,0.05);}

button.primary-btn { width: 100%; padding: 16px; background: #111; color: #fff; border: none; border-radius: 10px; font-size: 16px; font-weight: 700; cursor: pointer; transition: 0.2s; font-family: 'Inter', sans-serif; display: flex; justify-content: center; align-items: center; gap: 8px;}
button.primary-btn:hover:not(:disabled) { background: #333; transform: translateY(-2px);}
button.primary-btn:active:not(:disabled) { transform: translateY(0);}
button.primary-btn:disabled { opacity: 0.7; cursor: not-allowed; }

.spinner { width: 18px; height: 18px; border: 2px solid rgba(255,255,255,0.3); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s infinite linear; display: none; margin: 0 auto; box-sizing: border-box; flex: none;}
@keyframes spin { 100% { transform: rotate(360deg); } }

.link-row { display: flex; justify-content: space-between; align-items: center; background: #fafafa; padding: 12px; border: 1px solid #e5e5e5; border-radius: 10px; margin-top: 8px; }
.view-btn { background: #111; color: #fff; padding: 8px 16px; border: none; border-radius: 10px; font-size: 12px; font-weight: 600; text-decoration: none; font-family: 'Inter'; cursor: pointer; white-space: nowrap; transition: 0.2s;}
.view-btn:hover { background: #333; }

#result-ui { display: none; text-align: left; }
.icon-svg { width: 16px; height: 16px; vertical-align: middle; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ===== Lịch sử các lần chụp trước ===== */
.hist-group { border: 1px solid #e5e5e5; border-radius: 16px; margin-bottom: 8px; overflow: hidden; background: #fafafa; }
.hist-head { width: 100%; background: none; border: none; padding: 16px 16px; cursor: pointer; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 8px; font-family: 'Inter'; transition: 0.15s; }
.hist-head:hover { background: #f0f0f0; }
.hist-date { font-size: 14px; font-weight: 700; color: #111; display: block; }
.hist-meta { font-size: 12px; color: #666; display: block; margin-top: 4px; font-weight: 500; }
.hist-arrow { font-size: 12px; color: #666; transition: transform 0.2s; flex: none; }
.hist-body { padding: 0 16px 16px; }
.hist-empty { font-size: 12px; color: #666; text-align: center; padding: 16px; background: #fff; border: 1px solid #e5e5e5; border-radius: 10px; }

.hist-title { font-size: 12px; font-weight: 700; color: #111; margin: 0 0 8px; }
.hist-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid #e5e5e5; }

.new-session { margin-top: 24px; padding-top: 16px; border-top: 1px solid #e5e5e5; text-align: center; }
.new-session p { font-size: 14px; color: #666; margin: 0 0 12px; font-weight: 500; }

#send-hint { display: none; font-size: 12px; color: #666; text-align: center; margin-top: 8px; line-height: 1.5; }

/* Màn hình cảm ứng: ô nhập 16px để iOS không tự phóng to trang khi bấm vào */
@media (hover: none) and (pointer: coarse) {
    input, select { font-size: 16px; }
    .primary-btn, .view-btn, .hist-head { min-height: 46px; }
}

/* Màn hẹp: lề 30px hai bên ăn mất chỗ, thu lại cho nội dung rộng hơn */
@media (max-width: 420px) {
    body { padding: 8px; }
    .card { padding: 24px 16px; border-radius: 16px; }
}

/* ===== Album ảnh cho khách: xem và lưu ngay trong web ===== */
.alb-modal { display: none; position: fixed; inset: 0; background: var(--card-bg); z-index: 3000; flex-direction: column; }
.alb-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid #e5e5e5; flex: none; }
/* Cùng cỡ chữ và cách giãn với tiêu đề trên trang chính */
.alb-head span { font-size: 14px; font-weight: 700; color: var(--text-main); }
.alb-chon { margin-left: auto; min-height: 44px; padding: 0 14px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--card-bg); color: var(--text-main); font: 600 14px 'Inter', sans-serif; cursor: pointer; }
/* Chế độ chọn nhiều: ô có vòng tick góc trên phải, ô đã chọn viền đen + vòng đen có dấu tick vẽ bằng viền */
.alb-modal.chon .alb-item { position: relative; }
.alb-modal.chon .alb-item::after { content: ""; position: absolute; top: 10px; right: 10px; width: 24px; height: 24px; border-radius: 12px; border: 2px solid #fff; background: rgba(0,0,0,.25); box-sizing: border-box; box-shadow: 0 1px 3px rgba(0,0,0,.3); }
.alb-modal.chon .alb-item.on { border-color: var(--text-main); box-shadow: 0 0 0 1px var(--text-main); }
.alb-modal.chon .alb-item.on::after { background: var(--text-main); }
.alb-modal.chon .alb-item.on::before { content: ""; position: absolute; top: 16px; right: 18px; width: 5px; height: 10px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); z-index: 1; }
.alb-chon-chan { flex: none; flex-direction: column; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border-color); background: var(--card-bg); }
.alb-chon-hang { display: flex; gap: 8px; }
.alb-chon-het { flex: none; min-height: 44px; padding: 0 16px; border: 1px solid var(--border-color); border-radius: 10px; background: var(--card-bg); color: var(--text-main); font: 600 14px 'Inter', sans-serif; cursor: pointer; }
.alb-save.alb-tai { flex: 1; width: auto; min-width: 0; max-width: none; padding: 12px 16px; box-sizing: border-box; }
.alb-chon-chan, .alb-chon, .alb-modal.chon .alb-grid { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
.alb-chon-chan .alb-goc { margin-top: 0; }
.alb-close { background: none; border: none; font-size: 28px; line-height: 1; color: var(--text-muted); cursor: pointer; padding: 4px 12px; font-family: 'Inter', sans-serif; }
/* Xếp như thư mục ảnh trên máy tính: mỗi ảnh một ô riêng, ảnh nằm gọn giữa
   ô, tên ảnh bên dưới. Ảnh chụp đo được đều ngang 3:2 (3984x2656), ảnh ghép
   1.42 cũng ngang. Hai cột trên điện thoại vì ảnh ngang xếp ba cột thì mặt
   người quá nhỏ. */
.alb-grid { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 8px; align-content: start; }

/* Không dùng content-visibility ở đây: nó cho phép trình duyệt bỏ qua việc
   dựng ô chưa nhìn thấy, Safari tính nhầm chiều cao rồi các ô chồng lên nhau. */
.alb-item { display: flex; flex-direction: column; width: 100%; min-width: 0; border: 1px solid #e5e5e5; padding: 4px; background: var(--card-bg); border-radius: 10px; cursor: pointer; font-family: 'Inter', sans-serif; box-sizing: border-box; transition: 0.2s; }
.alb-item:active { border-color: var(--text-main); background: var(--bg-main); }

/* Khung ảnh cố định tỷ lệ, ảnh vừa khung chứ không cắt */
.alb-thumb { width: 100%; aspect-ratio: 3/2; background: var(--bg-main); border-radius: 10px; overflow: hidden; flex: none; }
.alb-thumb img { width: 100%; height: 100%; object-fit: contain; display: block; }
/* Giữ ngón tay lên ảnh nhỏ thì điện thoại lưu luôn bản nhỏ 600px, không nét.
   Chặn menu đó: giữ là mở ảnh to, lưu bằng nút LƯU ẢNH (bản gốc). */
.alb-thumb img, #alb-zoom-img:not(.goc) { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
.alb-goc { font-size: 12px; color: var(--text-muted); margin-top: -8px; text-align: center; }

/* Tên ảnh: một dòng, dài quá thì cắt bằng dấu ba chấm như trên máy tính */
.alb-name { margin-top: 8px; font-size: 12px; color: var(--text-muted); font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Màn rộng hơn thì thêm cột, ảnh vẫn đủ to để nhìn rõ mặt */
@media (min-width: 560px) { .alb-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 12px; } }
@media (min-width: 900px) { .alb-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.alb-hint { flex: none; margin: 0; padding: 12px 16px 16px; font-size: 12px; color: var(--text-muted); font-weight: 500; text-align: center; border-top: 1px solid var(--border-color); }

/* Xem ảnh lớn rồi mới lưu */
/* Cùng nền sáng và nút đen như trang chính, thay vì nền đen nút trắng ngược hẳn */
.alb-zoom { display: none; position: fixed; inset: 0; background: var(--card-bg); z-index: 3100; flex-direction: column; align-items: center; justify-content: center; padding: 16px; box-sizing: border-box; gap: 16px; }
.alb-zoom video { max-width: 100%; max-height: calc(100% - 100px); border-radius: 10px; background: #000; }
.alb-thumb.vid { display: flex; align-items: center; justify-content: center; background: #18181b; position: relative; }
.alb-thumb.vid svg { width: 36px; height: 36px; fill: #fff; }
.alb-zoom img { max-width: 100%; max-height: calc(100% - 100px); object-fit: contain; border-radius: 10px; background: var(--bg-main); }
.alb-zoom-close { position: absolute; top: 8px; right: 8px; color: var(--text-muted); font-size: 28px; z-index: 1; }
/* Cùng dáng nút chính của trang: bo 12px, chữ hoa, đậm */
.alb-save { width: 100%; max-width: 320px; padding: 16px; background: var(--btn-bg); color: #fff; border: none; border-radius: 10px; font-weight: 700; font-size: 14px; font-family: 'Inter', sans-serif; cursor: pointer; flex: none; transition: 0.2s; }
.alb-save:active:not(:disabled) { background: #333; }
.alb-save:disabled { opacity: 0.7; cursor: not-allowed; }

@media (hover: none) and (pointer: coarse) {
    .alb-close { min-width: 44px; min-height: 44px; }
    .alb-save { min-height: 52px; }
}

/* Chữ báo trạng thái trong album: cùng cỡ và màu với phần còn lại của trang */
.alb-loading { grid-column: 1 / -1; margin: 0; padding: 32px 16px; text-align: center; font-size: 14px; color: var(--text-muted); font-weight: 500; line-height: 1.6; }

/* Nút tạo lượt mới ở trên cùng: bỏ đường kẻ và khoảng cách trên vì không còn
   ngăn cách với phần nào phía trước nữa */
.new-session-top { margin-top: 0; padding-top: 0; border-top: none; }

/* Dải báo mất mạng */
.mat-mang { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 10px); transform: translate(-50%, -160%); transition: transform .25s; z-index: 6000;
            background: #111; color: #fff; padding: 8px 16px; border-radius: 16px; font: 600 12px 'Inter', sans-serif; box-shadow: 0 4px 14px rgba(0,0,0,.2); pointer-events: none; }
.mat-mang.on { transform: translate(-50%, 0); }

/* Ảnh thẻ: trang anh-the.html phủ toàn màn hình (dưới hộp thoại Swal) */
#at-lop { position: fixed; inset: 0; z-index: 1000; background: #fafafa; display: none; }
#at-lop.on { display: block; }
#at-lop iframe { width: 100%; height: 100%; border: 0; display: block; }
body.at-mo { overflow: hidden; touch-action: pan-x pan-y; }

/* Ô tick, thanh kéo: màu của trang thay cho xanh mặc định của trình duyệt */
input[type=checkbox], input[type=radio], input[type=range] { accent-color: #111; }

/* Điện thoại: nút / link bấm được cao tối thiểu 44px (luật 0b) */
@media (hover: none) and (pointer: coarse) {
    label[for="cFile"], #link-fb, #link-ig, #link-tk, #link-map { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; }
    button[onclick="lookupAnother()"] { min-height: 44px; }
}

/* Album: chạm đúp không phóng cả trang (khách chạm nhanh 2 lần là trang bị zoom, lệch hết). Chụm 2 ngón vẫn phóng xem ảnh. */
.alb-modal, .alb-zoom { touch-action: manipulation; }
