@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

/* ═══════════════════════════════════════════════════════════
   MAID FORUM — Design System
   Light mode (default) + Dark mode (data-theme="dark")
   Toggle lưu vào localStorage key: "maidTheme"
═══════════════════════════════════════════════════════════ */

:root {
  /* ── Light palette ── */
  --bg:            #F0F2F5;
  --surface:       #FFFFFF;
  --surface-2:     #F5F6FA;
  --border:        #E6E8ED;
  --text:          #1C1E21;
  --muted:         #6B7280;
  --primary:       #7c3aed;
  --primary-dim:   #6d28d9;
  --primary-tint:  #ede9fe;
  --coral:         #FA5252;
  --coral-tint:    #FFECEC;
  --success:       #10B981;
  --success-tint:  #E7F9F1;
  --gold:          #F5A524;
  --gold-tint:     #FFF6E2;
  --blue:          #3B82F6;
  --blue-tint:     #EAF2FE;

  /* ── Layout tokens ── */
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow:    0 1px 2px rgba(20,20,43,.04), 0 6px 20px rgba(20,20,43,.05);
  --font:      'Manrope', system-ui, -apple-system, "Segoe UI", sans-serif;

  /* ── Topbar glow (off in light) ── */
  --topbar-glow: none;
  --topbar-border: var(--border);
}

/* ── Dark mode overrides ── */
[data-theme="dark"] {
  --bg:           #0d0d1a;
  --surface:      #131326;
  --surface-2:    #1a1a35;
  --border:       rgba(124,58,237,0.22);
  --text:         #f1f5f9;
  --muted:        #94a3b8;
  --primary:      #a78bfa;
  --primary-dim:  #7c3aed;
  --primary-tint: #1e1b4b;
  --coral:        #f87171;
  --coral-tint:   #2d1515;
  --success:      #34d399;
  --success-tint: #0d2a1f;
  --gold:         #fbbf24;
  --gold-tint:    #2a1f05;
  --blue:         #60a5fa;
  --blue-tint:    #0c1e3a;

  --shadow:       0 1px 3px rgba(0,0,0,0.4), 0 6px 24px rgba(0,0,0,0.35);
  --topbar-glow:  0 1px 0 rgba(124,58,237,0.5);
  --topbar-border: rgba(124,58,237,0.3);
}

/* ── Dark: nền toàn trang có ánh tím nhẹ ── */
[data-theme="dark"] body {
  background:
    radial-gradient(ellipse 55% 35% at 15% 0%, rgba(124,58,237,0.13) 0%, transparent 70%),
    radial-gradient(ellipse 45% 30% at 85% 100%, rgba(167,139,250,0.09) 0%, transparent 65%),
    var(--bg);
  background-attachment: fixed;
}

/* ═══════════════════════════════════════════════════════════
   BASE
═══════════════════════════════════════════════════════════ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.55;
  min-height: 100vh;
  transition: background 0.25s ease, color 0.2s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--font); font-weight: 800; margin: 0 0 12px; letter-spacing: -0.01em; }
hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.ml-auto { margin-left: auto; }

/* ═══════════════════════════════════════════════════════════
   TOPBAR
═══════════════════════════════════════════════════════════ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--topbar-border);
  box-shadow: var(--topbar-glow);
  position: sticky; top: 0; z-index: 20;
  transition: background 0.25s, border-color 0.25s, box-shadow 0.25s;
}

/* Signature dark: shimmer tím chạy ngang bottom border */
[data-theme="dark"] .topbar::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(167,139,250,0.7) 30%,
    rgba(124,58,237,1) 50%,
    rgba(167,139,250,0.7) 70%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: topbar-shimmer 4s linear infinite;
}
@keyframes topbar-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.topbar-inner {
  max-width: 1080px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px;
}
.brand {
  font-family: var(--font); font-weight: 800; font-size: 1.15rem;
  color: var(--text); display: flex; align-items: center;
  gap: 9px; flex-shrink: 0; min-width: 0;
}
.brand:hover { text-decoration: none; color: var(--primary); }
.brand-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 11px; font-size: 17px; flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  box-shadow: 0 4px 10px rgba(124,58,237,.4);
}

/* icon nav */
.icon-nav { display: flex; gap: 4px; align-items: center; }
.icon-btn {
  position: relative; display: flex; align-items: center; justify-content: center;
  width: 44px; height: 40px; border-radius: 10px; color: var(--muted); flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.icon-btn .icon-glyph { font-size: 19px; line-height: 1; }
.icon-btn.active { color: var(--primary); }
.icon-btn.active::after {
  content: ''; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 3px; border-radius: 3px 3px 0 0; background: var(--primary);
}
.icon-btn-cta { background: var(--primary-tint); }
.icon-btn-cta:hover { background: var(--primary-dim); color: #fff; }

.topbar-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.pill {
  background: var(--coral); color: #fff; font-size: 0.68rem;
  padding: 1px 6px; border-radius: 20px; margin-left: 4px; font-weight: 800;
}
.pill-badge {
  position: absolute; top: -2px; right: 2px; margin-left: 0;
  min-width: 16px; text-align: center; font-size: 0.62rem; padding: 1px 4px;
}

/* ── Theme Toggle Button ── */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; font-size: 17px; line-height: 1;
  transition: background 0.2s, border-color 0.2s, transform 0.15s, box-shadow 0.2s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.15);
  transform: rotate(20deg);
}
.theme-toggle:active { transform: rotate(20deg) scale(0.9); }

/* avatar dropdown */
.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-chip { display: flex; align-items: center; border-radius: 999px; padding: 2px; }
.user-chip:hover { background: var(--surface-2); }
.user-menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px); width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0,0,0,.2);
  padding: 8px; z-index: 30;
  transition: background 0.2s;
}
.user-menu-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-md); color: var(--text);
}
.user-menu-head:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-name { font-weight: 800; font-size: 0.92rem; }
.user-menu-panel hr { margin: 8px 4px; }
.user-menu-item {
  display: block; padding: 10px 8px; border-radius: var(--radius-md);
  color: var(--text); font-weight: 600; font-size: 0.9rem;
}
.user-menu-item:hover { background: var(--surface-2); text-decoration: none; }
.user-menu-item.admin-link { color: var(--gold); }
.user-menu-item.admin-link:hover { background: var(--gold-tint); }
.desktop-only { display: flex; }
.mobile-only { display: none; }

/* ═══════════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════════ */
.btn-primary, .btn-ghost, .btn-danger, .btn-link {
  font-family: var(--font); font-size: 0.9rem; font-weight: 700; cursor: pointer;
  border-radius: 999px; padding: 10px 18px; border: 1px solid transparent; display: inline-block;
  transition: background 0.15s, color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary-dim), var(--primary));
  color: #fff; box-shadow: 0 4px 12px rgba(124,58,237,.3);
}
.btn-primary:hover { background: linear-gradient(135deg, #5b21b6, var(--primary-dim)); text-decoration: none; transform: translateY(-1px); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); text-decoration: none; color: var(--primary); }
.btn-danger { background: var(--coral-tint); border-color: transparent; color: var(--coral); }
.btn-danger:hover { background: var(--coral); color: #fff; text-decoration: none; }
.btn-block { width: 100%; text-align: center; }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; border-radius: 999px; }
.btn-xs { padding: 3px 10px; font-size: 0.75rem; border-radius: 999px; }
.btn-link { background: none; border: none; color: var(--muted); padding: 0; font-weight: 700; border-radius: 0; }
.btn-link:hover { color: var(--primary); text-decoration: none; }
.btn-link.danger:hover { color: var(--coral); }
button:disabled { opacity: 0.6; cursor: default; }

/* ═══════════════════════════════════════════════════════════
   LAYOUT
═══════════════════════════════════════════════════════════ */
.page-wrap { max-width: 700px; margin: 0 auto; padding: 24px 20px 60px; min-height: 70vh; }
.narrow-wrap { max-width: 560px; margin: 0 auto; padding: 24px 20px 60px; }
.card-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-bottom: 14px;
  box-shadow: var(--shadow);
  transition: background 0.25s, border-color 0.25s;
}
.site-footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 24px; }
.page-wrap.wide { max-width: 1080px; }

/* ═══════════════════════════════════════════════════════════
   FLASH / BANNERS / TOAST
═══════════════════════════════════════════════════════════ */
.flash {
  max-width: 700px; margin: 12px auto 0;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600;
}
.flash-success, .flash-info { background: var(--success-tint); border: 1px solid rgba(16,185,129,0.3); color: var(--success); }
.flash-error { background: var(--coral-tint); border: 1px solid rgba(250,82,82,0.3); color: var(--coral); }
.ban-banner {
  max-width: 700px; margin: 12px auto 0; padding: 12px 16px;
  border-radius: var(--radius-sm); background: var(--coral-tint);
  border: 1px solid rgba(250,82,82,0.3); color: var(--coral); font-size: 0.9rem;
}
.toast-host {
  position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none;
}
.toast {
  pointer-events: auto; background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: var(--radius-sm); font-size: 0.85rem; font-weight: 600;
  box-shadow: 0 8px 22px rgba(0,0,0,.3); opacity: 0; transform: translateY(-8px);
  transition: opacity .2s, transform .2s; max-width: min(90vw, 360px); text-align: center;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error   { background: var(--coral); color: #fff; }
.toast-success { background: var(--success); color: #fff; }
.toast-info    { background: var(--primary); color: #fff; }

/* ═══════════════════════════════════════════════════════════
   FORMS
═══════════════════════════════════════════════════════════ */
.stack-form { display: flex; flex-direction: column; gap: 14px; }
.stack-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); font-weight: 700; }
input[type=text], input[type=email], input[type=password], input[type=search],
input[type=color], textarea, select {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 14px;
  font-family: var(--font); font-size: 16px; resize: vertical;
  max-width: 100%; box-sizing: border-box;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); background: var(--surface); outline: none; box-shadow: 0 0 0 3px rgba(124,58,237,0.15); }
.inline-form { display: inline-block; }

/* ── Install / Auth ── */
.install-body {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(160deg, var(--primary-tint), var(--bg) 55%);
}
.install-wrap { width: 100%; max-width: 440px; padding: 20px; }
.install-card, .auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 36px 32px;
  text-align: center; box-shadow: var(--shadow);
}
.install-mark {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: linear-gradient(135deg, #7c3aed, #a78bfa);
  box-shadow: 0 8px 20px rgba(124,58,237,.4);
}
.install-card form, .auth-card form { text-align: left; }
.ok-msg { color: var(--success); font-weight: 600; }
.auth-wrap { display: flex; justify-content: center; padding: 40px 0; }
.auth-card { width: 100%; max-width: 400px; }

/* ═══════════════════════════════════════════════════════════
   POST FEED
═══════════════════════════════════════════════════════════ */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.post-list { display: flex; flex-direction: column; gap: 12px; }
.post-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; color: var(--text);
  box-shadow: var(--shadow); transition: transform .12s, box-shadow .12s, border-color .2s;
}
.post-row:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,.1), 0 14px 28px rgba(0,0,0,.12);
  border-color: rgba(124,58,237,0.35);
  text-decoration: none;
}
.post-row-main { flex: 1; min-width: 0; }
.post-row-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.post-row-title { font-weight: 700; font-size: 1.03rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.post-row-excerpt {
  color: var(--muted); font-size: 0.85rem; margin-top: 4px; line-height: 1.5;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.post-row-meta { color: var(--muted); font-size: 0.8rem; margin-top: 6px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.post-row-stats { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.stat-pill {
  display: flex; align-items: center; gap: 5px;
  background: var(--surface-2); border-radius: 999px; padding: 5px 10px;
  font-weight: 700; font-size: 0.82rem; color: var(--text); min-width: 52px; justify-content: center;
}
.stat-pill .stat-icon { font-size: 0.85rem; line-height: 1; }
.stat-pill .stat-val { min-width: 1ch; text-align: left; }
.empty-state {
  color: var(--muted); text-align: center; padding: 36px 20px;
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg);
}

/* ── Chuyên mục ── */
.tag-cat {
  background: color-mix(in srgb, var(--cat-color) 16%, transparent);
  color: var(--cat-color);
}
[data-theme="dark"] .tag-cat { background: color-mix(in srgb, var(--cat-color) 26%, transparent); }
.post-cat-row { margin-bottom: 6px; }
.cat-filter-bar {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px;
  scrollbar-width: none;
}
.cat-filter-bar::-webkit-scrollbar { display: none; }
.cat-pill {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-weight: 700; font-size: 0.82rem; padding: 8px 14px; border-radius: 999px;
  transition: border-color .15s, color .15s, background .15s;
}
.cat-pill:hover { text-decoration: none; border-color: var(--cat-color, var(--primary)); }
.cat-pill.active {
  background: color-mix(in srgb, var(--cat-color, var(--primary)) 16%, var(--surface));
  border-color: var(--cat-color, var(--primary));
  color: var(--cat-color, var(--primary));
}

/* ── Thông báo quản trị viên ── */
.announcement-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--primary-tint); border: 1px solid rgba(124,58,237,0.3);
  border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 16px;
  color: var(--text); box-shadow: var(--shadow);
}
.announcement-icon { font-size: 1.3rem; line-height: 1; flex-shrink: 0; }
.announcement-text { font-weight: 600; font-size: 0.94rem; line-height: 1.5; white-space: pre-wrap; }
.announcement-meta { margin-top: 4px; }
.search-entry { flex-shrink: 0; }

/* ── Tìm kiếm ── */
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input[type="search"] {
  flex: 1; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); padding: 11px 14px; font-family: var(--font); font-size: 16px;
}
.search-result-count { margin-bottom: 12px; }

/* ── Quản trị chuyên mục ── */
.cat-inline-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.cat-inline-form label { flex: 1; min-width: 120px; }
.cat-admin-list { display: flex; flex-direction: column; gap: 4px; }
.cat-admin-row {
  display: flex; align-items: center; gap: 8px; padding: 8px 4px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.cat-preview {
  width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--cat-color) 18%, transparent); flex-shrink: 0;
}
.cat-icon-input { width: 48px; text-align: center; padding: 8px; }
.cat-name-input { flex: 1; min-width: 100px; }
.cat-color-input { width: 40px; padding: 2px; height: 34px; }
.cat-sort-input { width: 56px; padding: 8px; }
.cat-post-count { flex-shrink: 0; white-space: nowrap; }
.cat-delete-btn { margin: -4px 0 8px 40px; font-size: 0.78rem; }

/* ═══════════════════════════════════════════════════════════
   AVATARS & TAGS
═══════════════════════════════════════════════════════════ */
.avatar-sm { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.avatar-md { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.avatar-lg { width: 92px; height: 92px; border-radius: 50%; object-fit: cover; flex-shrink: 0; border: 4px solid var(--surface); box-shadow: 0 0 0 1px var(--border); }
.tag { display: inline-block; font-size: 0.68rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; vertical-align: middle; }
.tag-locked { background: var(--coral-tint); color: var(--coral); }
.tag-warn { background: var(--gold-tint); color: var(--gold); }

.maid-typing { display: flex; align-items: center; gap: 8px; padding: 6px 4px; color: var(--muted); font-size: 0.82rem; }
.maid-typing .maid-typing-dots { display: inline-flex; gap: 3px; }
.maid-typing .maid-typing-dots span { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0.3; animation: maidTypingBlink 1.2s infinite ease-in-out; }
.maid-typing .maid-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.maid-typing .maid-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes maidTypingBlink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.tag-role-admin { background: var(--gold-tint); color: var(--gold); }
.tag-role-mod   { background: var(--blue-tint); color: var(--blue); }

.badge-row { display: inline-flex; gap: 6px; flex-wrap: wrap; margin: 4px 0; }
.seal-badge {
  display: inline-flex; align-items: center; gap: 4px; font-size: 0.7rem; font-weight: 800;
  padding: 3px 10px; border-radius: 999px;
  background: color-mix(in srgb, var(--seal-color, var(--primary)) 15%, transparent);
  color: var(--seal-color, var(--primary));
}

/* ═══════════════════════════════════════════════════════════
   PAGINATION
═══════════════════════════════════════════════════════════ */
.pagination { display: flex; gap: 6px; justify-content: center; margin: 22px 0; }
.pagination a {
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 999px; min-width: 36px; text-align: center;
  padding: 7px 10px; color: var(--text); font-weight: 600; font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination a:hover { border-color: var(--primary); text-decoration: none; }

/* ═══════════════════════════════════════════════════════════
   POST DETAIL
═══════════════════════════════════════════════════════════ */
.mod-toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: var(--gold-tint); border-radius: var(--radius-md);
  padding: 10px 14px; margin-bottom: 14px;
}
.mod-toolbar-label { color: var(--gold); font-weight: 800; font-size: 0.72rem; text-transform: uppercase; letter-spacing: .04em; flex-basis: 100%; margin-bottom: 2px; }
.mod-toolbar .inline-form { display: contents; }
.post-detail-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.author-name { color: var(--text); font-weight: 800; }
.post-title { font-size: 1.5rem; margin: 10px 0; }
.post-content { white-space: pre-wrap; font-size: 1rem; }
.comments-heading { margin: 22px 0 12px; font-size: 1.05rem; font-weight: 800; }

/* ── Comments: mỗi bình luận là 1 thẻ riêng biệt (đầu = người viết, thân = nội dung, chân = thao tác) ── */
#comments-list { display: flex; flex-direction: column; gap: 12px; }
.comment-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; transition: border-color .15s, box-shadow .15s;
}
.comment-item:target { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-tint); }
.comment-head { display: flex; align-items: flex-start; gap: 10px; padding: 14px 16px 0; }
.comment-head-meta { flex: 1; min-width: 0; }
.comment-head-nameline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.comment-head-time { margin-top: 2px; font-size: 0.78rem; }
.bubble-name { color: var(--text); font-weight: 800; font-size: 0.92rem; }
.comment-bubble {
  padding: 8px 16px 14px;
  overflow-wrap: anywhere; word-break: break-word;
}
.comment-text { white-space: pre-wrap; font-size: 0.97rem; line-height: 1.65; color: var(--text); }
.comment-item.is-deleted { border-style: dashed; background: transparent; }
.comment-deleted-box { padding: 14px 16px; }
.comment-deleted { color: var(--muted); font-style: italic; margin-top: 2px; }
.quote-block {
  border-left: 3px solid var(--gold); background: var(--surface-2);
  padding: 8px 12px; border-radius: 0 10px 10px 0; margin: 2px 0 10px;
  font-size: 0.85rem; color: var(--muted);
}
.quote-author { font-weight: 800; color: var(--gold); display: block; margin-bottom: 2px; font-size: 0.78rem; }

.comment-toolbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 2px;
  border-top: 1px solid var(--border); background: var(--surface-2); padding: 4px 8px;
}
.comment-toolbar-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: none; border: none; border-radius: var(--radius-sm);
  padding: 8px 10px; font-size: 0.82rem; font-weight: 700; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.comment-toolbar-btn:hover { background: var(--surface); color: var(--text); }
.comment-toolbar-btn.js-like.is-liked { color: var(--primary); }
.comment-toolbar-btn.danger:hover { color: var(--coral); }
.comment-item .likers-row { padding: 0 16px 10px; }
.edit-box { margin-top: 8px; }
.edit-box textarea { width: 100%; }
.edit-box-actions { display: flex; gap: 8px; margin-top: 6px; }
.quote-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--gold-tint); border-radius: var(--radius-sm);
  padding: 8px 14px; margin-bottom: 10px; font-size: 0.85rem; color: var(--gold);
}
#comment-form-wrap textarea { width: 100%; }

/* ═══════════════════════════════════════════════════════════
   CHAT
═══════════════════════════════════════════════════════════ */
.chat-wrap { max-width: 700px; margin: 0 auto; }
.chat-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); height: 55vh; overflow-y: auto;
  padding: 16px; display: flex; flex-direction: column;
  gap: 14px; margin-bottom: 12px; box-shadow: var(--shadow);
  transition: background 0.25s, border-color 0.25s;
}
.chat-msg { display: flex; gap: 8px; padding: 6px 4px; align-items: flex-start; }
.chat-msg-mine { flex-direction: row-reverse; }
.chat-msg-body { max-width: 78%; }
.chat-msg-mine .chat-msg-body { text-align: right; }
.chat-msg-head { font-size: .8rem; margin-bottom: 2px; }
.chat-bubble {
  display: inline-block; background: var(--surface-2);
  padding: 8px 12px; border-radius: var(--radius-md);
  overflow-wrap: anywhere; word-break: break-word; max-width: 100%;
  transition: background 0.2s;
}
.chat-msg-mine .chat-bubble { background: var(--primary-tint); }
.chat-msg-time { font-size: .72rem; margin-top: 2px; }
.avatar-xs { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.chat-msg-meta { font-size: 0.8rem; display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.chat-msg-meta a { color: var(--text); font-weight: 800; }
.chat-msg-bubble { background: var(--surface-2); border-radius: var(--radius-md); padding: 8px 14px; display: inline-block; word-break: break-word; }
.chat-msg.mine .chat-msg-bubble { background: var(--primary-tint); color: var(--primary); }
.chat-form { display: flex; gap: 10px; min-width: 0; }
.chat-form input { flex: 1; min-width: 0; border-radius: 999px !important; padding: 12px 18px !important; }
.chat-form-rich { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.chat-input-row { display: flex; align-items: flex-end; gap: 8px; min-width: 0; }
.chat-input-row textarea { flex: 1; min-width: 0; resize: none; overflow-y: hidden; max-height: 140px; border-radius: 20px; line-height: 1.4; display: block; }
.chat-input-row .file-label-icon,
.chat-input-row button[type=submit] { flex-shrink: 0; }

/* ═══════════════════════════════════════════════════════════
   MESSAGES
═══════════════════════════════════════════════════════════ */
.messages-wrap { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; min-width: 0; }
.conv-list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; box-shadow: var(--shadow); min-width: 0; }
.conv-item { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: var(--radius-md); color: var(--text); }
.conv-item:hover, .conv-item.active { background: var(--surface-2); text-decoration: none; }
.conv-item.active { background: var(--primary-tint); }
.conv-item-main { flex: 1; min-width: 0; }
.conv-item-name { font-weight: 800; font-size: 0.9rem; }
.conv-item-preview { color: var(--muted); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-thread {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 18px; min-height: 420px;
  display: flex; flex-direction: column; box-shadow: var(--shadow); min-width: 0;
}
.thread-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.thread-head a { color: var(--text); font-weight: 800; }
.thread-box { flex: 1; overflow-y: auto; max-height: 55vh; display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.thread-msg { display: flex; flex-direction: column; max-width: 68%; }
.thread-msg.mine { align-self: flex-end; align-items: flex-end; }
.thread-msg.theirs { align-self: flex-start; }
.thread-bubble { padding: 10px 15px; border-radius: 18px; background: var(--surface-2); overflow-wrap: anywhere; word-break: break-word; }
.thread-msg.mine .thread-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; }
.thread-msg.theirs .thread-bubble { border-bottom-left-radius: 4px; }
.thread-time { font-size: 0.7rem; color: var(--muted); margin-top: 3px; }

/* ═══════════════════════════════════════════════════════════
   PROFILE
═══════════════════════════════════════════════════════════ */
.profile-cover {
  height: 130px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  margin-bottom: -56px;
  background: linear-gradient(120deg, #6d28d9, #a78bfa 45%, #c084fc);
}
[data-theme="dark"] .profile-cover {
  background: linear-gradient(120deg, #4c1d95, #7c3aed 45%, #a78bfa);
}
.profile-header { display: flex; gap: 18px; align-items: flex-end; position: relative; }
.profile-avatar { margin-top: -14px; }
.profile-header-main { flex: 1; padding-top: 8px; }
.profile-bio { margin: 8px 0; }
.profile-stats { display: flex; gap: 16px; color: var(--muted); font-size: 0.85rem; margin-top: 6px; flex-wrap: wrap; }
.profile-stats strong { color: var(--text); }
.profile-actions { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; }
.activity-log { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.activity-log li { border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.activity-time { float: right; }
.avatar-edit-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.file-label { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 12px; cursor: pointer; font-size: 0.85rem; color: var(--muted); flex: 1; text-align: center; }
.file-label-upload {
  display: flex; align-items: center; gap: 14px; text-align: left;
  flex: 1 1 220px; min-width: 200px; max-width: 100%; box-sizing: border-box;
  border: 2px dashed var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; background: var(--surface-2);
  transition: border-color .15s, background .15s, transform .1s;
}
.file-label-upload:hover { border-color: var(--primary); background: var(--surface); }
.file-label-upload:active { transform: scale(0.99); }
.file-label-upload:focus-within { border-color: var(--primary); outline: 2px solid var(--primary-tint); outline-offset: 2px; }
.file-label-upload-icon {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; background: var(--surface); border: 1px solid var(--border);
}
.file-label-upload-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.file-label-upload-title { font-weight: 700; color: var(--text); font-size: 0.9rem; }
.file-label-upload-hint { font-size: 0.78rem; color: var(--muted); overflow-wrap: anywhere; }

/* ═══════════════════════════════════════════════════════════
   ADMIN
═══════════════════════════════════════════════════════════ */
.admin-wrap h1 { margin-bottom: 18px; }
.admin-section-title { margin: 26px 0 10px; font-size: 1.05rem; }
.admin-wrap .card-panel + .admin-section-title { margin-top: 30px; }
.ext-group-label { display: block; font-weight: 700; font-size: 0.85rem; color: var(--muted); margin-bottom: 8px; }
.ext-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 12px; }
.ext-group { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 10px 12px; }
.ext-group-title { font-weight: 700; font-size: 0.82rem; margin-bottom: 6px; }
.ext-checks { display: flex; flex-direction: column; gap: 4px; }
.ext-checks .chk-inline { font-size: 0.82rem; }
.admin-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; text-align: center; box-shadow: var(--shadow); }
.stat-card-num { font-size: 1.9rem; font-weight: 800; color: var(--primary); }
.admin-menu { display: flex; gap: 14px; }
.admin-menu-item { flex: 1; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; color: var(--text); font-weight: 700; box-shadow: var(--shadow); }
.admin-menu-item:hover { border-color: var(--primary); text-decoration: none; }
.search-form { display: flex; gap: 8px; margin-bottom: 16px; }
.search-form input { flex: 1; }
.user-admin-list { display: flex; flex-direction: column; gap: 8px; }
.user-admin-row { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; flex-wrap: wrap; box-shadow: var(--shadow); }
.user-admin-main { flex: 1; min-width: 200px; }
.user-admin-actions { display: flex; align-items: center; gap: 8px; position: relative; }
.ban-details summary { list-style: none; cursor: pointer; }
.ban-details summary::-webkit-details-marker { display: none; }
.ban-form { position: absolute; right: 0; top: 40px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; display: flex; flex-direction: column; gap: 8px; z-index: 10; width: 240px; box-shadow: var(--shadow); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.awarded-list { display: flex; flex-direction: column; gap: 8px; }
.awarded-row { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-md); }
.admin-table { width: 100%; min-width: 640px; border-collapse: collapse; margin-top: 8px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: .9rem; vertical-align: top; white-space: normal; }
.admin-table th { color: var(--muted); font-weight: 700; white-space: nowrap; }
.admin-table-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table code { overflow-wrap: anywhere; word-break: break-all; white-space: pre-wrap; display: inline-block; max-width: 100%; }

/* ═══════════════════════════════════════════════════════════
   BOTTOM TAB BAR (mobile)
═══════════════════════════════════════════════════════════ */
.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--surface); border-top: 1px solid var(--topbar-border);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  box-shadow: 0 -2px 12px rgba(0,0,0,.1);
  transition: background 0.25s, border-color 0.25s;
}
[data-theme="dark"] .bottom-nav { box-shadow: 0 -1px 0 rgba(124,58,237,0.4), 0 -4px 20px rgba(0,0,0,0.5); }
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; padding: 6px 2px;
  border-radius: var(--radius-sm); color: var(--muted); min-width: 0;
}
.bn-item:hover, .bn-item:active { text-decoration: none; background: var(--surface-2); }
.bn-item.active { color: var(--primary); }
.bn-icon { font-size: 20px; line-height: 1; position: relative; display: inline-block; }
.bn-label { font-size: 0.62rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bn-avatar { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; border: 2px solid transparent; }
.bn-item.active .bn-avatar { border-color: var(--primary); }
.pill-bn { position: absolute; top: -6px; right: -10px; }
.bn-item-cta { flex: 0 0 auto; }
.bn-icon-cta {
  display: flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-dim), var(--primary));
  color: #fff; font-size: 18px; box-shadow: 0 4px 12px rgba(124,58,237,.4);
}

/* ═══════════════════════════════════════════════════════════
   EXPANDABLE / IMAGES / LIKES
═══════════════════════════════════════════════════════════ */
.expandable { overflow: hidden; position: relative; transition: max-height .25s ease; }
.expandable.truncated { mask-image: linear-gradient(to bottom, #000 75%, transparent 100%); -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent 100%); }
.expand-toggle { display: inline-block; margin: 4px 0 8px; font-weight: 700; font-size: .85rem; }
.attach-img { display: block; margin-top: 10px; border-radius: var(--radius-md); max-height: 420px; object-fit: cover; border: 1px solid var(--border); }
.attach-img-lg { max-height: 520px; width: 100%; object-fit: contain; background: var(--surface-2); }
.attach-img-chat { max-height: 220px; margin-top: 6px; }
.post-like-row { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.js-like { font-weight: 700; }
.js-like.is-liked { color: var(--primary); }
.likers-row { margin-top: 2px; }
.likers-more { font-weight: 700; }
.attach-file-chip {
  display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; max-width: 100%;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-2); color: var(--text); text-decoration: none;
  transition: border-color .15s, background .15s;
}
.attach-file-chip:hover { border-color: var(--primary); background: var(--surface); text-decoration: none; }
.attach-file-chip-icon { font-size: 1.5rem; flex-shrink: 0; line-height: 1; }
.attach-file-chip-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attach-file-chip-name { font-weight: 700; font-size: 0.88rem; overflow-wrap: anywhere; }
.attach-file-chip-size { font-size: 0.76rem; color: var(--muted); }

.attach-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* ---- Khu đính kèm ảnh/file khi đăng bài & bình luận ---- */
.attach-zone { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.attach-zone-buttons { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.attach-pill-btn {
  position: relative;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); color: var(--text); font-size: 0.83rem; font-weight: 600;
  cursor: pointer; transition: border-color .15s, background .15s, transform .1s; user-select: none;
}
.attach-pill-btn:hover { border-color: var(--primary); background: var(--surface); }
.attach-pill-btn:active { transform: scale(0.97); }
.attach-pill-btn:focus-within { border-color: var(--primary); outline: 2px solid var(--primary-tint); outline-offset: 2px; }
.attach-pill-icon { font-size: 1rem; line-height: 1; }
.attach-pill-btn .attach-file-input {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; white-space: nowrap; border: 0; opacity: 0.01; clip-path: inset(50%);
}
.attach-hint { font-size: 0.74rem; color: var(--muted); }
.attach-preview-list:empty { display: none; }
.attach-preview-list { display: flex; flex-direction: column; gap: 8px; }
.attach-preview-chip {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
}
.attach-preview-thumb { width: 42px; height: 42px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; border: 1px solid var(--border); }
.attach-preview-icon { width: 42px; height: 42px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 1.3rem; background: var(--surface); border: 1px solid var(--border); flex-shrink: 0; }
.attach-preview-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.attach-preview-name { font-weight: 700; font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-preview-meta { font-size: 0.76rem; color: var(--muted); }
.attach-preview-remove {
  flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); cursor: pointer; font-size: 0.9rem; line-height: 1;
  display: flex; align-items: center; justify-content: center; transition: border-color .15s, color .15s;
}
.attach-preview-remove:hover { border-color: var(--coral); color: var(--coral); }
.attach-existing-chip { border-style: dashed; }
.attach-existing-chip .attach-preview-meta { color: var(--muted); }

/* trạng thái chip khi upload nhiều ảnh/file tuần tự qua AJAX */
.attach-uploading-chip { opacity: 0.85; }
.attach-uploading-chip .attach-preview-icon { position: relative; overflow: hidden; }
.attach-uploading-chip .attach-preview-icon::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  border: 2px solid transparent; border-top-color: var(--primary); border-right-color: var(--primary);
  animation: attach-spin 0.7s linear infinite;
}
@keyframes attach-spin { to { transform: rotate(360deg); } }
.attach-uploading-chip .attach-preview-meta { color: var(--primary); }
.attach-done-chip { border-color: rgba(16,185,129,0.4); background: var(--success-tint); }
.attach-done-chip .attach-preview-meta { color: var(--success); }
.attach-error-chip { border-color: rgba(250,82,82,0.4); background: var(--coral-tint); }
.attach-error-chip .attach-preview-meta { color: var(--coral); overflow-wrap: anywhere; white-space: normal; }

/* danh sách nhiều file đính kèm hiển thị khi xem bài viết/bình luận */
.attach-file-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.attach-file-list .attach-file-chip { margin-top: 0; }
.chk-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; font-size: .9rem; color: var(--muted); }
.file-label-sm { padding: 6px 10px; font-size: .85rem; }
.file-label-icon {
  flex: 0 0 auto; width: 46px; height: 46px; padding: 0; box-sizing: border-box;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border);
  font-size: 1.2rem; line-height: 1; transition: border-color 0.15s, background 0.15s;
}
.file-label-icon:hover { border-color: var(--primary); background: var(--surface); }
.edit-box { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.edit-box textarea { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--font); resize: vertical; }
.edit-box-actions { display: flex; gap: 8px; }
.edit-post-form { margin-top: 10px; background: var(--surface-2); border-radius: var(--radius-md); padding: 12px; }
.tag-ai { background: var(--primary-tint); color: var(--primary); font-weight: 700; }

/* ═══════════════════════════════════════════════════════════
   AVATAR FRAME & NAME FX (Shop)
═══════════════════════════════════════════════════════════ */
.avatar-framed { padding: 3px; border-radius: 50%; box-sizing: border-box; }
img.avatar-framed { background-color: transparent; }
.display-name { font-weight: 700; }
.name-fx-fire     { background: linear-gradient(90deg,#ff9a3c,#ff3d3d,#ff9a3c); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-slide 3s linear infinite; }
.name-fx-ice      { background: linear-gradient(90deg,#8fd3f4,#3ec6e0,#8fd3f4); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-slide 3s linear infinite; }
.name-fx-rainbow  { background: linear-gradient(90deg,#ff5e5e,#ffb347,#ffe45e,#5ee08c,#5eb3ff,#c05eff,#ff5e5e); background-size: 300% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-slide 4s linear infinite; }
.name-fx-gold     { background: linear-gradient(90deg,#caa14b,#fff3c4,#caa14b); background-size: 200% auto; -webkit-background-clip: text; background-clip: text; color: transparent; animation: fx-slide 3.5s linear infinite; }
.name-fx-sparkle  { position: relative; color: var(--text); background: linear-gradient(90deg,#fff 0%, #ffe8a3 45%, #fff 55%, #fff 100%); background-size: 250% auto; -webkit-background-clip: text; background-clip: text; animation: fx-slide 2.2s linear infinite; text-shadow: 0 0 6px rgba(255,215,120,.5); }
@keyframes fx-slide { 0% { background-position: 0% 50%; } 100% { background-position: 200% 50%; } }
.shop-title-tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; color: #fff; background: var(--title-color, var(--primary)); vertical-align: middle; }

/* ═══════════════════════════════════════════════════════════
   BBCODE / EMOJI TOOLBAR
═══════════════════════════════════════════════════════════ */
.bb-toolbar { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 6px 4px; border: 1px solid var(--border); border-bottom: none; border-radius: var(--radius-sm) var(--radius-sm) 0 0; background: var(--surface-2); }
.bb-btn { border: none; background: transparent; padding: 5px 9px; border-radius: 8px; cursor: pointer; font-size: .9rem; color: var(--text); }
.bb-btn:hover { background: var(--primary-tint); color: var(--primary); }
.bb-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.bb-toolbar + textarea, .bb-toolbar + input { border-top-left-radius: 0; border-top-right-radius: 0; }
.emoji-picker-wrap { position: relative; }
.emoji-panel { position: absolute; z-index: 60; bottom: calc(100% + 8px); top: auto; left: 0; width: 260px; max-width: min(80vw, 300px); max-height: 45vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: 0 8px 28px rgba(0,0,0,.25); padding: 6px; }
.emoji-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.emoji-close { border: none; background: var(--surface-2); width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: .8rem; line-height: 1; color: var(--muted); }
.emoji-close:hover { background: var(--coral-tint); color: var(--coral); }
.emoji-panel-grid { display: flex; flex-wrap: wrap; gap: 2px; }
.emoji-item { border: none; background: transparent; font-size: 1.2rem; padding: 4px 6px; border-radius: 6px; cursor: pointer; }
.emoji-item:hover { background: var(--primary-tint); }
.bbcode-quote { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--primary); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.bbcode-code { display: block; padding: 8px 10px; background: #1C1E21; color: #E6E8ED; border-radius: var(--radius-sm); font-family: monospace; white-space: pre-wrap; }
.bbcode-img { max-width: 100%; border-radius: var(--radius-sm); margin: 6px 0; }

/* ═══════════════════════════════════════════════════════════
   SHOP
═══════════════════════════════════════════════════════════ */
.wide-wrap { max-width: 1080px; margin: 0 auto; padding: 18px 16px 40px; }
.shop-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.shop-balance { background: var(--gold-tint); color: var(--gold); font-weight: 800; padding: 8px 14px; border-radius: 999px; }
.frame-preview { width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; padding: 4px; }
.frame-preview img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; border: 2px solid var(--surface); }
.frame-preview-sm { width: 56px; height: 56px; }
.name-fx-preview { font-weight: 800; font-size: 1.05rem; }
.linh-thach-chip { background: var(--gold-tint); color: var(--gold); font-weight: 800; padding: 6px 12px; border-radius: 999px; font-size: .9rem; }
.inv-cat-title { font-size: 1rem; margin: 14px 0 8px; }
.inventory-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.inv-card { background: var(--surface-2); border-radius: var(--radius-md); padding: 12px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ai-account-card { display: flex; align-items: center; gap: 12px; }

/* ── Trang Cửa hàng: giao diện showcase giống gian hàng thật ── */
.shop-hero {
  display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--primary-tint), var(--surface) 70%);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px 24px; margin-bottom: 16px;
}
[data-theme="dark"] .shop-hero { background: linear-gradient(135deg, rgba(124,58,237,.2), var(--surface) 70%); }
.shop-hero-info h1 { margin: 0 0 6px; font-size: 1.4rem; }
.shop-hero-sub { color: var(--muted); font-size: .88rem; max-width: 480px; margin: 0; }
.shop-wallet {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 18px; text-align: right;
}
.shop-wallet-label { font-size: .7rem; color: var(--muted); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.shop-wallet-amount { font-size: 1.35rem; font-weight: 800; color: var(--gold); line-height: 1.3; }
.shop-wallet-earn { font-size: .78rem; font-weight: 700; }

.shop-tabs-row { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
.shop-tab-pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 16px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); font-weight: 700; color: var(--text); font-size: .87rem;
  transition: background .15s, color .15s, border-color .15s;
}
.shop-tab-pill:hover { border-color: var(--primary); text-decoration: none; }
.shop-tab-pill.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.shop-tab-count { background: var(--surface-2); color: var(--muted); border-radius: 999px; padding: 1px 8px; font-size: .72rem; font-weight: 800; }
.shop-tab-pill.active .shop-tab-count { background: rgba(255,255,255,.25); color: #fff; }
.shop-tab-inventory { background: var(--surface-2); }

.shop-empty { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-lg); }
.shop-empty-icon { font-size: 2rem; display: block; margin-bottom: 8px; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.shop-card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: border-color .2s, transform .15s, box-shadow .2s;
}
.shop-card:hover { border-color: rgba(124,58,237,.45); transform: translateY(-3px); box-shadow: 0 12px 26px rgba(20,20,43,.12); }
.shop-card.is-equipped { border-color: var(--primary); }
.shop-card-badge { position: absolute; top: 10px; left: 10px; z-index: 2; font-size: .66rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.badge-equipped { background: var(--primary); color: #fff; }
.badge-owned { background: var(--surface); color: var(--muted); border: 1px solid var(--border); }
.shop-card-stage { display: flex; align-items: center; justify-content: center; padding: 28px 16px; background: repeating-linear-gradient(45deg, var(--surface-2) 0 10px, var(--surface) 10px 20px); }
.stage-title, .stage-namefx { background: linear-gradient(135deg,#1a1a2e,#242447); }
.frame-preview-lg { width: 92px; height: 92px; }
.nameplate-mock { display: inline-flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; background: rgba(255,255,255,.08); padding: 9px 16px; border-radius: 18px; max-width: 100%; }
.nameplate-mock .avatar-sm { width: 30px; height: 30px; }
.stage-title .display-name, .stage-namefx .display-name { color: #f1f5f9; }
.stage-namefx .name-fx-preview { font-size: 1.2rem; }
.shop-card-body { padding: 12px 16px 0; text-align: left; flex: 1; }
.shop-card-name { font-weight: 800; }
.shop-card-desc { min-height: 32px; margin-top: 2px; }
.shop-card-footer { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 10px; padding: 12px 16px 16px; }
.shop-card-price { display: inline-flex; align-items: center; gap: 4px; font-weight: 800; color: var(--gold); background: var(--gold-tint); padding: 5px 10px; border-radius: 999px; font-size: .84rem; white-space: nowrap; }
.shop-card-price.cannot-afford { color: var(--muted); background: var(--surface-2); }
.shop-card-footer .btn-sm { flex: 1 1 auto; min-width: 120px; text-align: center; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════════════════════ */
@media (max-width: 800px) {
  .brand-text { display: none; }
  .icon-nav { display: none; }
  .icon-btn-cta.desktop-only { display: none; }
  .bottom-nav { display: flex; }
  body.has-bottom-nav { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
  .messages-wrap { grid-template-columns: 1fr; }
  .admin-stats { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .admin-menu { flex-direction: column; }
  .post-row { flex-wrap: wrap; }
  .user-menu-panel { right: -8px; width: 220px; }
  .page-wrap, .narrow-wrap { padding-left: 14px; padding-right: 14px; }
  .profile-header { flex-wrap: wrap; }
  .profile-actions { flex-direction: row; flex-wrap: wrap; width: 100%; padding-top: 12px; }
  .profile-actions .btn-primary, .profile-actions .btn-ghost { flex: 1; text-align: center; }
  .user-admin-row { padding: 12px; }
  /* Ẩn theme-toggle label trên mobile, giữ button */
  .theme-toggle-label { display: none; }
}
@media (max-width: 720px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block; }
  .inventory-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .shop-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
  .shop-hero { padding: 18px; }
  .shop-wallet { align-items: stretch; text-align: left; width: 100%; }
  .shop-wallet-amount { font-size: 1.5rem; }
}

/* ── Overflow safety ── */
html { overflow-x: hidden; }
img { max-width: 100%; }
.post-row-title, .conv-item-name, .brand { min-width: 0; }
.thread-msg { max-width: 82%; }

/* ── Minigame "Ai là triệu phú" cùng Maid ── */
.quiz-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.quiz-side { display: flex; flex-direction: column; gap: 16px; }
@media (max-width: 800px) { .quiz-layout { grid-template-columns: 1fr; } }

/* ── Sân khấu: Maid làm MC đứng đối diện người chơi, "nói" qua khung hội thoại bên cạnh ── */
.quiz-stage { display: flex; align-items: flex-start; gap: 22px; padding: 20px; }
@media (max-width: 720px) { .quiz-stage { flex-direction: column; align-items: center; padding: 16px; gap: 14px; } }

.quiz-host { display: flex; flex-direction: column; align-items: center; gap: 8px; flex-shrink: 0; width: 190px; }
@media (max-width: 720px) { .quiz-host { width: 100%; flex-direction: row; align-self: flex-start; gap: 12px; } }
@media (max-width: 720px) { .quiz-host-tag { align-items: flex-start; text-align: left; } }

.quiz-host-frame {
  position: relative; width: 100%; aspect-ratio: 563 / 592; border-radius: 22px; overflow: hidden;
  background: linear-gradient(160deg, var(--primary-tint), var(--surface-2));
  border: 3px solid var(--primary);
  box-shadow: 0 0 0 4px var(--primary-tint), 0 10px 28px -10px rgba(124,58,237,0.55);
  animation: quizHostFloat 4.2s ease-in-out infinite;
  transition: border-color .25s, box-shadow .25s;
}
@media (max-width: 720px) { .quiz-host-frame { width: 148px; flex-shrink: 0; animation: none; } }
.quiz-host-img { width: 100%; height: 100%; object-fit: cover; object-position: center 18%; display: block; }

@keyframes quizHostFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

.quiz-host-live {
  position: absolute; top: 8px; left: 8px; display: flex; align-items: center; gap: 4px;
  background: rgba(0,0,0,0.55); color: #fff; font-size: 0.62rem; font-weight: 800; letter-spacing: 0.02em;
  padding: 3px 7px; border-radius: 999px; backdrop-filter: blur(2px);
}

.quiz-host-mood {
  position: absolute; bottom: -6px; right: -6px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; box-shadow: var(--shadow); opacity: 0; transform: scale(0.6); transition: opacity .2s, transform .2s;
}
.quiz-host-frame.mood-thinking .quiz-host-mood::before { content: '💭'; }
.quiz-host-frame.mood-correct .quiz-host-mood::before { content: '✅'; }
.quiz-host-frame.mood-wrong .quiz-host-mood::before { content: '❌'; }
.quiz-host-frame.mood-win .quiz-host-mood::before { content: '🏆'; }
.quiz-host-frame.mood-lost .quiz-host-mood::before { content: '💥'; }
.quiz-host-frame.mood-cashed .quiz-host-mood::before { content: '🤝'; }
.quiz-host-frame.mood-thinking .quiz-host-mood,
.quiz-host-frame.mood-correct .quiz-host-mood,
.quiz-host-frame.mood-wrong .quiz-host-mood,
.quiz-host-frame.mood-win .quiz-host-mood,
.quiz-host-frame.mood-lost .quiz-host-mood,
.quiz-host-frame.mood-cashed .quiz-host-mood { opacity: 1; transform: scale(1); }

.quiz-host-frame.mood-asking { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-tint), 0 10px 28px -10px rgba(124,58,237,0.6); }
.quiz-host-frame.mood-thinking { animation: quizHostFloat 4.2s ease-in-out infinite, quizHostPulse 1.1s ease-in-out infinite; border-color: var(--muted); }
.quiz-host-frame.mood-correct { border-color: var(--success); box-shadow: 0 0 0 5px var(--success-tint), 0 10px 30px -10px rgba(16,185,129,0.6); animation: quizHostPop .5s ease; }
.quiz-host-frame.mood-wrong { border-color: var(--coral); box-shadow: 0 0 0 5px var(--coral-tint), 0 10px 30px -10px rgba(250,82,82,0.6); animation: quizHostShake .45s ease; }
.quiz-host-frame.mood-win { border-color: var(--gold); box-shadow: 0 0 0 6px var(--gold-tint), 0 12px 32px -10px rgba(245,165,36,0.65); animation: quizHostPulse 1.4s ease-in-out infinite; }
.quiz-host-frame.mood-lost { border-color: var(--border); filter: saturate(0.75); }
.quiz-host-frame.mood-cashed { border-color: var(--success); box-shadow: 0 0 0 5px var(--success-tint), 0 10px 28px -10px rgba(16,185,129,0.5); }

@keyframes quizHostPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.035); } }
@keyframes quizHostPop { 0% { transform: scale(1); } 40% { transform: scale(1.07); } 100% { transform: scale(1); } }
@keyframes quizHostShake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }

.quiz-host-tag { display: flex; flex-direction: column; align-items: center; text-align: center; }
.quiz-host-name { font-weight: 800; color: var(--text); font-size: 0.95rem; }
.quiz-host-role { font-size: 0.72rem; color: var(--muted); }

/* ── Khung hội thoại: nơi "Maid" đặt câu hỏi, có mũi tên bong bóng chỉ về phía cô ── */
.quiz-dialog-wrap { flex: 1; min-width: 0; position: relative; }
.quiz-dialog {
  position: relative; min-height: 300px; display: flex; align-items: center; justify-content: center;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 22px; width: 100%;
}
.quiz-dialog::before {
  content: ''; position: absolute; width: 18px; height: 18px; background: var(--surface-2);
  border-left: 1px solid var(--border); border-bottom: 1px solid var(--border);
  top: 34px; left: -10px; transform: rotate(45deg); border-radius: 0 0 0 4px;
}
@media (max-width: 720px) {
  .quiz-dialog::before { top: -10px; left: 34px; transform: rotate(135deg); border-radius: 0 0 0 4px; }
}

.quiz-idle { text-align: center; padding: 20px 10px; max-width: 460px; }
.quiz-idle-icon { font-size: 2.6rem; margin-bottom: 6px; }
.quiz-idle h2 { margin: 4px 0; }
.quiz-idle .btn-primary { margin-top: 14px; }

.quiz-result-box { margin: 16px 0; padding: 14px; border-radius: var(--radius-md); background: var(--surface-2); border: 1px solid var(--border); }
.quiz-result-title { font-weight: 800; margin-bottom: 4px; }
.quiz-result-won .quiz-result-title { color: var(--gold); }
.quiz-result-lost .quiz-result-title { color: var(--coral); }
.quiz-result-cashed_out .quiz-result-title { color: var(--success); }
.quiz-result-detail { color: var(--muted); font-size: 0.9rem; }

.quiz-playing { width: 100%; }
.quiz-question-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.quiz-question-num { font-weight: 800; color: var(--primary); }
.quiz-timer { display: flex; align-items: center; gap: 8px; }
.quiz-timer-bar-wrap { width: 90px; height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.quiz-timer-bar { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-dim)); transition: width 1s linear; }
.quiz-timer-text { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 32px; text-align: right; }

.quiz-question-text { font-size: 1.15rem; font-weight: 700; margin-bottom: 16px; line-height: 1.5; }

.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
@media (max-width: 560px) { .quiz-options { grid-template-columns: 1fr; } }
.quiz-option {
  display: flex; align-items: center; gap: 10px; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px 14px; color: var(--text); font-weight: 600; cursor: pointer; transition: border-color .15s, transform .1s;
}
.quiz-option:hover:not(:disabled) { border-color: var(--primary); transform: translateY(-1px); }
.quiz-option.selected { border-color: var(--primary); background: var(--primary-tint); }
.quiz-option.correct { border-color: var(--success); background: var(--success-tint); color: var(--success); }
.quiz-option.wrong { border-color: var(--coral); background: var(--coral-tint); color: var(--coral); }
.quiz-option:disabled { cursor: default; opacity: 0.85; }
.quiz-option-letter {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 28px; height: 28px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border);
  font-weight: 800; font-size: 0.85rem;
}

.quiz-actions { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

.quiz-ladder-panel h3, .quiz-leaderboard-panel h3 { margin-top: 0; margin-bottom: 10px; }
.quiz-ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; max-height: 460px; overflow-y: auto; }
.quiz-ladder-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--radius-sm);
  font-size: 0.85rem; color: var(--muted); font-weight: 600;
}
.quiz-ladder-item.passed { color: var(--text); }
.quiz-ladder-item.checkpoint { font-weight: 800; }
.quiz-ladder-item.current { background: var(--primary-tint); color: var(--primary); }
.quiz-ladder-level { width: 22px; text-align: center; flex-shrink: 0; }
.quiz-ladder-amount { flex: 1; }
.quiz-ladder-flag { flex-shrink: 0; }

.quiz-leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.quiz-leaderboard-row { display: flex; align-items: center; gap: 8px; }
.quiz-lb-rank { font-weight: 800; color: var(--muted); width: 26px; flex-shrink: 0; }
.quiz-lb-name { font-weight: 700; flex-shrink: 0; }
.quiz-lb-stat { flex: 1; }
.quiz-lb-total { font-weight: 800; color: var(--gold); flex-shrink: 0; }

/* ================= Cấu hình lưu trữ ảnh ================= */
.storage-option { display: flex; align-items: flex-start; gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-md); cursor: pointer; background: var(--surface-2); }
.storage-option input[type=radio] { margin-top: 4px; width: 18px; height: 18px; flex-shrink: 0; }
.storage-option:has(input:checked) { border-color: var(--primary); background: var(--primary-tint); }

.storage-block-head { margin-bottom: 14px; }
.storage-block-head h2 { margin: 0 0 4px; font-size: 1.05rem; }
.storage-block-head p { margin: 0; }
.storage-form { display: flex; flex-direction: column; gap: 16px; }
.storage-provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.storage-provider-panel { display: none; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2); padding: 16px; }
.storage-provider-panel.active { display: block; }
.storage-panel-head { font-weight: 700; font-size: 0.9rem; margin-bottom: 12px; display: flex; align-items: center; gap: 6px; }
.storage-panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 4px; }
.storage-panel-grid label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); font-weight: 700; }
.storage-optional { font-weight: 400; color: var(--muted); font-size: 0.78rem; }
.storage-test-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--border);
}
.storage-test-row input[type=file] { flex: 1 1 200px; min-width: 160px; font-size: 0.82rem; }
.storage-test-hint { flex-basis: 100%; }
.storage-test-result { margin-top: 12px; }
.storage-common-panel { border-top: 1px solid var(--border); padding-top: 16px; }
.storage-ext-custom { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); font-weight: 700; margin-top: 4px; }
.storage-save-btn { align-self: flex-start; }
.storage-notes { margin: 8px 0 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }

/* ================= Cấu hình Maid — đa nhà cung cấp AI ================= */
.aiadm { display: flex; flex-direction: column; gap: 18px; }

.aiadm-hero {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  background: linear-gradient(135deg, var(--primary-tint), var(--surface));
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow);
}
.aiadm-hero-avatar-wrap { position: relative; flex-shrink: 0; }
.aiadm-hero-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.aiadm-hero-status { position: absolute; bottom: 0; right: 0; width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--surface); background: #9CA3AF; }
.aiadm-hero-status.on { background: #22C55E; }
.aiadm-hero-body { flex: 1 1 240px; min-width: 200px; }
.aiadm-hero-name { font-size: 1.2rem; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aiadm-hero-sub { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.aiadm-hero-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

/* Tabs */
.aiadm-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 2px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.aiadm-tabs::-webkit-scrollbar { display: none; }
.aiadm-tab-btn {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border: none; background: none; cursor: pointer;
  font-family: var(--font); font-weight: 700; font-size: 0.88rem; color: var(--muted);
  border-radius: var(--radius-sm) var(--radius-sm) 0 0; border-bottom: 3px solid transparent;
  margin-bottom: -1px; white-space: nowrap;
}
.aiadm-tab-btn:hover { color: var(--text); background: var(--surface-2); }
.aiadm-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.aiadm-panel { display: none; flex-direction: column; gap: 14px; }
.aiadm-panel.active { display: flex; }

/* Toggle switch hiện đại thay cho checkbox thường */
.aiadm-toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface-2);
}
.aiadm-toggle-row + .aiadm-toggle-row { margin-top: 8px; }
.aiadm-toggle-text { min-width: 0; }
.aiadm-toggle-title { font-weight: 700; font-size: 0.9rem; }
.aiadm-toggle-desc { color: var(--muted); font-size: 0.78rem; margin-top: 2px; line-height: 1.4; }
.aiadm-switch { position: relative; flex-shrink: 0; width: 44px; height: 26px; display: inline-block; }
.aiadm-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.aiadm-switch-track {
  position: absolute; inset: 0; background: #CBD5E1; border-radius: 999px; cursor: pointer; transition: background .18s;
}
.aiadm-switch-track::before {
  content: ""; position: absolute; width: 20px; height: 20px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .18s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.aiadm-switch input:checked + .aiadm-switch-track { background: var(--primary); }
.aiadm-switch input:checked + .aiadm-switch-track::before { transform: translateX(18px); }
.aiadm-switch input:focus-visible + .aiadm-switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
[data-theme="dark"] .aiadm-switch-track { background: #475569; }

/* Nhà cung cấp AI */
.aiadm-provider-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.aiadm-provider-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
  padding: 16px; display: flex; flex-direction: column; gap: 10px; position: relative;
}
.aiadm-provider-card.is-chat { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }
.aiadm-provider-card.is-image { border-color: #F59E0B; box-shadow: 0 0 0 1px #F59E0B inset; }
.aiadm-provider-card.is-chat.is-image { box-shadow: 0 0 0 1px var(--primary) inset, 0 0 0 3px rgba(245,158,11,.25) inset; }
.aiadm-provider-name { font-weight: 800; font-size: 1rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.aiadm-provider-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.aiadm-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.68rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; }
.aiadm-badge-chat { background: var(--primary-tint); color: var(--primary); }
.aiadm-badge-image { background: #FEF3C7; color: #92400E; }
.aiadm-badge-active { background: #DCFCE7; color: #15803D; }
.aiadm-badge-none { background: var(--surface-2); color: var(--muted); }
.aiadm-provider-meta { font-size: 0.78rem; color: var(--muted); display: flex; flex-direction: column; gap: 3px; word-break: break-all; }
.aiadm-provider-meta code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px; font-size: 0.75rem; }
.aiadm-provider-notes { font-size: 0.8rem; color: var(--muted); font-style: italic; }
.aiadm-provider-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; padding-top: 8px; border-top: 1px dashed var(--border); }
.aiadm-provider-test-result { font-size: 0.78rem; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); white-space: pre-line; }

.aiadm-add-provider { border: 2px dashed var(--border); border-radius: var(--radius-lg); }
.aiadm-add-provider > summary {
  list-style: none; cursor: pointer; padding: 16px; display: flex; align-items: center; gap: 10px;
  font-weight: 700; color: var(--primary); user-select: none;
}
.aiadm-add-provider > summary::-webkit-details-marker { display: none; }
.aiadm-add-provider[open] > summary { border-bottom: 1px solid var(--border); }
.aiadm-provider-form { padding: 16px; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.aiadm-provider-form label { display: flex; flex-direction: column; gap: 5px; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.aiadm-provider-form .aiadm-full { grid-column: 1 / -1; }
.aiadm-provider-form-actions { grid-column: 1 / -1; display: flex; gap: 10px; }

.aiadm-assign-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.aiadm-assign-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; background: var(--surface-2); display: flex; flex-direction: column; gap: 8px; }
.aiadm-assign-card-title { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.aiadm-assign-card select { width: 100%; }
.aiadm-assign-hint { font-size: 0.78rem; color: var(--muted); }
.aiadm-assign-warn { font-size: 0.78rem; color: var(--coral); font-weight: 700; }

.aiadm-empty { text-align: center; padding: 30px 16px; color: var(--muted); }

/* ════════════════════════════════════
   Pi Network Login Button & Divider
   ════════════════════════════════════ */
.btn-pi-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #7B3FE4, #A67CF7);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .18s, transform .18s;
    box-shadow: 0 4px 16px rgba(123, 63, 228, .35);
}
.btn-pi-login:hover:not(:disabled) { opacity: .9; transform: translateY(-1px); }
.btn-pi-login:disabled { opacity: .65; cursor: wait; }

.pi-logo-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,.25);
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
    color: var(--muted);
    font-size: 13px;
}
.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

.pi-login-msg {
    padding: 9px 13px;
    border-radius: 8px;
    font-size: 13.5px;
    margin-bottom: 10px;
    line-height: 1.5;
}
.pi-login-msg--info    { background: var(--bg-card, #f3f4f6); color: var(--muted); }
.pi-login-msg--success { background: rgba(74,222,128,.12); color: #16a34a; }
.pi-login-msg--warn    { background: rgba(251,191,36,.12);  color: #d97706; }
.pi-login-msg--error   { background: rgba(248,113,113,.12); color: #dc2626; }
