:root {
  --den: #0f0f0f;
  --den-2: #1b1b1b;
  --vang: #d9b45a;
  --vang-dam: #a8843a;
  --nga: #faf8f3;
  --trang: #ffffff;
  --chu: #1d1d1b;
  --chu-nhat: #6b665c;
  --vien: #e7e1d3;
  --do: #c8102e;
  --xanh: #1f7a4d;
  --cam: #b86e00;
  --bo: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--nga); color: var(--chu);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: inherit; }
button, input, select, textarea { font: inherit; }

/* đầu trang */
.dau {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--den); color: var(--trang);
  border-bottom: 2px solid var(--vang);
}
.logo img { height: 34px; display: block; }
#menu { display: flex; gap: 6px; align-items: center; }
#menu a, #menu button {
  color: var(--vang); text-decoration: none; background: none; border: 1px solid #3a3426;
  padding: 6px 10px; border-radius: 999px; font-size: 14px; cursor: pointer;
}
#menu a.dang { background: var(--vang); color: var(--den); border-color: var(--vang); }

main { max-width: 920px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 6px 0 14px; line-height: 1.3; }
h2 { font-size: 18px; margin: 22px 0 10px; }
.cho { color: var(--chu-nhat); text-align: center; padding: 40px 0; }
.nhat { color: var(--chu-nhat); font-size: 14px; }

/* thẻ */
.the {
  background: var(--trang); border: 1px solid var(--vien); border-radius: var(--bo);
  padding: 16px; margin-bottom: 12px;
}
.the-khoa { display: block; text-decoration: none; }
.the-khoa h3 { margin: 0 0 4px; font-size: 17px; }
.thanh { height: 8px; background: #efe9da; border-radius: 99px; overflow: hidden; margin: 10px 0 6px; }
.thanh > i { display: block; height: 100%; background: var(--vang); border-radius: 99px; }
.nhan {
  display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px;
  background: #efe9da; color: var(--chu);
}
.nhan.xanh { background: #e3f3ea; color: var(--xanh); }
.nhan.cam { background: #fff1dc; color: var(--cam); }
.nhan.do { background: #fde4e8; color: var(--do); }

/* nút */
.nut {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 10px; border: 1px solid var(--den);
  background: var(--den); color: var(--vang); font-weight: 600; cursor: pointer; text-decoration: none;
}
.nut.phu { background: var(--trang); color: var(--chu); border-color: var(--vien); }
.nut.do { background: var(--do); border-color: var(--do); color: #fff; }
.nut.nho { min-height: 34px; padding: 5px 12px; font-size: 14px; }
.nut:disabled { opacity: .5; cursor: default; }
.hang-nut { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }

/* biểu mẫu */
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--vien); background: var(--trang); color: var(--chu);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--vang); border-color: var(--vang); }
.o-chon { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 6px 0; }
.o-chon input { width: 20px; min-height: 20px; }
.loi { color: var(--do); font-size: 14px; margin-top: 8px; min-height: 1em; }

.dang-nhap { max-width: 400px; margin: 30px auto; }
.dang-nhap .the { padding: 22px; }

/* danh sách bài */
.ds-bai { list-style: none; margin: 0; padding: 0; }
.ds-bai li a {
  display: flex; align-items: center; gap: 12px; padding: 12px 4px; text-decoration: none;
  border-bottom: 1px solid var(--vien);
}
.ds-bai .so {
  flex: 0 0 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: #efe9da; font-size: 13px; font-weight: 700;
}
.ds-bai .so.xong { background: var(--xanh); color: #fff; }
.ds-bai .ten-bai { flex: 1; }

/* trình phát + hình mờ */
.khung-video {
  position: relative; background: #000; border-radius: var(--bo); overflow: hidden;
  aspect-ratio: 16 / 9; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.khung-video video { width: 100%; height: 100%; display: block; background: #000; }
.hinh-mo {
  position: absolute; z-index: 5; pointer-events: none; white-space: nowrap;
  color: rgba(255, 255, 255, .55); text-shadow: 0 0 3px rgba(0, 0, 0, .7);
  font-size: clamp(11px, 2.4vw, 16px); font-weight: 600;
  transition: left 1.2s ease, top 1.2s ease;
}
.hinh-mo-nen {
  position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: hidden;
  display: grid; grid-template-columns: repeat(3, 1fr); align-content: space-around; justify-items: center;
  transform: rotate(-18deg) scale(1.3);
  color: rgba(255, 255, 255, .09); font-size: clamp(10px, 2vw, 14px); font-weight: 700;
}
.nut-phong {
  position: absolute; z-index: 6; right: 10px; top: 10px;
  background: rgba(0, 0, 0, .55); color: #fff; border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.khung-video.toan-man {
  position: fixed; inset: 0; z-index: 100; border-radius: 0; aspect-ratio: auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.khung-video.toan-man video { object-fit: contain; }
body.dang-phong { overflow: hidden; }
.chan-video {
  position: absolute; inset: 0; z-index: 7; display: grid; place-items: center; text-align: center;
  background: rgba(0, 0, 0, .85); color: #fff; padding: 20px;
}

/* quản trị */
.bang { width: 100%; border-collapse: collapse; background: var(--trang); }
.hv-dong {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px; border-bottom: 1px solid var(--vien); text-decoration: none;
}
.hv-dong:last-child { border-bottom: 0; }
.hv-dong .ten { font-weight: 600; }
.the.dem { padding: 0; overflow: hidden; }
.o-thong-ke { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.o-thong-ke .the { margin: 0; text-align: center; }
.o-thong-ke b { display: block; font-size: 26px; color: var(--vang-dam); }
.hop-mk {
  background: #fffaf0; border: 1px dashed var(--vang); border-radius: 10px; padding: 12px; white-space: pre-wrap;
  font-family: ui-monospace, Menlo, monospace; font-size: 14px;
}
.nhat-ky { font-size: 13px; color: var(--chu-nhat); }
.nhat-ky div { padding: 4px 0; border-bottom: 1px dotted var(--vien); }

#thong-bao {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--den); color: var(--vang); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 200; max-width: calc(100% - 32px);
}
#thong-bao.hien { opacity: 1; }

@media (min-width: 700px) {
  h1 { font-size: 26px; }
  .luoi-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
}

/* tốc độ phát */
.nut-toc {
  position: absolute; z-index: 6; left: 10px; top: 10px; min-width: 52px;
  background: rgba(0, 0, 0, .55); color: #fff; border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.bang-toc {
  position: absolute; z-index: 8; left: 10px; top: 46px; max-height: calc(100% - 56px); overflow-y: auto;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px;
  background: rgba(15, 15, 15, .92); border: 1px solid rgba(217, 180, 90, .5); border-radius: 10px;
}
.bang-toc[hidden] { display: none; }
.bang-toc button {
  background: transparent; color: #fff; border: 1px solid rgba(255, 255, 255, .2); border-radius: 6px;
  padding: 6px 8px; font-size: 13px; cursor: pointer; min-width: 52px;
}
.bang-toc button.chon { background: var(--vang, #d9b45a); color: #0f0f0f; border-color: transparent; font-weight: 700; }
/* hiện mật khẩu */
.o-mk { position: relative; }
.o-mk input { padding-right: 84px; }
.nut-mat {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; color: var(--chu, #333); font-size: 14px; padding: 6px 8px; cursor: pointer;
}
