:root{
  --navy-950: #f4f9ff;
  --navy-900: #e4effa;
  --navy-800: #d0e3f5;
  --navy-700: #bce0fd;
  --ice-500: #35b7ff;
  --ice-300: #00509e;
  --text: #061827;
  --muted: #555555;
  --card: #ffffff;
  --card-2: #f9f9f9;
  --stroke: #cce6ff;
  --shadow: 0 4px 15px rgba(0,0,0,0.05);
  --radius: 18px;
  --radius-sm: 14px;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
}

.bubble ul, .bubble ol { margin-top: 6px; margin-bottom: 6px; padding-left: 20px; }
.bubble li { margin-bottom: 4px; }

.bubble p { margin: 0 0 8px 0; }
.bubble ul, .bubble ol { margin: 4px 0 8px 0; padding-left: 20px; }
.bubble li { margin-bottom: 4px; }
.bubble > *:last-child { margin-bottom: 0; }


*{box-sizing:border-box}

html, body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body{
  display:flex;
  justify-content:center;
  font-family:var(--font);
  color:#061827;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(53,183,255,.18), transparent 60%),
    radial-gradient(1200px 800px at 90% 30%, rgba(138,217,255,.10), transparent 55%),
    linear-gradient(180deg, var(--navy-950), var(--navy-900));
}

.page{
  width:100%;
  max-width:1200px;
  height:100%;
  display:flex;
  flex-direction:column;
  padding:0;
  margin:0;
}

.shell{
  flex:1;
  width:100%;
  height:100%;
  background:#ffffff;
  border:none;
  border-radius:0;
  box-shadow:none;
  overflow:hidden;
  backdrop-filter: blur(10px);
  display:flex;
  flex-direction:column;
}

.topbar{
  padding:16px 18px;
  display:flex;
  flex-direction:row;
  align-items:center;
  justify-content:space-between;
  flex-wrap:nowrap;
  gap:10px;
  border-bottom:1px solid var(--stroke);
  background:#ffffff;
}

/* Desktop header layout: single row */
.header-main{
  display:flex;
  align-items:center;
  gap:12px;
  min-width:0;
}

.header-meta{
  display:flex;
  align-items:center;
  gap:10px;
}

.brand{display:flex; gap:12px; align-items:center; min-width:0}
.brand__logo{
  width: 40px;
  height: 40px;
  object-fit: contain;
  border-radius: 10px;
  flex: 0 0 auto;
}
.brand__text{min-width:0}
.brand__name{font-weight:700; letter-spacing:.2px; white-space:nowrap}
.brand__sub{font-size:12px; color:var(--muted); margin-top:2px}

.meta{display:flex; gap:10px; align-items:center; flex-wrap:wrap; justify-content:flex-end}
.meta__pill{
  font-size:12px;
  color:var(--muted);
  border:1px solid var(--stroke);
  padding:7px 10px;
  border-radius:999px;
  background:rgba(255,255,255,.04);
}

/* Nút header: cùng ngôn ngữ với composer (viền ice, hover nổi nhẹ) */
.btn-admin-trigger{
  padding:8px 16px;
  border-radius:var(--radius-sm);
  border:1px solid var(--stroke);
  background:#ffffff;
  color:var(--text);
  font-weight:600;
  font-size:14px;
  cursor:pointer;
  font-family:inherit;
  box-shadow:0 1px 2px rgba(6,24,39,.06);
  transition:transform .18s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease;
}
.btn-admin-trigger:hover{
  border-color:rgba(53,183,255,.45);
  background:linear-gradient(180deg, rgba(53,183,255,.12), rgba(53,183,255,.04));
  box-shadow:0 4px 14px rgba(53,183,255,.18);
  transform:translateY(-1px);
}
.btn-admin-trigger:active{
  transform:translateY(0);
  box-shadow:0 1px 3px rgba(6,24,39,.08);
}

.chat{flex:1; display:flex; flex-direction:column; min-height:0; position:relative}
.messages{
  flex:1;
  overflow:auto;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.msg{display:flex; align-items:flex-end; gap:10px; max-width:100%}
.msg--user{justify-content:flex-end}
.msg--bot{justify-content:flex-start}

.bubble{
  width: fit-content;
  max-width: 100%;
  padding:12px 14px;
  border-radius:16px;
  border:1px solid var(--stroke);
  background:rgba(255,255,255,.06);
  color:var(--text);
  line-height:1.45;
  white-space:pre-wrap;
  word-wrap:break-word;
}

.badge-source {
  user-select: none; -webkit-user-select: none; pointer-events: none;
  display: inline-block; margin-left: 6px; font-size: 11px; font-weight: 800;
  padding: 2px 6px; border-radius: 4px; vertical-align: middle; opacity: 0.8;
}
.badge-cache { color: #f1c40f; background: rgba(241, 196, 15, 0.15); }
.badge-gemini { color: #3498db; background: rgba(52, 152, 219, 0.15); }
.badge-openai { color: #2ecc71; background: rgba(46, 204, 113, 0.15); }
.badge-groq { color: #e67e22; background: rgba(230, 126, 34, 0.15); }

.msg--user .bubble {
  background: #ebf5ff;
  border-color: #cce6ff;
  color: #061827;
}

.msg--bot .bubble {
  background: #ffffff;
  border-color: #e1ecf4;
  color: #061827;
}

.avatar{
  width:36px; height:36px;
  border-radius:50%;
  border:2px solid var(--ice-500);
  background:var(--navy-800);
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
  flex:0 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.avatar__img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.avatar__svg{
  width: 20px;
  height: 20px;
  display: block;
  color: var(--ice-300);
}

.msg--user .avatar__svg{
  color: var(--muted);
}

.bubble-wrapper{
  position:relative;
  display:flex;
  flex-direction:column;
  width: fit-content;
  max-width:min(720px, 85%);
}

.msg--user .bubble-wrapper{align-items:flex-end}
.msg--bot .bubble-wrapper{align-items:flex-start}

.bubble__copy{
  position:absolute;
  bottom:-22px;
  right:0;
  background:transparent;
  border:none;
  color:var(--muted);
  cursor:pointer;
  padding:4px;
  display:flex;
  align-items:center;
  justify-content:center;
  opacity:0.4;
  transition:opacity 0.2s, color 0.2s;
}

.msg:hover .bubble__copy{opacity:1; color:var(--ice-300)}

.toast{
  position:fixed;
  bottom:100px;
  left:50%;
  transform:translateX(-50%) translateY(20px);
  background:rgba(11,34,56,0.95);
  color:var(--ice-300);
  padding:10px 20px;
  border-radius:20px;
  border:1px solid var(--ice-500);
  font-size:14px;
  font-weight:600;
  z-index:9999;
  opacity:0;
  pointer-events:none;
  transition:all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast--show{
  opacity:1;
  transform:translateX(-50%) translateY(0);
}

.composer{
  padding:14px;
  border-top: 1px solid #cce6ff;
  display:flex;
  gap:10px;
  align-items:center;
  background: #f4f9ff;
}

.composer__input{
  flex:1;
  width:100%;
  max-width:none;
  resize:none;
  border-radius:var(--radius-sm);
  border:1px solid #bce0fd;
  background:#f0f7ff;
  color:#061827;
  padding:14px 16px;
  outline:none;
  font-size:15px;
  min-height:48px;
  max-height:140px;
}

.composer__send{
  height:48px;
  padding:0 20px;
  border-radius:var(--radius-sm);
  border:1px solid rgba(53,183,255,.40);
  background:linear-gradient(180deg, rgba(53,183,255,.35), rgba(53,183,255,.18));
  color:var(--text);
  cursor:pointer;
  font-weight:700;
  font-size:15px;
  flex:0 0 auto;
  transition:transform .18s ease, box-shadow .18s ease, filter .18s ease, border-color .18s ease;
}
.composer__send:hover{
  background:linear-gradient(180deg, rgba(53,183,255,.50), rgba(53,183,255,.28));
  box-shadow:0 4px 16px rgba(53,183,255,.22);
  transform:translateY(-1px);
}
.composer__send:active{
  transform:translateY(0);
  filter:brightness(.97);
}
.composer__image{
  height:48px;
  width:48px;
  padding:0;
  border-radius:var(--radius-sm);
  border:1px solid rgba(53,183,255,.40);
  background:linear-gradient(180deg, rgba(53,183,255,.35), rgba(53,183,255,.18));
  color:var(--text);
  cursor:pointer;
  font-size:20px;
  flex:0 0 auto;
  display:flex;
  align-items:center;
  justify-content:center;
  transition:transform .18s ease, box-shadow .18s ease, filter .18s ease;
}
.composer__image:hover{
  background:linear-gradient(180deg, rgba(53,183,255,.50), rgba(53,183,255,.30));
  box-shadow:0 4px 14px rgba(53,183,255,.2);
  transform:translateY(-1px);
}
.composer__image:active{
  transform:translateY(0);
  filter:brightness(.96);
}
.image-preview-container{
  position:relative;
  display:inline-block;
  margin-bottom:8px;
}
.image-preview-container[hidden]{
  display:none !important;
}
.image-preview{
  max-width: 180px;
  max-height: 140px;
  border-radius: var(--radius-sm);
  border: 1px solid #bce0fd;
  object-fit: contain;
  background: #ffffff;
}
.group-preview-wrap {
  align-self: flex-end;
  margin-bottom: 0;
  margin-right: 10px;
}
.group-preview-img {
  max-height: 100px;
}
.image-preview-remove{
  position:absolute;
  top:-8px;
  right:-8px;
  width:20px;
  height:20px;
  border-radius:50%;
  background:#ff4444;
  color:white;
  border:none;
  cursor:pointer;
  font-size:12px;
  display:flex;
  align-items:center;
  justify-content:center;
}

.typing{
  display:inline-flex;
  gap:4px;
  align-items:center;
  padding:4px 0;
}
.dot{
  width:6px; height:6px; border-radius:50%;
  background: rgba(6, 24, 39, 0.7);
  animation: bounce 1.2s infinite ease-in-out;
}
.dot:nth-child(2){animation-delay:.2s}
.dot:nth-child(3){animation-delay:.4s}
@keyframes bounce{
  0%, 60%, 100% {transform: translateY(0)}
  30% {transform: translateY(-6px)}
}

/* =========================================================
   🚀 BẢN CẬP NHẬT GIAO DIỆN ADMIN 3D HIỆN ĐẠI (SaaS UI)
   ========================================================= */

.admin {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  display: none;
  flex-direction: column;
  padding: 14px;
  gap: 12px;
  z-index: 9999;
  color: #061827;
  /* Glassmorphism */
  background: rgba(240, 247, 255, 0.85) !important;
  backdrop-filter: blur(20px) saturate(160%) !important;
  -webkit-backdrop-filter: blur(20px) saturate(160%) !important;
}
.admin.is-open { display: flex; }

.admin__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.admin__title {
  font-weight: 900;
  letter-spacing: .2px;
  font-size: 18px;
  color: #061827;
}

/* Nút Back 3D */
.admin__back {
  padding: 10px 14px;
  cursor: pointer;
  background: linear-gradient(135deg, #0056b3 0%, #00a8ff 100%) !important;
  border: none !important;
  color: white !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 15px rgba(0, 168, 255, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: translateY(0);
  font-weight: 700 !important;
  letter-spacing: 0.3px;
}
.admin__back:hover {
  box-shadow: 0 8px 20px rgba(0, 168, 255, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  transform: translateY(-2px) !important;
}
.admin__back:active {
  transform: translateY(2px) !important;
  box-shadow: 0 2px 5px rgba(0, 168, 255, 0.3), inset 0 2px 0 rgba(0, 0, 0, 0.1) !important;
}

/* Các khối Card 3D */
.admin__auth, .admin__section {
  background: linear-gradient(145deg, #ffffff, #fbfdff) !important;
  border: 1px solid rgba(255, 255, 255, 0.9) !important;
  box-shadow: 0 10px 30px rgba(0, 80, 158, 0.05), 0 4px 6px rgba(0, 80, 158, 0.02), inset 0 2px 0 rgba(255, 255, 255, 1) !important;
  border-radius: 16px !important;
  transition: all 0.3s ease;
  padding: 12px;
  color: #061827;
}
.admin__section {
  flex: 1;
  overflow: auto;
}

.admin__btn-small {
  background: transparent;
  border: none;
  color: #00509e;
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
  padding: 0;
  font-weight: bold;
}
.admin__btn-small:hover { color: #d35400; }

#adminAuthControls.is-hidden,
.admin__password.is-hidden,
.admin__hint.is-hidden {
  display: none !important;
}

.admin__hint { margin-top: 6px; font-size: 12px; color: #555555; font-weight: 600; }
.admin__label { font-size: 12px; color: #555555; font-weight: 600; }
.admin__password { margin-top: 6px; display: flex; gap: 10px; align-items: center; }

/* Ô nhập liệu 3D chìm */
.admin__input, .admin__file, .admin__select {
  background: #f8fafc !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02) !important;
  border-radius: 12px !important;
  transition: all 0.2s ease !important;
  color: #0f172a !important;
}
.admin__input {
  flex: 1;
  height: 52px;
  padding: 0 16px;
  outline: none;
  font-size: 16px;
  margin-bottom: 8px;
}
.admin__select {
  height: 44px;
  padding: 0 12px;
  outline: none;
}
.admin__input:focus, .admin__select:focus {
  background: #ffffff !important;
  border-color: #00a8ff !important;
  box-shadow: 0 0 0 4px rgba(0, 168, 255, 0.15), inset 0 1px 2px rgba(0,0,0,0.01) !important;
  outline: none !important;
}
.admin__eye {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid #bce0fd;
  background: #ffffff;
  color: #555555;
  cursor: pointer;
}

/* Tabs viên thuốc 3D */
.admin__tabs {
  gap: 10px !important;
  padding: 4px;
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center;
}
.admin__tab {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 2px 5px rgba(0,0,0,0.02) !important;
  color: #64748b !important;
  border-radius: 999px !important;
  padding: 10px 16px !important;
  transition: all 0.25s ease !important;
  font-weight: 700 !important;
  font-size: 12px;
  cursor: pointer;
}
.admin__tab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(0,0,0,0.08) !important;
  color: #00509e !important;
}
.admin__tab--active {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%) !important;
  color: #ffffff !important;
  border: none !important;
  box-shadow: 0 6px 15px rgba(15, 23, 42, 0.25) !important;
  transform: scale(1.02);
}

.guide-select-wrapper {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.guide-label {
  color: #555555;
  font-size: 13px;
  font-weight: 600;
}
#guideSelect {
  width: auto;
  max-width: 250px;
}
#guideSelect option, .admin__select option {
  color: #c0392b;
  background-color: #ffffff;
  font-weight: 600;
}

.admin__section[data-admin-section="guides"] {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

#guideFrame,
.admin__guide-frame {
  width: 100%;
  height: 100%;
  flex: 1;
  border: none;
  border-radius: 0 0 14px 14px;
  background: #ffffff;
}

.admin__form { display: flex; flex-direction: column; gap: 12px; }
/* Trong form dọc: khong flex-grow o input (flex:1 lam o co/khong thay duoc tren mot so trinh duyet) */
.admin__form .admin__input,
.admin__form .admin__select,
.admin__form .admin__file {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}
.admin__field { display: flex; flex-direction: column; gap: 8px; }

.admin__file {
  border: 1px dashed #35b7ff !important;
  background: #f4f9ff !important;
  padding: 10px;
}
.admin__filename { font-size: 12px; color: #00509e; font-weight: bold; }

/* Nút Submit chính 3D */
.admin__btn {
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  background: linear-gradient(135deg, #0056b3 0%, #00a8ff 100%) !important;
  border: none !important;
  color: white !important;
  border-radius: 12px !important;
  box-shadow: 0 6px 15px rgba(0, 168, 255, 0.3), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
  transform: translateY(0);
  font-weight: 900 !important;
  letter-spacing: 0.3px;
}
.admin__btn[disabled] { opacity: .6; cursor: not-allowed; }
.admin__btn:hover {
  box-shadow: 0 8px 20px rgba(0, 168, 255, 0.4), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.5) !important;
  transform: translateY(-2px) !important;
}
.admin__btn:active {
  transform: translateY(2px) !important;
  box-shadow: 0 2px 5px rgba(0, 168, 255, 0.3), inset 0 2px 0 rgba(0, 0, 0, 0.1) !important;
}

.admin__spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(234, 242, 255, 0.25);
  border-top-color: rgba(234, 242, 255, 0.85);
  display: none;
  animation: spin 0.9s linear infinite;
}
.admin__btn.is-loading .admin__spinner { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg) } }

.admin__result {
  font-size: 13px;
  color: #061827;
  border: 1px solid #bce0fd;
  background: #f4f9ff;
  border-radius: 12px;
  padding: 10px;
}

/* Bảng dữ liệu tối ưu ngang Mobile */
.admin__tableWrap {
  border-radius: 12px !important;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04) !important;
  border: 1px solid #e2e8f0 !important;
  overflow-x: auto !important;
  background: #ffffff !important;
}
.admin__table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  color: #061827;
  border: none !important;
  margin: 0 !important;
}
.admin__table th,
.admin__table td {
  padding: 10px 12px;
  font-size: 12px;
}
.admin__table th {
  background: #f8fafc !important;
  color: #475569 !important;
  font-weight: 800 !important;
  text-transform: uppercase;
  font-size: 11px !important;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #e2e8f0 !important;
  text-align: left;
}
.admin__table td {
  border-bottom: 1px solid #f1f5f9 !important;
  color: #334155 !important;
}
.admin__table tr:last-child td { border-bottom: none; }

/* Nút xóa 3D */
.admin__danger {
  background: linear-gradient(135deg, #e74c3c 0%, #ff7675 100%) !important;
  box-shadow: 0 5px 15px rgba(231, 76, 60, 0.25), inset 0 -3px 0 rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
  border: none !important;
  border-radius: 8px !important;
  color: white !important;
  font-weight: 700 !important;
  transition: all 0.2s ease !important;
  padding: 8px 10px;
  cursor: pointer;
}
.admin__danger:active {
  transform: translateY(2px) !important;
  box-shadow: 0 2px 5px rgba(231, 76, 60, 0.3), inset 0 2px 0 rgba(0, 0, 0, 0.1) !important;
}

.admin__code {
  margin: 0;
  padding: 12px;
  border-radius: 14px;
  background: #f4f9ff;
  border: 1px solid #bce0fd;
  overflow: auto;
  color: #061827;
  font-size: 12px;
}

/* --- LOGIN OVERLAY LỘT XÁC --- */
.login-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: linear-gradient(135deg, #e0eafc 0%, #cfdef3 100%);
  z-index: 10000;
}
.login-overlay.is-hidden { display: none; }
.login-card {
  width: min(460px, 100%);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 25px 50px rgba(0, 51, 102, 0.15);
  padding: 40px 30px;
  backdrop-filter: blur(20px);
  text-align: center;
  display: flex; flex-direction: column; align-items: center;
}
.login-logo {
  width: 100px; height: 100px;
  object-fit: contain;
  border-radius: 20px;
  margin-bottom: 15px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}
.login-title { font-weight: 900; letter-spacing: 0.5px; font-size: 28px; color: var(--secondary); }
.login-welcome { margin-top: 8px; color: var(--primary); font-size: 15px; font-weight: 600; line-height: 1.4; }
.login-sub { margin-top: 5px; color: #64748b; font-size: 14px; margin-bottom: 25px; }
.login-form { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.login-input {
  width: 100%; height: 56px;
  border-radius: 14px;
  border: 2px solid #e2e8f0; background: #f8fafc;
  color: #1e293b; padding: 0 20px; font-size: 16px; outline: none;
  transition: all 0.3s;
}
.login-input:focus { border-color: var(--primary); background: #ffffff; box-shadow: 0 0 0 4px rgba(188, 0, 45, 0.1); }
.login-password-wrapper { position: relative; width: 100%; }
.login-eye {
  position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
  background: transparent; border: none; font-size: 20px; color: #94a3b8;
  cursor: pointer; padding: 5px; transition: color 0.2s;
}
.login-eye:hover { color: var(--primary); }
.login-btn {
  height: 56px; border-radius: 14px; margin-top: 10px;
  border: none; background: #BC002D;
  color: #ffffff; font-weight: 800; font-size: 18px; cursor: pointer;
  box-shadow: 0 10px 20px rgba(188, 0, 45, 0.3); transition: all 0.2s;
}
.login-btn:hover { transform: translateY(-2px); box-shadow: 0 15px 25px rgba(188, 0, 45, 0.4); }
.login-error { margin-top: 15px; color: #ef4444; font-size: 14px; font-weight: 600; min-height: 20px; }
.login-footer {
  margin-top: 30px; font-size: 13px; color: #64748b;
  border-top: 1px solid #e2e8f0; padding-top: 15px; width: 100%; line-height: 1.6;
}
.login-footer b { color: var(--secondary); }

/* Mobile Group Chat - Responsive */
@media (max-width: 768px) {
  .group-chat-container {
    flex-direction: column !important;
    width: 100vw !important;
    height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
  }
  .group-chat-sidebar {
    width: 100% !important;
    min-width: 100% !important;
    height: auto !important;
    border-right: none !important;
    border-bottom: 1px solid #cce6ff !important;
    display: flex !important;
    flex-direction: column !important;
  }
  .chat-sidebar-header {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 10px 15px !important;
  }
  .btn-new-channel {
    margin: 0 !important;
    padding: 8px 12px !important;
  }
  /* Header mobile: hàng ngang — không cho nút chiếm full width */
  .chat-sidebar-header .btn-new-channel {
    width: auto !important;
    flex: 0 1 auto;
    white-space: nowrap;
  }
  .chat-channel-list {
    display: flex !important;
    flex-direction: row !important;
    overflow-x: auto !important;
    white-space: nowrap !important;
    padding: 5px 15px 10px 15px !important;
    gap: 10px !important;
  }
  .chat-channel-item {
    display: inline-block !important;
    margin: 0 !important;
    border: 1px solid #bce0fd;
  }
  .group-chat-main {
    flex: 1 !important;
    width: 100% !important;
    min-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    height: 0 !important; /* Ép cuộn tin nhắn ở thẻ con */
  }
  .group-chat-messages {
    padding: 10px !important;
  }
  .group-msg {
    max-width: 90% !important;
  }
  .group-chat-input-area {
    padding: 10px !important;
  }
  /* Phình to ô gõ AI trên Mobile */
  .composer__input:focus {
    max-height: 40vh !important;
  }
  /* Phình to ô gõ Group Chat trên Mobile */
  .group-chat-input-area textarea:focus {
    max-height: 40vh !important;
  }
  .group-chat-input-area {
    align-items: flex-end !important;
  }
}

/* Mặc định: Ẩn nút chỉ dành cho Mobile trên màn hình máy tính */
.mobile-only {
  display: none !important;
}

@media (max-width:640px){
  .page{padding:0}
  .shell{height:100%; width:100%; border-radius:0; border:none}

  /* Keep existing 2-line mobile header rules */
  .topbar {
    padding: 10px 14px;
    flex-direction: column; /* Quan trọng: Đổi thành xếp dọc để không bị nén */
    align-items: stretch;
    height: auto;
    gap: 10px;
  }
  .header-main{
    display:flex;
    justify-content:space-between;
    align-items:center;
    width:100%;
    gap:10px;
  }
  .header-meta{
    display:flex;
    gap:5px;
    margin-top:5px;
    font-size:10px;
    width:100%;
    justify-content:flex-end;
  }
  .meta__pill{font-size:10px; padding:5px 8px}

  .brand__logo{width:28px; height:28px}
  .brand__name{font-size:14px}

  .messages{padding:14px}
  .bubble-wrapper{max-width:90%}
  .bubble{padding:10px 14px; font-size:15px}
  .avatar{width:32px; height:32px}
  .composer{padding:10px; gap:8px}
  .bubble__copy{opacity:0.6; bottom:-20px}

  .admin{position:fixed; inset:0; padding:14px; z-index:9999}
  .admin__guide-frame{height:calc(100vh - 220px)}

  .login-form{flex-direction:column}
  .login-btn{width:100%}

  /* Hiện lại nút trên màn hình Mobile */
  .mobile-only {
    display: flex !important;
  }
}
/* Ép ẩn tuyệt đối các section và kết quả rỗng */
.admin__section[hidden] {
  display: none !important;
}
#adminUploadResult:empty {
  display: none !important;
  padding: 0 !important;
  border: none !important;
}

/* Role switch divider in chat */
.role-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 20px 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.role-divider::before, .role-divider::after {
  content: "";
  flex: 1;
  border-bottom: 1px solid var(--stroke);
}
.role-divider span {
  padding: 0 15px;
  color: var(--ice-300);
}

/* Bảng HTML cho AI Chat */
.bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0;
  display: block;
  overflow-x: auto; /* Tạo thanh cuộn ngang chống vỡ layout */
  white-space: normal; /* Reset lại để text trong bảng không bị lỗi pre-wrap */
  font-size: 13px;
}
.bubble th, .bubble td {
  border: 1px solid #cce6ff;
  padding: 10px 14px;
  text-align: left;
}
.bubble th {
  background: #ebf5ff;
  color: #061827;
  font-weight: bold;
  white-space: nowrap;
}
.bubble tr:nth-child(even) {
  background: #f7fbff;
}

/* --- ADMIN LOG VIEWER --- */
.admin__log-container { background: #ffffff; border: 1px solid #cce6ff; border-radius: 14px; padding: 15px; margin-top: 15px; color: #061827; }
.admin__log-content { max-height: 400px; overflow-y: auto; background: #f4f9ff; border-radius: 8px; padding: 10px; border: 1px solid #e1ecf4; }
.log-msg { margin-bottom: 12px; font-size: 13px; line-height: 1.4; padding: 10px; border-radius: 8px; word-break: break-word; color: #061827; }
.log-msg--user { background: #ebf5ff; border-left: 4px solid #35b7ff; }
.log-msg--assistant { background: #ffffff; border-left: 4px solid #b9c8de; border: 1px solid #e1ecf4; }

/* --- GROUP CHAT INTERNAL — đồng bộ ice-blue với composer / trang chủ --- */
.btn-group-chat {
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.35), rgba(53, 183, 255, 0.18));
  border: 1px solid rgba(53, 183, 255, 0.42);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  box-shadow: 0 1px 3px rgba(6, 24, 39, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}
.btn-group-chat:hover {
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.5), rgba(53, 183, 255, 0.28));
  box-shadow: 0 4px 16px rgba(53, 183, 255, 0.22);
  transform: translateY(-1px);
}
.btn-group-chat:active {
  transform: translateY(0);
  filter: brightness(0.97);
}
.btn-media-gallery {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.2), rgba(124, 58, 237, 0.08));
  border: 1px solid rgba(124, 58, 237, 0.35);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 3px rgba(6, 24, 39, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  white-space: nowrap;
}
.btn-media-gallery:hover {
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.2);
  transform: translateY(-1px);
}
.btn-media-gallery:active {
  transform: translateY(0);
  filter: brightness(0.97);
}

/* Dropdown tài liệu nhóm (header, cạnh Thư viện media) */
.header-dropdown-wrap {
  position: relative;
  flex: 0 0 auto;
}
.header-dropdown-caret {
  font-size: 0.75em;
  opacity: 0.85;
  margin-left: 2px;
}
.btn-team-guides {
  background: linear-gradient(180deg, rgba(14, 165, 233, 0.18), rgba(14, 165, 233, 0.06));
  border: 1px solid rgba(14, 165, 233, 0.38);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 8px 14px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 3px rgba(6, 24, 39, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
  white-space: nowrap;
}
.btn-team-guides:hover {
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.22);
  transform: translateY(-1px);
}
.btn-team-guides:active {
  transform: translateY(0);
  filter: brightness(0.97);
}
.btn-team-guides[aria-expanded="true"] {
  border-color: rgba(14, 165, 233, 0.65);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.team-guides-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: min(320px, 92vw);
  max-width: min(400px, 96vw);
  max-height: min(70vh, 420px);
  overflow-y: auto;
  padding: 8px 0;
  margin: 0;
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(6, 24, 39, 0.14);
  z-index: 200;
}
.team-guides-menu__section {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.team-guides-menu__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px 10px 16px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  transition: background 0.12s ease;
}
.team-guides-menu__item:hover,
.team-guides-menu__item:focus-visible {
  background: rgba(53, 183, 255, 0.1);
  outline: none;
}
.team-guides-menu__meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}
.team-guides-menu__empty {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}
.team-guides-menu__err {
  padding: 14px 16px;
  font-size: 13px;
  color: #c0392b;
}

/* Chat full chiều cao khi không còn tab Hướng dẫn dưới cùng */
.main-chat-panel--full {
  flex: 1;
  min-height: 0;
}

.chat-badge {
  background: #ff4444;
  color: white;
  font-size: 11px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}
.chat-badge[hidden] {
  display: none;
}

.group-chat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 24, 39, 0.42);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}
.group-chat-overlay[hidden] {
  display: none;
}
.group-chat-container {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--stroke);
  width: 95vw;
  height: 90vh;
  max-width: 1400px;
  display: flex;
  flex-direction: row;
  box-shadow: 0 24px 60px rgba(0, 80, 158, 0.18), 0 8px 24px rgba(6, 24, 39, 0.08);
  overflow: hidden;
}

/* Sidebar - Danh sách kênh */
.group-chat-sidebar {
  width: 250px;
  min-width: 250px;
  background: #f4f9ff;
  border-right: 1px solid var(--stroke);
  display: flex;
  flex-direction: column;
}
.chat-sidebar-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, #f4f9ff, #e8f4fc);
}
.chat-sidebar-header h4 {
  margin: 0 0 12px 0;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}
.chat-channel-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
}
.chat-channel-item {
  padding: 10px 12px;
  margin-bottom: 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text);
  font-size: 14px;
  border: 1px solid transparent;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}
.chat-channel-item:hover {
  background: #e8f4fc;
  border-color: rgba(53, 183, 255, 0.2);
}
.chat-channel-item.active {
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.95), rgba(53, 183, 255, 0.82));
  color: #ffffff;
  border-color: rgba(53, 183, 255, 0.5);
  box-shadow: 0 4px 14px rgba(53, 183, 255, 0.35);
}
.chat-channel-item.active .channel-delete-btn {
  color: #ffffff;
  opacity: 0.75;
}
.chat-channel-item.active .channel-delete-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  opacity: 1;
}
.chat-channel-item .channel-icon {
  margin-right: 8px;
}

/* Nút xóa kênh (Admin only) */
.chat-channel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.channel-delete-btn {
  background: transparent;
  border: none;
  color: #e74c3c;
  opacity: 0.45;
  cursor: pointer;
  font-weight: bold;
  padding: 4px 8px;
  border-radius: 8px;
  transition: background 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}
.channel-delete-btn:hover {
  background: rgba(231, 76, 60, 0.12);
  opacity: 1;
  transform: scale(1.05);
}

.btn-new-channel {
  margin: 0;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(53, 183, 255, 0.4);
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.38), rgba(53, 183, 255, 0.16));
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(53, 183, 255, 0.15);
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
.btn-new-channel:hover {
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.52), rgba(53, 183, 255, 0.26));
  box-shadow: 0 4px 16px rgba(53, 183, 255, 0.25);
  transform: translateY(-1px);
}
.btn-new-channel:active {
  transform: translateY(0);
  filter: brightness(0.96);
}

/* Main Chat Area */
.group-chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #ffffff;
}

.group-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: #f4f9ff;
  border-bottom: 1px solid var(--stroke);
}
.group-chat-header h3 {
  margin: 0;
  color: var(--text);
  font-size: 17px;
  font-weight: 700;
}
/* Chỉ nút Đóng — không dùng coral; ghost ice giống admin / outline trang chủ */
#btnCloseGroupChat {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: #ffffff;
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 1px 2px rgba(6, 24, 39, 0.06);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}
#btnCloseGroupChat:hover {
  border-color: rgba(53, 183, 255, 0.45);
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.1), rgba(53, 183, 255, 0.03));
  box-shadow: 0 4px 14px rgba(53, 183, 255, 0.16);
  transform: translateY(-1px);
}
#btnCloseGroupChat:active {
  transform: translateY(0);
}

.group-chat-filters {
  display: flex;
  gap: 10px;
  padding: 12px 18px;
  background: #f7fbff;
  border-bottom: 1px solid #e1ecf4;
}
.group-chat-filters input {
  padding: 10px 12px;
  border: 1px solid #bce0fd;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: #f0f7ff;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.group-chat-filters input:focus {
  outline: none;
  border-color: rgba(53, 183, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(53, 183, 255, 0.15);
}
.group-chat-filters input[type="text"] {
  flex: 1;
}
.group-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.group-msg {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  position: relative;
  word-break: break-word;
  box-shadow: 0 1px 3px rgba(6, 24, 39, 0.04);
}
.group-msg--other {
  align-self: flex-start;
  background: #ffffff;
  border: 1px solid #e1ecf4;
  color: var(--text);
  border-bottom-left-radius: 6px;
}
/* Tin mình: cùng tông bubble user trang chủ */
.group-msg--self {
  align-self: flex-end;
  background: #ebf5ff;
  border: 1px solid #cce6ff;
  color: var(--text);
  border-bottom-right-radius: 6px;
}
.group-msg__content img {
  max-width: 200px;
  border-radius: var(--radius-sm);
  margin-top: 8px;
  border: 1px solid var(--stroke);
}
.group-msg__content {
  word-wrap: break-word;
}
.group-msg__meta {
  font-size: 11px;
  opacity: 0.75;
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.group-msg__delete {
  background: transparent;
  border: none;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  transition: opacity 0.18s ease, background 0.18s ease;
}
.group-msg__delete:hover {
  opacity: 1;
  background: rgba(231, 76, 60, 0.12);
}
.group-chat-input-area {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  background: #f4f9ff;
  border-top: 1px solid var(--stroke);
}
/* Giữ nút đính kèm đúng style composer (selector cũ .group-chat-input-area button đè mất) */
.group-chat-input-area .composer__image {
  flex: 0 0 auto;
}
.group-chat-input-area textarea {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid #bce0fd;
  border-radius: var(--radius-sm);
  resize: none;
  font-size: 14px;
  font-family: inherit;
  min-height: 48px;
  max-height: 120px;
  background: #f0f7ff;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.group-chat-input-area textarea:focus {
  outline: none;
  border-color: rgba(53, 183, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(53, 183, 255, 0.12);
}
/* Nút Gửi = composer__send */
#btnSendGroupChat {
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(53, 183, 255, 0.4);
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.35), rgba(53, 183, 255, 0.18));
  color: var(--text);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  font-family: inherit;
  flex: 0 0 auto;
  transition: transform 0.18s ease, box-shadow 0.18s ease, filter 0.18s ease;
}
#btnSendGroupChat:hover {
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.5), rgba(53, 183, 255, 0.28));
  box-shadow: 0 4px 16px rgba(53, 183, 255, 0.22);
  transform: translateY(-1px);
}
#btnSendGroupChat:active {
  transform: translateY(0);
  filter: brightness(0.97);
}

/* Tab màn chính: Trò chuyện / Hướng dẫn nhóm */
.main-view-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px 0;
  flex-shrink: 0;
  border-bottom: 1px solid var(--stroke);
  background: linear-gradient(180deg, #f8fcff, #fff);
}
.main-view-tab {
  padding: 10px 18px;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
.main-view-tab:hover {
  color: var(--ice-300);
  background: rgba(53, 183, 255, 0.08);
}
.main-view-tab--active {
  color: var(--ice-300);
  background: #fff;
  border-color: var(--stroke);
  border-bottom-color: #fff;
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}
.main-view-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.main-guides-panel {
  overflow: hidden;
  background: #fff;
}
.main-guides-layout {
  display: grid;
  grid-template-columns: minmax(200px, 260px) 1fr;
  gap: 0;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--stroke);
}
@media (max-width: 640px) {
  .main-guides-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
}
.main-guides-sidebar {
  border-right: 1px solid var(--stroke);
  background: var(--card-2);
  padding: 14px 12px;
  overflow-y: auto;
  max-height: 100%;
}
.main-guides-sidebar__title {
  font-size: 13px;
  font-weight: 800;
  color: var(--ice-300);
  margin-bottom: 10px;
  letter-spacing: 0.02em;
}
.main-guides-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.main-guides-list__item {
  margin-bottom: 6px;
}
.main-guides-list__btn {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--stroke);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.main-guides-list__btn:hover {
  border-color: rgba(53, 183, 255, 0.45);
}
.main-guides-list__btn.is-active {
  border-color: var(--ice-500);
  box-shadow: 0 0 0 2px rgba(53, 183, 255, 0.15);
  font-weight: 700;
}
.main-guides-kind {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.65;
  flex-shrink: 0;
}
.main-guides-empty {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
  margin-top: 8px;
}
.main-guides-preview {
  min-height: 0;
  background: #f4f9ff;
  display: flex;
  flex-direction: column;
}
.main-guide-frame {
  flex: 1;
  width: 100%;
  min-height: 320px;
  border: none;
  background: #fff;
}

/* ----- Cửa sổ pop-out (media-gallery, team-guide-viewer): cùng nền + topbar với app chat ----- */
html.popout-root {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

html.popout-root body.popout-window {
  display: block;
  margin: 0;
  padding: 0;
  height: auto;
  min-height: 100%;
  overflow: visible;
  justify-content: flex-start;
  background:
    radial-gradient(1200px 800px at 20% 10%, rgba(53, 183, 255, 0.18), transparent 60%),
    radial-gradient(1200px 800px at 90% 30%, rgba(138, 217, 255, 0.1), transparent 55%),
    linear-gradient(180deg, var(--navy-950), var(--navy-900));
}

html.popout-root .page.popout-page {
  width: 100%;
  max-width: 1200px;
  height: auto;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0;
}

html.popout-root .shell.popout-shell {
  flex: 1;
  width: 100%;
  min-height: 100vh;
  height: auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #ffffff;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

html.popout-root .topbar.popout-topbar {
  flex-shrink: 0;
}

html.popout-root .popout-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px 18px 28px;
}

html.popout-root .popout-body--frame {
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

html.popout-root .popout-doc-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: #f4f9ff;
}

html.popout-root .popout-hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

/* Lưới thẻ — thư viện media (pop-out) */
html.popout-root .mg-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

html.popout-root .mg-head h1 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--ice-300);
  letter-spacing: 0.02em;
}

html.popout-root .mg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

html.popout-root .mg-card {
  background: #fff;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow);
}

html.popout-root .mg-card__media {
  background: #0f172a;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}

html.popout-root .mg-card__media video,
html.popout-root .mg-card__media img {
  max-width: 100%;
  max-height: 220px;
  vertical-align: middle;
}

html.popout-root .mg-card__body {
  padding: 12px 14px;
  font-size: 13px;
}

html.popout-root .mg-card__title {
  font-weight: 700;
  margin-bottom: 6px;
  word-break: break-word;
}

html.popout-root .mg-card__desc {
  color: var(--muted);
  margin-bottom: 10px;
  line-height: 1.45;
  min-height: 2.8em;
}

html.popout-root .mg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

html.popout-root .mg-actions a,
html.popout-root .mg-actions button {
  font-size: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  border: 1px solid rgba(53, 183, 255, 0.4);
  background: linear-gradient(180deg, rgba(53, 183, 255, 0.25), rgba(53, 183, 255, 0.1));
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

html.popout-root .mg-actions a:hover,
html.popout-root .mg-actions button:hover {
  box-shadow: 0 4px 12px rgba(53, 183, 255, 0.2);
  transform: translateY(-1px);
}

html.popout-root .mg-actions button.secondary {
  background: #f4f9ff;
}

html.popout-root .mg-empty,
html.popout-root .mg-err {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

html.popout-root .mg-err {
  color: #c0392b;
  font-weight: 600;
}

html.popout-root .mg-badge {
  display: inline-block;
  margin-bottom: 6px;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}

html.popout-root .mg-badge--posted {
  background: rgba(34, 197, 94, 0.15);
  color: #166534;
}

html.popout-root .mg-badge--draft {
  background: #f1f5f9;
  color: #64748b;
  font-weight: 600;
}

/* Fix missing admin fieldset layout */
.admin__fieldset {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f8fafc;
  padding: 16px;
  border-radius: var(--radius-sm, 12px);
  border: 1px solid var(--stroke, #e2e8f0);
}
.admin__fieldset .admin__label {
  margin-top: 0 !important;
}
.admin__fieldset .admin__btn {
  margin-top: 4px !important;
  align-self: flex-start;
}