#aichat {
    /* Amber gold */
    --ac-primary: #eab741;
    --ac-primary-d: #c98a12;
    --ac-primary-l: #f6cd63;
    --ac-amber-deep: #9a6400;          /* chữ/icon nhấn trên nền sáng (đủ tương phản) */
    --ac-primary-hair: rgba(201, 138, 18, .3);
    --ac-primary-glow: rgba(201, 138, 18, .4);

    --ac-gold: #eab741;
    --ac-gold-hover: #f1c458;
    --ac-gold-soft: #fff4d6;
    --ac-gold-ink: #7a5600;

    /* Nền + chip */
    --ac-bg: #fffcf5;
    --ac-surface: #ffffff;
    --ac-chip: #fff3d0;
    --ac-hover: #fff8e6;
    --ac-line: #f0e3c0;
    --ac-line-2: #f7eed6;

    /* Chữ (nâu ấm, không đen) */
    --ac-ink: #3b2d12;
    --ac-text: #5a4826;
    --ac-muted: #8b7a55;
    --ac-faint: #b9aa86;

    --ac-online: #25a869;
    --ac-danger: #e5484d;
    --ac-call: #1d8f55;

    --ac-radius-lg: 18px;
    --ac-radius-md: 14px;
    --ac-shadow-panel: 0 32px 72px -28px rgba(160, 108, 10, .5), 0 10px 24px -12px rgba(90, 60, 8, .2);
    --ac-shadow-card: 0 1px 2px rgba(90, 60, 8, .05), 0 6px 16px -10px rgba(160, 108, 10, .28);
    --ac-font: "Be Vietnam Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    font-family: var(--ac-font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ac-text);
    text-align: left;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

/* ---------- RESET (specificity 0 để không đè style bên dưới) ------------ */
:where(#aichat, #aichat *) { box-sizing: border-box; }
:where(#aichat) :where(button, input, textarea) {
    font: inherit;
    color: inherit;
    margin: 0;
    letter-spacing: inherit;
    -webkit-tap-highlight-color: transparent;
}
:where(#aichat) button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    text-align: inherit;
    -webkit-appearance: none;
    appearance: none;
}
:where(#aichat) :where(p, h3, h4, ul, ol) { margin: 0; padding: 0; }
:where(#aichat) :where(ul, ol) { list-style: revert; }
#aichat [hidden] { display: none !important; }
#aichat svg { display: block; }
#aichat :focus { outline: none; }
#aichat :focus-visible { outline: 2px solid var(--ac-primary); outline-offset: 2px; }

/* ==========================================================================
   1. PANEL
   ========================================================================== */
#aichat .aichat-panel {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999991;
    width: min(420px, calc(100vw - 32px));
    height: min(700px, calc(100vh - 40px));
    height: min(700px, calc(100dvh - 40px));
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--ac-bg);
    border-radius: 22px;
    border: 1px solid var(--ac-primary-hair);
    box-shadow: var(--ac-shadow-panel);
    transform-origin: 100% 100%;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px) scale(.97);
    transition: opacity .22s ease, transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s;
}
#aichat .aichat-panel.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: none;
    transition-delay: 0s;
}

/* ---------- Header ------------------------------------------------------- */
#aichat .aichat-head {
    position: relative;
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 15px 11px 15px 14px;
    color: var(--ac-ink);
    background:
        radial-gradient(120% 150% at 0% 0%, rgba(255, 255, 255, .5), rgba(255, 255, 255, 0) 55%),
        linear-gradient(135deg, #f9d878 0%, var(--ac-primary) 58%, #dba02a 100%);
}
#aichat .aichat-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
#aichat .aichat-brand > div { min-width: 0; }
#aichat .aichat-brand strong {
    display: block;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -.005em;
    line-height: 1.25;
    color: var(--ac-ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#aichat .aichat-avatar {
    flex: 0 0 auto;
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), 0 6px 14px -6px rgba(110, 72, 8, .5);
    overflow: hidden;
}
#aichat .aichat-avatar svg { width: 24px; height: 24px; }
#aichat .aichat-avatar .mark-a { fill: #f6d98a; }
#aichat .aichat-avatar .mark-b { fill: var(--ac-primary); }
#aichat .aichat-avatar .mark-c { fill: var(--ac-primary-d); }
#aichat .aichat-avatar.has-image img { width: 100%; height: 100%; object-fit: scale-down; display: block; }

#aichat .aichat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: -2px;
    padding: 4px 0 4px 5px;   /* chừa chỗ cho vòng sáng của chấm online */
    font-size: 11.5px;
    color: rgba(59, 45, 18, .78);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
#aichat .aichat-status i {
    flex: 0 0 auto;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ac-online);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .85);
    animation: aichat-pulse 2.6s ease-out infinite;
}

#aichat .aichat-head-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 4px; }
#aichat .aichat-restart,
#aichat .aichat-minimize,
#aichat .aichat-close {
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--ac-ink);
    background: rgba(255, 255, 255, .45);
    border: 1px solid rgba(255, 255, 255, .75);
    border-radius: 16px;
    transition: background .15s ease, transform .15s ease;
}
#aichat .aichat-restart { padding: 0 10px 0 8px; font-size: 11.5px; }
#aichat .aichat-restart span { font-size: 15px; line-height: 1; }
#aichat .aichat-restart b { font-weight: 600; }
#aichat .aichat-minimize,
#aichat .aichat-close { width: 32px; font-size: 19px; line-height: 1; }
#aichat .aichat-restart:hover,
#aichat .aichat-minimize:hover,
#aichat .aichat-close:hover { background: rgba(255, 255, 255, .75); }
#aichat .aichat-restart:active,
#aichat .aichat-minimize:active,
#aichat .aichat-close:active { transform: scale(.95); }
#aichat .aichat-head :focus-visible { outline-color: var(--ac-ink); }

/* ---------- Tabs mobile (ẩn trên desktop) -------------------------------- */
#aichat .aichat-mobile-tabs { display: none; }

/* ---------- Vùng nội dung ------------------------------------------------ */
#aichat .aichat-catalog,
#aichat .aichat-messages {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px 12px;
    scrollbar-width: thin;
    scrollbar-color: #ecd9a0 transparent;
}
#aichat .aichat-messages { scroll-behavior: smooth; }
#aichat .aichat-catalog > *,
#aichat .aichat-messages > * { flex: 0 0 auto; }
#aichat .aichat-messages::-webkit-scrollbar,
#aichat .aichat-catalog::-webkit-scrollbar { width: 6px; }
#aichat .aichat-messages::-webkit-scrollbar-thumb,
#aichat .aichat-catalog::-webkit-scrollbar-thumb { background: #ecd9a0; border-radius: 6px; }

/* ---------- Nút "Tin nhắn mới" ------------------------------------------ */
#aichat .aichat-new-message {
    position: absolute;
    left: 50%;
    bottom: 96px;
    z-index: 3;
    padding: 7px 15px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ac-ink);
    background: var(--ac-primary);
    border-radius: 999px;
    box-shadow: 0 10px 22px -8px var(--ac-primary-glow);
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, 8px);
    transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
#aichat .aichat-new-message.is-visible { opacity: 1; visibility: visible; transform: translate(-50%, 0); transition-delay: 0s; }

/* ---------- Composer ----------------------------------------------------- */
#aichat .aichat-composer {
    flex: 0 0 auto;
    padding: 10px 12px 8px;
    background: var(--ac-surface);
    border-top: 1px solid var(--ac-line);
}
#aichat .aichat-form {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 5px 5px 5px 13px;
    background: var(--ac-bg);
    border: 1px solid var(--ac-line);
    border-radius: 24px;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
#aichat .aichat-form:focus-within {
    background: #fff;
    border-color: var(--ac-amber-deep);
    box-shadow: 0 0 0 3px rgba(234, 183, 65, .16);
}
#aichat .aichat-attach { flex: 0 0 auto; width: 22px; height: 36px; display: grid; place-items: center; color: var(--ac-faint); }
#aichat .aichat-attach svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#aichat .aichat-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 36px;
    min-height: 36px;
    max-height: 112px;
    padding: 8px 0;
    font-size: 14.5px;
    line-height: 20px;
    color: var(--ac-ink);
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    resize: none;
    overflow-y: auto;
    outline: none;
}
#aichat .aichat-input::placeholder { color: var(--ac-faint); }
#aichat .aichat-input:disabled { opacity: .6; cursor: progress; }
/* nút gửi: vàng thương hiệu */
#aichat .aichat-send {
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: var(--ac-ink);
    background: var(--ac-gold);
    border-radius: 50%;
    box-shadow: 0 6px 12px -6px rgba(180, 130, 20, .6);
    transition: background .15s ease, transform .15s ease, opacity .15s ease;
}
#aichat .aichat-send svg { width: 18px; height: 18px; }
#aichat .aichat-send:hover { background: var(--ac-gold-hover); }
#aichat .aichat-send:active { transform: scale(.92); }
#aichat .aichat-send:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
#aichat.is-sending .aichat-send { background: #efe3bd; }
#aichat .aichat-hint { margin-top: 6px; font-size: 11px; line-height: 1.3; text-align: center; color: var(--ac-faint); }

/* ==========================================================================
   2. TIN NHẮN
   ========================================================================== */
#aichat .aichat-msg {
    position: relative;
    max-width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    line-height: 1.6;
    overflow-wrap: anywhere;
    word-break: break-word;
}
#aichat .aichat-msg.user {
    align-self: flex-end;
    max-width: 84%;
    font-weight: 500;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l) 0%, var(--ac-primary) 100%);
    border-radius: 18px 18px 4px 18px;
    white-space: pre-wrap;
    box-shadow: 0 10px 20px -12px var(--ac-primary-glow);
    animation: aichat-rise .22s ease both;
}
#aichat .aichat-msg-wrap {
    align-self: flex-start;
    max-width: 94%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    animation: aichat-rise .22s ease both;
}
#aichat .aichat-msg.assistant {
    color: var(--ac-text);
    background: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: 18px 18px 18px 4px;
    box-shadow: var(--ac-shadow-card);
}
#aichat .aichat-msg.assistant > * + * { margin-top: 8px; }
#aichat .aichat-msg.assistant h4 { font-size: 15px; font-weight: 700; line-height: 1.35; color: var(--ac-ink); }
#aichat .aichat-msg.assistant ul,
#aichat .aichat-msg.assistant ol { padding-left: 20px; }
#aichat .aichat-msg.assistant ul li{list-style-type: disc !important;}
#aichat .aichat-msg.assistant li { margin: 3px 0; padding-left: 2px; }
#aichat .aichat-msg.assistant li::marker { color: var(--ac-amber-deep); font-weight: 700; }
#aichat .aichat-msg.assistant strong { font-weight: 700; color: var(--ac-ink); }
#aichat .aichat-msg.assistant a {
    color: var(--ac-amber-deep);
    font-weight: 600;
    text-decoration: underline;
    text-decoration-color: rgba(201, 138, 18, .55);
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
    word-break: break-all;
}
#aichat .aichat-msg.assistant a:hover { background: var(--ac-hover); }

/* Rút gọn tin nhắn dài */
#aichat .aichat-msg-wrap.is-collapsed .aichat-msg.assistant { max-height: 330px; overflow: hidden; }
#aichat .aichat-msg-wrap.is-collapsed .aichat-msg.assistant::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 84px;
    pointer-events: none;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0), #fff 82%);
}
#aichat .aichat-expand {
    padding: 4px 13px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ac-amber-deep);
    background: var(--ac-surface);
    border: 1px solid var(--ac-primary-hair);
    border-radius: 999px;
    transition: background .15s ease, border-color .15s ease;
}
#aichat .aichat-expand:hover { background: var(--ac-hover); border-color: var(--ac-amber-deep); }

/* Đang gõ */
#aichat .aichat-msg.aichat-typing {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 14px 9px 9px;
    animation: aichat-rise .2s ease both;
}
#aichat .aichat-typing-avatar {
    flex: 0 0 auto;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .04em;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l), var(--ac-primary));
    border-radius: 50%;
}
#aichat .aichat-typing-dots { display: inline-flex; align-items: center; gap: 4px; }
#aichat .aichat-typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--ac-primary); animation: aichat-dot 1.1s ease-in-out infinite; }
#aichat .aichat-typing-dots i:nth-child(2) { animation-delay: .15s; }
#aichat .aichat-typing-dots i:nth-child(3) { animation-delay: .3s; }
#aichat .aichat-typing-text { font-size: 12.5px; color: var(--ac-muted); }

/* ==========================================================================
   3. WELCOME + DỊCH VỤ + GỢI Ý
   ========================================================================== */
#aichat .aichat-welcome {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 18px 8px 16px 18px;
    overflow: hidden;
    background: linear-gradient(150deg, #ffffff 0%, var(--ac-chip) 100%);
    border: 1px solid var(--ac-primary-hair);
    border-radius: var(--ac-radius-lg);
    box-shadow: var(--ac-shadow-card);
}
#aichat .aichat-welcome-copy { position: relative; z-index: 1; min-width: 0; flex: 1 1 auto; }
/* nhãn vàng: điểm nhấn thương hiệu */
#aichat .aichat-welcome-badge {
    display: inline-block;
    margin-bottom: 10px;
    padding: 3px 10px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .08em;
    color: var(--ac-gold-ink);
    background: #fff;
    border: 1px solid var(--ac-primary-hair);
    border-radius: 999px;
}
#aichat .aichat-welcome h3 { font-size: 24px; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; color: var(--ac-ink); }
#aichat .aichat-welcome-copy strong { display: block; margin-top: 4px; font-size: 13.5px; font-weight: 600; color: var(--ac-amber-deep); }
#aichat .aichat-welcome-copy p { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--ac-primary-hair); font-size: 12.5px; line-height: 1.55; color: var(--ac-muted); }
#aichat .aichat-mascot { flex: 0 0 auto; width: 118px; }
#aichat .aichat-mascot-card-stage { display: block; width: 118px; height: 118px; }
#aichat .aichat-mascot-card-stage img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 8px 8px rgba(160, 108, 10, .25));
    user-select: none;
    -webkit-user-drag: none;
    animation: aichat-float 3.8s ease-in-out .5s infinite;
    will-change: transform;
}

#aichat .aichat-section-title { margin-top: 6px; font-size: 15px; font-weight: 700; color: var(--ac-ink); }
#aichat .aichat-more-title { margin-top: 2px; font-size: 12px; font-weight: 500; letter-spacing: .02em; color: var(--ac-muted); }

/* Lưới dịch vụ */
#aichat .aichat-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
#aichat .aichat-action {
    display: flex;
    align-items: center;
    gap: 11px;
    min-width: 0;
    padding: 11px 10px;
    text-align: left;
    background: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: var(--ac-radius-md);
    transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
    animation: aichat-rise .3s ease both;
    animation-delay: var(--action-delay, 0ms);
}
#aichat .aichat-action:hover { border-color: var(--ac-amber-deep); box-shadow: var(--ac-shadow-card); transform: translateY(-1px); }
#aichat .aichat-action:active { transform: scale(.985); }
#aichat .aichat-action-icon {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: var(--ac-amber-deep);
    background: var(--ac-chip);
    border-radius: 12px;
    overflow: hidden;
}
#aichat .aichat-action-icon svg,
#aichat .aichat-suggestion svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#aichat .aichat-action-icon.has-image img { width: 100%; height: 100%; object-fit: cover; display: block; }
#aichat .aichat-action-copy { min-width: 0; display: flex; flex-direction: column; }
#aichat .aichat-action-copy strong { font-size: 13px; font-weight: 600; line-height: 1.3; color: var(--ac-ink); overflow-wrap: anywhere; }
#aichat .aichat-action-copy small { margin-top: 1px; font-size: 11.5px; line-height: 1.35; color: var(--ac-muted); overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }

/* Chip gợi ý */
#aichat .aichat-suggestions,
#aichat .aichat-followups { display: flex; flex-wrap: wrap; gap: 7px; }
#aichat .aichat-suggestion,
#aichat .aichat-followups button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px 7px 10px;
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ac-ink);
    background: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: 999px;
    transition: border-color .15s ease, background .15s ease;
    animation: aichat-rise .3s ease both;
    animation-delay: var(--action-delay, 0ms);
}
#aichat .aichat-followups button { padding: 7px 14px; animation: none; }
#aichat .aichat-suggestion > span { display: grid; place-items: center; color: var(--ac-amber-deep); }
#aichat .aichat-suggestion svg { width: 15px; height: 15px; }
#aichat .aichat-suggestion:hover,
#aichat .aichat-followups button:hover { background: var(--ac-hover); border-color: var(--ac-amber-deep); }

/* ---------- Danh sách lựa chọn (flow catalog) ---------------------------- */
#aichat .aichat-website-choices { padding: 14px 12px 10px; background: var(--ac-surface); border: 1px solid var(--ac-line); border-radius: var(--ac-radius-lg); box-shadow: var(--ac-shadow-card); }
#aichat .aichat-website-choices-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 10px; padding: 0 2px 10px; border-bottom: 1px solid var(--ac-line); }
#aichat .aichat-website-choices-head strong { font-size: 14px; font-weight: 700; color: var(--ac-ink); }
#aichat .aichat-website-choices-head small { font-size: 11.5px; color: var(--ac-muted); white-space: nowrap; }
#aichat .aichat-website-choices-grid { display: grid; grid-template-columns: 1fr; gap: 4px; }
#aichat .aichat-website-choice {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 8px 10px 8px 8px;
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    transition: background .15s ease, border-color .15s ease;
}
#aichat .aichat-website-choice.is-extra { display: none; }
#aichat .aichat-website-choices.is-expanded .aichat-website-choice.is-extra { display: flex; }
#aichat .aichat-website-choice:hover { background: var(--ac-hover); border-color: var(--ac-primary-hair); }
#aichat .aichat-website-choice-number {
    flex: 0 0 auto;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--ac-amber-deep);
    background: var(--ac-chip);
    border-radius: 8px;
}
#aichat .aichat-website-choice-label { flex: 1 1 auto; min-width: 0; font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--ac-ink); overflow-wrap: anywhere; }
#aichat .aichat-website-choice-arrow { flex: 0 0 auto; font-size: 18px; line-height: 1; color: var(--ac-primary-l); }
#aichat .aichat-website-choices-toggle { width: 100%; margin-top: 6px; padding: 8px; font-size: 12.5px; font-weight: 700; text-align: center; color: var(--ac-amber-deep); border-radius: 10px; }
#aichat .aichat-website-choices-toggle:hover { background: var(--ac-hover); }

/* ---------- Nguồn tham khảo --------------------------------------------- */
#aichat .aichat-source-summary {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 94%;
    padding: 6px 12px 6px 9px;
    font-size: 12px;
    color: var(--ac-muted);
    background: transparent;
    border: 1px solid var(--ac-line);
    border-radius: 12px;
}
#aichat .aichat-source-summary-icon { color: var(--ac-amber-deep); font-size: 16px; line-height: 1; }
#aichat .aichat-source-summary-text strong { font-weight: 600; color: var(--ac-ink); }
#aichat .aichat-source-summary-count { margin-left: 4px; }

#aichat .aichat-sources { align-self: flex-start; width: 94%; overflow: hidden; background: var(--ac-surface); border: 1px solid var(--ac-line); border-radius: var(--ac-radius-md); }
#aichat .aichat-sources-head { width: 100%; display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 10px; text-align: left; transition: background .15s ease; }
#aichat .aichat-sources-head:hover { background: var(--ac-hover); }
#aichat .aichat-sources-icon {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    font-size: 16px;
    line-height: 1;
    color: var(--ac-amber-deep);
    background: var(--ac-chip);
    border-radius: 9px;
}
#aichat .aichat-sources-head-copy { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
#aichat .aichat-sources-head-copy strong { font-size: 12.5px; font-weight: 600; color: var(--ac-ink); line-height: 1.3; }
#aichat .aichat-sources-head-copy small { font-size: 11px; color: var(--ac-muted); line-height: 1.3; }
#aichat .aichat-sources-toggle { flex: 0 0 auto; font-size: 16px; line-height: 1; color: var(--ac-muted); transition: transform .2s ease; }
#aichat .aichat-sources.is-expanded .aichat-sources-toggle { transform: rotate(180deg); }
#aichat .aichat-sources-list { border-top: 1px solid var(--ac-line); }
#aichat .aichat-source-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px 9px 10px; color: inherit; text-decoration: none; }
#aichat .aichat-source-item + .aichat-source-item { border-top: 1px solid var(--ac-line-2); }
#aichat a.aichat-source-item:hover { background: var(--ac-hover); }
#aichat .aichat-source-number {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ac-ink);
    background: var(--ac-primary);
    border-radius: 50%;
}
#aichat .aichat-source-copy { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
#aichat .aichat-source-copy strong { font-size: 12.5px; font-weight: 600; line-height: 1.35; color: var(--ac-ink); overflow-wrap: anywhere; }
#aichat .aichat-source-copy small { margin-top: 1px; font-size: 11px; line-height: 1.35; color: var(--ac-muted); overflow-wrap: anywhere; }
#aichat .aichat-source-open { flex: 0 0 auto; font-size: 18px; line-height: 1; color: var(--ac-primary-l); }

/* ==========================================================================
   4. FORM TƯ VẤN (LEAD)
   ========================================================================== */
#aichat .aichat-lead-card { padding: 16px 14px 14px; background: var(--ac-surface); border: 1px solid var(--ac-line); border-radius: var(--ac-radius-lg); box-shadow: var(--ac-shadow-card); animation: aichat-rise .25s ease both; }
#aichat .aichat-lead-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--ac-line); }
#aichat .aichat-lead-icon {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    font-size: 17px;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l), var(--ac-primary));
    border-radius: 12px;
    box-shadow: 0 8px 14px -8px var(--ac-primary-glow);
}
#aichat .aichat-lead-head strong { display: block; font-size: 15px; font-weight: 700; color: var(--ac-ink); }
#aichat .aichat-lead-head small { display: block; margin-top: 1px; font-size: 12px; line-height: 1.4; color: var(--ac-muted); }
#aichat .aichat-lead-form { display: flex; flex-direction: column; gap: 11px; }
#aichat .aichat-lead-form > label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ac-ink); }
#aichat .aichat-lead-form > label input,
#aichat .aichat-lead-form > label textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 0;
    line-height: 1.4;
    color: var(--ac-ink);
    background: var(--ac-bg);
    border: 1px solid var(--ac-line);
    border-radius: 12px;
    box-shadow: none;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
#aichat .aichat-lead-form > label textarea { min-height: 62px; resize: vertical; }
#aichat .aichat-lead-form > label input::placeholder,
#aichat .aichat-lead-form > label textarea::placeholder { color: var(--ac-faint); }
#aichat .aichat-lead-form > label input:focus,
#aichat .aichat-lead-form > label textarea:focus { background: #fff; border-color: var(--ac-amber-deep); box-shadow: 0 0 0 3px rgba(234, 183, 65, .16); outline: none; }
#aichat .aichat-contact-method { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
#aichat .aichat-contact-method > span { flex: 1 0 100%; font-size: 12px; font-weight: 600; letter-spacing: .02em; color: var(--ac-ink); }
#aichat .aichat-contact-method label { position: relative; flex: 1 1 0; cursor: pointer; }
#aichat .aichat-contact-method input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
#aichat .aichat-contact-method b {
    display: block;
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 500;
    text-align: center;
    color: var(--ac-ink);
    background: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: 12px;
    transition: background .15s ease, border-color .15s ease;
}
#aichat .aichat-contact-method input:checked + b { font-weight: 700; color: var(--ac-amber-deep); background: var(--ac-chip); border-color: var(--ac-amber-deep); }
#aichat .aichat-contact-method input:focus-visible + b { outline: 2px solid var(--ac-primary); outline-offset: 2px; }
#aichat .aichat-lead-error { padding: 8px 12px; font-size: 12.5px; line-height: 1.4; color: #b42318; background: #fff1f0; border: 1px solid #ffd3d0; border-radius: 10px; }
#aichat .aichat-lead-error:empty { display: none; }
#aichat .aichat-lead-submit {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .01em;
    text-align: center;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l) 0%, var(--ac-primary) 100%);
    border-radius: 12px;
    box-shadow: 0 12px 20px -12px var(--ac-primary-glow);
    transition: filter .15s ease, transform .15s ease, opacity .15s ease;
}
#aichat .aichat-lead-submit:hover { filter: brightness(1.06); }
#aichat .aichat-lead-submit:active { transform: scale(.985); }
#aichat .aichat-lead-submit:disabled { opacity: .55; cursor: progress; box-shadow: none; }
#aichat .aichat-privacy { display: block; font-size: 11px; line-height: 1.4; text-align: center; color: var(--ac-faint); }

#aichat .aichat-lead-card.is-success { background: #f2fbf6; border-color: #c9e8d6; }
#aichat .aichat-lead-success { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px 10px; text-align: center; }
#aichat .aichat-lead-success span { width: 40px; height: 40px; display: grid; place-items: center; margin-bottom: 4px; font-size: 19px; font-weight: 700; color: #fff; background: var(--ac-call); border-radius: 50%; }
#aichat .aichat-lead-success strong { font-size: 15px; font-weight: 700; color: #165c39; }
#aichat .aichat-lead-success p { font-size: 12.5px; line-height: 1.5; color: #3f6a55; }

#aichat .aichat-direct-contact { display: flex; gap: 8px; margin-top: 10px; }
#aichat .aichat-direct-contact button {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--ac-ink);
    background: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: 12px;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
#aichat .aichat-direct-contact button:hover { background: var(--ac-hover); border-color: var(--ac-amber-deep); }
#aichat .aichat-direct-contact button:active { transform: scale(.97); }
#aichat .aichat-direct-contact .zalo span { width: 20px; height: 20px; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: #0068ff; border-radius: 6px; }
#aichat .aichat-direct-contact .phone span { font-size: 15px; line-height: 1; color: var(--ac-call); }

#aichat .aichat-contact-prompt {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 12px 12px 15px;
    background: linear-gradient(150deg, #ffffff 0%, var(--ac-chip) 100%);
    border: 1px solid var(--ac-primary-hair);
    border-radius: var(--ac-radius-md);
    animation: aichat-rise .25s ease both;
}
#aichat .aichat-contact-prompt strong { display: block; font-size: 13px; font-weight: 700; line-height: 1.4; color: var(--ac-ink); }
#aichat .aichat-contact-prompt small { display: block; margin-top: 1px; font-size: 11.5px; color: var(--ac-muted); }
#aichat .aichat-contact-prompt button { flex: 0 0 auto; padding: 8px 14px; font-size: 12.5px; font-weight: 700; color: var(--ac-ink); background: var(--ac-primary); border-radius: 10px; white-space: nowrap; }
#aichat .aichat-contact-prompt button:hover { background: var(--ac-primary-d); }

/* ==========================================================================
   5. LAUNCHER (mascot cố định + menu hỗ trợ dạng quạt)
   Hình học khớp viewBox 344×230 của SVG connectors trong chatbot.js:
   tâm hub (260,138) = tâm nút mascot; 4 node tại x=200, y=40/91/142/193.
   ========================================================================== */
#aichat .aichat-launcher-wrap {
    position: fixed;
    right: 14px;
    bottom: var(--chatbot-safe-bottom, 94px);
    z-index: 999990;
    width: 92px;
    height: 92px;
    transition: opacity .2s ease, visibility 0s linear 0s;
}
#aichat.is-open .aichat-launcher-wrap,
#aichat.legacy-support-open .aichat-launcher-wrap,
#aichat.zalo-window-open .aichat-launcher-wrap { opacity: 0; visibility: hidden; pointer-events: none; }
#aichat.zalo-window-open .aichat-panel { opacity: 0; visibility: hidden; pointer-events: none; }

/* Nút mascot */
#aichat .aichat-toggle { position: relative; z-index: 3; display: block; width: 92px; height: 92px; border-radius: 50%; transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
#aichat .aichat-toggle:hover { transform: translateY(-3px); }
#aichat .aichat-toggle:active { transform: scale(.96); }
#aichat .aichat-mascot-stage { position: absolute; inset: 0; display: block; }
#aichat .aichat-mascot-glow { display: none; }
/* bóng dưới chân: co lại khi mascot bay lên, to ra khi hạ xuống */
#aichat .aichat-mascot-stage::after {
    content: "";
    position: absolute;
    left: 26%;
    right: 26%;
    bottom: -4px;
    height: 9px;
    border-radius: 50%;
    background: radial-gradient(closest-side, rgba(150, 100, 8, .32), rgba(150, 100, 8, 0));
    animation: aichat-float-shadow 3.4s ease-in-out infinite;
    pointer-events: none;
}
#aichat .aichat-mascot-image {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    filter: drop-shadow(0 6px 8px rgba(160, 108, 10, .28));
    user-select: none;
    -webkit-user-drag: none;
    animation: aichat-float 3.4s ease-in-out infinite;
    will-change: transform;
}
#aichat .aichat-mascot-fallback {
    position: absolute;
    inset: 8px;
    display: grid;
    place-items: center;
    font-size: 14px;
    font-weight: 800;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l), var(--ac-primary-d));
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: 0 10px 20px -8px var(--ac-primary-glow);
}

/* Chấm chưa đọc */
#aichat .aichat-unread { position: absolute; top: 8px; right: 10px; z-index: 2; width: 13px; height: 13px; background: var(--ac-danger); border: 2px solid #fff; border-radius: 50%; opacity: 0; transform: scale(.4); transition: opacity .15s ease, transform .2s ease; }
#aichat .aichat-unread.is-visible { opacity: 1; transform: scale(1); }

/* Nhãn "Tư vấn cùng I-WEB" */
#aichat .aichat-launcher-label {
    position: absolute;
    right: 98px;
    bottom: 29px;
    z-index: 4;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 34px;
    padding: 0 12px 0 13px;
    font-size: 12.5px;
    font-weight: 700;
    letter-spacing: .01em;
    white-space: nowrap;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l) 0%, var(--ac-primary) 100%);
    border: 1px solid rgba(255, 255, 255, .5);
    border-radius: 17px;
    box-shadow: 0 12px 22px -12px var(--ac-primary-glow);
    transition: right .28s cubic-bezier(.2, .8, .2, 1), bottom .28s cubic-bezier(.2, .8, .2, 1), filter .15s ease;
}
#aichat .aichat-launcher-label:hover { filter: brightness(1.06); }
#aichat .aichat-launcher-label i { font-style: normal; color: #fff; font-size: 12px; }
#aichat .aichat-label-chevron { display: inline-block; font-weight: 700; font-size: 14px; line-height: 1;transition: transform .25s ease; }
#aichat.support-expanded .aichat-launcher-label { right: 106px; bottom: 176px; }
#aichat.support-expanded .aichat-label-chevron { transform: rotate(180deg); margin-top: 2px; }

/* Menu hỗ trợ */
#aichat .aichat-support-menu { position: absolute; right: 106px; bottom: -31px; z-index: 3; width: 188px; height: 197px; pointer-events: none; }
#aichat.support-expanded .aichat-support-menu { pointer-events: auto; }
#aichat .aichat-support-item {
    position: absolute;
    right: 0;
    left: 0;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px 0 7px;
    text-align: left;
    color: var(--ac-ink);
    background: var(--ac-surface);
    border: 1px solid var(--ac-line);
    border-radius: 22px;
    box-shadow: 0 12px 22px -14px rgba(201, 138, 18, .55);
    opacity: 0;
    visibility: hidden;
    transform: translateX(16px) scale(.95);
    transition: opacity .2s ease, transform .28s cubic-bezier(.2, .8, .2, 1), visibility 0s linear .28s, border-color .15s ease, background .15s ease;
}
#aichat .aichat-support-item[data-support="services"] { top: 0; }
#aichat .aichat-support-item[data-support="zalo"] { top: 51px; }
#aichat .aichat-support-item[data-support="phone"] { top: 102px; }
#aichat .aichat-support-item[data-support="lead"] { top: 153px; }
#aichat.support-expanded .aichat-support-item { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
#aichat.support-expanded .aichat-support-item[data-support="phone"] { transition-delay: .04s; }
#aichat.support-expanded .aichat-support-item[data-support="lead"] { transition-delay: .08s; }
#aichat.support-expanded .aichat-support-item[data-support="zalo"] { transition-delay: .12s; }
#aichat.support-expanded .aichat-support-item[data-support="services"] { transition-delay: .16s; }
#aichat .aichat-support-item:hover,
#aichat .aichat-support-item.is-native-hover { background: var(--ac-hover); border-color: var(--ac-amber-deep); }
/* 4 icon đồng bộ: vòng tròn sapphire + nét trắng */
#aichat .aichat-support-icon {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: .02em;
    color: var(--ac-ink);
    background: linear-gradient(160deg, var(--ac-primary-l), var(--ac-primary));
    border-radius: 50%;
}
#aichat .aichat-support-icon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#aichat .aichat-support-item strong { flex: 1 1 auto; font-size: 13px; font-weight: 700; white-space: nowrap; }
#aichat .aichat-support-arrow { flex: 0 0 auto; font-size: 18px; line-height: 1; color: var(--ac-primary-l); }

/* Đường nối quạt */
#aichat .aichat-support-connectors { position: absolute; right: -38px; bottom: -46px; z-index: 2; width: 344px; height: 230px; overflow: visible; pointer-events: none; }
#aichat .support-path { fill: none; stroke: #e2b24a; stroke-width: 1.4; stroke-linecap: round; stroke-dasharray: 160; stroke-dashoffset: 160; opacity: 0; transition: stroke-dashoffset .45s ease, opacity .25s ease; }
#aichat .support-node { fill: #fff; stroke: var(--ac-primary); stroke-width: 1.8; opacity: 0; transition: opacity .25s ease; }
#aichat .support-node.hub-node { fill: var(--ac-gold); stroke: #fff; }
#aichat.support-expanded .support-path { stroke-dashoffset: 0; opacity: .9; }
#aichat.support-expanded .support-node { opacity: 1; }
#aichat:not(.has-support-zalo) .path-zalo,
#aichat:not(.has-support-zalo) .node-zalo,
#aichat:not(.has-support-phone) .path-phone,
#aichat:not(.has-support-phone) .node-phone,
#aichat:not(.has-support-lead) .path-lead,
#aichat:not(.has-support-lead) .node-lead { display: none; }

/* ==========================================================================
   6. MOBILE (≤ 640px): panel toàn màn hình + tab Dịch vụ / Trò chuyện
   ========================================================================== */
@media (max-width: 640px) {
    #aichat .aichat-panel {
        inset: 0;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        transform-origin: 50% 100%;
        transform: translateY(24px);
    }
    #aichat .aichat-panel.is-open { transform: none; }
    #aichat .aichat-head { padding-top: calc(15px + env(safe-area-inset-top, 0px)); }
    #aichat .aichat-restart b { display: none; }
    #aichat .aichat-restart { width: 32px; padding: 0; }

    #aichat .aichat-mobile-tabs { flex: 0 0 auto; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 10px 12px 0; padding: 4px; background: #f8ecc8; border-radius: 14px; }
    #aichat .aichat-tab { height: 36px; font-size: 13px; font-weight: 500; text-align: center; color: var(--ac-muted); border-radius: 11px; transition: background .15s ease, color .15s ease; }
    #aichat .aichat-tab.is-selected { font-weight: 700; color: var(--ac-ink); background: linear-gradient(160deg, var(--ac-primary-l), var(--ac-primary)); box-shadow: 0 8px 14px -8px var(--ac-primary-glow); }

    #aichat .aichat-composer { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
    #aichat .aichat-input { font-size: 16px; }   /* tránh iOS tự zoom */
    #aichat .aichat-hint { display: none; }
    #aichat .aichat-new-message { bottom: calc(72px + env(safe-area-inset-bottom, 0px)); }

    #aichat .aichat-msg.user { max-width: 88%; }
    #aichat .aichat-msg-wrap { max-width: 96%; }

    #aichat .aichat-launcher-wrap { right: 10px; width: 80px; height: 80px; }
    #aichat .aichat-toggle { width: 80px; height: 80px; }
    #aichat .aichat-launcher-label { right: 88px; bottom: 23px; }
    #aichat.support-expanded .aichat-launcher-label { right: 96px; bottom: 170px; }
    /* tâm mascot dịch vào 6px → dịch menu/connector tương ứng */
    #aichat .aichat-support-menu { right: 100px; bottom: -37px; }
    #aichat .aichat-support-connectors { right: -44px; bottom: -52px; }
}
@media (max-width: 640px) {
    body.aichat-open { overflow: hidden !important; touch-action: none; overscroll-behavior: none; }
    #aichat .aichat-messages,
    #aichat .aichat-catalog { touch-action: pan-y; }
}
@media (max-width: 380px) {
    #aichat .aichat-actions { grid-template-columns: 1fr; }
    #aichat .aichat-welcome h3 { font-size: 21px; }
    #aichat .aichat-mascot,
    #aichat .aichat-mascot-card-stage { width: 96px; height: 96px; }
}

/* ==========================================================================
   7. ANIMATION + REDUCED MOTION
   ========================================================================== */
@keyframes aichat-float {
    0%, 100% { transform: translateY(0) rotate(-1.2deg); }
    50% { transform: translateY(-8px) rotate(1.2deg); }
}
@keyframes aichat-float-shadow {
    0%, 100% { transform: scale(1); opacity: .95; }
    50% { transform: scale(.74); opacity: .5; }
}
@keyframes aichat-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes aichat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-3px); opacity: 1; } }
@keyframes aichat-pulse { 0% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85), 0 0 0 2px rgba(37, 168, 105, .55); } 70%, 100% { box-shadow: 0 0 0 2px rgba(255, 255, 255, .85), 0 0 0 5px rgba(37, 168, 105, 0); } }

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