:root { --bg-main: #fafafa; --card-bg: #fff; --text-main: #111; --text-muted: #666; --border-color: #f0f0f0; --btn-bg: #111; }
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: 20px; box-sizing: border-box; }
.card { background: var(--card-bg); padding: 40px 30px; border-radius: 24px; 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: 15px;}

input, select { width: 100%; padding: 14px; margin-bottom: 15px; border: 1px solid #e5e5e5; border-radius: 12px; 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: 12px; font-weight: 700; cursor: pointer; transition: 0.2s; text-transform: uppercase; 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: 10px; }
.view-btn { background: #111; color: #fff; padding: 8px 16px; border: none; border-radius: 8px; 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: 14px; margin-bottom: 10px; overflow: hidden; background: #fafafa; }
.hist-head { width: 100%; background: none; border: none; padding: 14px 16px; cursor: pointer; text-align: left; display: flex; justify-content: space-between; align-items: center; gap: 10px; 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: 3px; font-weight: 500; }
.hist-arrow { font-size: 11px; 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: 14px; background: #fff; border: 1px dashed #e5e5e5; border-radius: 8px; }

.hist-title { font-size: 12px; font-weight: 700; color: #111; text-transform: uppercase; letter-spacing: 0.5px; margin: 0 0 10px; }
.hist-section { margin-top: 20px; padding-top: 18px; border-top: 1px dashed #e5e5e5; }

.new-session { margin-top: 22px; padding-top: 18px; border-top: 1px dashed #e5e5e5; text-align: center; }
.new-session p { font-size: 13px; color: #666; margin: 0 0 12px; font-weight: 500; }

#send-hint { display: none; font-size: 11px; 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: 10px; }
    .card { padding: 28px 18px; border-radius: 18px; }
}

/* ===== 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: 13px; font-weight: 700; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px; }
.alb-close { background: none; border: none; font-size: 26px; 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, 1fr); gap: 8px; padding: 10px; 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%; border: 1px solid #e5e5e5; padding: 5px; background: var(--card-bg); border-radius: 12px; 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: 8px; 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: 6px; font-size: 11px; 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, 1fr); gap: 12px; padding: 12px; } }
@media (min-width: 900px) { .alb-grid { grid-template-columns: repeat(5, 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 img { max-width: 100%; max-height: calc(100% - 100px); object-fit: contain; border-radius: 12px; background: var(--bg-main); }
.alb-zoom-close { position: absolute; top: 8px; right: 8px; color: var(--text-muted); font-size: 30px; 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: 12px; font-weight: 700; font-size: 14px; text-transform: uppercase; 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: 40px 20px; text-align: center; font-size: 13px; 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: 20px; 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; }
