.tool-ai-assistant-wrapper {
    margin-top: 32px;
    margin-bottom: 32px;
}

.tool-ai-assistant-wrapper .section-title {
    display: none;
}

.tool-ai-widget {
    --tai-card-bg: var(--card-bg, #111827);
    --tai-card-overlay: color-mix(in srgb, var(--accent-blue, #3b82f6) 14%, transparent);
    --tai-card-border: color-mix(in srgb, var(--accent-blue, #3b82f6) 20%, transparent);
    --tai-card-shadow: 0 24px 48px -32px color-mix(in srgb, var(--primary-bg, #0f172a) 68%, transparent);
    --tai-text-primary: var(--text-primary, #f8fafc);
    --tai-text-secondary: var(--text-secondary, rgba(148, 163, 184, 0.85));
    --tai-text-muted: color-mix(in srgb, var(--text-secondary, rgba(148, 163, 184, 0.85)) 65%, transparent);
    --tai-accent: var(--accent-blue, #3b82f6);
    --tai-accent-strong: var(--accent-purple, #6366f1);
    --tai-chip-bg: color-mix(in srgb, var(--tai-accent) 12%, transparent);
    --tai-chip-border: color-mix(in srgb, var(--tai-accent) 30%, transparent);
    --tai-input-bg: var(--input-bg, rgba(15, 23, 42, 0.86));
    --tai-input-border: var(--input-border, rgba(148, 163, 255, 0.22));
    --tai-input-focus: var(--input-focus, var(--tai-accent));

    border: 1px solid var(--tai-card-border, rgba(79, 119, 233, 0.18));
    border-radius: 18px;
    background: var(--tai-card-bg);
    box-shadow: var(--tai-card-shadow);
    padding: 24px 26px;
    transition: box-shadow 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
    position: relative;
    overflow: hidden;
    color: var(--tai-text-primary);
}

@supports not (color-mix(in srgb, red 50%, blue 50%)) {
    .tool-ai-widget {
        --tai-card-overlay: rgba(79, 119, 233, 0.12);
        --tai-card-border: rgba(79, 119, 233, 0.15);
        --tai-text-muted: rgba(226, 232, 255, 0.6);
        --tai-chip-bg: rgba(56, 189, 248, 0.12);
        --tai-chip-border: rgba(125, 211, 252, 0.3);
        --tai-input-bg: rgba(15, 23, 42, 0.82);
        --tai-input-border: rgba(148, 163, 255, 0.22);
        --tai-input-focus: rgba(56, 189, 248, 0.8);
    }
}

.tool-ai-widget::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(140deg, var(--tai-card-overlay, transparent) 0%, transparent 65%);
    pointer-events: none;
}

.tool-ai-widget .tai-loading-state {
    font-size: 14px;
    color: var(--tai-text-muted);
}

.tool-ai-widget .tai-inner {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.tool-ai-widget .tai-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.tool-ai-widget .tai-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    color: var(--tai-text-primary);
    letter-spacing: 0.01em;
}

.tool-ai-widget .tai-subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--tai-text-muted);
    line-height: 1.5;
}

.tool-ai-widget .tai-history {
    background: color-mix(in srgb, var(--tai-card-bg) 92%, var(--tai-card-overlay) 8%);
    border: none;
    border-radius: 14px;
    padding: 18px 20px;
    max-height: 720px;
    overflow-y: auto;
    backdrop-filter: blur(6px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
}

@supports not (color-mix(in srgb, red 50%, blue 50%)) {
    .tool-ai-widget .tai-history {
        background: rgba(15, 23, 42, 0.65);
        border: 1px solid rgba(148, 163, 255, 0.22);
    }
}

.tool-ai-widget .tai-history::-webkit-scrollbar {
    width: 6px;
}

.tool-ai-widget .tai-history::-webkit-scrollbar-thumb {
    background: color-mix(in srgb, var(--tai-card-border) 45%, transparent);
    border-radius: 4px;
}

.tool-ai-widget .tai-history.tai-history-empty {
    border-color: transparent;
    background: transparent;
    box-shadow: none;
}

.tool-ai-widget .tai-history.tai-history-awaiting {
    border-color: transparent;
    box-shadow: none;
}

.tool-ai-widget .tai-placeholder {
    font-size: 13px;
    color: var(--tai-text-muted);
    text-align: center;
}

.tool-ai-widget .tai-message {
    margin-bottom: 10px;
    display: flex;
    gap: 12px;
}

.tool-ai-widget .tai-message:last-child {
    margin-bottom: 0;
}

.tool-ai-widget .tai-message .tai-avatar {
    width: 32px;
    height: 32px;
.tool-ai-widget .tai-message-loading .tai-avatar {
    background: linear-gradient(135deg, #38bdf8, #6366f1);
    border-color: rgba(148, 163, 255, 0.5);
}

.tool-ai-widget .tai-message-loading .tai-message-body {
    width: 100%;
    text-align: center;
    font-style: italic;
    opacity: 0.9;
}

.tool-ai-widget .tai-message-loading {
    margin-top: 6px;
}

.tool-ai-widget .tai-message-loading:first-child {
    margin-top: 0;
}

.tool-ai-widget .tai-thinking-indicator {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}

.tool-ai-widget .tai-thinking-bubble {
    display: inline-flex;
    gap: 10px;
    padding: 10px 20px;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.15);
    border: 1px solid rgba(125, 211, 252, 0.4);
    box-shadow: inset 0 0 12px rgba(56, 189, 248, 0.25), 0 10px 30px -20px rgba(59, 130, 246, 0.6);
    animation: tai-breathe 2s ease-in-out infinite;
}

.tool-ai-widget .tai-thinking-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(125, 211, 252, 0.9);
    animation: tai-bounce 1.2s infinite ease-in-out !important;
}

.tool-ai-widget .tai-thinking-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.tool-ai-widget .tai-thinking-dot:nth-child(3) {
    animation-delay: 0.3s;
}

.tool-ai-widget .tai-thinking-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: rgba(191, 219, 254, 0.95);
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

@keyframes tai-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40% { transform: translateY(-8px); opacity: 1; }
}

@keyframes tai-breathe {
    0%, 100% { opacity: 0.6; transform: scale(0.96); }
    50% { opacity: 1; transform: scale(1); }
}

    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: var(--tai-text-primary);
    flex-shrink: 0;
    box-shadow: 0 12px 32px -18px rgba(15, 23, 42, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.45);
    overflow: hidden;
}

.tool-ai-widget .tai-message-user .tai-avatar {
    background: linear-gradient(135deg, var(--accent-orange, #f97316), #facc15);
}

.tool-ai-widget .tai-message-assistant .tai-avatar {
    background: linear-gradient(135deg, var(--tai-accent), var(--tai-accent-strong));
}

.tool-ai-widget .tai-message-error .tai-avatar {
    background: linear-gradient(135deg, #f87171, #ef4444);
}

.tool-ai-widget .tai-avatar.tai-avatar-ai {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 255, 0.45);
}

.tool-ai-widget .tai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.tool-ai-widget .tai-message-body {
    flex: 1;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(148, 163, 255, 0.18);
    color: #e2e8f0;
}

.tool-ai-widget .tai-message-loading .tai-message-body {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 10px 0;
}


@supports not (color-mix(in srgb, red 50%, blue 50%)) {
    .tool-ai-widget .tai-message-body {
        background: rgba(15, 23, 42, 0.6);
        border: 1px solid rgba(148, 163, 255, 0.18);
    }
}

.tool-ai-widget .tai-message-user .tai-message-body {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.25);
    color: #f8fafc;
}

.tool-ai-widget .tai-message-assistant .tai-message-body {
    background: rgba(30, 41, 59, 0.75);
    border-color: rgba(99, 102, 241, 0.35);
    color: #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tool-ai-widget .tai-message-error .tai-message-body {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.16), rgba(239, 68, 68, 0.12));
    border-color: rgba(248, 113, 113, 0.28);
    color: #fee2e2;
}

.tool-ai-widget .tai-message-content {
    font-size: 14px;
    color: #e2e8f0;
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
}

.tool-ai-widget .tai-summary {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 10px;
    color: #f1f5f9;
}

.tool-ai-widget .tai-block {
    margin-top: 12px;
    border-top: 1px solid rgba(148, 163, 255, 0.15);
    padding-top: 12px;
}

.tool-ai-widget .tai-block-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: rgba(191, 219, 254, 0.88);
    letter-spacing: 0.01em;
}

.tool-ai-widget ul.tai-list {
    padding-left: 18px;
    margin: 0;
    display: grid;
    gap: 6px;
}

.tool-ai-widget ul.tai-list li {
    font-size: 13px;
    color: rgba(226, 232, 255, 0.82);
    line-height: 1.55;
}

.tool-ai-widget .tai-related-list,
.tool-ai-widget .tai-reference-list {
    display: grid;
    gap: 6px;
}

.tool-ai-widget .tai-related-item,
.tool-ai-widget .tai-reference-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    background: rgba(56, 189, 248, 0.08);
    border: 1px solid rgba(125, 211, 252, 0.25);
    border-radius: 10px;
    padding: 8px 10px;
    color: rgba(226, 232, 255, 0.82);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.tool-ai-widget .tai-reference-item {
    background: rgba(79, 70, 229, 0.12);
    border-color: rgba(129, 140, 248, 0.32);
}

.tool-ai-widget .tai-related-item:hover,
.tool-ai-widget .tai-reference-item:hover {
    background: rgba(56, 189, 248, 0.16);
    border-color: rgba(125, 211, 252, 0.45);
    transform: translateY(-1px);
}

.tool-ai-widget .tai-reference-item:hover {
    background: rgba(99, 102, 241, 0.22);
    border-color: rgba(165, 180, 252, 0.5);
}

.tool-ai-widget .tai-related-item a,
.tool-ai-widget .tai-reference-item a {
    color: inherit;
    text-decoration: none;
}

.tool-ai-widget .tai-related-item a:hover,
.tool-ai-widget .tai-reference-item a:hover {
    text-decoration: underline;
}

.tool-ai-widget .tai-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 2px;
    overflow: visible;
    padding-bottom: 0;
}

.tool-ai-widget .tai-footer::after {
    content: '';
    display: block;
    width: 100%;
}

.tool-ai-widget .tai-suggestion-btn {
    border: 1px solid rgba(125, 211, 252, 0.35);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 13px;
    background: rgba(56, 189, 248, 0.12);
    color: rgba(240, 249, 255, 0.88);
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(6px);
    box-shadow: 0 12px 24px -20px rgba(14, 165, 233, 0.65);
    white-space: nowrap;
}

.tool-ai-widget .tai-suggestion-btn:hover {
    background: rgba(56, 189, 248, 0.2);
    border-color: rgba(125, 211, 252, 0.55);
    transform: translateY(-1px);
}

.tool-ai-widget .tai-footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tool-ai-widget .tai-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-ai-widget .tai-input-control {
    flex: 1;
    border: 1px solid rgba(148, 163, 255, 0.22);
    border-radius: 14px;
    padding: 14px 16px;
    min-height: 46px;
    resize: none;
    font-size: 14px;
    line-height: 1.4;
    color: #e2e8f0;
    background: rgba(15, 23, 42, 0.82);
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.tool-ai-widget .tai-input-control::-webkit-scrollbar {
    width: 6px;
}

.tool-ai-widget .tai-input-control::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.35);
    border-radius: 10px;
}

.tool-ai-widget .tai-input-control::-webkit-scrollbar-thumb {
    background: rgba(99, 102, 241, 0.55);
    border-radius: 10px;
}

.tool-ai-widget .tai-input-control::-webkit-scrollbar-thumb:hover {
    background: rgba(99, 102, 241, 0.8);
}

.tool-ai-widget .tai-input-control::placeholder {
    color: rgba(203, 213, 225, 0.55);
}

.tool-ai-widget .tai-input-control:focus {
    border-color: rgba(148, 163, 255, 0.5);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.18);
    outline: none;
    background: rgba(15, 23, 42, 0.9);
}

.tool-ai-widget .tai-send-btn {
    min-width: 96px;
    height: 48px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, #f97316 0%, #f43f5e 50%, #a855f7 100%);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 24px 48px -18px rgba(244, 63, 94, 0.55);
}

.tool-ai-widget .tai-send-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 28px 56px -20px rgba(244, 63, 94, 0.65);
}

.tool-ai-widget .tai-send-btn:disabled {
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
    box-shadow: none;
}

.tool-ai-widget .tai-send-btn.loading {
    color: transparent;
    position: relative;
    pointer-events: none;
}

.tool-ai-widget .tai-send-btn.loading::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #ffffff;
    animation: tai-send-spin 0.8s linear infinite;
}

@keyframes tai-send-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.tool-ai-widget .tai-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: rgba(216, 225, 255, 0.5);
    flex-wrap: wrap;
    gap: 8px;
}

.tool-ai-widget .tai-loading {
    display: none;
    align-items: center;
    gap: 8px;
    color: rgba(125, 211, 252, 0.8);
    font-weight: 500;
}

.tool-ai-widget .tai-loading.active {
    display: inline-flex;
}

.tool-ai-widget .tai-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid rgba(125, 211, 252, 0.35);
    border-top-color: rgba(56, 189, 248, 0.9);
    animation: tai-spin 0.8s linear infinite;
}

.tool-ai-widget .tai-spinner-inline {
    width: 18px;
    height: 18px;
    border-width: 2px;
}

@keyframes tai-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@media (max-width: 768px) {
    .tool-ai-widget .tai-message {
        flex-direction: column;
        align-items: flex-start;
    }

    .tool-ai-widget .tai-message .tai-avatar {
        width: 28px;
        height: 28px;
        margin-bottom: 6px;
    }

    .tool-ai-widget .tai-message-body {
        width: 100%;
    }

    .tool-ai-assistant-wrapper {
        margin-top: 24px;
        margin-bottom: 24px;
    }

    .tool-ai-widget {
        padding: 18px;
    }

    .tool-ai-widget .tai-history {
        max-height: 260px;
    }

    .tool-ai-widget .tai-suggestions {
        gap: 2px;
        margin-bottom: 0;
    }

    .tool-ai-widget .tai-suggestion-btn {
        padding: 5px 10px;
        font-size: 12px;
    }
}

html[data-theme='light'] .tool-ai-widget {
    --tai-card-bg: var(--primary-bg, #ffffff);
    --tai-card-overlay: rgba(148, 163, 184, 0.08);
    --tai-card-border: rgba(203, 213, 225, 0.9);
    --tai-text-primary: #111827;
    --tai-text-secondary: rgba(17, 24, 39, 0.7);
    --tai-input-bg: #ffffff;
    --tai-input-border: rgba(148, 163, 184, 0.7);
    --tai-input-focus: rgba(99, 102, 241, 0.4);
    color: var(--tai-text-primary);
    border-color: rgba(203, 213, 225, 0.6);
    box-shadow: 0 18px 48px -32px rgba(15, 23, 42, 0.25);
}

html[data-theme='light'] .tool-ai-widget .tai-history {
    background: rgba(255, 255, 255, 0.8);
    border: none;
    box-shadow: none;
}

html[data-theme='light'] .tool-ai-widget .tai-history.tai-history-empty,
html[data-theme='light'] .tool-ai-widget .tai-history.tai-history-awaiting {
    border-color: transparent;
    box-shadow: none;
    background: transparent;
}

html[data-theme='light'] .tool-ai-widget .tai-history::before,
html[data-theme='light'] .tool-ai-widget .tai-history::after {
    display: none;
}


html[data-theme='light'] .tool-ai-widget .tai-message-body {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(203, 213, 225, 0.9);
    box-shadow: 0 12px 28px -24px rgba(15, 23, 42, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.8);
    color: #111827;
}

html[data-theme='light'] .tool-ai-widget .tai-message-loading .tai-message-body {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

html[data-theme='light'] .tool-ai-widget .tai-message-assistant .tai-message-body {
    background: rgba(238, 242, 255, 0.9);
    border-color: rgba(148, 163, 184, 0.8);
}

html[data-theme='light'] .tool-ai-widget .tai-message-content {
    color: #0f172a;
}

html[data-theme='light'] .tool-ai-widget .tai-title,
html[data-theme='light'] .tool-ai-widget .tai-subtitle,
html[data-theme='light'] .tool-ai-widget .tai-meta,
html[data-theme='light'] .tool-ai-widget .tai-block-title,
html[data-theme='light'] .tool-ai-widget .tai-list li {
    color: #111827;
}

html[data-theme='light'] .tool-ai-widget .tai-summary {
    color: #0f172a;
}

html[data-theme='light'] .tool-ai-widget .tai-message-user .tai-avatar {
    background: linear-gradient(135deg, #facc15, #fb923c);
    border-color: rgba(251, 191, 36, 0.6);
}

html[data-theme='light'] .tool-ai-widget .tai-input-control {
    background: rgba(255, 255, 255, 0.95);
    border-color: var(--tai-input-border);
    color: #0f172a;
    box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.05);
}

html[data-theme='light'] .tool-ai-widget .tai-input-control:focus {
    border-color: var(--tai-input-focus);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.18);
}

html[data-theme='light'] .tool-ai-widget .tai-send-btn {
    background: linear-gradient(135deg, #4f46e5, #6366f1, #8b5cf6);
    box-shadow: 0 16px 34px -18px rgba(79, 70, 229, 0.45);
    color: #f8fafc;
}

html[data-theme='light'] .tool-ai-widget .tai-send-btn.loading::after {
    border-color: rgba(79, 70, 229, 0.25);
    border-top-color: #4f46e5;
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.12);
}

html[data-theme='light'] .tool-ai-widget .tai-suggestion-btn {
    border-color: rgba(148, 163, 184, 0.4);
    background: rgba(148, 163, 184, 0.15);
    color: #111827;
}

html[data-theme='light'] .tool-ai-widget .tai-suggestion-btn:hover {
    background: rgba(148, 163, 184, 0.28);
    border-color: rgba(99, 102, 241, 0.45);
}

html[data-theme='light'] .tool-ai-widget .tai-related-item,
html[data-theme='light'] .tool-ai-widget .tai-reference-item {
    background: rgba(148, 163, 184, 0.12);
    border-color: rgba(148, 163, 184, 0.4);
    color: #111827;
}

html[data-theme='light'] .tool-ai-widget .tai-related-item a,
html[data-theme='light'] .tool-ai-widget .tai-reference-item a {
    color: #111827;
}

html[data-theme='light'] .tool-ai-widget .tai-thinking-bubble {
    background: rgba(99, 102, 241, 0.14);
    border: 1px solid rgba(99, 102, 241, 0.35);
    box-shadow: 0 10px 30px -24px rgba(99, 102, 241, 0.45);
}

html[data-theme='light'] .tool-ai-widget .tai-thinking-dot {
    background: linear-gradient(135deg, #4f46e5, #3b82f6);
}

html[data-theme='light'] .tool-ai-widget .tai-thinking-text {
    color: rgba(79, 70, 229, 0.95);
}

