:root {
  --nen: #f3f6f1; --the: #fff; --vien: #dce6d8; --chu: #14301c; --mo: #5b7262;
  --xanh: #1b5e20; --xanh-dam: #0f3d2e; --xanh-nhat: #e8f3e3; --do: #d32f2f; --vang: #f6b21b;
  --bo: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font: 16px/1.5 "Be Vietnam Pro", system-ui, sans-serif; background: var(--nen); color: var(--chu); }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }

/* ── Khung chính */
.trang { max-width: 640px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px 110px; }
.dau { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.dau h1 { font-size: 21px; margin: 0; flex: 1; color: var(--xanh-dam); }
.nut { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--xanh); color: #fff; font-weight: 600; }
.nut.phu { background: var(--xanh-nhat); color: var(--xanh-dam); }
.nut.do { background: #fdecea; color: var(--do); }
.nut.rong { width: 100%; }
.nut:disabled { opacity: .5; }
.the { background: var(--the); border: 1px solid var(--vien); border-radius: var(--bo); padding: 14px; margin-bottom: 10px; }
.the h3 { margin: 0 0 4px; font-size: 16.5px; }
.mo { color: var(--mo); font-size: 14px; }
.hai-dong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.trong { text-align: center; color: var(--mo); padding: 40px 10px; }
.nhan { display: inline-block; font-size: 12.5px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: #eef1ec; color: var(--mo); }
.nhan.cho-duyet { background: #fff4d6; color: #8a5a00; }
.nhan.moi, .nhan.dang-dung { background: #e3effd; color: #1c4f8a; }
.nhan.da-duyet, .nhan.da-len-lich { background: var(--xanh-nhat); color: var(--xanh); }
.nhan.lam-lai, .nhan.loi { background: #fdecea; color: var(--do); }
.hang { display: flex; gap: 8px; align-items: center; }
.hang > .gian { flex: 1; min-width: 0; }
label.o { display: block; font-weight: 600; font-size: 14.5px; margin: 12px 0 6px; }
.o-nhap { width: 100%; padding: 12px; border: 1px solid #c7d6c3; border-radius: 10px; background: #fff; }
textarea.o-nhap { min-height: 220px; resize: vertical; line-height: 1.55; }
.thanh-tai { height: 6px; background: #dbe8d7; border-radius: 4px; overflow: hidden; margin-top: 8px; }
.thanh-tai > i { display: block; height: 100%; background: var(--xanh); width: 0; transition: width .3s; }

/* ── Thanh dưới */
.thanh-duoi { position: fixed; left: 0; right: 0; bottom: 0; background: #fff; border-top: 1px solid var(--vien);
  display: flex; justify-content: space-around; align-items: center; padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px); z-index: 5; }
.thanh-duoi button { background: none; border: 0; color: var(--mo); font-size: 12.5px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 70px; }
.thanh-duoi button.dang { color: var(--xanh); font-weight: 600; }
.thanh-duoi .bieu { font-size: 22px; line-height: 1; }
.thanh-duoi .nut-quay { width: 62px; height: 62px; border-radius: 50%; background: var(--do); color: #fff; font-size: 13px; font-weight: 700;
  margin-top: -26px; box-shadow: 0 6px 18px rgba(211,47,47,.35); justify-content: center; border: 4px solid #fff; }

/* ── Lớp phủ (ngăn kéo dưới) */
#lop:empty { display: none; }
.man-mo { position: fixed; inset: 0; background: rgba(10,30,18,.45); z-index: 20; display: flex; align-items: flex-end; }
.ngan { background: var(--nen); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0;
  max-height: 92vh; overflow: auto; padding: 16px 16px calc(env(safe-area-inset-bottom) + 18px); }
.ngan video, .the video { width: 100%; border-radius: 12px; background: #000; max-height: 60vh; display: block; }
.chon-kenh label { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--vien); font-size: 15px; }
.chon-kenh input { width: 22px; height: 22px; accent-color: var(--xanh); }

.bao { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 96px); transform: translateX(-50%);
  background: #14301c; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14.5px; opacity: 0; pointer-events: none;
  transition: opacity .2s; z-index: 60; max-width: 90vw; }
.bao.hien { opacity: 1; }

/* ── Màn đăng nhập */
.dang-nhap { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; max-width: 380px; margin: 0 auto; padding: 24px; }
.dang-nhap img { width: 76px; height: 76px; border-radius: 18px; margin-bottom: 14px; }

/* ── Màn quay (toàn màn hình, nền đen) */
.quay { position: fixed; inset: 0; background: #000; z-index: 40; color: #fff; overflow: hidden; touch-action: none; }
.quay .xem { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
/* camera thật chạy ngầm để canvas vẽ lại (iPhone dừng giải mã nếu display:none) */
.quay .cam-an { position: absolute; width: 2px; height: 2px; opacity: 0; pointer-events: none; }
.quay .xem.guong { transform: scaleX(-1); }
.quay .xem.ngang { object-fit: contain; } /* khổ ngang: thấy trọn khung ghi, giữa màn hình */
.o-ghi { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.o-ghi span { font-size: 14px; font-weight: 700; text-shadow: 0 1px 3px rgba(0,0,0,.7); }
.chu-chay { position: absolute; left: 0; right: 0; top: 0; overflow: hidden;
  padding: calc(env(safe-area-inset-top) + 56px) 22px 0;
  background: linear-gradient(rgba(0,0,0,.72) 70%, rgba(0,0,0,0)); }
.chu-chay .ruot { will-change: transform; white-space: pre-wrap; font-weight: 600; line-height: 1.45; text-align: center;
  text-shadow: 0 1px 3px rgba(0,0,0,.6); padding-bottom: 60vh; }
.chu-chay .vach-doc { position: absolute; left: 6px; right: 6px; height: 0; border-top: 2px dashed rgba(246,178,27,.55); pointer-events: none; }
.chu-chay.dung .ruot { opacity: .75; }
.quay .tren { position: absolute; top: calc(env(safe-area-inset-top) + 10px); left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; z-index: 3; }
.quay .tron { width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255,255,255,.18); color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px); }
.quay .toc { display: flex; align-items: center; gap: 4px; background: rgba(255,255,255,.18); border-radius: 99px; padding: 3px; backdrop-filter: blur(6px); }
.quay .toc button { width: 36px; height: 36px; border-radius: 50%; border: 0; background: rgba(0,0,0,.35); color: #fff; font-size: 22px; line-height: 1; }
.quay .toc b { min-width: 30px; text-align: center; font-variant-numeric: tabular-nums; }
.quay .gio { flex: 1; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }
.quay .gio.ghi::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--do); margin-right: 7px; animation: nhap 1s infinite; }
@keyframes nhap { 50% { opacity: .25; } }
.quay .duoi { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 28px calc(env(safe-area-inset-bottom) + 22px);
  display: flex; align-items: center; justify-content: space-between; z-index: 3; }
.nut-ghi { width: 78px; height: 78px; border-radius: 50%; border: 5px solid #fff; background: transparent; padding: 0; display: flex; align-items: center; justify-content: center; }
.nut-ghi i { display: block; width: 58px; height: 58px; border-radius: 50%; background: var(--do); transition: all .2s; }
.nut-ghi.dang i { width: 30px; height: 30px; border-radius: 7px; }
.dem-nguoc { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 120px; font-weight: 700; z-index: 4; pointer-events: none; text-shadow: 0 4px 20px rgba(0,0,0,.5); }
.cai-chu { position: absolute; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 120px); background: rgba(20,20,20,.86);
  border-radius: 16px; padding: 14px 16px; z-index: 5; backdrop-filter: blur(8px); }
.cai-chu label { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 6px 0; }
.cai-chu label span { width: 92px; flex: 0 0 auto; }
.cai-chu input[type=range] { flex: 1; accent-color: var(--vang); }
.cai-chu b { width: 40px; text-align: right; font-variant-numeric: tabular-nums; }
.goi-y { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom) + 112px); text-align: center; font-size: 13px; color: rgba(255,255,255,.75); z-index: 2; }

/* Xem lại sau khi quay */
.xem-lai { position: absolute; inset: 0; background: #000; z-index: 6; display: flex; flex-direction: column; }
.xem-lai video { flex: 1; width: 100%; min-height: 0; object-fit: contain; background: #000; }
.xem-lai .duoi2 { padding: 14px 16px calc(env(safe-area-inset-bottom) + 16px); display: flex; gap: 10px; }
.xem-lai .duoi2 .nut { flex: 1; padding: 15px; }
