/* Slate Frame — giao diện tối lấy cảm hứng từ Frame.io */
:root {
  --bg: #0d0e12;
  --bg-1: #14161c;
  --bg-2: #1b1e26;
  --bg-3: #242833;
  --line: #2b2f3b;
  --line-soft: #23262f;
  --txt: #e8eaf0;
  --txt-2: #9aa1b1;
  --txt-3: #6a7183;
  --accent: #5b53ff;
  --accent-hi: #6f68ff;
  --ok: #2fbf71;
  --warn: #f5a623;
  --danger: #ef4b5a;
  --radius: 10px;
  --header-h: 56px;
  --shadow: 0 12px 40px rgba(0, 0, 0, .55);
  /* Vạch home của iPhone — mọi thanh dính đáy phải kê lên trên nó */
  --safe-b: env(safe-area-inset-bottom, 0px);
  /* Sàn vùng chạm: 44px theo Apple HIG */
  --tap: 44px;
}

* { box-sizing: border-box; }

/* Thuộc tính hidden phải thắng mọi display của class (vd .gate dùng display:grid),
   nếu không phần tử đã ẩn vẫn hiện đè lên giao diện. */
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--txt);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: #fff; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333846; border-radius: 6px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 34px; padding: 0 14px;
  background: var(--bg-3); border: 1px solid var(--line);
  border-radius: 8px; cursor: pointer; white-space: nowrap;
  transition: background .12s, border-color .12s, opacity .12s;
}
.btn:hover { background: #2d3140; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hi); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--txt-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--txt); }
.btn.danger { border-color: #55232a; color: #ff8b96; background: transparent; }
.btn.danger:hover { background: #2a1518; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }

.input, textarea.input, select.input {
  width: 100%; height: 36px; padding: 0 12px;
  background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 8px; outline: none;
}
textarea.input { height: auto; padding: 9px 12px; resize: vertical; min-height: 76px; line-height: 1.5; }
.input:focus { border-color: var(--accent); }
.input::placeholder { color: var(--txt-3); }

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; margin-bottom: 6px; color: var(--txt-2); font-size: 12.5px; }

.row { display: flex; align-items: center; gap: 10px; }
.spacer { flex: 1; }
.muted { color: var(--txt-2); }
.dim { color: var(--txt-3); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--bg-3); font-size: 11.5px; color: var(--txt-2);
}
.chip.ok { background: rgba(47, 191, 113, .15); color: #6fe0a4; }
.chip.warn { background: rgba(245, 166, 35, .15); color: #ffc766; }
.chip.acc { background: rgba(91, 83, 255, .18); color: #b0abff; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h); display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: rgba(20, 22, 28, .92);
  backdrop-filter: blur(12px); border-bottom: 1px solid var(--line-soft);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: .2px; }
.brand .dot {
  width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
  background: linear-gradient(140deg, #9aa3d8, var(--accent)); font-size: 11px; font-weight: 800; color: #fff;
}

/* Logo Slate Frame: icon 3 thanh chéo + wordmark 2 màu — nền app tối nên chữ "Slate" để sáng màu */
.logo-icon { border-radius: 7px; flex: none; display: block; }
.wordmark {
  font-family: 'Poppins', -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-weight: 700; letter-spacing: -.01em; font-size: 15px;
}
.wordmark .w-slate { color: var(--txt); }
.wordmark .w-frame { color: var(--accent); }
.crumb { color: var(--txt-2); }
.crumb b { color: var(--txt); font-weight: 600; }

/* ---------- layout ---------- */
.wrap { max-width: 1400px; margin: 0 auto; padding: 22px 18px 80px; }
.page-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 21px; font-weight: 650; }

.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 0; border-bottom: 1px solid var(--line-soft); margin-bottom: 18px;
}

/* ---------- project cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card {
  background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform .14s, border-color .14s;
}
.card:hover { transform: translateY(-2px); border-color: var(--line); }
.card .thumb {
  aspect-ratio: 16/10; background: var(--bg-2) center/cover no-repeat;
  display: grid; place-items: center; color: var(--txt-3);
}
.card .meta { padding: 11px 13px 13px; }
.card .meta h3 { margin: 0 0 5px; font-size: 14.5px; font-weight: 600; }
.card .meta .sub { font-size: 12px; color: var(--txt-3); display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- thùng rác ---------- */
.card.trash { cursor: default; }
.card.trash:hover { transform: none; border-color: var(--line-soft); }
.card.trash .thumb { filter: grayscale(1) brightness(.6); }
.card-actions { display: flex; gap: 8px; padding: 0 13px 13px; }
.card-actions .btn { flex: 1; }

/* ---------- thông báo ---------- */
.notif-wrap { position: relative; }
.notif-badge {
  position: absolute; top: -4px; right: -4px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: #ff4d5e; color: #fff; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.notif-drop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 250; width: 340px; max-height: 420px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-size: 13px; font-weight: 600;
}
.notif-head .link { font-weight: 500; font-size: 12px; color: var(--accent); cursor: pointer; }
.notif-list { overflow-y: auto; }
.notif-item {
  display: block; width: 100%; text-align: left; padding: 10px 14px; border: none; background: none;
  cursor: pointer; border-bottom: 1px solid var(--line-soft); color: inherit; font: inherit;
}
.notif-item:hover { background: var(--bg-3); }
.notif-item.unread { background: rgba(91, 83, 255, .07); }
.notif-item .ntitle { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.notif-item .ntitle .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex: none; }
.notif-item .nbody { font-size: 12.5px; color: var(--txt-2); margin-top: 3px; }
.notif-item .ntime { font-size: 11px; color: var(--txt-3); margin-top: 4px; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--txt-3); font-size: 13px; }
.mention { color: var(--accent); font-weight: 600; }

/* ---------- thanh tìm kiếm + chuyển chế độ xem ---------- */
.fbar { display: flex; align-items: center; gap: 10px; margin: 14px 0; }
.fbar .input { flex: 1; max-width: 360px; }
.viewtoggle { display: flex; border: 1px solid var(--line-soft); border-radius: 8px; overflow: hidden; flex: none; }
.vt-btn {
  padding: 7px 10px; background: var(--bg-1); border: none; color: var(--txt-3);
  cursor: pointer; display: flex; align-items: center;
}
.vt-btn.on { background: var(--bg-3); color: var(--txt); }
.vt-btn:hover { color: var(--txt); }

/* ---------- chế độ xem danh sách ---------- */
/* cột cố định theo thứ tự: chọn · ảnh · Tên · Trạng thái · Ngày · Người tải · Comment · Rating · Dung lượng · Ghi chú.
   Tên không còn là 1fr (trước đây nó nuốt hết chỗ trống, đẩy các cột khác ra rìa) — giờ cố định,
   Ghi chú giãn theo chỗ còn lại; hàng có min-width riêng nên thiếu chỗ thì cuộn ngang thay vì bị bóp méo. */
.flist { border: 1px solid var(--line-soft); border-radius: 10px; overflow: hidden; }
.frow-scroll { overflow-x: auto; }
.frow {
  display: grid;
  grid-template-columns: 34px 46px 260px 110px 150px 140px 90px 110px 90px minmax(220px, 1fr);
  min-width: 1350px;
  align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--line-soft);
  cursor: pointer; user-select: none;
}
.frow:last-child { border-bottom: none; }
.frow:hover { background: var(--bg-2); }
.frow.picked { background: rgba(91, 83, 255, .08); }
.frow-head {
  cursor: default; font-size: 11px; color: var(--txt-3); text-transform: uppercase;
  letter-spacing: .02em; background: var(--bg-2);
}
.frow-head:hover { background: var(--bg-2); }
.fl-check { display: flex; justify-content: center; }
.fl-check .checkbox {
  position: static; width: 19px; height: 19px; border-radius: 5px; border: 1.5px solid var(--line);
  display: grid; place-items: center; background: transparent; color: transparent; cursor: pointer; font-size: 12px;
}
.frow.picked .fl-check .checkbox { background: var(--accent); border-color: var(--accent); color: #fff; }
.fl-thumb { width: 42px; height: 42px; border-radius: 6px; overflow: hidden; background: var(--bg-2); flex: none; }
.fl-thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .2s; }
.fl-thumb img.on { opacity: 1; }
.fl-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.fl-status, .fl-date, .fl-uploader, .fl-cmt, .fl-size {
  font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--txt-3);
}
.fl-cmt { text-align: center; }
.fl-rate { display: flex; align-items: center; }
.fl-note { min-width: 0; }
.fl-note-input {
  width: 100%; background: transparent; border: 1px solid transparent; border-radius: 6px;
  padding: 5px 7px; font: inherit; font-size: 12.5px; color: var(--txt-2); transition: border-color .12s, background .12s;
}
.fl-note-input:hover { border-color: var(--line-soft); }
.fl-note-input:focus { outline: none; border-color: var(--accent); background: var(--bg-2); color: var(--txt); }

/* Trang khách: ít cột hơn admin (không có Người tải / Ghi chú — hai thứ đó chỉ studio dùng) */
.frow.frow-guest { grid-template-columns: 34px 46px 1fr 110px 150px 90px 110px 90px; min-width: 980px; }

/* Danh sách project dạng list — không có ô chọn, cột khác hẳn cột của ảnh trong project */
.frow.frow-project { grid-template-columns: 46px 1fr 120px 110px 90px 90px 90px; min-width: 760px; }

/* ---------- grid ảnh ---------- */
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(var(--tile, 220px), 1fr)); }
.tile {
  position: relative; background: var(--bg-1); border: 1px solid var(--line-soft);
  border-radius: 10px; overflow: hidden; cursor: pointer;
  transition: border-color .12s;
  /* không cho bôi đen chữ khi giữ Shift chọn nhiều ảnh */
  user-select: none; -webkit-user-select: none;
}
.tile:hover { border-color: #3a4152; }
.tile.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tile .ph { position: relative; aspect-ratio: 1/1; background: var(--bg-2); display: block; overflow: hidden; }
/* phủ màu lên ô đang chọn để nhìn lướt cả lưới vẫn thấy ngay */
.tile.picked .ph::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: rgba(91, 83, 255, .32);
  box-shadow: inset 0 0 0 2px var(--accent);
}
.tile .ph img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .25s; }
.tile .ph img.on { opacity: 1; }
/* tệp không phải ảnh: server trả về icon, hiển thị thu nhỏ ở giữa cho gọn */
.tile .ph.isfile { display: grid; place-items: center; }
.tile .ph.isfile img { width: 72%; height: 72%; object-fit: contain; }
/* PDF: trang giấy phải thấy trọn, cắt cúp kiểu ảnh thì chẳng đọc được gì */
.tile .ph.isdoc { background: #fff; display: grid; place-items: center; }
.tile .ph.isdoc img { width: 100%; height: 100%; object-fit: contain; }
#tabPhotos.drag-over, #viewProjects.drag-over { outline: 2px dashed var(--accent); outline-offset: 10px; border-radius: 12px; }
.tile .cap {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  padding: 7px 9px; font-size: 12px; color: var(--txt-2);
  border-top: 1px solid var(--line-soft);
}
.tile .cap .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* mọi thứ còn lại trong dòng đều không được xuống hàng */
.tile .cap > :not(.nm) { flex: none; white-space: nowrap; }
.tile .cap .cmt-n { display: inline-flex; align-items: center; gap: 3px; }
/* ---------- sao đánh giá ---------- */
.stars { display: flex; gap: 1px; line-height: 1; }
.stars .star { color: var(--line); cursor: pointer; font-size: 13px; transition: color .1s, transform .1s; }
.stars .star:hover { transform: scale(1.15); }
.stars .star.on { color: var(--txt); }
.tile .stars.tile-stars { padding: 3px 9px 6px; }
.tile .stars.tile-stars .star { font-size: 14px; }
#albStars.lb-stars, .lb-stars { display: flex; gap: 2px; }
.lb-stars .star { font-size: 16px; }

/* dòng "ai đưa lên • lúc nào", ngay dưới tên tệp */
.tile .by {
  padding: 0 9px 8px;
  font-size: 11.5px; color: var(--txt-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tile .badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; }
.tile .pickbtn {
  position: absolute; top: 7px; right: 7px; width: 26px; height: 26px;
  border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .55);
  background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px);
  display: grid; place-items: center; opacity: 0; transition: opacity .12s;
  cursor: pointer; color: #fff;
}
.tile:hover .pickbtn, .tile .pickbtn.on { opacity: 1; }
.tile .pickbtn.on { background: var(--ok); border-color: var(--ok); }
.tile .pickbtn.changes { background: var(--warn); border-color: var(--warn); color: #201400; }

/* Ô tích chọn của người quản trị — góc phải, tách biệt với huy hiệu của khách ở góc trái */
.tile .checkbox {
  position: absolute; top: 7px; right: 7px; width: 22px; height: 22px;
  border-radius: 6px; border: 1.5px solid rgba(255, 255, 255, .6);
  background: rgba(0, 0, 0, .45); backdrop-filter: blur(4px);
  display: grid; place-items: center; color: #fff; font-size: 13px;
  opacity: 0; transition: opacity .12s; cursor: pointer; z-index: 3;
}
.tile:hover .checkbox, .tile.picked .checkbox { opacity: 1; }
.tile.picked .checkbox { background: var(--accent); border-color: var(--accent); }
.tile.picked { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
/* Trang khách: góc phải đã có nút đánh dấu của khách, nên ô tích chọn nằm góc trái */
#grid .tile .checkbox { left: 7px; right: auto; }

/* Vòng xoay trong lúc chờ hình đại diện — ẩn ngay khi ảnh tải xong */
.spin { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.spin::before {
  content: ''; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .16); border-top-color: var(--txt-2);
  animation: wahspin .9s linear infinite;
}
@keyframes wahspin { to { transform: rotate(360deg); } }
.tile .ph img.on + .spin { display: none; }
.tile .cap .working { color: var(--txt-3); font-size: 11.5px; }

/* Vòng tròn phần trăm khi đang chuyển mã video */
.ring {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center; pointer-events: none;
}
.ring svg { width: 58%; max-width: 96px; aspect-ratio: 1; transform: rotate(-90deg); grid-area: 1/1; }
.ring circle { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.ring .rbg { stroke: rgba(255, 255, 255, .12); }
.ring .rfg { stroke: var(--accent-hi); transition: stroke-dashoffset .6s linear; }
.ring .rpct {
  grid-area: 1/1; font-size: 19px; font-weight: 600; color: var(--txt-1);
  letter-spacing: -.5px;
}
.ring .rpct i { font-style: normal; font-size: 11px; color: var(--txt-3); margin-left: 1px; }
/* đang xử lý thì giấu nút play; có phần trăm rồi thì thay luôn vòng xoay */
.tile.busy .playicon, .tile.busy .vdur { display: none !important; }
.tile.pct .ph img { opacity: .25 !important; }
.tile.pct .spin { display: none; }
.tile.busy .cap .working { color: var(--accent-hi); }

/* Rê chuột ngang ô video để xem nhanh khung hình.
   Ảnh dải gồm 10 ô vuông, trượt bằng left nên không lệ thuộc tỉ lệ khung hình. */
.scrub {
  position: absolute; inset: 0; overflow: hidden; z-index: 1;
  opacity: 0; transition: opacity .1s; pointer-events: none;
}
.scrub.on { opacity: 1; }
.tile .ph .scrub img {
  position: absolute; top: 0; left: calc(var(--i, 0) * -100%);
  width: 1000%; height: 100%; max-width: none;
  object-fit: fill; opacity: 1; display: block;
}
.scrub .playline { position: absolute; top: 0; bottom: 0; width: 2px; background: #ff3b30; }

/* Ảnh chưa tải xong thì chỉ có vòng xoay, đừng chồng thêm nút play và thời lượng */
.tile:not(.loaded) .playicon,
.tile:not(.loaded) .vdur { display: none; }

/* dấu hiệu ô là video */
.tile .playicon {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 42px; height: 42px; border-radius: 50%; pointer-events: none;
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(3px);
  display: grid; place-items: center; color: #fff; z-index: 2;
}
.tile .vdur {
  position: absolute; right: 7px; bottom: 40px; z-index: 2;
  padding: 1px 6px; border-radius: 5px; pointer-events: none;
  background: rgba(0, 0, 0, .65); color: #fff; font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.badge-dot {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 10px; font-weight: 700; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px);
}

/* Huy hiệu góp ý: icon kèm luôn số lượng nên phải nới ra thành viên thuốc */
.badge-cmt {
  width: auto; min-width: 20px; padding: 0 6px; border-radius: 10px;
  display: inline-flex; align-items: center; gap: 3px; font-size: 11px;
}

/* ---------- lightbox ---------- */
.lb { position: fixed; inset: 0; z-index: 100; background: #08090c; display: none; }
/* minmax(0,1fr) để hàng ảnh không bị content đẩy tràn ra ngoài màn hình */
.lb.open { display: grid; grid-template-rows: var(--header-h) minmax(0, 1fr) auto; }
.lb-head {
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  border-bottom: 1px solid var(--line-soft); background: var(--bg-1);
}
.lb-body { display: grid; grid-template-columns: minmax(0, 1fr) 0; min-height: 0; transition: grid-template-columns .18s; }
.lb-body.with-panel { grid-template-columns: minmax(0, 1fr) 340px; }
.stage { position: relative; min-width: 0; min-height: 0; overflow: hidden; touch-action: none; }
/* Không đặt will-change: transform ở đây. Nó đẩy ảnh sang một lớp GPU riêng,
   trình duyệt vẽ ảnh đúng một lần ở cỡ vừa khung rồi kéo giãn lớp đó khi zoom —
   ảnh nạp bao nhiêu megapixel cũng vẫn mờ. zoom.js đổi kích thước thật thay vì scale. */
.stage img {
  position: absolute; inset: 20px; margin: auto;
  max-width: calc(100% - 40px); max-height: calc(100% - 40px);
  width: auto; height: auto; object-fit: contain;
  user-select: none; -webkit-user-drag: none; border-radius: 4px;
}
.stage canvas {
  position: absolute; pointer-events: none; z-index: 1;
  border-radius: 4px;
}
/* Video trong khung xem: cùng cách căn với ảnh, nhưng giữ thanh điều khiển riêng */
.stage video {
  position: absolute; inset: 20px; margin: auto;
  max-width: calc(100% - 40px); max-height: calc(100% - 40px);
  width: auto; height: auto; border-radius: 4px; background: #000; z-index: 1;
}

/* Bộ chọn chất lượng phát và trạng thái đang chuyển mã */
/* Góc dưới phải khung xem: vòng xoay "đang xử lý" nằm ngay bên trái ô chất lượng */
.qwrap {
  position: absolute; right: 16px; bottom: 16px; z-index: 3;
  display: flex; align-items: center; gap: 8px;
}
.qspin {
  flex: none; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .16); border-top-color: var(--txt-2);
  animation: wahspin .9s linear infinite;
}
.qbar {
  height: 30px; padding: 0 8px; cursor: pointer;
  background: rgba(20, 22, 28, .88); border: 1px solid var(--line);
  border-radius: 9px; color: var(--txt-2); font-size: 12.5px;
  backdrop-filter: blur(8px);
}
.qbar:hover { color: var(--txt); }
.prepping {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 3;
  padding: 14px 18px; border-radius: 12px; font-size: 13px; text-align: center;
  min-width: 260px; max-width: 80%;
  background: rgba(20, 22, 28, .9); border: 1px solid var(--line); color: var(--txt-2);
}
.prepping .prep-bar {
  height: 5px; margin: 12px 0 7px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); overflow: hidden;
}
.prepping .prep-bar > i { display: block; height: 100%; width: 0; background: var(--accent-hi); transition: width .6s linear; }
.prepping .prep-eta { font-size: 12px; color: var(--txt-3); }

/* Mốc thời gian trong góp ý video */
.tc {
  display: inline-flex; align-items: center; height: 19px; padding: 0 7px;
  margin-right: 6px; border-radius: 5px; cursor: pointer;
  background: rgba(91, 83, 255, .2); color: #b0abff;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px;
}
.tc:hover { background: var(--accent); color: #fff; }
.tcbtn {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--bg-3); border-radius: 8px;
  cursor: pointer; font-size: 12.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.tcbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.nav { z-index: 2; }
.nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(20, 22, 28, .8); display: grid; place-items: center; cursor: pointer;
}
.nav:hover { background: var(--bg-3); }
.nav.prev { left: 16px; } .nav.next { right: 16px; }

.panel { border-left: 1px solid var(--line-soft); background: var(--bg-1); display: flex; flex-direction: column; overflow: hidden; }
.panel .p-head { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); font-weight: 600; }
.panel .p-body { flex: 1; overflow-y: auto; padding: 12px 14px; }
.panel .p-foot { border-top: 1px solid var(--line-soft); padding: 10px 12px; }

.cmt { margin-bottom: 14px; border-radius: 8px; transition: background-color .3s; }
.cmt.flash { background-color: rgba(91, 83, 255, .18); }
.cmt .who { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.avatar {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; flex: none;
}
.cmt .body {
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
  background: var(--bg-2); padding: 8px 10px; border-radius: 8px;
}
.cmt .body a.lnk { color: #b0abff; text-decoration: underline; text-underline-offset: 2px; }
.cmt .body a.lnk:hover { color: #fff; }
.cmt .when { font-size: 11.5px; color: var(--txt-3); }

.filmstrip {
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px;
  border-top: 1px solid var(--line-soft); background: var(--bg-1);
}
.filmstrip img {
  height: 54px; width: 54px; object-fit: cover; border-radius: 5px;
  border: 2px solid transparent; cursor: pointer; opacity: .55; flex: none;
}
.filmstrip img.cur { border-color: var(--accent); opacity: 1; }

/* ---------- thanh zoom ---------- */
.zoombar {
  position: absolute; left: 16px; bottom: 16px; z-index: 3;
  display: flex; align-items: center; gap: 2px; padding: 4px;
  background: rgba(20, 22, 28, .88); border: 1px solid var(--line);
  border-radius: 10px; backdrop-filter: blur(8px);
}
.zoombar button {
  width: 26px; height: 26px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; color: var(--txt-2); font-size: 15px; line-height: 1;
}
.zoombar button:hover { background: var(--bg-3); color: var(--txt); }
.zoombar .pct {
  min-width: 46px; text-align: center; font-size: 12px;
  color: var(--txt-2); cursor: pointer; user-select: none;
}
.zoombar .pct:hover { color: var(--txt); }

/* ---------- bút vẽ đánh dấu ---------- */
.drawbar { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
.swatch {
  width: 20px; height: 20px; border-radius: 50%; cursor: pointer;
  border: 2px solid transparent; box-shadow: 0 0 0 1px rgba(255, 255, 255, .18) inset;
}
.swatch.on { border-color: #fff; }
.pen {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px;
  border: 1px solid var(--line); background: var(--bg-3); border-radius: 8px;
  cursor: pointer; font-size: 12.5px;
}
.pen.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- emoji + tệp đính kèm ---------- */
.emoji-pop {
  position: absolute; left: 0; bottom: 36px; z-index: 10;
  width: 268px; max-height: 210px; overflow-y: auto; padding: 8px;
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
.emoji-pop span {
  display: grid; place-items: center; height: 28px;
  font-size: 18px; border-radius: 6px; cursor: pointer;
}
.emoji-pop span:hover { background: var(--bg-3); }

.file-chip {
  display: flex; align-items: center; gap: 7px; margin-top: 6px;
  padding: 5px 8px; background: var(--bg-2); border: 1px solid var(--line-soft);
  border-radius: 8px; font-size: 12px;
}
.file-chip .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip .rm { cursor: pointer; color: var(--txt-3); padding: 0 2px; }
.file-chip .rm:hover { color: #ff8b96; }
.file-chip.up { opacity: .55; }
a.file-chip:hover { border-color: var(--line); background: var(--bg-3); }

.cmt.has-draw { cursor: pointer; }
.cmt.has-draw .body { border-left: 2px solid var(--accent); }
.cmt.showing .body { background: var(--bg-3); }
.draw-tag { font-size: 11px; color: var(--txt-3); margin-top: 3px; }

.cmt.reply { margin-left: 22px; padding-left: 10px; border-left: 1px solid var(--line-soft); }
.avatar.studio { background: linear-gradient(140deg, #ff7a45, var(--accent)); }
.cmt-acts { display: flex; gap: 12px; margin-top: 4px; opacity: 0; transition: opacity .12s; }
.cmt:hover .cmt-acts { opacity: 1; }
.cmt-acts .act { font-size: 11.5px; color: var(--txt-3); cursor: pointer; }
.cmt-acts .act:hover { color: var(--txt); }
.cmt-acts .act.del:hover { color: #ff8b96; }

.reply-to {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  padding: 5px 9px; background: var(--bg-2); border-left: 2px solid var(--accent);
  border-radius: 0 8px 8px 0; font-size: 12px; color: var(--txt-2);
}
.reply-to .x { cursor: pointer; color: var(--txt-3); }
.reply-to .x:hover { color: var(--txt); }

/* ---------- modal ---------- */
.mask { position: fixed; inset: 0; background: rgba(4, 5, 8, .72); display: none; place-items: center; z-index: 200; padding: 20px; }
.mask.open { display: grid; }
.modal {
  width: min(520px, 100%); background: var(--bg-1); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow); overflow: hidden;
}
.modal h2 { margin: 0; padding: 16px 18px; font-size: 16px; border-bottom: 1px solid var(--line-soft); }
.modal .m-body { padding: 18px; max-height: 65vh; overflow-y: auto; }
.modal .m-foot { padding: 12px 18px; border-top: 1px solid var(--line-soft); display: flex; gap: 10px; justify-content: flex-end; }

/* ---------- gate (màn hình nhập mật khẩu) ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.gate-box { width: min(400px, 100%); background: var(--bg-1); border: 1px solid var(--line); border-radius: 16px; padding: 30px; box-shadow: var(--shadow); }
.gate-box .brand { justify-content: center; margin-bottom: 6px; font-size: 16px; }
.gate-box h1 {
  text-align: center; font-size: 19px; margin: 12px 0 4px;
  /* tên file dài không được tràn ra khỏi hộp */
  overflow-wrap: anywhere; word-break: break-word;
}
.gate-box p.sub { text-align: center; color: var(--txt-2); margin: 0 0 22px; }
.err { color: #ff8b96; font-size: 13px; min-height: 18px; margin-top: 4px; }

/* ---------- thư mục con trong project ---------- */
.crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 14px; font-size: 13px; flex-wrap: wrap; }
.crumbs .cr { color: var(--txt-2); cursor: pointer; }
.crumbs .cr:hover { color: var(--txt); }
.crumbs .cr.cur { color: var(--txt); cursor: default; }
.crumbs .sep { color: var(--txt-3); }

/* Ô thư mục: ghép tối đa 3 ảnh đầu thành preview */
.tile.folder .ph { position: relative; background: var(--bg-2); }
.mosaic { position: absolute; inset: 0; display: grid; gap: 2px; }
.mosaic.n1 { grid-template-columns: 1fr; }
.mosaic.n2 { grid-template-columns: 2fr 1fr; }
.mosaic.n3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.mosaic.n3 > :first-child { grid-row: span 2; }
/* Selector phải đủ mạnh để thắng `.tile .ph img { opacity: 0 }` của ô ảnh lazy-load,
   nếu không mosaic sẽ tải xong mà vẫn trong suốt. */
.tile.folder .ph .mosaic img {
  width: 100%; height: 100%; object-fit: cover; display: block; opacity: 1;
}
/* ô đại diện cho thư mục con nằm trong mosaic */
.mcell-folder {
  display: grid; place-items: center;
  background: var(--bg-3); color: var(--txt-2);
}
.tile.folder .mcell-folder .fic { position: static; color: inherit; filter: none; }
.tile.folder .fic {
  position: absolute; left: 8px; top: 8px; z-index: 2; color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .8));
}
.tile.folder .ph.empty { display: grid; place-items: center; }
.tile.folder .ph.empty .fic { position: static; color: var(--txt-3); filter: none; }
.tile.ctx-on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

/* Dải phân vùng giữa thư mục và ảnh */
.sec-head {
  display: flex; align-items: center; gap: 8px;
  margin: 4px 0 12px; font-size: 12.5px; color: var(--txt-2);
}
.sec-head .caret {
  width: 20px; height: 20px; display: grid; place-items: center;
  border-radius: 5px; cursor: pointer; color: var(--txt-3);
  transition: transform .15s;
}
.sec-head .caret:hover { background: var(--bg-2); color: var(--txt); }
.sec-head .caret.closed { transform: rotate(-90deg); }
.sec { margin-bottom: 26px; }

.dropzone {
  margin-top: 18px; padding: 40px 20px; text-align: center;
  border: 1px dashed var(--line); border-radius: 12px; color: var(--txt-3);
}
.dropzone.over { border-color: var(--accent); color: var(--txt-2); background: rgba(91, 83, 255, .06); }

/* ---------- menu chuột phải ---------- */
.ctxmenu {
  position: fixed; z-index: 300; min-width: 200px; padding: 5px;
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: var(--shadow);
}
.ctx-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 7px; cursor: pointer; font-size: 13px;
}
.ctx-item:hover { background: var(--bg-3); }
.ctx-item.danger { color: #ff8b96; }
.ctx-item.danger:hover { background: #2a1518; }
.ctx-sep { height: 1px; margin: 5px 6px; background: var(--line-soft); }
.ctx-head {
  padding: 7px 10px 5px; font-size: 11.5px; color: var(--txt-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px;
}

/* ---------- chọn ảnh bìa project ---------- */
.cover-pick {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px;
  max-height: 360px; overflow-y: auto;
}
.cover-pick-item {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: pointer;
  border: 2px solid transparent; transition: border-color .12s;
}
.cover-pick-item:hover { border-color: var(--accent); }

/* ---------- Project Settings ---------- */
.psettings { display: grid; grid-template-columns: 160px 1fr; gap: 22px; }
.ps-cover {
  aspect-ratio: 1; border-radius: 10px; background: var(--bg-2) center/cover no-repeat;
  border: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: center;
  color: var(--txt-3);
}
.ps-fields { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.ps-sec { padding-top: 12px; border-top: 1px solid var(--line-soft); }
.ps-sec-head { font-size: 11.5px; color: var(--txt-3); text-transform: uppercase; letter-spacing: .03em; margin-bottom: 8px; }
.ps-row {
  display: flex; align-items: flex-start; gap: 10px; font-size: 13px; cursor: default;
}
.ps-row input[type="checkbox"] { margin-top: 3px; }
.ps-row.disabled { opacity: .55; }
.ps-row .dim { font-size: 12px; }
.ps-static {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line-soft); color: var(--txt-2); font-size: 13px;
}
.ps-static svg { flex: none; opacity: .7; }

/* ---------- misc ---------- */
.warnbox {
  padding: 11px 14px; border-radius: 10px; font-size: 13px;
  background: rgba(245, 166, 35, .12); border: 1px solid rgba(245, 166, 35, .35);
  color: #ffc766;
}
.warnbox b { color: #ffd899; }

/* Thanh cảnh báo bấm được: mở ra danh sách video đang chuyển mã */
.warnbox.clickable { cursor: pointer; display: flex; align-items: center; gap: 10px; }
.warnbox.clickable:hover { background: rgba(245, 166, 35, .18); }
.warnbox .warn-caret {
  margin-left: auto; flex: none; font-size: 11px; opacity: .8;
  transition: transform .15s;
}
.warnbox.open .warn-caret { transform: rotate(180deg); }
.warnjobs {
  margin-top: 6px; border-radius: 10px; overflow: hidden;
  background: rgba(245, 166, 35, .06); border: 1px solid rgba(245, 166, 35, .22);
}
.warnjobs .wj {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; cursor: pointer;
  border-top: 1px solid rgba(245, 166, 35, .14); font-size: 12.5px; color: var(--txt-2);
}
.warnjobs .wj:first-child { border-top: 0; }
.warnjobs .wj:hover { background: rgba(245, 166, 35, .12); color: var(--txt); }
.warnjobs .wj .wj-nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.warnjobs .wj .wj-pj { color: var(--txt-3); font-size: 11.5px; flex: none; }
.warnjobs .wj .wj-bar {
  flex: none; width: 120px; height: 5px; border-radius: 999px;
  background: rgba(255, 255, 255, .1); overflow: hidden;
}
.warnjobs .wj .wj-bar > i { display: block; height: 100%; width: 0; background: var(--accent-hi); transition: width .6s linear; }
.warnjobs .wj .wj-pct { flex: none; width: 74px; text-align: right; color: #ffc766; font-size: 11.5px; }
.warnjobs .wj-empty { padding: 10px 12px; font-size: 12.5px; color: var(--txt-3); }

.empty { text-align: center; padding: 80px 20px; color: var(--txt-3); }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 20px);
  background: var(--bg-3); border: 1px solid var(--line); padding: 10px 16px;
  border-radius: 10px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .18s, transform .18s; z-index: 500;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.selbar {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); z-index: 60;
}
.tabs { display: flex; gap: 4px; }
.tab { padding: 6px 12px; border-radius: 8px; cursor: pointer; color: var(--txt-2); font-size: 13px; }
.tab.on { background: var(--bg-3); color: var(--txt); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.tbl th { color: var(--txt-3); font-weight: 500; font-size: 12px; }

/* ============================================================
   MOBILE — trang khách trên điện thoại
   Mọi thứ dưới đây nằm trong media query, desktop không đổi.
   ============================================================ */

@keyframes sheetup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Phần tử chỉ dành cho điện thoại — mặc định không tồn tại */
.mob-only { display: none !important; }
/* Thanh trên của chế độ chọn — chỉ điện thoại mới có chế độ này */
.tb-sel { display: none; }

/* Nhóm hành động trong lightbox: ở desktop nó chỉ là một cụm nút trong thanh trên,
   giữ nguyên thứ tự cũ (các nút rồi mới tới chip phần trăm zoom). */
.lb-acts { display: flex; align-items: center; gap: 12px; }
.lb-head > .lb-acts { order: 1; }
.lb-head > #lbZoom { order: 2; }

/* Sheet trượt từ đáy — chỉ mở từ nút ⋯ (nút này chỉ có trên điện thoại) */
.sheet-mask { position: fixed; inset: 0; z-index: 300; background: rgba(4, 5, 8, .55); animation: fadein .15s ease; }
.sheet {
  position: absolute; left: 10px; right: 10px; bottom: calc(16px + var(--safe-b));
  padding: 6px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  animation: sheetup .2s cubic-bezier(.22, .8, .2, 1);
}
.sheet-title {
  padding: 9px 12px 7px; font-size: 11.5px; color: var(--txt-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet-item {
  display: flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 8px 12px; border-radius: 9px; cursor: pointer; font-size: 14.5px;
}
.sheet-item:active { background: var(--bg-3); }
.sheet-item .si-ic { width: 20px; flex: none; display: grid; place-items: center; color: var(--txt-2); }
.sheet-item .si-lb { flex: 1; min-width: 0; }
.sheet-item .si-hint { flex: none; color: var(--txt-3); font-size: 12.5px; }
.sheet-sep { height: 1px; margin: 5px 6px; background: var(--line-soft); }
.sheet-close { justify-content: center; color: var(--txt-2); }

/* Thiết bị cảm ứng: những nút vốn chỉ hiện khi rê chuột phải hiện thường trực */
@media (hover: none) {
  .cmt-acts { opacity: 1; }
  .tile .pickbtn { opacity: 1; }
}

@media (max-width: 720px) {
  .wrap { padding: 16px 12px 120px; }
}

@media (max-width: 640px) {

  .mob-only:not([hidden]) { display: inline-flex !important; }

  /* ---------- thanh trên: 2 tầng ---------- */
  .topbar {
    height: auto; min-height: 50px; padding: 0 12px 6px;
    flex-wrap: wrap; column-gap: 8px; row-gap: 0;
  }
  .topbar .spacer { display: none; }
  .topbar .brand { flex: none; }
  .topbar .crumb {
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px;
  }
  /* tabs lọc xuống tầng 2, cuộn ngang có chủ đích */
  .topbar > .tabs {
    order: 2; flex: 1 1 100%;
    overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .topbar > .tabs::-webkit-scrollbar { width: 0; height: 0; }
  .tab { flex: none; padding: 8px 13px; font-size: 13.5px; white-space: nowrap; }
  /* đã dọn vào menu ⋯ hoặc bỏ hẳn */
  #btnZoomIn, #btnZoomOut, #btnDlAll, #btnDlPicked, #meChip { display: none !important; }
  #btnSelMode { height: var(--tap); padding: 0 13px; font-size: 13.5px; }
  #btnMoreGrid, #lbMore { width: var(--tap); height: var(--tap); font-size: 19px; padding: 0; }

  /* thanh trên thay thế khi đang chọn nhiều ảnh */
  body.sel-mode .topbar:not(.tb-sel) { display: none; }
  body.sel-mode .tb-sel { display: flex; }
  .tb-sel { height: 50px; padding: 0 8px; gap: 6px; flex-wrap: nowrap; }
  .tb-sel .btn { height: var(--tap); padding: 0 10px; font-size: 13.5px; }
  .tb-sel-label { flex: 1; text-align: center; font-size: 13.5px; font-weight: 600; }
  .tb-sel-all { color: #b0abff; }

  /* ---------- thanh lọc ---------- */
  .fbar { flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
  .fbar .spacer { display: none; }
  /* max-width đặt inline trong HTML nên phải !important mới ghi đè được */
  .fbar .input { flex: 1 1 45%; max-width: none !important; height: var(--tap); font-size: 13.5px; }
  #viewToggle { order: 1; flex: none; }
  #colToggle { order: 2; flex: none; margin-left: auto; }
  .fbar .viewtoggle .vt-btn { min-width: 48px; height: 40px; justify-content: center; }
  #colToggle .vt-btn { min-width: 44px; padding: 0 12px; font-size: 13px; }

  /* ---------- lưới ảnh ---------- */
  .grid { gap: 8px; grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr)) !important; }
  /* Thư mục luôn 2 cột — phải !important vì .grid ở trên cũng !important,
     specificity cao hơn không thắng được nếu bên kia có !important còn bên này thì không. */
  #gridF { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; --tile: none; }

  .tile .cap { padding: 7px 9px; }
  /* dòng "ai đưa lên • lúc nào" chiếm chỗ mà ít ai đọc trên điện thoại */
  .tile .by { display: none; }
  .tile .stars.tile-stars { padding: 0 9px 9px; gap: 6px; }
  .tile .stars.tile-stars .star { font-size: 20px; padding: 2px 0; }
  .tile .pickbtn { width: 32px; height: 32px; top: 8px; right: 8px; font-size: 15px; font-weight: 700; }

  /* ô tích chỉ xuất hiện khi đã vào chế độ chọn, để không lẫn với nút đánh dấu */
  #grid .tile .checkbox { opacity: 0; pointer-events: none; }
  body.sel-mode #grid .tile .checkbox {
    opacity: 1; pointer-events: auto;
    width: 32px; height: 32px; border-radius: 8px; top: 8px; left: 8px; right: auto; font-size: 15px;
  }
  body.sel-mode .tile .pickbtn { display: none; }

  /* ---------- danh sách: mỗi dòng thành một thẻ dọc ---------- */
  .frow-scroll { overflow-x: visible; }
  .frow.frow-guest.frow-head { display: none; }
  .frow.frow-guest {
    min-width: 0;
    grid-template-columns: 64px auto auto auto 1fr 32px;
    gap: 3px 8px; padding: 10px 12px; min-height: 88px; align-items: center;
  }
  .frow-guest .fl-thumb {
    grid-column: 1; grid-row: 1 / 4;
    width: 64px; height: 64px; border-radius: 6px; align-self: center;
  }
  .frow-guest .fl-name {
    grid-column: 2 / 6; grid-row: 1;
    white-space: normal; font-size: 13.5px; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  }
  .frow-guest .fl-rate { grid-column: 2 / 6; grid-row: 2; }
  .frow-guest .fl-rate .stars { gap: 5px; }
  .frow-guest .fl-rate .star { font-size: 18px; }
  /* dòng phụ: trạng thái · dung lượng · góp ý · ngày */
  .frow-guest .fl-status { grid-column: 2; grid-row: 3; }
  .frow-guest .fl-size   { grid-column: 3; grid-row: 3; }
  .frow-guest .fl-cmt    { grid-column: 4; grid-row: 3; text-align: left; }
  .frow-guest .fl-date   { grid-column: 5; grid-row: 3; }
  .frow-guest .fl-status, .frow-guest .fl-size,
  .frow-guest .fl-cmt, .frow-guest .fl-date { font-size: 11.5px; }
  .frow-guest .fl-status .chip { height: 18px; padding: 0 6px; font-size: 11px; }
  .frow-guest .fl-check { grid-column: 6; grid-row: 1 / 4; justify-self: end; }
  .frow-guest .fl-check .checkbox { width: 32px; height: 32px; border-radius: 8px; font-size: 15px; }

  /* ---------- thanh thao tác hàng loạt ---------- */
  .selbar {
    left: 10px; right: 10px; bottom: calc(16px + var(--safe-b));
    transform: none; flex-wrap: wrap; gap: 8px;
    padding: 10px 12px 12px; border-radius: 14px;
  }
  .selbar > .dim { display: none; }
  #selCount { flex: 1 1 100%; font-size: 13px; color: var(--txt-2); }
  .selbar [data-bulk] { flex: 1 1 30%; height: var(--tap); padding: 0 8px; font-size: 13px; justify-content: center; }
  #selDl { flex: 1 1 100%; height: var(--tap); justify-content: center; }
  /* đã có nút Huỷ ở thanh trên của chế độ chọn */
  #selClear { display: none; }
  /* thanh thao tác cao 2 tầng, chừa chỗ để ảnh cuối cùng không bị nó che */
  body.sel-mode .wrap { padding-bottom: 215px; }

  /* ---------- lightbox ---------- */
  /* 100dvh thay cho inset:0 — thanh địa chỉ iOS co giãn sẽ không cắt mất đáy */
  .lb { height: 100dvh; }
  .lb.open {
    grid-template-rows: auto minmax(0, 1fr) auto;
    padding-bottom: calc(60px + var(--safe-b));
    transition: padding-bottom .22s;
  }
  .lb.open.chrome-off { padding-bottom: 0; }

  .lb-head {
    height: 52px; padding: 0 8px; gap: 8px;
    transition: height .22s, opacity .18s;
  }
  /* Không dùng overflow:hidden để giấu thanh trên. .lb-acts nằm bên trong thanh này
     nhưng lại định vị tuyệt đối theo .lb — overflow của thanh trên không cắt được nó,
     nên phải giấu bằng opacity + visibility (cả hai cùng ẩn, đúng ý đồ). */
  .lb.chrome-off .lb-head {
    height: 0; opacity: 0; visibility: hidden;
    border-bottom-width: 0;
    transition: height .22s, opacity .18s, visibility 0s .18s;
  }
  .lb-head > div:not(.spacer):not(.lb-acts) { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #lbClose { width: var(--tap); height: var(--tap); }

  /* nhóm hành động tụt xuống thành thanh dưới */
  .lb-acts {
    position: absolute; left: 0; right: 0; bottom: 0; z-index: 6;
    height: calc(60px + var(--safe-b)); padding: 0 10px var(--safe-b);
    gap: 6px; background: var(--bg-1); border-top: 1px solid var(--line-soft);
    overflow: hidden; transition: height .22s, opacity .18s;
  }
  /* .lb-acts thừa hưởng opacity/visibility của thanh trên, chỉ cần co chiều cao về 0 */
  .lb.chrome-off .lb-acts { height: 0; padding-bottom: 0; border-top-width: 0; }
  .lb-acts #lbStars { flex: none; }
  .lb-acts .lb-stars { gap: 6px; }
  .lb-acts .lb-stars .star { font-size: 22px; padding: 4px 1px; }
  #lbPick { margin-left: auto; }
  #lbPick, #lbChanges, #lbPanel { height: var(--tap); padding: 0 10px; font-size: 13px; flex: none; }
  /* Tải về đã chuyển vào menu ⋯ */
  .lb-acts #lbDl { display: none !important; }

  /* khung ảnh: lấy lại 24px mỗi chiều */
  .stage img, .stage video { inset: 8px; max-width: calc(100% - 16px); max-height: calc(100% - 16px); }
  /* đã có vuốt để chuyển ảnh, hai nút này chỉ che mất ảnh */
  .nav { display: none; }
  .zoombar { display: none; }
  .qwrap { right: 12px; bottom: 12px; }
  .qbar { height: 38px; font-size: 13px; }

  /* dải ảnh nhỏ: ẩn mặc định, bật từ menu ⋯ */
  .lb .filmstrip { display: none; }
  .lb.strip-on:not(.chrome-off) .filmstrip { display: flex; }

  /* ---------- panel góp ý thành sheet trượt lên ---------- */
  .lb-body, .lb-body.with-panel { grid-template-columns: minmax(0, 1fr); }
  .panel {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
    max-height: 74dvh; border-left: none; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, .6);
    transform: translateY(101%); transition: transform .24s cubic-bezier(.22, .8, .2, 1);
  }
  .lb-body.with-panel .panel { transform: translateY(0); }
  /* tay nắm kéo ở mép trên sheet */
  .panel .p-head { position: relative; padding-top: 18px; }
  .panel .p-head::before {
    content: ''; position: absolute; top: 7px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 999px; background: #3a3f4d;
  }
  .panel .p-foot { padding: 10px 12px calc(12px + var(--safe-b)); }

  /* ---------- ô nhập & vùng chạm trong góp ý ---------- */
  /* 16px là bắt buộc: nhỏ hơn thì iOS tự phóng to cả trang khi khách bấm vào ô */
  input.input, textarea.input { font-size: 16px; }
  .gate-box .input { height: 46px; }
  .gate-box .btn.primary { height: 48px; }
  .drawbar { flex-wrap: wrap; gap: 8px; }
  .swatch { width: 28px; height: 28px; }
  .pen { height: 36px; padding: 0 12px; }
  .drawbar .btn.sm { height: 36px; min-width: 40px; justify-content: center; }
  .emoji-pop {
    position: static; flex: 1 1 100%; width: 100%;
    grid-template-columns: repeat(6, 1fr); max-height: 132px;
  }
  .emoji-pop span { height: 36px; font-size: 20px; }
  #cmtSend { height: var(--tap); padding: 0 20px; }

  /* ---------- kê mọi thứ dính đáy lên trên vạch home ---------- */
  .toast { bottom: calc(26px + var(--safe-b)); }
  .modal .m-foot { padding-bottom: calc(12px + var(--safe-b)); }
  .modal .m-foot .btn { height: var(--tap); }
}
