/* CodeNumber – phong cách Zalo, gọn cho điện thoại, dễ đọc cho người mắt kém. */
:root {
  --primary: #1A7CFF;
  --primary-dark: #0B68E6;
  --grad: linear-gradient(120deg, #4A9DFF 0%, #2E8BFF 45%, #1A78F2 100%);
  --on-primary: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F1F3F6;
  --chat-bg: #E9EDF1;
  --text: #081C36;
  --muted: #5A6981;
  --line: #DDE2E8;
  --bubble: #EEF5FF;
  --bubble-line: #D2E4FF;
  --danger: #E5383B;
  --ok: #18904A;
  --focus: #FF9800;
  --shadow-sm: 0 1px 2px rgba(8, 28, 54, .08), 0 2px 8px rgba(8, 28, 54, .06);
  --shadow-lg: 0 12px 40px rgba(8, 28, 54, .22);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  font-size: 18px;
}
html.fs-2 { font-size: 21px; }
html.fs-3 { font-size: 24px; }

html.hc {
  --primary: #FFD400;
  --primary-dark: #E6BE00;
  --grad: #000;
  --on-primary: #000;
  --surface: #000;
  --surface-2: #161616;
  --chat-bg: #000;
  --text: #FFFFFF;
  --muted: #FFE45C;
  --line: #5C5C5C;
  --bubble: #FFD400;
  --bubble-line: #FFD400;
  --danger: #FF5A5A;
  --ok: #4CFF7A;
  --shadow-sm: none;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.4;
  color: var(--text);
  background: #CBD3DD;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-user-select: none; user-select: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
svg { flex: none; }
.ico-s { width: 1em; height: 1em; }

/* ---------- Khung ứng dụng: luôn vừa màn hình điện thoại ---------- */
.app {
  position: relative;
  max-width: 480px;
  height: var(--app-h, 100dvh);
  margin: 0 auto;
  overflow: hidden;
  background: var(--surface);
}
@media (min-width: 560px) and (min-height: 700px) {
  body { background: radial-gradient(circle at 30% 20%, #DCE6F5, #B9C5D6); }
  .app { height: calc(var(--app-h, 100dvh) - 40px); margin: 20px auto; border-radius: 28px; box-shadow: var(--shadow-lg); }
}
.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}
.view.enter { animation: view-in .4s var(--ease) both; }

/* ---------- Thanh tiêu đề ---------- */
.topbar {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top) + 8px) 10px 8px 12px;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 2px 10px rgba(26, 120, 242, .22);
}
.topbar.admin { background: linear-gradient(120deg, #22304A, #0F172A); box-shadow: 0 2px 10px rgba(15, 23, 42, .3); }
html.hc .topbar { color: #FFD400; border-bottom: 2px solid #FFD400; box-shadow: none; }
.avatar {
  width: 42px; height: 42px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
}
.avatar svg { width: 24px; height: 24px; }
html.hc .avatar { background: #222; }
.title {
  flex: 1; min-width: 0;
  padding: 2px 0;
  border: 0; background: none; color: inherit; text-align: left;
}
.title-main { display: block; font-size: 1.05rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.title-sub { display: flex; align-items: center; gap: 4px; font-size: .75rem; opacity: .92; }
.icon-btn {
  width: 46px; height: 46px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: rgba(255, 255, 255, .16);
  color: inherit;
  transition: transform .2s var(--spring), background .2s;
}
.icon-btn svg { width: 26px; height: 26px; transition: transform .5s var(--ease); }
.icon-btn:active { transform: scale(.88); background: rgba(255, 255, 255, .3); }
.icon-btn.gear:active svg { transform: rotate(90deg); }
html.hc .icon-btn { background: #222; }

/* ---------- Vùng tin nhắn ---------- */
.chat-body { position: relative; flex: 1; min-height: 0; background: var(--chat-bg); }
.msgs {
  position: absolute; inset: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 10px 10px 14px;
}
.day { display: flex; justify-content: center; margin: 12px 0 8px; }
.day span {
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(8, 28, 54, .38);
  color: #fff;
  font-size: .72rem; font-weight: 600;
}
html.hc .day span { background: #222; border: 1px solid #fff; }

.row { display: flex; justify-content: flex-end; margin: 5px 0; transform-origin: 100% 100%; }
.row.enter { animation: msg-in .42s var(--spring) both; }
.row.leaving, .day.leaving { overflow: hidden; pointer-events: none; }
.day.enter { animation: fade-in .4s ease both; }

.bubble {
  position: relative;
  max-width: 80%;
  padding: 8px 12px 6px;
  border: 1px solid var(--bubble-line);
  border-radius: 14px 14px 4px 14px;
  background: var(--bubble);
  color: var(--text);
  text-align: left;
  box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), box-shadow .2s;
}
html.hc .bubble { color: #000; }
.bubble:active { transform: scale(.97); }
.bubble .text { font-size: 1rem; line-height: 1.38; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-start; gap: 4px 8px;
  margin-top: 3px;
  font-size: .68rem; font-weight: 500;
  color: var(--muted);
}
html.hc .bubble .meta { color: #000; }
.exp { display: inline-flex; align-items: center; gap: 3px; }
.exp.soon { color: var(--danger); font-weight: 700; animation: pulse 1s ease-in-out infinite; }
html.hc .bubble .exp.soon { color: #B00000; }
.state.error { color: var(--danger); font-weight: 700; }
.row.failed .bubble { border-color: var(--danger); }

/* Ảnh */
.bubble.img { padding: 3px; border-radius: 14px 14px 4px 14px; overflow: hidden; }
.bubble.img img {
  display: block;
  max-width: 100%;
  max-height: 52vh;
  min-width: 140px; min-height: 120px;
  border-radius: 11px 11px 2px 11px;
  object-fit: cover;
  opacity: 0;
  transition: opacity .4s ease;
}
.bubble.img img.loaded { opacity: 1; }
.bubble.img .ph { border-radius: 11px; overflow: hidden; }
.bubble.img .meta {
  position: absolute; right: 8px; bottom: 8px;
  margin: 0; padding: 2px 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
html.hc .bubble.img .meta { color: #fff; }
.row.sending .bubble.img img { filter: brightness(.75); }
.progress {
  position: absolute; left: 12px; right: 12px; top: 50%;
  height: 6px; margin-top: -3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .35);
  overflow: hidden;
}
.progress i { display: block; height: 100%; width: 0; background: #fff; border-radius: 3px; transition: width .25s var(--ease); }

/* Tệp đính kèm */
.bubble.file { min-width: 230px; padding: 10px 12px 6px; }
.file-card { display: flex; align-items: center; gap: 10px; }
.file-ic {
  position: relative;
  width: 44px; height: 52px; flex: none;
  display: grid; place-items: end center;
  padding-bottom: 6px;
  border-radius: 6px 14px 6px 6px;
  background: var(--fc, #5A6981);
  color: #fff;
  font-size: .58rem; font-weight: 800; letter-spacing: .02em;
}
.file-ic::before {
  content: ''; position: absolute; top: 0; right: 0;
  border-style: solid; border-width: 0 14px 14px 0;
  border-color: transparent var(--bubble) rgba(255, 255, 255, .45) transparent;
}
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: .9rem; font-weight: 700; line-height: 1.25;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere;
}
.file-size { font-size: .72rem; color: var(--muted); margin-top: 2px; }
html.hc .file-size { color: #000; }
.file-dl {
  width: 38px; height: 38px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(26, 124, 255, .12);
  color: var(--primary);
}
html.hc .file-dl { background: #000; color: #FFD400; }
.file-dl svg { width: 22px; height: 22px; }
.bubble.file .progress { position: static; margin: 8px 0 2px; background: rgba(26, 124, 255, .15); }
.bubble.file .progress i { background: var(--primary); }

/* Nút cuộn xuống (giống Zalo) */
.to-bottom {
  position: absolute; right: 12px; bottom: 12px; z-index: 2;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: var(--surface);
  color: var(--muted);
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translateY(16px) scale(.6);
  pointer-events: none;
  transition: opacity .25s, transform .35s var(--spring);
}
.to-bottom.show { opacity: 1; transform: none; pointer-events: auto; }
.to-bottom svg { width: 26px; height: 26px; }
html.hc .to-bottom { border: 2px solid #FFD400; color: #FFD400; }

/* ---------- Ô soạn tin (kiểu Zalo) ---------- */
.composer {
  flex: none;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tools {
  display: flex; gap: 2px;
  padding: 4px 6px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tools::-webkit-scrollbar { display: none; }
.tool {
  display: flex; align-items: center; gap: 6px;
  min-height: 44px;
  padding: 4px 12px;
  border: 0; border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: .82rem; font-weight: 600;
  white-space: nowrap;
  transition: background .15s, transform .2s var(--spring);
}
.tool svg { width: 26px; height: 26px; color: var(--primary); }
html.hc .tool svg { color: #FFD400; }
.tool:active { background: var(--surface-2); transform: scale(.94); }
.input-row {
  display: flex; align-items: flex-end; gap: 6px;
  padding: 4px 8px 8px 12px;
}
.input-row textarea {
  flex: 1; min-width: 0;
  min-height: 46px; max-height: 32vh;
  padding: 11px 4px;
  border: 0; border-bottom: 2px solid var(--line);
  background: transparent;
  color: var(--text);
  font-size: 1rem; line-height: 1.3;
  resize: none; outline: none;
  transition: border-color .2s;
}
.input-row textarea:focus { border-bottom-color: var(--primary); }
.input-row textarea::placeholder { color: var(--muted); opacity: 1; }
.send-btn {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border: 0; border-radius: 50%;
  background: transparent;
  color: #A5B1C2;
  transition: color .2s, background .25s, transform .3s var(--spring);
}
.send-btn svg { width: 28px; height: 28px; transform: translateX(2px); }
.send-btn.ready { background: var(--primary); color: var(--on-primary); animation: pop .4s var(--spring); }
.send-btn:active { transform: scale(.86); }

/* ---------- Nút chung ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%;
  min-height: 52px;
  margin-top: 10px;
  padding: 8px 16px;
  border: 0; border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1rem; font-weight: 700;
  transition: transform .18s var(--ease), filter .2s, opacity .2s, background .2s;
}
.btn svg { width: 22px; height: 22px; }
.btn:active { transform: scale(.97); filter: brightness(.95); }
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--grad); color: #fff; box-shadow: 0 6px 16px rgba(26, 124, 255, .28); }
html.hc .btn.primary { background: #FFD400; color: #000; box-shadow: none; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger-soft { background: rgba(229, 56, 59, .1); color: var(--danger); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn.square { width: 52px; flex: none; padding: 0; }
html.hc .btn { border: 1px solid #5C5C5C; }

/* ---------- Bảng trượt ---------- */
dialog.sheet {
  width: 100%; max-width: 480px;
  max-height: 88dvh;
  margin: auto auto 0;
  padding: 6px 16px calc(env(safe-area-inset-bottom) + 14px);
  border: 0;
  border-radius: 24px 24px 0 0;
  background: var(--surface);
  color: var(--text);
  overflow-y: auto;
  overscroll-behavior: contain;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .2);
}
html.hc dialog.sheet { border-top: 2px solid #FFD400; }
dialog.sheet[open] { animation: sheet-in .42s var(--ease) both; }
dialog.sheet.closing { animation: sheet-out .26s cubic-bezier(.4, 0, 1, 1) both; }
dialog::backdrop { background: rgba(8, 18, 35, .5); }
dialog[open]::backdrop { animation: fade-in .3s ease both; }
dialog.closing::backdrop { animation: fade-out .26s ease both; }
.grabber { width: 42px; height: 5px; margin: 4px auto 10px; border-radius: 3px; background: var(--line); }
.sheet h2 { margin: 0 0 4px; font-size: 1.15rem; }
.group { padding: 12px 0; border-bottom: 1px solid var(--line); }
.group h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: .95rem; }
.group h3 svg { color: var(--primary); }
.hint { margin: 6px 0 0; font-size: .78rem; color: var(--muted); }

.ttl-input { display: flex; align-items: stretch; gap: 8px; }
.step {
  width: 56px; flex: none;
  border: 0; border-radius: 14px;
  background: var(--surface-2);
  color: var(--primary);
  font-size: 1.6rem; font-weight: 700; line-height: 1;
  transition: transform .2s var(--spring), background .2s;
}
.step:active { transform: scale(.9); }
.ttl-field {
  flex: 1; min-width: 0;
  display: flex; align-items: center; gap: 6px;
  padding: 0 14px;
  border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface);
  transition: border-color .2s, box-shadow .2s;
}
.ttl-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(26, 124, 255, .15); }
.ttl-field input {
  flex: 1; min-width: 0; width: 100%;
  height: 58px;
  border: 0; background: transparent; outline: none;
  font-size: 1.6rem; font-weight: 800; text-align: center;
  color: var(--text);
  -moz-appearance: textfield;
}
.ttl-field input::-webkit-outer-spin-button, .ttl-field input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ttl-field span { font-weight: 700; color: var(--muted); }
.ttl-field.bad { border-color: var(--danger); animation: shake .35s; }

.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.chips.quick { margin-top: 10px; }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip > span, .chip.q {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  width: 100%;
  min-height: 50px;
  padding: 6px 4px;
  border: 2px solid transparent; border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: .85rem; font-weight: 600; text-align: center;
  cursor: pointer;
  transition: background .2s, border-color .2s, color .2s, transform .25s var(--spring);
}
.chip > span b { line-height: 1; }
.chip input:checked + span, .chip.q.on {
  border-color: var(--primary);
  background: rgba(26, 124, 255, .1);
  color: var(--primary);
  transform: scale(1.03);
}
html.hc .chip input:checked + span, html.hc .chip.q.on { background: #2A2400; color: #FFD400; }
.chip input:focus-visible + span { outline: 3px solid var(--focus); }
.chip > span:active, .chip.q:active { transform: scale(.95); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch-row h3 { margin-bottom: 0; }
.switch { position: relative; width: 60px; height: 34px; flex: none; }
.switch input { position: absolute; inset: 0; z-index: 1; margin: 0; opacity: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: #B9C3D0; transition: background .25s; }
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px;
  width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25);
  transition: transform .35s var(--spring);
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(26px); }
.switch input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Menu thao tác */
.sheet-title { margin: 0 0 6px; font-size: .85rem; font-weight: 600; color: var(--muted); text-align: center; }
.action {
  display: flex; align-items: center; gap: 14px;
  width: 100%; min-height: 56px;
  padding: 6px 10px;
  border: 0; border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 1rem; font-weight: 600; text-align: left;
  transition: background .15s, transform .2s var(--spring);
}
.action:active { background: var(--surface-2); transform: scale(.98); }
.a-ic { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 12px; background: rgba(26, 124, 255, .1); color: var(--primary); }
.a-ic svg { width: 24px; height: 24px; }
.action.danger { color: var(--danger); }
.action.danger .a-ic { background: rgba(229, 56, 59, .1); color: var(--danger); }

/* Xác nhận */
.confirm-icon {
  width: 64px; height: 64px; margin: 6px auto 10px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(229, 56, 59, .12); color: var(--danger);
  animation: pop .5s var(--spring) .1s both;
}
.confirm-icon svg { width: 32px; height: 32px; }
.confirm-msg { margin: 0 0 6px; font-size: 1.02rem; font-weight: 600; text-align: center; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Xem ảnh lớn */
dialog.viewer {
  width: 100vw; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0;
  background: #000;
}
dialog.viewer[open] { display: flex; flex-direction: column; animation: fade-in .25s ease both; }
dialog.viewer.closing { animation: fade-out .22s ease both; }
dialog.viewer::backdrop { background: #000; }
dialog.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
dialog.viewer[open] img { animation: zoom-in .4s var(--ease) both; }
.viewer-close {
  position: absolute; top: calc(env(safe-area-inset-top) + 12px); right: 12px;
  display: flex; align-items: center; gap: 6px;
  min-height: 48px; padding: 0 18px 0 12px;
  border: 0; border-radius: 999px;
  background: rgba(255, 255, 255, .2); color: #fff;
  font-size: 1rem; font-weight: 700;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.viewer-close svg { width: 24px; height: 24px; }

/* Thông báo nổi */
.toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 130px); z-index: 1000;
  width: max-content; max-width: min(440px, calc(100vw - 32px));
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, .92); color: #fff;
  font-size: .92rem; font-weight: 600; text-align: center;
  box-shadow: var(--shadow-lg);
  opacity: 0; transform: translate(-50%, 24px) scale(.9);
  pointer-events: none;
  transition: opacity .25s, transform .4s var(--spring);
}
.toast.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
html.hc .toast { border: 2px solid #FFD400; }

/* ---------- Màn PIN ---------- */
#pin-view { background: var(--grad); justify-content: center; padding: 16px; }
.pin-card {
  width: 100%; max-width: 400px; margin: 0 auto;
  padding: 26px 20px 18px;
  border-radius: 26px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop-in .5s var(--spring) both;
}
html.hc .pin-card { border: 2px solid #FFD400; }
.pin-card.shake { animation: shake .4s; }
.lock { width: 68px; height: 68px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; background: rgba(26, 124, 255, .1); color: var(--primary); }
.lock svg { width: 34px; height: 34px; }
.pin-card h1 { margin: 0; font-size: 1.25rem; }
.pin-hint { margin: 4px 0 14px; color: var(--muted); font-size: .9rem; }
#pin {
  width: 100%; height: 64px;
  border: 2px solid var(--line); border-radius: 16px;
  background: var(--surface-2);
  font-size: 1.4rem; letter-spacing: .25em; text-align: center;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
#pin:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(26, 124, 255, .15); }
.err { min-height: 1.3em; margin: 8px 0 0; color: var(--danger); font-weight: 700; font-size: .9rem; }

/* ---------- Quản lý ảnh ---------- */
.toolbar { flex: none; padding: 10px 10px 10px; background: var(--surface); border-bottom: 1px solid var(--line); }
.segmented { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); padding: 4px; border-radius: 14px; background: var(--surface-2); }
.seg-indicator {
  position: absolute; top: 4px; bottom: 4px; left: 4px;
  width: calc((100% - 8px) / 3);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .4s var(--spring);
}
html.hc .seg-indicator { background: #2A2400; border: 1px solid #FFD400; }
.filter {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 52px; padding: 4px 2px;
  border: 0; background: transparent;
  color: var(--muted);
  font-size: .8rem; font-weight: 700;
  transition: color .25s;
}
.filter[aria-selected="true"] { color: var(--primary); }
.filter b { min-width: 24px; padding: 0 7px; border-radius: 999px; background: rgba(90, 105, 129, .15); font-size: .72rem; transition: transform .3s var(--spring); }
.filter b.bump { animation: pop .4s var(--spring); }
.tool-row { display: flex; gap: 8px; margin-top: 8px; }
.tool-row .btn { margin: 0; }

.admin-list { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 12px 10px calc(env(safe-area-inset-bottom) + 20px); background: var(--chat-bg); }
.admin-empty { padding: 40px 10px; text-align: center; color: var(--muted); font-weight: 600; animation: fade-in .4s ease both; }
.card {
  margin: 0 0 12px;
  padding: 8px;
  border-radius: 20px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: card-in .5s var(--ease) both;
  animation-delay: calc(var(--i, 0) * 60ms);
}
html.hc .card { border: 1px solid #5C5C5C; }
.thumb {
  position: relative; display: block;
  width: 100%; aspect-ratio: 4 / 3;
  padding: 0; border: 0; border-radius: 14px;
  overflow: hidden;
}
.thumb img { display: block; width: 100%; height: 100%; object-fit: contain; opacity: 0; transform: scale(1.04); transition: opacity .45s ease, transform .6s var(--ease); }
.thumb.loaded { background: #0F172A; }
.thumb.loaded img { opacity: 1; transform: none; }
.thumb .badge { position: absolute; top: 10px; left: 10px; }
.thumb.scanning::after {
  content: ''; position: absolute; left: 0; right: 0; top: 0;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(0, 140, 255, .55), transparent);
  border-bottom: 2px solid rgba(120, 200, 255, .9);
  animation: scan 1.1s ease-in-out infinite alternate;
}
.badge {
  display: inline-block; padding: 3px 12px;
  border-radius: 999px;
  font-size: .72rem; font-weight: 700;
  color: #fff; background: rgba(90, 105, 129, .9);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
.badge.new { background: rgba(214, 110, 0, .92); }
.badge.done { background: rgba(24, 144, 74, .92); }
.info { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 10px; margin: 8px 4px 0; font-size: .78rem; font-weight: 600; color: var(--muted); }
.result {
  margin: 8px 2px 0; padding: 8px 14px;
  border-radius: 14px;
  background: rgba(24, 144, 74, .1);
  border: 1px solid rgba(24, 144, 74, .35);
  font-size: .78rem; font-weight: 600; color: var(--muted);
  animation: pop-in .45s var(--spring) both;
}
.result .num { display: block; font-size: 1.9rem; font-weight: 800; letter-spacing: .04em; color: var(--text); overflow-wrap: anywhere; }
.card .btns { display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 6px; margin-top: 8px; }
.card .btns .btn { margin: 0; min-height: 48px; padding: 4px 6px; font-size: .85rem; gap: 5px; }
.card .btns .btn svg { width: 20px; height: 20px; }
.list-end { padding: 10px; text-align: center; font-size: .8rem; font-weight: 600; color: var(--muted); }
.spinner { width: 18px; height: 18px; border: 3px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
html.hc .spinner { border-color: rgba(0, 0, 0, .3); border-top-color: #000; }

/* Khung chờ lấp lánh khi ảnh đang tải */
.shimmer, .thumb:not(.loaded), .bubble.img .ph {
  background: linear-gradient(100deg, #DCE3EC 30%, #EEF2F7 50%, #DCE3EC 70%);
  background-size: 300% 100%;
  animation: shimmer 1.4s linear infinite;
}
html.hc .thumb:not(.loaded), html.hc .bubble.img .ph { background: linear-gradient(100deg, #1A1A1A 30%, #2C2C2C 50%, #1A1A1A 70%); background-size: 300% 100%; }

/* ---------- Chuyển động ---------- */
@keyframes view-in { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes msg-in { from { opacity: 0; transform: translateY(18px) scale(.9); } to { opacity: 1; transform: none; } }
@keyframes card-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@keyframes sheet-out { from { transform: none; } to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes zoom-in { from { opacity: 0; transform: scale(.88); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(.6); } 60% { transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes pop-in { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
@keyframes pulse { 50% { opacity: .45; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -50% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes scan { from { transform: translateY(-10%); } to { transform: translateY(260%); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
.bubble.img .ph { display: block; }
.bubble.img .ph.done { animation: none; background: none; }
