:root {
  --nen: #f6f4ef; --mat: #ffffff; --chu: #1c1f1d; --chu-2: #5d635f; --chu-3: #8b918d;
  --vien: #e3e0d8; --chinh: #1f3a2e; --chinh-chu: #ffffff; --nhan: #c8a24a; --loi: #b3261e;
  --bong: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --tron: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --nen: #121513; --mat: #1b1f1c; --chu: #eceee9; --chu-2: #a9afa9; --chu-3: #7b817c;
    --vien: #2a302c; --chinh: #8fc4a8; --chinh-chu: #0f1a14; --nhan: #e0bd68; --loi: #f2827a;
    --bong: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --nen: #121513; --mat: #1b1f1c; --chu: #eceee9; --chu-2: #a9afa9; --chu-3: #7b817c;
  --vien: #2a302c; --chinh: #8fc4a8; --chinh-chu: #0f1a14; --nhan: #e0bd68; --loi: #f2827a;
  --bong: none; color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--nen); color: var(--chu);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom);
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* thanh trên */
.top {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 4px;
  padding: calc(env(safe-area-inset-top) + 8px) 8px 8px 16px;
  background: color-mix(in srgb, var(--nen) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--vien);
}
.top h1 { flex: 1; margin: 0; font-size: 19px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#nut-lui:not([hidden]) + h1 { margin-left: -4px; }
.nut-icon { border: 0; background: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; flex: none; }
.nut-icon:active { background: var(--vien); }
.nut {
  border: 0; border-radius: 999px; padding: 11px 20px; min-height: 44px; cursor: pointer;
  background: var(--chinh); color: var(--chinh-chu); font-weight: 600;
}
.nut.phu { background: var(--vien); color: var(--chu); }
.nut.do { background: var(--loi); color: #fff; }
.nut:disabled { opacity: .5; }
.nut.rong { width: 100%; }

main { padding: 16px; max-width: 960px; margin: 0 auto; }

/* đăng nhập */
.cua { max-width: 380px; margin: 8vh auto 0; }
.cua .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 12px; }
.cua h2 { text-align: center; margin: 0 0 4px; font-size: 26px; }
.cua .phu-de { text-align: center; color: var(--chu-2); margin: 0 0 24px; }
.the { background: var(--mat); border: 1px solid var(--vien); border-radius: var(--tron); padding: 20px; box-shadow: var(--bong); }
.tab2 { display: grid; grid-template-columns: 1fr 1fr; background: var(--vien); border-radius: 999px; padding: 4px; margin-bottom: 18px; }
.tab2 button { border: 0; background: none; padding: 8px; border-radius: 999px; cursor: pointer; font-weight: 600; color: var(--chu-2); }
.tab2 button.on { background: var(--mat); color: var(--chu); box-shadow: var(--bong); }
.o { display: block; margin-bottom: 14px; }
.o span { display: block; font-size: 14px; color: var(--chu-2); margin-bottom: 4px; }
.o input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--vien);
  background: var(--nen); font-size: 16px; outline: none;
}
.o input:focus { border-color: var(--chinh); }
.loi-chu { color: var(--loi); font-size: 14px; min-height: 20px; margin: 0 0 8px; }

.bao-trong { text-align: center; color: var(--chu-2); padding: 48px 16px; }
.bao-trong b { display: block; color: var(--chu); font-size: 18px; margin-bottom: 6px; }

/* danh sách album */
.dau-ds { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 12px; }
.dau-ds p { margin: 0; color: var(--chu-2); font-size: 14px; }
.luoi-album { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.album { border: 0; padding: 0; background: none; text-align: left; cursor: pointer; }
.album .bia {
  aspect-ratio: 1; border-radius: var(--tron); overflow: hidden; background: var(--vien);
  display: grid; place-items: center; color: var(--chu-3);
}
.album .bia img { width: 100%; height: 100%; object-fit: cover; display: block; }
.album b { display: block; margin-top: 8px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.album small { color: var(--chu-2); font-size: 13px; }

/* lưới ảnh */
.dong-album { display: flex; justify-content: space-between; align-items: center; margin: -4px 0 10px; color: var(--chu-2); font-size: 14px; gap: 8px; }
.dong-album button { border: 0; background: none; color: var(--chinh); font-weight: 600; cursor: pointer; padding: 8px 0; }
.luoi-anh { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; margin: 0 -13px; }
@media (min-width: 640px) { .luoi-anh { grid-template-columns: repeat(5, 1fr); margin: 0; gap: 6px; } }
.o-anh { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: var(--vien); cursor: pointer; overflow: hidden; }
@media (min-width: 640px) { .o-anh { border-radius: 8px; } }
.o-anh img { width: 100%; height: 100%; object-fit: cover; display: block; }
.o-anh .ten-tep { position: absolute; inset: 0; display: grid; place-items: center; font-size: 11px; color: var(--chu-2); padding: 6px; word-break: break-all; }
.o-anh .dau { position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%; border: 2px solid #fff; background: rgba(0,0,0,.25); display: none; }
.dang-chon .o-anh .dau { display: block; }
.o-anh.chon .dau { background: var(--chinh); border-color: #fff; }
.o-anh.chon .dau::after { content: ""; position: absolute; left: 6px; top: 2px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.o-anh.chon img { opacity: .75; }
.them-nua { display: block; margin: 16px auto; }

.fab {
  position: fixed; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 18px); z-index: 20;
  display: flex; align-items: center; gap: 8px; padding: 14px 20px 14px 16px; border-radius: 999px;
  background: var(--chinh); color: var(--chinh-chu); font-weight: 650; box-shadow: 0 6px 20px rgba(0,0,0,.22); cursor: pointer;
}
.thanh-chon {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px calc(env(safe-area-inset-bottom) + 12px); background: var(--mat); border-top: 1px solid var(--vien);
}
.tien-do {
  position: fixed; left: 16px; right: 16px; bottom: calc(env(safe-area-inset-bottom) + 84px); z-index: 30; max-width: 480px; margin: 0 auto;
  background: var(--mat); border: 1px solid var(--vien); border-radius: var(--tron); padding: 12px 14px; box-shadow: var(--bong);
}
.td-dong { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 8px; gap: 8px; }
.td-thanh { height: 6px; border-radius: 3px; background: var(--vien); overflow: hidden; }
.td-thanh i { display: block; height: 100%; width: 0; background: var(--chinh); transition: width .2s; }

/* xem ảnh */
.xem { position: fixed; inset: 0; z-index: 50; background: #000; color: #fff; display: flex; flex-direction: column; }
.xem-tren, .xem-duoi { display: flex; align-items: center; justify-content: space-between; padding: 8px; gap: 8px; }
.xem-tren { padding-top: calc(env(safe-area-inset-top) + 8px); }
.xem-duoi { padding-bottom: calc(env(safe-area-inset-bottom) + 12px); }
.xem-tren #xem-vt { font-size: 14px; opacity: .8; }
.xem-nut-phai { display: flex; gap: 2px; }
#xem-bia.on { color: #f2c94c; }
#xem-bia.on svg path { fill: currentColor; }
.xem-khung { flex: 1; min-height: 0; display: grid; place-items: center; overflow: hidden; touch-action: pan-y pinch-zoom; }
.xem-khung img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; user-select: none; -webkit-user-drag: none; }
.xem-bao { color: #ccc; text-align: center; padding: 24px; max-width: 320px; }
.nut-icon.sang:active { background: rgba(255,255,255,.15); }
.nut.sang { background: #fff; color: #111; }
.xem-thongtin { padding: 12px 16px; font-size: 14px; line-height: 1.7; background: rgba(255,255,255,.08); }
.xem-thongtin b { font-weight: 600; }

/* hộp thoại */
.hop-thoai { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.45); display: grid; place-items: end center; padding: 16px; }
@media (min-width: 640px) { .hop-thoai { place-items: center; } }
.ht-the { width: 100%; max-width: 420px; background: var(--mat); border-radius: 18px; padding: 20px; margin-bottom: env(safe-area-inset-bottom); }
.ht-the h3 { margin: 0 0 6px; font-size: 18px; }
.ht-the p { margin: 0 0 16px; color: var(--chu-2); }
.ht-nut { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }
.ds-menu { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 12px; }
.ds-menu button { border: 0; background: none; text-align: left; padding: 12px 4px; border-radius: 10px; cursor: pointer; font-weight: 550; }
.ds-menu button:active { background: var(--vien); }

/* quản trị */
.nguoi { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--vien); }
.nguoi div { flex: 1; min-width: 0; }
.nguoi b { display: block; }
.nguoi small { color: var(--chu-2); display: block; overflow: hidden; text-overflow: ellipsis; }
.nhan { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--vien); color: var(--chu-2); margin-top: 4px; }
.nhan.cho { background: color-mix(in srgb, var(--nhan) 25%, transparent); color: var(--chu); }
.nguoi .nut { padding: 8px 14px; min-height: 38px; font-size: 14px; }
.nguoi .nguoi-nut { display: flex; flex-direction: column; gap: 6px; align-items: stretch; flex: none; }

.thong-bao {
  position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 70px); transform: translateX(-50%); z-index: 70;
  background: var(--chu); color: var(--nen); padding: 10px 16px; border-radius: 999px; font-size: 14px; max-width: calc(100% - 32px); text-align: center;
}
