/* Bộ sưu tập AI — Google Drive style (cây thư mục + lưới thumbnail). Dùng var(--cm-*). */
.aig { position: relative; display: flex; flex-direction: column; min-height: 70vh; }
.aig [v-cloak], .aig[v-cloak] { display: none; }

/* Thanh trên */
.aig-top { display: flex; align-items: center; justify-content: space-between; gap: var(--cm-space-md);
  flex-wrap: wrap; padding: var(--cm-space-sm) 0 var(--cm-space-md); border-bottom: 1px solid var(--cm-border); margin-bottom: var(--cm-space-md); }
.aig-top-left { display: flex; align-items: center; gap: var(--cm-space-sm); min-width: 0; }
.aig-top-ic { color: #a855f7; font-size: var(--cm-font-xl); }
.aig-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 2px; min-width: 0; }
.aig-crumb-wrap { display: inline-flex; align-items: center; gap: 2px; }
.aig-crumb { background: none; border: none; cursor: pointer; color: var(--cm-text-secondary);
  font-size: var(--cm-font-md); font-weight: 600; padding: 4px 8px; border-radius: var(--cm-radius-sm); }
.aig-crumb:hover { background: var(--cm-bg-card); color: var(--cm-text-primary); }
.aig-crumb.active { color: var(--cm-text-primary); }
.aig-crumb-sep { color: var(--cm-text-dim); font-size: 10px; }
.aig-top-right { display: flex; align-items: center; gap: var(--cm-space-sm); flex-wrap: wrap; }
.aig-kinds { display: inline-flex; background: var(--cm-bg-card); border: 1px solid var(--cm-border); border-radius: var(--cm-radius-full); padding: 3px; }
.aig-kind { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; cursor: pointer;
  color: var(--cm-text-secondary); font-size: var(--cm-font-sm); font-weight: 600; padding: 6px 12px; border-radius: var(--cm-radius-full); transition: var(--cm-transition-fast); }
.aig-kind:hover { color: var(--cm-text-primary); }
/* Tông TÍM studio (KHÔNG dùng --cm-gradient-primary xanh) — đồng bộ với Canvas/con trỏ/context menu. */
.aig-kind:hover:not(.active) { color: var(--ais-accent3, #c084fc); }
.aig-kind.active { background: linear-gradient(135deg, var(--ais-accent, #6366f1), var(--ais-accent2, #a855f7)); color: #fff;
  box-shadow: 0 2px 10px rgba(168, 85, 247, .3); }
.aig-kind.active i { color: #fff; }

/* Body: cây trái + lưới phải */
.aig-body { display: flex; gap: var(--cm-space-lg); align-items: flex-start; }
.aig-tree { flex: 0 0 260px; max-width: 260px; background: var(--cm-bg-card); border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-lg); padding: var(--cm-space-sm); position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow-y: auto; }
.aig-tnode { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--cm-text-secondary); font-size: var(--cm-font-sm); font-weight: 600; padding: 9px 10px; border-radius: var(--cm-radius-md); transition: var(--cm-transition-fast); }
.aig-tnode > i { width: 16px; text-align: center; color: var(--cm-text-dim); }
.aig-tnode:hover { background: var(--cm-bg-dark); color: var(--cm-text-primary); }
.aig-tnode.active { background: rgba(168, 85, 247, .16); color: #d8b4fe; }
.aig-tnode.active > i { color: #c084fc; }
.aig-tnode.dragover { outline: 2px dashed #a855f7; outline-offset: -2px; background: rgba(168, 85, 247, .1); }
.aig-tname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aig-tcount { font-size: 11px; color: var(--cm-text-dim); background: var(--cm-bg-dark); border-radius: var(--cm-radius-full); padding: 1px 7px; }
.aig-tnode.active .aig-tcount { background: rgba(0,0,0,.25); }
.aig-tnode-row { display: flex; align-items: center; position: relative; }
.aig-tnode-row .aig-tnode-child { flex: 1; }
.aig-texp { background: none; border: none; cursor: pointer; color: var(--cm-text-dim); width: 18px; height: 26px; font-size: 10px; padding: 0; flex: 0 0 18px; }
.aig-texp:hover { color: var(--cm-text-primary); }
.aig-texp-spacer { flex: 0 0 18px; }
.aig-tmenu { position: absolute; right: 4px; display: none; gap: 2px; }
.aig-tnode-row:hover .aig-tmenu { display: inline-flex; }

.aig-cx { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--cm-border); }
.aig-tnode-row .aig-tnode-cxroot { flex: 1; }
.aig-tnode-cxroot > i { color: var(--ais-accent3, #c084fc); }
.aig-cx-tong { padding: 0 10px 6px 52px; font-size: 10px; color: var(--cm-text-dim); }
.aig-ctx-chixem { display: flex; align-items: center; gap: 6px; color: var(--ais-accent3, #c084fc);
  text-transform: none; letter-spacing: 0; font-weight: 600; }
.aig-tnode-cx > i { color: var(--ais-accent3, #c084fc); }

.aig-cxbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: var(--cm-space-md);
  padding: 10px 14px; border-radius: var(--cm-radius-lg); border: 1px solid rgba(168, 85, 247, .3);
  background: rgba(168, 85, 247, .08); font-size: var(--cm-font-sm); }
.aig-cxbar > i { color: #c084fc; }
.aig-cxbar-ten { font-weight: 700; color: var(--cm-text-primary); }
.aig-cxbar-so { color: var(--cm-text-secondary); }
.aig-cxbar-note { color: var(--cm-text-dim); font-size: 12px; margin-left: auto; }
.aig-cxbar-mo { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; border: none;
  padding: 7px 14px; border-radius: var(--cm-radius-full); font-size: 12px; font-weight: 600; color: #fff;
  background: linear-gradient(135deg, var(--ais-accent, #6366f1), var(--ais-accent2, #a855f7));
  box-shadow: 0 2px 10px rgba(168, 85, 247, .3); transition: var(--cm-transition-fast); }
.aig-cxbar-mo:hover { filter: brightness(1.1); }
.aig-cx + .aig-cx { margin-top: 4px; padding-top: 6px; }
@media (max-width: 640px) { .aig-cxbar-note { margin-left: 0; width: 100%; } }
.aig-tmenu button { background: var(--cm-bg-dark); border: 1px solid var(--cm-border); cursor: pointer; color: var(--cm-text-secondary);
  width: 24px; height: 24px; border-radius: var(--cm-radius-sm); font-size: 11px; }
.aig-tmenu button:hover { color: var(--cm-text-primary); border-color: var(--cm-border-strong); }

/* Lưới media — vùng "canvas" của Bộ sưu tập: con trỏ studio + right-click phủ CẢ khoảng trống (không chỉ trên ảnh).
   min-height lớn để right-click/con trỏ vẫn tác dụng khi bấm xa/dưới các thẻ. cursor kế thừa xuống mọi con. */
/* VÙNG LÀM VIỆC — khung nhìn thấy được, nền chấm như canvas studio (user chốt 2026-08-04).
   Trước đây vùng này VÔ HÌNH: khách không biết phải đè chuột từ đâu mới bao khối được, đè hụt ra
   ngoài thì không có gì xảy ra và cũng không có gì gợi ý. Nay khung nói rõ "trong đây là chỗ thao tác".
   Chấm mờ hơn canvas (.055 vs .10) vì còn phải đỡ thẻ ảnh nằm lên trên. */
.aig-grid-wrap {
  position: relative; flex: 1; min-width: 0; min-height: 62vh;
  cursor: var(--ais-grab, default);
  padding: var(--cm-space-md);
  border: 1px solid var(--cm-border);
  border-radius: var(--cm-radius-lg);
  background-color: rgba(10, 10, 12, .45);
  background-image: radial-gradient(circle, rgba(255, 255, 255, .055) 1px, transparent 1.3px);
  background-size: 22px 22px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.aig-grid-wrap:hover { border-color: rgba(99, 102, 241, .34); }
html.sbk-dang-keo .aig-grid-wrap { border-color: rgba(99, 102, 241, .6); box-shadow: inset 0 0 0 1px rgba(99, 102, 241, .22); }
/* Mách nước góc dưới — tự mờ đi khi khách đã biết dùng (đang bao khối / đã chọn được ảnh). */
.aig-hint {
  position: absolute; right: 12px; bottom: 10px; z-index: 4; pointer-events: none;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--cm-text-muted);
  background: rgba(10, 10, 12, .72); border: 1px solid var(--cm-border);
  border-radius: 999px; padding: 4px 10px; opacity: .85; transition: opacity .18s ease;
}
.aig-hint i { color: var(--ais-accent3, #c084fc); }
html.sbk-dang-keo .aig-hint { opacity: 0; }
/* Kéo TỆP TỪ MÁY vào — báo hiệu y hệt canvas (.aist-drop-hint): viền đứt + nền indigo + mũi tên lên.
   Nhãn "+ Copy" cạnh con trỏ là của HỆ ĐIỀU HÀNH, web không ẩn được → phải nói bằng lớp phủ trong trang. */
.aig-drop-hint {
  position: absolute; inset: 10px; z-index: 12; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  border: 2px dashed var(--ais-accent, #6366f1); border-radius: var(--cm-radius-lg);
  background: rgba(99, 102, 241, .12); backdrop-filter: blur(2px);
  color: #c7d2fe; font-weight: 700; font-size: var(--cm-font-lg); text-align: center; padding: 0 16px;
}
.aig-drop-hint .fa-arrow-up-from-bracket { font-size: 34px; }
.aig-drop-hint em { font-style: normal; font-weight: 500; font-size: var(--cm-font-xs); color: var(--cm-text-muted); }
.aig.dropfile .aig-grid-wrap { border-color: var(--ais-accent, #6366f1); }
.aig.dropfile .aig-card { opacity: .45; }                 /* lùi thẻ cũ xuống để lớp phủ nổi lên */
.aig.dropfile .aig-tnode.dragover { background: rgba(99, 102, 241, .22); }
.aig-loading { display: flex; align-items: center; gap: 10px; color: var(--cm-text-secondary); padding: var(--cm-space-xl); }
.aig-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--cm-space-md); }
.aig-card { position: relative; background: var(--cm-bg-card); border: 2px solid var(--cm-border); border-radius: var(--cm-radius-md);
  overflow: hidden; cursor: var(--ais-grab, grab); transition: var(--cm-transition-fast); }
.aig-card:active { cursor: var(--ais-grabbing, grabbing); }
.aig-card:hover { border-color: var(--cm-border-strong); transform: translateY(-2px); box-shadow: var(--cm-shadow-hover); }
.aig-card.sel { border-color: #a855f7; box-shadow: 0 0 0 2px rgba(168, 85, 247, .3); }
.aig-thumb { position: relative; aspect-ratio: 1 / 1; background: var(--cm-bg-dark); display: flex; align-items: center; justify-content: center; }
.aig-thumb img, .aig-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.aig-sortbox { display: inline-flex; }
.aig-sort { min-width: 132px; }
.aig-more { display: flex; align-items: center; justify-content: center; gap: var(--cm-space-md); padding: var(--cm-space-lg) 0 var(--cm-space-md); }
.aig-more-count { font-size: 12px; color: var(--cm-text-dim); }
.aig-thumb-icon { color: var(--cm-text-dim); font-size: 40px; }
.aig-thumb-icon-nen { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; z-index: 0; }
.aig-thumb video { position: relative; z-index: 1; background: transparent; }
.aig-thumb video::-webkit-media-controls-overlay-play-button { opacity: .92; }
.aig-lon {
    position: absolute; right: 6px; top: 6px; z-index: 4;
    width: 28px; height: 28px; border: none; border-radius: 8px;
    background: rgba(2, 6, 23, .72); color: #e5e7eb;
    font-size: 13px; cursor: pointer; opacity: 0;
    display: flex; align-items: center; justify-content: center;
    transition: opacity .15s, background .15s;
}
.aig-card:hover .aig-lon, .aig-lon:focus-visible { opacity: 1; }
.aig-lon:hover { background: rgba(2, 6, 23, .92); }
@media (hover: none) { .aig-lon { opacity: 1; } }
.aig-kind-badge { position: absolute; bottom: 6px; right: 6px; background: rgba(0,0,0,.6); color: #fff; border-radius: var(--cm-radius-sm); padding: 3px 7px; font-size: 11px; }
.aig-role-badge { position: absolute; bottom: 6px; left: 6px; background: rgba(245, 158, 11, .85); color: #1a1200; border-radius: var(--cm-radius-sm); padding: 1px 6px; font-size: 10px; font-weight: 700; }
/* Đếm lùi tới lúc XOÁ (ảnh free 30 ngày / premium đang grace). Vàng thường, ĐỎ khi ≤3 ngày. Ẩn cho premium còn gói (vĩnh viễn). */
.aig-del-badge { position: absolute; top: 6px; right: 6px; z-index: 2; display: inline-flex; align-items: center; gap: 3px;
  background: rgba(245, 158, 11, .92); color: #1a1200; border-radius: var(--cm-radius-sm); padding: 2px 6px; font-size: 10px; font-weight: 700;
  box-shadow: 0 1px 4px rgba(0,0,0,.35); pointer-events: auto; }
.aig-del-badge i { font-size: 9px; }
.aig-del-badge.urgent { background: rgba(239, 68, 68, .95); color: #fff; animation: aig-del-pulse 1.6s ease-in-out infinite; }
@keyframes aig-del-pulse { 0%,100% { box-shadow: 0 1px 4px rgba(0,0,0,.35); } 50% { box-shadow: 0 0 0 3px rgba(239,68,68,.35); } }
.aig-check { position: absolute; top: 6px; left: 6px; z-index: 2; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,.85); font-size: 20px; opacity: 0; transition: var(--cm-transition-fast); text-shadow: 0 1px 3px rgba(0,0,0,.6); }
.aig-card:hover .aig-check, .aig-card.sel .aig-check { opacity: 1; }
.aig-card.sel .aig-check { color: #c084fc; }
.aig-meta { padding: 7px 9px; }
.aig-meta-name { font-size: 12px; font-weight: 600; color: var(--cm-text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aig-meta-row { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.aig-meta-model { font-size: 11px; color: var(--cm-text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.aig-meta-sz { font-size: 10px; color: var(--cm-text-dim); flex: none; }
.aig-meta-mid {
  flex: none; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px; font-weight: 700; color: var(--cm-text-muted); user-select: all;
}
.aig-them { display: none; }
.aig-hint-cham { display: none; }
@media (hover: none) and (pointer: coarse) {
  .aig-meta { position: relative; padding-right: 46px; }
  .aig-them {
    display: flex; position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
    width: 36px; height: 36px; border: 1px solid var(--cm-border); border-radius: 10px;
    background: var(--cm-bg-dark); color: var(--cm-text-primary); font-size: 15px;
    align-items: center; justify-content: center; cursor: pointer; padding: 0;
  }
  .aig-them:active { background: rgba(99, 102, 241, .22); border-color: var(--ais-accent, #6366f1); }
  .aig-them-hang { position: static; transform: none; flex: none; margin-left: auto; }
  .aig-check { opacity: .85; }
  .aig-hint-chuot { display: none; }
  .aig-hint-cham { display: inline; }
}

/* Ô tìm trên thanh công cụ */
/* co giãn được để thanh công cụ không xuống dòng ở màn hình vừa (~1280px) */
.aig-searchbox { position: relative; display: inline-flex; align-items: center; flex: 1 1 150px; min-width: 120px; max-width: 240px; }
.aig-searchbox > .fa-magnifying-glass { position: absolute; left: 10px; font-size: 11px; color: var(--cm-text-dim); pointer-events: none; }
.aig-searchbox input { width: 100%; padding: 8px 28px; border-radius: 9px; font-size: var(--cm-font-sm);
  background: var(--cm-bg-dark); border: 1px solid var(--cm-border); color: var(--cm-text-primary); outline: 0; }
.aig-searchbox input:focus { border-color: var(--ais-accent, #6366f1); }
.aig-search-clear { position: absolute; right: 6px; background: 0; border: 0; color: var(--cm-text-muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.aig-search-clear:hover { color: #fff; }

/* THẺ CHỜ khi đang tải lên — viền neon xoáy (.aist-neon, studio-ui.css) + ảnh xem trước cục bộ + % thật */
.aig-card.aig-uploading { cursor: default; }
.aig-card.aig-uploading:hover { transform: none; box-shadow: none; border-color: var(--cm-border); }
.aig-card.aig-uploading.err { border-color: var(--cm-danger, #ef4444); }
.aig-uploading .aig-thumb img { opacity: .35; filter: saturate(.6); }
.aig-upl-veil { position: absolute; inset: 0; z-index: 3; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  background: rgba(10, 10, 12, .45); color: #e0e7ff; }
.aig-upl-veil > i { font-size: 20px; color: var(--ais-accent3, #c084fc); }
.aig-upl-pct { font-size: 13px; font-weight: 700; letter-spacing: .02em; }
.aig-upl-bar { width: 62%; height: 3px; border-radius: 999px; background: rgba(255, 255, 255, .16); overflow: hidden; }
.aig-upl-bar > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, #22d3ee, #a855f7); transition: width .18s ease; }

/* Thanh chọn nổi */
.aig-selbar { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40;
  display: flex; align-items: center; gap: var(--cm-space-sm); background: var(--cm-bg-card); border: 1px solid var(--cm-border-strong);
  border-radius: var(--cm-radius-full); padding: 8px 14px; box-shadow: var(--cm-shadow-card); }
.aig-selbar-n { font-weight: 700; color: var(--cm-text-primary); font-size: var(--cm-font-sm); padding-right: 4px; }
.aig-move-wrap { position: relative; }
.aig-move-menu { position: absolute; bottom: calc(100% + 8px); left: 0; min-width: 220px; max-height: 320px; overflow-y: auto;
  background: var(--cm-bg-card); border: 1px solid var(--cm-border-strong); border-radius: var(--cm-radius-md); padding: 6px; box-shadow: var(--cm-shadow-card); }
.aig-move-item { display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  color: var(--cm-text-secondary); font-size: var(--cm-font-sm); padding: 8px 10px; border-radius: var(--cm-radius-sm); }
.aig-move-item:hover { background: var(--cm-bg-dark); color: var(--cm-text-primary); }
.aig-move-item > i { color: var(--cm-text-dim); }

/* Lightbox */
.aig-lb { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.82); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; }
.aig-lb-close { position: absolute; top: 18px; right: 22px; background: rgba(255,255,255,.1); border: none; color: #fff; width: 40px; height: 40px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.aig-lb-close:hover { background: rgba(255,255,255,.2); }
.aig-lb-inner { max-width: 90vw; max-height: 74vh; display: flex; align-items: center; justify-content: center; }
.aig-lb-inner img, .aig-lb-inner video { max-width: 90vw; max-height: 74vh; border-radius: var(--cm-radius-md); box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.aig-lb-inner { position: relative; min-width: 220px; min-height: 160px; }
.aig-lb-inner img { transition: filter .28s ease-out; }
.aig-lb-inner img.mo { filter: blur(14px) saturate(1.05); }
.aig-lb-quay {
    position: absolute; inset: 0; z-index: 2;
    display: flex; align-items: center; justify-content: center;
    color: rgba(255, 255, 255, .82); font-size: 26px; pointer-events: none;
    text-shadow: 0 2px 10px rgba(0, 0, 0, .6);
}
.aig-lb-trong {
    width: min(70vw, 520px); height: min(52vh, 380px);
    border-radius: var(--cm-radius-md);
    background: rgba(255, 255, 255, .05);
}
.aig-lb-icon { color: rgba(255,255,255,.4); font-size: 80px; }
.aig-lb-info { margin-top: 16px; max-width: 720px; text-align: center; color: var(--cm-text-secondary); }
.aig-lb-model { font-size: var(--cm-font-sm); color: #d8b4fe; margin-bottom: 6px; }
.aig-lb-prompt { font-size: var(--cm-font-sm); line-height: 1.5; max-height: 6em; overflow-y: auto; }
.aig-lb-actions { margin-top: 14px; display: flex; gap: var(--cm-space-sm); justify-content: center; }

/* Transitions */
.aig-bar-fade-enter-active, .aig-bar-fade-leave-active { transition: opacity .2s, transform .2s; }
.aig-bar-fade-enter-from, .aig-bar-fade-leave-to { opacity: 0; transform: translate(-50%, 12px); }
.aig-menu-fade-enter-active, .aig-menu-fade-leave-active { transition: opacity .15s, transform .15s; }
.aig-menu-fade-enter-from, .aig-menu-fade-leave-to { opacity: 0; transform: translateY(6px); }
.aig-lb-fade-enter-active, .aig-lb-fade-leave-active { transition: opacity .2s; }
.aig-lb-fade-enter-from, .aig-lb-fade-leave-to { opacity: 0; }

/* ===== THU GỌN CÂY THƯ MỤC — CHỈ PC (≥901px) =========================================
   Cùng cơ chế nút ẩn/hiện của sidebar AI (xem docs/frontend-css-reference.md mục "Ngăn kéo
   sidebar" → phần THU GỌN trên PC), khác đúng MỘT con số: mốc gãy ở trang này là **900px**
   (`.aig-tree` xếp chồng từ ≤900px) chứ không phải 1024px như sidebar. Khoá vào min-width:901px
   để ở điện thoại cây vẫn là dải ngang bình thường dù lớp .aig-tree-off còn trên .aig-body.

   Nút lúc thu vẫn NẰM TRONG DÒNG CHẢY (rail 38px), KHÔNG position:fixed — fixed sẽ đè lên lưới
   ảnh ở cửa sổ hẹp. Cây giữ nguyên `position: sticky` nên nút tự bám theo lúc khách cuộn.
   Trạng thái do Vue giữ (`treeOff`, nhớ ở localStorage) — được phép, vì #aigallery có v-cloak
   nên trang chưa vẽ gì trước lúc Vue mount, không có cảnh cây hiện đủ rồi mới thụt lại. */
.aig-tree-tools { display: none; }

@media (min-width: 901px) {
  .aig-tree-tools { display: flex; justify-content: flex-end; padding: 0 2px 4px; }
  .aig-tree-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 26px; height: 26px; padding: 0; cursor: pointer;
    border: 1px solid var(--cm-border); border-radius: 8px;
    background: rgba(255, 255, 255, .03); color: var(--cm-text-muted);
    font-size: 11px; line-height: 1;
    transition: background .18s, border-color .18s, color .18s;
  }
  /* MỘT glyph quay 180° cho cả hai chiều: subset FontAwesome KHÔNG có `fa-chevron-left`. */
  .aig-tree-toggle i { transition: transform .22s ease; transform: rotate(180deg); }
  .aig-tree { transition: flex-basis .22s ease, max-width .22s ease, background .22s ease, border-color .22s ease; }

  .aig-body.aig-tree-off { gap: 10px; }
  .aig-body.aig-tree-off .aig-tree {
    flex: 0 0 38px; max-width: 38px; padding: 0;
    background: none; border-color: transparent; overflow: visible;
  }
  .aig-body.aig-tree-off .aig-tree > :not(.aig-tree-tools) { display: none; }
  .aig-body.aig-tree-off .aig-tree-tools { padding: 0; justify-content: center; }
  .aig-body.aig-tree-off .aig-tree-toggle {
    width: 34px; height: 54px; font-size: 13px; border-radius: 10px;
    color: var(--cm-text-primary);
    background: linear-gradient(135deg, rgba(99, 102, 241, .28) 0%, rgba(168, 85, 247, .2) 100%);
    border-color: rgba(99, 102, 241, .45);
  }
  .aig-body.aig-tree-off .aig-tree-toggle i { transform: none; }
  /* ⚠ Hover phải LẶP LẠI cả tổ tiên .aig-tree-off: luật lúc-đã-thu ở trên là 0-3-0, mà
     `.aig-tree-toggle:hover` chỉ 0-2-0 nên để trơn là THUA — nút thu gọn rê vào không đổi màu,
     trông y như hỏng. (Bên sidebar không phải làm vậy vì hai bên đều 0-2-0, chỉ cần xếp sau.) */
  .aig-tree-toggle:hover,
  .aig-body.aig-tree-off .aig-tree-toggle:hover {
    background: rgba(99, 102, 241, .18); border-color: var(--ais-accent, #6366f1); color: var(--cm-text-primary);
  }
}

@media (prefers-reduced-motion: reduce) {
  .aig-tree, .aig-tree-toggle i { transition: none; }
}

/* Responsive */
@media (max-width: 900px) {
  .aig-body { flex-direction: column; }
  .aig-tree { flex: none; max-width: none; width: 100%; position: static; max-height: 240px; }
  .aig-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

.aig-xem {
    display: inline-flex;
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-full);
    overflow: hidden;
    background: rgba(255, 255, 255, .04);
}

.aig-xem button {
    border: 0;
    background: transparent;
    color: var(--cm-text-muted);
    padding: 7px 12px;
    font-size: var(--cm-font-sm);
    cursor: pointer;
    transition: background var(--cm-transition-fast), color var(--cm-transition-fast);
}

.aig-xem button:hover { color: var(--cm-text-primary); background: rgba(255, 255, 255, .06); }
.aig-xem button.aig-xem-on { background: var(--ais-accent, #6366f1); color: #fff; }

.aig-ds-wrap {
    overflow-x: auto;
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-lg);
    background: var(--cm-bg-card);
}

.aig-ds {
    width: 100%;
    min-width: 780px;
    border-collapse: collapse;
    font-size: var(--cm-font-sm);
}

.aig-ds thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    text-align: left;
    white-space: nowrap;
    padding: 10px 12px;
    background: var(--cm-bg-dark);
    color: var(--cm-text-muted);
    font-weight: 600;
    border-bottom: 1px solid var(--cm-border);
    user-select: none;
}

.aig-ds thead th.sapduoc { cursor: pointer; }
.aig-ds thead th.sapduoc:hover { color: var(--cm-text-primary); }
.aig-ds thead th.dangsap { color: var(--ais-accent, #6366f1); }
.aig-ds thead th i { margin-left: 5px; font-size: 10px; }
.aig-ds-mo { color: var(--cm-text-dim); opacity: .72; }

.aig-dsr { cursor: pointer; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.aig-dsr:hover { background: rgba(255, 255, 255, .045); }
.aig-dsr.sel { background: rgba(99, 102, 241, .16); }
.aig-dsr td { padding: 7px 12px; color: var(--cm-text-secondary); vertical-align: middle; }

.aig-ds-ck { width: 34px; text-align: center; color: var(--cm-text-dim); }
.aig-dsr.sel .aig-ds-ck { color: var(--ais-accent, #6366f1); }
.aig-ds-ck i { font-size: 14px; }

.aig-ds-bia { width: 52px; }

.aig-ds-bia img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: var(--cm-radius-sm);
    display: block;
    background: var(--cm-bg-dark);
}

.aig-ds-icon {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--cm-radius-sm);
    background: var(--cm-bg-dark);
    color: var(--cm-text-dim);
}

.aig-ds-ten { color: var(--cm-text-primary); max-width: 220px; }

.aig-ds-ten-hang { display: flex; align-items: center; gap: 6px; min-width: 0; }

.aig-ds-ref {
    margin-left: 6px;
    padding: 1px 6px;
    border-radius: var(--cm-radius-full);
    background: rgba(255, 255, 255, .08);
    color: var(--cm-text-muted);
    font-size: var(--cm-font-xs);
}

.aig-ds-loai, .aig-ds-noi { white-space: nowrap; }
.aig-ds-dl, .aig-ds-ngay, .aig-ds-ma { white-space: nowrap; font-variant-numeric: tabular-nums; }
.aig-ds-ma { color: var(--cm-text-dim); }
.aig-ds-han { white-space: nowrap; }

.aig-ds-han .aig-del-badge {
    position: static;
    top: auto;
    right: auto;
    box-shadow: none;
}
.aig-dsr-upl td { color: var(--cm-text-muted); }
.aig-ds-uplst { font-size: var(--cm-font-xs); }

@media (max-width: 1180px) {
    .aig-ds-noi { display: none; }
    .aig-ds { min-width: 680px; }
}

@media (max-width: 640px) {
    .aig-ds-ma, .aig-ds-loai { display: none; }
    .aig-ds { min-width: 520px; }
}
