/* ============================================================
   EcomCX AI Studio — Design System
   Nguồn CSS duy nhất của toàn bộ ứng dụng.
   ============================================================ */

/* ---------- 1. Tokens ---------- */
:root {
    color-scheme: dark;

    /* Bề mặt */
    --bg:          #09090B;
    --surface-1:   #101013;
    --surface-2:   #17171B;
    --surface-3:   #202027;

    /* Đường kẻ */
    --line:        rgba(255, 255, 255, .07);
    --line-strong: rgba(255, 255, 255, .13);

    /* Chữ */
    --text:        #FAFAFA;
    --text-2:      #A1A1AA;
    --text-3:      #71717A;

    /* Nhấn */
    --accent:      #0A84FF;
    --accent-hi:   #3D9BFF;
    --accent-soft: rgba(10, 132, 255, .15);
    --on-accent:   #FFFFFF;

    /* Trạng thái */
    --ok:          #30D158;
    --ok-soft:     rgba(48, 209, 88, .14);
    --warn:        #FFD60A;
    --warn-soft:   rgba(255, 214, 10, .14);
    --danger:      #FF453A;
    --danger-soft: rgba(255, 69, 58, .14);
    --info:        #64D2FF;
    --info-soft:   rgba(100, 210, 255, .14);

    /* Bo góc */
    --r-sm:   8px;
    --r-md:   12px;
    --r-lg:   16px;
    --r-full: 999px;

    /* Khoảng cách — thang 4px */
    --s-1:  4px;
    --s-2:  8px;
    --s-3:  12px;
    --s-4:  16px;
    --s-5:  24px;
    --s-6:  32px;
    --s-7:  48px;

    /* Thang chữ */
    --t-xs:  0.75rem;    /* 12 */
    --t-sm:  0.8125rem;  /* 13 */
    --t-md:  0.9375rem;  /* 15 */
    --t-lg:  1.0625rem;  /* 17 */
    --t-xl:  1.375rem;   /* 22 */
    --t-2xl: 1.75rem;    /* 28 */

    /* Bố cục */
    --sidebar-w:  256px;
    --rail-w:     68px;
    --topbar-h:   56px;
    --content-max: 1280px;

    /* Đổ bóng */
    --shadow-md: 0 4px 16px rgba(0, 0, 0, .4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .55);

    --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    font-size: var(--t-md);
    line-height: 1.55;
    letter-spacing: -0.011em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

/* Không có dòng này thì display:flex/grid của component sẽ ghi đè thuộc tính hidden */
[hidden] { display: none !important; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 1.3; }
p  { margin: 0; }
ul, ol { margin: 0; padding: 0; }
a  { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hi); }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }

:focus { outline: none; }
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: var(--r-sm);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--surface-3);
    border-radius: var(--r-full);
    border: 3px solid transparent;
    background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #33333d; background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- 3. Icon ---------- */
.icon {
    width: 20px;
    height: 20px;
    flex: none;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

/* ---------- 4. Vỏ ứng dụng ---------- */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100dvh;
}

.app-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.app-content {
    flex: 1;
    width: 100%;
    max-width: var(--content-max);
    margin-inline: auto;
    padding: var(--s-6) var(--s-6) var(--s-7);
    min-width: 0;
}

/* Trang toàn khung (Chat) — không giới hạn bề rộng, không padding dưới */
.app-content--full {
    max-width: none;
    padding: var(--s-5) var(--s-5);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ---------- 5. Sidebar ---------- */
.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--surface-1);
    border-right: 1px solid var(--line);
    z-index: 40;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    height: var(--topbar-h);
    padding-inline: var(--s-4);
    flex: none;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    color: var(--text);
    min-width: 0;
}
.brand:hover { color: var(--text); }

.brand-mark {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: var(--r-sm);
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: var(--t-md);
    letter-spacing: -0.03em;
}

.brand-name {
    font-weight: 600;
    font-size: var(--t-md);
    letter-spacing: -0.02em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: var(--s-3) var(--s-3) var(--s-4);
    display: flex;
    flex-direction: column;
    gap: var(--s-1);
}

.nav-section {
    padding: var(--s-4) var(--s-3) var(--s-2);
    font-size: var(--t-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-3);
}
.nav-section:first-child { padding-top: var(--s-2); }

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: var(--t-md);
    font-weight: 500;
    white-space: nowrap;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
.nav-item[aria-current="page"] .icon { color: var(--accent); }

.sidebar-foot {
    flex: none;
    border-top: 1px solid var(--line);
    padding: var(--s-3);
}

/* Menu tài khoản */
.user-btn {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    padding: var(--s-2) var(--s-3);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    cursor: pointer;
    text-align: left;
    transition: background .15s var(--ease);
}
.user-btn:hover { background: var(--surface-2); color: var(--text); }

.avatar {
    width: 28px;
    height: 28px;
    flex: none;
    border-radius: var(--r-full);
    background: var(--accent-soft);
    color: var(--accent-hi);
    display: grid;
    place-items: center;
    font-size: var(--t-sm);
    font-weight: 600;
    text-transform: uppercase;
}

.user-name {
    flex: 1;
    min-width: 0;
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- 6. Thanh trên (chỉ mobile) ---------- */
.topbar {
    display: none;
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--topbar-h);
    align-items: center;
    gap: var(--s-3);
    padding-inline: var(--s-3);
    background: color-mix(in srgb, var(--bg) 85%, transparent);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid var(--line);
}

.scrim {
    position: fixed;
    inset: 0;
    z-index: 39;
    background: rgba(0, 0, 0, .6);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s var(--ease), visibility .25s var(--ease);
}
.scrim[data-open="true"] { opacity: 1; visibility: visible; }

/* ---------- 7. Điểm ngắt bố cục ---------- */

/* Tablet: sidebar thu thành thanh icon */
@media (max-width: 1199px) {
    .app { grid-template-columns: var(--rail-w) minmax(0, 1fr); }
    .app-content { padding: var(--s-5) var(--s-5) var(--s-6); }

    .sidebar-head { justify-content: center; padding-inline: 0; }
    .brand-name,
    .nav-section,
    .user-name,
    .nav-item > span,          /* nhãn chữ của mục điều hướng */
    .user-btn > .icon { display: none; }

    .sidebar-nav { padding-inline: var(--s-2); align-items: center; }
    .nav-item {
        justify-content: center;
        padding: var(--s-3);
        width: 44px;
        position: relative;
    }
    .sidebar-foot { padding: var(--s-2); }
    .user-btn { justify-content: center; padding: var(--s-2); }

    /* Nhãn hiện khi rê chuột trên thanh icon */
    .nav-item::after {
        content: attr(data-label);
        position: absolute;
        left: calc(100% + 10px);
        top: 50%;
        transform: translateY(-50%);
        padding: 6px 10px;
        border-radius: var(--r-sm);
        background: var(--surface-3);
        border: 1px solid var(--line-strong);
        box-shadow: var(--shadow-md);
        font-size: var(--t-sm);
        font-weight: 500;
        color: var(--text);
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .15s var(--ease), visibility .15s var(--ease);
        z-index: 50;
    }
    .nav-item:hover::after { opacity: 1; visibility: visible; }
}

/* Mobile: sidebar thành ngăn kéo trượt */
@media (max-width: 767px) {
    .app { grid-template-columns: minmax(0, 1fr); }
    .topbar { display: flex; }

    .app-content { padding: var(--s-4) var(--s-4) var(--s-6); }
    .app-content--full { padding: 0; }

    .sidebar {
        position: fixed;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(280px, 84vw);
        transform: translateX(-100%);
        transition: transform .28s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .sidebar[data-open="true"] { transform: translateX(0); }

    /* Trong ngăn kéo luôn hiển thị dạng đầy đủ */
    .sidebar-head { justify-content: flex-start; padding-inline: var(--s-4); }
    .brand-name, .nav-section, .user-name { display: block; }
    .nav-item > span { display: inline; }
    .user-btn > .icon { display: block; }
    .sidebar-nav { padding-inline: var(--s-3); align-items: stretch; }
    .nav-item { justify-content: flex-start; width: auto; padding: var(--s-3); }
    .nav-item::after { content: none; }
    .sidebar-foot { padding: var(--s-3); }
    .user-btn { justify-content: flex-start; padding: var(--s-2) var(--s-3); }
}

/* ---------- 8. Đầu trang ---------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--s-4);
    flex-wrap: wrap;
    margin-bottom: var(--s-5);
}

.page-title {
    font-size: var(--t-xl);
    font-weight: 650;
    letter-spacing: -0.025em;
}

.page-sub {
    margin-top: var(--s-1);
    font-size: var(--t-md);
    color: var(--text-2);
    max-width: 68ch;
}

.page-actions {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
}

@media (max-width: 639px) {
    .page-title { font-size: var(--t-lg); }
    .page-sub { font-size: var(--t-sm); }
    .page-actions { width: 100%; }
    .page-actions > * { flex: 1; justify-content: center; }
}

/* ---------- 9. Thẻ ---------- */
.card {
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
}
.card-pad { padding: var(--s-5); }

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--line);
}

.card-title { font-size: var(--t-md); font-weight: 600; }

@media (max-width: 639px) {
    .card-pad { padding: var(--s-4); }
    .card-head { padding: var(--s-4); }
}

/* ---------- 10. Nút ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--s-2);
    height: 38px;
    padding-inline: var(--s-4);
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text);
    font-size: var(--t-md);
    font-weight: 550;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), opacity .15s var(--ease);
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn .icon { width: 17px; height: 17px; }

.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:not(:disabled):hover { background: var(--accent-hi); color: var(--on-accent); }

.btn-secondary { background: var(--surface-2); border-color: var(--line-strong); color: var(--text); }
.btn-secondary:not(:disabled):hover { background: var(--surface-3); color: var(--text); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:not(:disabled):hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.btn-danger:not(:disabled):hover { background: var(--danger); color: #fff; }

.btn-sm { height: 32px; padding-inline: var(--s-3); font-size: var(--t-sm); }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-block { width: 100%; }

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    flex: none;
    border-radius: var(--r-sm);
    color: var(--text-2);
}
.btn-icon:hover { background: var(--surface-2); color: var(--text); }
.btn-icon.btn-sm { width: 32px; height: 32px; }

/* ---------- 11. Nhãn trạng thái ---------- */
.tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: var(--r-full);
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text-2);
    font-size: var(--t-xs);
    font-weight: 550;
    white-space: nowrap;
    line-height: 1.5;
}
.tag .icon { width: 13px; height: 13px; }

.tag-ok     { background: var(--ok-soft);     color: var(--ok);     border-color: transparent; }
.tag-warn   { background: var(--warn-soft);   color: var(--warn);   border-color: transparent; }
.tag-danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.tag-info   { background: var(--info-soft);   color: var(--info);   border-color: transparent; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

/* ---------- 12. Biểu mẫu ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field + .field { margin-top: var(--s-4); }

.label { font-size: var(--t-sm); font-weight: 550; color: var(--text-2); }
.hint  { font-size: var(--t-xs); color: var(--text-3); }

.input, .textarea, .select {
    width: 100%;
    min-height: 38px;
    padding: 8px var(--s-3);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    color: var(--text);
    font-size: var(--t-md);
    transition: border-color .15s var(--ease), background .15s var(--ease);
    appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover, .select:hover { border-color: rgba(255, 255, 255, .2); }
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface-1);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { resize: vertical; line-height: 1.6; }

.select {
    padding-right: var(--s-6);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23A1A1AA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--s-3) center;
    background-size: 15px;
    cursor: pointer;
}
.select option { background: var(--surface-2); color: var(--text); }

/* Ô tìm kiếm */
.search { position: relative; }
.search .icon {
    position: absolute;
    left: var(--s-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    width: 16px;
    height: 16px;
    pointer-events: none;
}
.search .input { padding-left: 36px; }

/* ---------- 13. Thông báo trong trang ---------- */
.callout {
    display: flex;
    gap: var(--s-3);
    padding: var(--s-4);
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--line);
    font-size: var(--t-sm);
    color: var(--text-2);
}
.callout .icon { flex: none; margin-top: 1px; }
.callout-title { font-weight: 600; color: var(--text); margin-bottom: 2px; font-size: var(--t-sm); }
.callout-danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.callout-danger .callout-title { color: var(--danger); }
.callout-warn { background: var(--warn-soft); border-color: transparent; color: #E6C200; }
.callout-warn .callout-title { color: var(--warn); }

/* ---------- 14. Bảng ---------- */
.table-wrap { width: 100%; overflow-x: auto; }

.table {
    width: 100%;
    min-width: 680px;          /* hẹp hơn thì cuộn ngang, không bóp cột */
    border-collapse: collapse;
    font-size: var(--t-sm);
}

.table th {
    padding: var(--s-3) var(--s-4);
    text-align: left;
    font-size: var(--t-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.table td {
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
    color: var(--text-2);
    vertical-align: middle;
    height: 52px;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: rgba(255, 255, 255, .022); }

.table .strong { color: var(--text); font-weight: 550; }
.table .num { font-variant-numeric: tabular-nums; }
.table .right { text-align: right; }
.table .nowrap { white-space: nowrap; }

/* Hàng thao tác chỉ hiện khi rê chuột (thiết bị có chuột) */
@media (hover: hover) and (min-width: 768px) {
    .row-actions { opacity: 0; transition: opacity .15s var(--ease); }
    tr:hover .row-actions,
    tr:focus-within .row-actions { opacity: 1; }
}

/* Bảng đổi thành danh sách thẻ trên mobile */
@media (max-width: 767px) {
    .table-wrap { overflow-x: visible; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table { min-width: 0; }   /* ở chế độ thẻ thì không cần bề rộng tối thiểu */
    .table thead { display: none; }

    .table tr {
        border: 1px solid var(--line);
        border-radius: var(--r-md);
        background: var(--surface-2);
        padding: var(--s-2) var(--s-3);
        margin-bottom: var(--s-3);
    }
    .table tr:last-child { margin-bottom: 0; }
    .table tbody tr:hover { background: var(--surface-2); }

    .table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: var(--s-4);
        height: auto;
        min-height: 34px;
        padding: 6px 0;
        border-bottom: 1px solid var(--line);
        text-align: right;
    }
    .table td:last-child { border-bottom: 0; }
    .table td::before {
        content: attr(data-label);
        flex: none;
        font-size: var(--t-xs);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .05em;
        color: var(--text-3);
        text-align: left;
    }
    .table td.right { text-align: right; }
    .table td[data-label=""]::before { content: none; }
    .row-actions { opacity: 1; }
}

/* ---------- 15. Trạng thái rỗng ---------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--s-3);
    padding: var(--s-7) var(--s-4);
}
.empty-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text-3);
    display: grid;
    place-items: center;
}
.empty-title { font-size: var(--t-md); font-weight: 600; color: var(--text); }
.empty-text { font-size: var(--t-sm); color: var(--text-3); max-width: 42ch; }

/* ---------- 16. Lưới thống kê ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--s-4);
}
@media (max-width: 1023px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 419px)  { .stat-grid { grid-template-columns: minmax(0, 1fr); } }

.stat { padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.stat-label {
    font-size: var(--t-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}
.stat-value {
    font-size: var(--t-2xl);
    font-weight: 650;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}
.stat-foot { display: flex; align-items: center; gap: var(--s-2); font-size: var(--t-xs); color: var(--text-3); }
.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: 600; }
.delta-up   { color: var(--ok); }
.delta-down { color: var(--danger); }
.delta-flat { color: var(--text-3); }

@media (max-width: 639px) {
    .stat { padding: var(--s-4); }
    .stat-value { font-size: var(--t-xl); }
}

/* ---------- 17. Biểu đồ ---------- */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart-grid  { stroke: rgba(255, 255, 255, .06); stroke-width: 1; }
.chart-axis  { fill: var(--text-3); font-size: 11px; font-family: inherit; }
.chart-line  { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-hit   { fill: transparent; cursor: pointer; }

.legend { display: flex; flex-wrap: wrap; gap: var(--s-4); }
.legend-item { display: inline-flex; align-items: center; gap: 7px; font-size: var(--t-sm); color: var(--text-2); }
.legend-swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.spark { width: 100%; height: 34px; display: block; overflow: visible; }
.spark path { fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }

/* ---------- 18. Hộp thoại ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    padding: var(--s-4);
    background: rgba(0, 0, 0, .65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity .2s var(--ease), visibility .2s var(--ease);
}
.modal[data-open="true"] { opacity: 1; visibility: visible; }

.modal-panel {
    width: min(460px, 100%);
    max-height: calc(100dvh - var(--s-6));
    overflow-y: auto;
    background: var(--surface-1);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    transform: translateY(8px) scale(.99);
    transition: transform .2s var(--ease);
}
.modal[data-open="true"] .modal-panel { transform: none; }
.modal-panel--wide { width: min(560px, 100%); }

.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    padding: var(--s-4) var(--s-5);
    border-bottom: 1px solid var(--line);
}
.modal-title { font-size: var(--t-md); font-weight: 600; }
.modal-body { padding: var(--s-5); }
.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--s-2);
    padding: var(--s-4) var(--s-5);
    border-top: 1px solid var(--line);
}
@media (max-width: 479px) {
    .modal-foot { flex-direction: column-reverse; }
    .modal-foot .btn { width: 100%; }
}

/* ---------- 19. Menu thả xuống ---------- */
.menu-wrap { position: relative; }
.menu {
    position: absolute;
    min-width: 190px;
    padding: var(--s-1);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity .15s var(--ease), visibility .15s var(--ease), transform .15s var(--ease);
}
.menu[data-open="true"] { opacity: 1; visibility: visible; transform: none; }
.menu--up     { bottom: calc(100% + 6px); left: 0; right: 0; }
.menu--down-end { top: calc(100% + 6px); right: 0; }

.menu-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    width: 100%;
    padding: var(--s-2) var(--s-3);
    border: 0;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--text-2);
    font-size: var(--t-sm);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.menu-item:hover { background: var(--surface-3); color: var(--text); }
.menu-item .icon { width: 16px; height: 16px; }
.menu-item--danger { color: var(--danger); }
.menu-item--danger:hover { background: var(--danger-soft); color: var(--danger); }
.menu-sep { height: 1px; background: var(--line); margin: var(--s-1) 0; }
.menu-label { padding: var(--s-2) var(--s-3); font-size: var(--t-xs); color: var(--text-3); }

/* ---------- 20. Toast ---------- */
.toasts {
    position: fixed;
    z-index: 80;
    bottom: var(--s-5);
    right: var(--s-5);
    display: flex;
    flex-direction: column;
    gap: var(--s-2);
    pointer-events: none;
}
@media (max-width: 639px) {
    .toasts { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); align-items: stretch; }
}

.toast {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-md);
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-lg);
    font-size: var(--t-sm);
    font-weight: 500;
    color: var(--text);
    animation: toast-in .22s var(--ease);
}
.toast[data-leaving="true"] { animation: toast-out .18s var(--ease) forwards; }
.toast-ok     .icon { color: var(--ok); }
.toast-danger .icon { color: var(--danger); }

@keyframes toast-in  { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to   { opacity: 0; transform: translateY(6px); } }

/* ---------- 21. Tiện ích ---------- */
.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.wrap    { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow    { flex: 1; min-width: 0; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); }
.mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); }
.mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }

.t-xs { font-size: var(--t-xs); }
.t-sm { font-size: var(--t-sm); }
.t-2  { color: var(--text-2); }
.t-3  { color: var(--text-3); }
.t-ok { color: var(--ok); }
.fw-6 { font-weight: 600; }
.num  { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.only-mobile { display: none; }
@media (max-width: 767px) {
    .only-mobile { display: inline-flex; }
    .no-mobile { display: none !important; }
}

/* ============================================================
   22. Vỏ đăng nhập
   ============================================================ */
.auth-shell {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: var(--s-5) var(--s-4);
}
.auth-card { width: min(400px, 100%); }
.auth-head { text-align: center; margin-bottom: var(--s-5); }
.auth-mark {
    width: 46px;
    height: 46px;
    margin: 0 auto var(--s-4);
    border-radius: var(--r-md);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    display: grid;
    place-items: center;
    font-size: var(--t-xl);
    font-weight: 700;
    letter-spacing: -0.04em;
}
.auth-title { font-size: var(--t-lg); font-weight: 600; }
.auth-sub { margin-top: var(--s-1); font-size: var(--t-sm); color: var(--text-2); }
.auth-foot { margin-top: var(--s-5); text-align: center; font-size: var(--t-xs); color: var(--text-3); }

/* ============================================================
   23. Vỏ toàn màn hình (Chat) — trang không cuộn, chỉ vùng nội dung cuộn
   ============================================================ */
body[data-shell="full"] { overflow: hidden; }
body[data-shell="full"] .app { height: 100dvh; }
body[data-shell="full"] .app-main { min-height: 0; overflow: hidden; }

/* ============================================================
   24. Chat
   ============================================================ */
.chat {
    position: relative;
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    flex: 1;
    min-height: 0;
    background: var(--surface-1);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    overflow: hidden;
}

/* --- Danh sách phiên --- */
.chat-sessions {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg);
    border-right: 1px solid var(--line);
}
.chat-sessions-head { padding: var(--s-3); display: flex; flex-direction: column; gap: var(--s-2); }
.chat-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 var(--s-2) var(--s-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.chat-sessions-label {
    padding: var(--s-3) var(--s-2) var(--s-1);
    font-size: var(--t-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-3);
}

.session {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    border-radius: var(--r-sm);
    color: var(--text-2);
    font-size: var(--t-sm);
    font-weight: 500;
    min-width: 0;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.session:hover { background: var(--surface-2); color: var(--text); }
.session[aria-current="page"] { background: var(--surface-3); color: var(--text); font-weight: 600; }
.session .icon { width: 15px; height: 15px; flex: none; color: var(--text-3); }
.session[aria-current="page"] .icon { color: var(--accent); }
.session-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --- Khung hội thoại --- */
.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }

.chat-head {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
    flex: none;
    min-height: 57px;
}
.chat-head-title { font-size: var(--t-md); font-weight: 600; }
.chat-head-meta { font-size: var(--t-xs); color: var(--text-3); }

.chat-scroll {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: var(--s-5) var(--s-4);
    scroll-behavior: smooth;
}
.chat-thread {
    width: 100%;
    max-width: 760px;      /* cột đọc — không kéo dài hết màn hình */
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    gap: var(--s-6);
}

/* --- Tin nhắn --- */
.msg { display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.msg-role {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--t-xs);
    font-weight: 600;
    color: var(--text-3);
}
.msg-role .icon { width: 13px; height: 13px; }

/* Người dùng: bong bóng, canh phải */
.msg-user { align-items: flex-end; }
.msg-user .msg-body {
    max-width: min(85%, 560px);
    padding: 10px var(--s-4);
    background: var(--accent);
    color: var(--on-accent);
    border-radius: var(--r-lg) var(--r-lg) var(--r-sm) var(--r-lg);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* AI: không bong bóng, trải hết cột đọc */
.msg-ai .msg-role { color: var(--text-2); }
.msg-ai .msg-role .icon { color: var(--accent); }
.msg-ai .msg-body { color: var(--text); overflow-wrap: anywhere; }

/* Con trỏ nhấp nháy khi đang trả lời */
.caret {
    display: inline-block;
    width: 7px;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--accent);
    border-radius: 1px;
    animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.thinking { display: inline-flex; gap: 4px; align-items: center; height: 1.4em; }
.thinking span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--text-3);
    animation: think 1.2s var(--ease) infinite;
}
.thinking span:nth-child(2) { animation-delay: .15s; }
.thinking span:nth-child(3) { animation-delay: .3s; }
@keyframes think { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* --- Nội dung markdown --- */
.prose > * + * { margin-top: .85em; }
.prose h1, .prose h2, .prose h3, .prose h4 { margin-top: 1.4em; font-weight: 600; line-height: 1.35; }
.prose h1 { font-size: 1.3em; }
.prose h2 { font-size: 1.18em; }
.prose h3 { font-size: 1.06em; }
.prose h4 { font-size: 1em; }
.prose ul, .prose ol { padding-left: 1.35em; }
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li::marker { color: var(--text-3); }
.prose li + li { margin-top: .3em; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose strong { font-weight: 650; color: #fff; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.4em 0; }
.prose blockquote {
    border-left: 2px solid var(--line-strong);
    padding-left: var(--s-4);
    color: var(--text-2);
}
.prose :not(pre) > code {
    background: var(--surface-3);
    border: 1px solid var(--line);
    padding: 1px 5px;
    border-radius: 5px;
    font-size: .875em;
    overflow-wrap: anywhere;
}
.prose table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); display: block; overflow-x: auto; }
.prose th, .prose td { padding: 7px 12px; border: 1px solid var(--line); text-align: left; }
.prose th { background: var(--surface-2); font-weight: 600; }

.code-block { position: relative; }
.code-block pre {
    margin: 0;
    background: #0A0A0D;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s-4);
    overflow-x: auto;
    font-size: var(--t-sm);
    line-height: 1.6;
}
.code-block pre code { background: none; border: 0; padding: 0; font-size: inherit; }
.code-lang {
    position: absolute;
    top: 9px;
    left: var(--s-4);
    font-size: var(--t-xs);
    color: var(--text-3);
    pointer-events: none;
}
.code-block:has(.code-lang:not(:empty)) pre { padding-top: var(--s-6); }
.code-copy { position: absolute; top: 6px; right: 6px; }
@media (hover: hover) {
    .code-copy { opacity: 0; transition: opacity .15s var(--ease); }
    .code-block:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
}

/* --- Ô soạn tin --- */
.compose { flex: none; border-top: 1px solid var(--line); padding: var(--s-3) var(--s-4) var(--s-4); }
.compose-inner { max-width: 760px; margin-inline: auto; }

.composer {
    display: flex;
    align-items: flex-end;
    gap: var(--s-2);
    padding: 6px 6px 6px var(--s-4);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: 22px;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.composer:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.composer textarea {
    flex: 1;
    min-width: 0;
    background: none;
    border: 0;
    outline: none;
    resize: none;
    color: var(--text);
    font-size: var(--t-md);
    line-height: 1.5;
    padding: 8px 0;
    max-height: 180px;
    overflow-y: auto;
}
.composer textarea::placeholder { color: var(--text-3); }

.composer-send {
    width: 34px;
    height: 34px;
    flex: none;
    margin-bottom: 1px;
    border: 0;
    border-radius: 50%;
    background: var(--accent);
    color: var(--on-accent);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background .15s var(--ease), opacity .15s var(--ease);
}
.composer-send:hover:not(:disabled) { background: var(--accent-hi); }
.composer-send:disabled { opacity: .35; cursor: not-allowed; }
.composer-send .icon { width: 17px; height: 17px; }
.composer-send[data-mode="stop"] { background: var(--surface-3); color: var(--text); }
.composer-send[data-mode="stop"]:hover { background: #33333d; }

.compose-hint {
    margin-top: 7px;
    text-align: center;
    font-size: var(--t-xs);
    color: var(--text-3);
}

/* Luôn tách khỏi luồng lưới: nếu để tĩnh, nó chiếm mất một ô của grid */
.chat-scrim {
    position: absolute;
    inset: 0;
    z-index: 19;
    background: rgba(0, 0, 0, .55);
    opacity: 0;
    visibility: hidden;
    transition: opacity .25s var(--ease), visibility .25s var(--ease);
}

/* --- Chat responsive --- */

/* Tablet & nhỏ hơn: danh sách phiên thành ngăn kéo phủ lên */
@media (max-width: 1023px) {
    .chat { grid-template-columns: minmax(0, 1fr); }
    .chat-sessions {
        position: absolute;
        inset-block: 0;
        inset-inline-start: 0;
        width: min(272px, 80vw);
        z-index: 20;
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .chat-sessions[data-open="true"] { transform: translateX(0); }
    .chat-scrim[data-open="true"] { opacity: 1; visibility: visible; }
}
@media (min-width: 1024px) { .chat-sessions-toggle { display: none; } }

@media (max-width: 767px) {
    .chat { border: 0; border-radius: 0; }
    .chat-scroll { padding: var(--s-4) var(--s-3); }
    .chat-thread { gap: var(--s-5); }
    .msg-user .msg-body { max-width: 90%; }
    .compose { padding: var(--s-2) var(--s-3) var(--s-3); }
    .compose-hint { display: none; }
    .chat-head { padding-inline: var(--s-3); gap: var(--s-2); }
    .chat-head .select { max-width: 124px; min-width: 0; font-size: var(--t-xs); }
}

/* ============================================================
   25. Phân trang
   ============================================================ */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s-3);
    flex-wrap: wrap;
    padding: var(--s-3) var(--s-5);
    border-top: 1px solid var(--line);
}
.pager-info { font-size: var(--t-sm); color: var(--text-3); font-variant-numeric: tabular-nums; }
.pager-nav { display: flex; align-items: center; gap: var(--s-1); }
.pager-nav .btn[aria-disabled="true"] { opacity: .35; pointer-events: none; }
@media (max-width: 639px) {
    .pager { padding: var(--s-3) var(--s-4); justify-content: center; }
    .pager-info { width: 100%; text-align: center; }
}

/* ============================================================
   26. Hộp hiển thị khóa API
   ============================================================ */
.key-box {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3);
    background: var(--surface-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
}
.key-value {
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--t-sm);
    color: var(--text);
    scrollbar-width: none;
}
.key-value::-webkit-scrollbar { height: 0; }

.mono-cell {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: var(--t-xs);
    color: var(--text-2);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 5px;
    padding: 2px 7px;
    white-space: nowrap;
}

/* ============================================================
   27. Thanh công cụ bảng
   ============================================================ */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--s-2);
    flex-wrap: wrap;
    padding: var(--s-3) var(--s-4);
    border-bottom: 1px solid var(--line);
}
.toolbar .search { flex: 1; min-width: 180px; max-width: 320px; }
.toolbar .input, .toolbar .select { min-height: 34px; font-size: var(--t-sm); }
@media (max-width: 639px) {
    .toolbar .search { max-width: none; flex-basis: 100%; }
    .toolbar .select { flex: 1; }
}

/* ============================================================
   28. Thanh tiến độ hạn ngạch
   ============================================================ */
.meter {
    height: 4px;
    border-radius: var(--r-full);
    background: var(--surface-3);
    overflow: hidden;
}
.meter-fill {
    height: 100%;
    border-radius: inherit;
    background: var(--accent);
    transition: width .4s var(--ease);
}
.meter-fill[data-level="warn"]   { background: var(--warn); }
.meter-fill[data-level="danger"] { background: var(--danger); }

/* Biểu đồ giữ tỉ lệ đọc được: hẹp quá thì cuộn ngang thay vì co nhỏ chữ */
.chart-scroll { overflow-x: auto; }
.chart-scroll .chart { min-width: 520px; }

/* ============================================================
   29. Danh sách hoạt động gần đây
   ============================================================ */
.feed { display: flex; flex-direction: column; }
.feed-item {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-5);
    border-bottom: 1px solid var(--line);
}
.feed-item:last-child { border-bottom: 0; }
.feed-icon {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: var(--r-sm);
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--text-3);
    display: grid;
    place-items: center;
}
.feed-icon .icon { width: 15px; height: 15px; }
.feed-icon[data-state="error"] { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.feed-main { flex: 1; min-width: 0; }
.feed-title { font-size: var(--t-sm); font-weight: 550; color: var(--text); }
.feed-meta  { font-size: var(--t-xs); color: var(--text-3); }
.feed-value { font-size: var(--t-sm); color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
@media (max-width: 639px) {
    .feed-item { padding: var(--s-3) var(--s-4); }
}

/* ============================================================
   30. Lưới nội dung 2 cột
   ============================================================ */
.split {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
    gap: var(--s-4);
    align-items: start;
}
@media (max-width: 1023px) { .split { grid-template-columns: minmax(0, 1fr); } }

/* ============================================================
   31. Hàng phiên chat (nút xóa hiện khi rê chuột)
   ============================================================ */
.session-row { position: relative; }
.session-row .session { padding-right: 36px; }
.session-del {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
}
.session-del .btn { width: 26px; height: 26px; color: var(--text-3); }
.session-del .btn:hover { background: var(--danger-soft); color: var(--danger); }
@media (hover: hover) and (pointer: fine) {
    .session-del { opacity: 0; transition: opacity .15s var(--ease); }
    .session-row:hover .session-del,
    .session-row:focus-within .session-del { opacity: 1; }
}

/* ============================================================
   32. Tệp đính kèm — dùng cho ảnh, PDF và tài liệu khác
   Đã có sẵn trong hệ thống thiết kế để tính năng tải tệp
   chỉ cần gắn markup, không phải nghĩ lại phần nhìn.
   ============================================================ */
.attachments {
    display: flex;
    flex-wrap: wrap;
    gap: var(--s-2);
    padding: 0 0 var(--s-2);
}
.attachments:empty { display: none; }

.attachment {
    display: inline-flex;
    align-items: center;
    gap: var(--s-2);
    max-width: 240px;
    padding: 6px var(--s-2) 6px var(--s-3);
    background: var(--surface-3);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font-size: var(--t-sm);
}
.attachment .icon { width: 16px; height: 16px; flex: none; color: var(--text-3); }
.attachment-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-size { font-size: var(--t-xs); color: var(--text-3); flex: none; }
.attachment[data-state="uploading"] { opacity: .6; }
.attachment[data-state="error"] { border-color: var(--danger); color: var(--danger); }

/* Ảnh xem trước dạng ô vuông */
.attachment-thumb {
    width: 56px;
    height: 56px;
    padding: 0;
    max-width: none;
    overflow: hidden;
    position: relative;
}
.attachment-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attachment-thumb .attachment-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, .65);
    color: #fff;
    border: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
}
.attachment-thumb .attachment-remove .icon { width: 11px; height: 11px; color: #fff; }

/* Vùng thả tệp phủ lên khung trò chuyện */
.dropzone {
    position: absolute;
    inset: var(--s-3);
    z-index: 25;
    display: grid;
    place-items: center;
    gap: var(--s-2);
    border: 2px dashed var(--accent);
    border-radius: var(--r-lg);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    color: var(--text);
    font-size: var(--t-md);
    font-weight: 550;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s var(--ease), visibility .18s var(--ease);
}
.dropzone[data-open="true"] { opacity: 1; visibility: visible; }

/* Tệp đính kèm hiển thị bên trong một tin nhắn đã gửi */
.msg-files { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.msg-files img {
    max-width: min(280px, 100%);
    border-radius: var(--r-md);
    border: 1px solid var(--line);
}

/* Nút đính kèm nằm trong ô soạn tin */
.composer-attach {
    width: 34px;
    height: 34px;
    flex: none;
    margin-bottom: 1px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-3);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.composer-attach:hover { background: var(--surface-3); color: var(--text); }
.composer-attach .icon { width: 18px; height: 18px; }
.composer { padding-left: var(--s-2); }
