/* AI Assistant Styles */
.ai-assistant-container {
    position: fixed;
    right: calc(2rem + 3.75rem);
    bottom: calc(2rem + 0.75rem + 40px);
    width: min(360px, calc(100vw - 4rem));
    height: 540px;
    max-height: min(80vh, calc(100vh - 3.5rem));
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.72), rgba(244, 247, 252, 0.68));
    box-shadow:
        0 8px 32px rgba(15, 23, 42, 0.12),
        0 2px 8px rgba(15, 23, 42, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.5);
    z-index: 1100;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 20px;
    transform: translateY(calc(100% + 1.5rem)) scale(0.94);
    opacity: 0;
    transition: transform 0.32s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.24s ease;
    pointer-events: none;
    backdrop-filter: blur(24px) saturate(180%);
    -webkit-backdrop-filter: blur(24px) saturate(180%);
    /* 排除 AI assistant 容器参与 view transition，避免主题切换时闪烁 */
    /* Exclude AI assistant container from view transitions to avoid flicker during theme changes */
    view-transition-name: none;
}

.ai-assistant-container.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: all;
}


.ai-assistant-header {
    padding: 16px 20px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, rgba(240, 244, 250, 0.4) 100%);
    color: var(--text-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    gap: 12px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.ai-assistant-header { cursor: grab; }
.ai-assistant-header.dragging { cursor: grabbing; }

.ai-assistant-header::before {
    content: none;
}

.ai-assistant-header::after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(59, 130, 246, 0.25), transparent);
}

.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1;
}

.ai-header-icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.24);
    background: rgba(248, 250, 252, 0.7);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.ai-header-icon-btn svg {
    width: 18px;
    height: 18px;
}

.ai-header-icon-btn:hover {
    transform: translateY(-1px);
    background: rgba(236, 244, 255, 0.92);
    color: var(--accent-primary);
    border-color: rgba(59, 130, 246, 0.32);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.18);
}

.ai-header-icon-btn:active {
    transform: translateY(0);
}

.ai-assistant-header h3 {
    margin: 0;
    font-size: 1.12rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1;
    flex: 1;
}

.ai-assistant-header .ai-status {
    width: 9px;
    height: 9px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.12);
    animation: pulse 2.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.ai-assistant-close {
    padding: 0;
}

.ai-assistant-refresh svg {
    transform: none;
}

.ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(180deg, rgba(248, 250, 252, 0.45), rgba(241, 245, 249, 0.5));
    position: relative;
    gap: 12px;
    display: flex;
    flex-direction: column;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.ai-resize-handle { position: absolute; z-index: 2; }
.ai-resize-n, .ai-resize-s { left: 8px; right: 8px; height: 8px; }
.ai-resize-n { top: -2px; cursor: ns-resize; }
.ai-resize-s { bottom: -2px; cursor: ns-resize; }
.ai-resize-e, .ai-resize-w { top: 8px; bottom: 8px; width: 8px; }
.ai-resize-e { right: -2px; cursor: ew-resize; }
.ai-resize-w { left: -2px; cursor: ew-resize; }
.ai-resize-ne, .ai-resize-se, .ai-resize-nw, .ai-resize-sw { width: 12px; height: 12px; }
.ai-resize-ne { right: -3px; top: -3px; cursor: nesw-resize; }
.ai-resize-se { right: -3px; bottom: -3px; cursor: nwse-resize; }
.ai-resize-nw { left: -3px; top: -3px; cursor: nwse-resize; }
.ai-resize-sw { left: -3px; bottom: -3px; cursor: nesw-resize; }

.ai-assistant-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-assistant-messages::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.ai-assistant-messages::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.35);
    border-radius: 3px;
}

.ai-assistant-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.55);
}


.message {
    margin-bottom: 0;
    display: flex;
    align-items: flex-end;
    gap: 12px;
    animation: fadeIn 0.3s ease-in;
}

.user-message {
    justify-content: flex-end;
}

.ai-message {
    justify-content: flex-start;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow:
        0 6px 14px rgba(15, 23, 42, 0.18),
        0 0 0 3px rgba(255, 255, 255, 0.25),
        0 0 20px rgba(99, 102, 241, 0.15);
    position: relative;
    overflow: visible;
}

.message-avatar svg {
    width: 30px;
    height: 30px;
    display: block;
}
.ai-avatar svg {
    width: 36px;
    height: 36px;
}

.message-avatar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.35);
    pointer-events: none;
}

.user-avatar {
    background: linear-gradient(135deg, var(--btn-fill-start), var(--btn-fill-end));
    color: #0f172a;
    box-shadow:
        0 6px 14px rgba(15, 23, 42, 0.18),
        0 0 0 3px rgba(118, 200, 250, 0.3),
        0 0 24px rgba(118, 200, 250, 0.25);
}

.ai-avatar {
    background: linear-gradient(135deg, #22d3ee, #6366f1);
    color: #ffffff;
    box-shadow:
        0 6px 14px rgba(15, 23, 42, 0.18),
        0 0 0 3px rgba(99, 102, 241, 0.3),
        0 0 24px rgba(99, 102, 241, 0.25);
}

.message-bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: 20px;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.6;
    font-size: 0.95rem;
    position: relative;
    box-shadow:
        0 4px 16px rgba(15, 23, 42, 0.06),
        0 1px 4px rgba(15, 23, 42, 0.04);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: var(--text-primary);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* Tidy typography and list layout inside message bubbles (more compact spacing) */
.message-bubble p { margin: 0.1em 0 0.3em; }
.message-bubble ul,
.message-bubble ol {
    margin: 0.2em 0 0.4em;
    padding-left: 0; /* reset default */
    list-style: none; /* remove default dots */
}
.message-bubble li { margin: 0.15em 0; position: relative; }

/* Unordered lists: use a clean bullet dot */
.message-bubble ul li {
    padding-left: 1.05em;
}
.message-bubble ul li::before {
    content: '\2022'; /* bullet • */
    position: absolute;
    left: 0;
    top: 0.05em;
    color: var(--text-primary);
    opacity: 0.8;
}

/* Ordered lists: subtle counters */
.message-bubble ol { counter-reset: ai-ol; }
.message-bubble ol li {
    counter-increment: ai-ol;
    padding-left: 1.2em;
}
.message-bubble ol li::before {
    content: counter(ai-ol) '.';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--text-tertiary);
}
.message-bubble a {
    color: var(--accent-primary);
    text-decoration: underline;
    word-break: break-all;
}
.message-bubble code {
    background: rgba(148, 163, 184, 0.18);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 4px;
    padding: 0.08em 0.38em;
    font-family: var(--font-mono);
}
.message-bubble pre {
    background: rgba(148, 163, 184, 0.16);
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 8px;
    padding: 10px 12px;
    overflow-x: auto;
    white-space: pre; /* preserve formatting for code blocks */
    margin: 0.4em 0 0.9em;
}

/* Headings */
.message-bubble h1, .message-bubble h2, .message-bubble h3,
.message-bubble h4, .message-bubble h5, .message-bubble h6 {
    margin: 0.6em 0 0.4em;
    font-weight: 600;
    line-height: 1.3;
}
.message-bubble h1 { font-size: 1.5em; }
.message-bubble h2 { font-size: 1.3em; }
.message-bubble h3 { font-size: 1.15em; }
.message-bubble h4 { font-size: 1.05em; }
.message-bubble h5 { font-size: 0.95em; }
.message-bubble h6 { font-size: 0.9em; opacity: 0.9; }

/* Blockquote */
.message-bubble blockquote {
    margin: 0.5em 0;
    padding: 8px 12px;
    border-left: 3px solid rgba(148, 163, 184, 0.4);
    background: rgba(148, 163, 184, 0.08);
    border-radius: 4px;
    font-style: italic;
}

/* Horizontal rule */
.message-bubble hr {
    margin: 0.8em 0;
    border: none;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
}

/* Table styles for better rendering */
.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5em 0 0.8em;
    font-size: 0.9em;
    overflow-x: auto;
    display: block;
}
.message-bubble thead {
    background: rgba(148, 163, 184, 0.12);
}
.message-bubble th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(148, 163, 184, 0.08);
}
.message-bubble td {
    padding: 7px 10px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    line-height: 1.5;
}
.message-bubble tbody tr:nth-child(even) {
    background: rgba(148, 163, 184, 0.04);
}
.message-bubble tbody tr:hover {
    background: rgba(148, 163, 184, 0.08);
}

.message-bubble.message-system {
    background: linear-gradient(135deg, rgba(240, 244, 255, 0.96), rgba(224, 240, 255, 0.9));
    border-color: rgba(148, 163, 184, 0.18);
    color: #1f2937;
}

.message-bubble.thinking {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    display: inline-flex;
    align-items: center;
    max-width: max-content;
}
.ai-message .message-bubble.thinking::before { content: none; }

.message-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.user-message .message-bubble {
    background: linear-gradient(135deg, var(--btn-fill-start), var(--btn-fill-end));
    color: #0f172a;
    border-bottom-right-radius: 6px;
    border: none;
    box-shadow: 0 6px 18px rgba(100, 116, 139, 0.25);
}

.ai-message .message-bubble {
    background: rgba(248, 250, 252, 0.7);
    color: #1f2937;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ai-message .message-bubble::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.35), transparent);
}

.ai-thinking-box {
    background: linear-gradient(135deg, rgba(118, 200, 250, 0.18), rgba(110, 193, 247, 0.15));
    border: 1px solid rgba(110, 193, 247, 0.35);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 0;
    color: var(--text-secondary);
    font-style: italic;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.thinking-icon {
    animation: rotate 2s linear infinite;
}

@keyframes rotate {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-assistant-input-area {
    padding: 16px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.5), rgba(245, 248, 252, 0.45));
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.ai-thinking-indicator {
    padding: 12px;
    background: linear-gradient(135deg, rgba(244, 247, 252, 0.95), rgba(226, 232, 240, 0.9));
    border-radius: 10px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideUp 0.3s ease-out;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: var(--btn-fill-start);
    border-radius: 50%;
    animation: bounce 1.4s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.thinking-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

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

.thinking-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.ai-input-wrapper {
    display: flex;
    gap: 10px;
    align-items: center;
}
.ai-lang-toggle {
    width: 42px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(255, 255, 255, 0.88);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s ease;
    backdrop-filter: blur(12px);
    font-size: 0.8rem;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    color: var(--text-primary);
}

.ai-lang-toggle::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(102, 126, 234, 0.1), transparent);
    transition: left 0.5s;
}

.ai-lang-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(37, 99, 235, 0.35);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.18);
}

.ai-lang-toggle:hover::before {
    left: 100%;
}

.ai-lang-toggle:active {
    transform: translateY(0);
}

.ai-lang-toggle span {
    font-size: 0.9rem;
    font-weight: 600;
    background: linear-gradient(135deg, var(--btn-fill-start), var(--btn-fill-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}


.ai-input {
    flex: 1;
    resize: none;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 0.95rem;
    font-family: inherit;
    background: rgba(255, 255, 255, 0.88);
    color: var(--text-primary);
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background-color 0.25s ease;
    backdrop-filter: blur(12px);
    line-height: 1.4;
    scrollbar-width: thin;
    scrollbar-color: rgba(100, 116, 139, 0.7) transparent;
}

.ai-input:focus {
    outline: none;
    border-color: rgba(59, 130, 246, 0.55);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.ai-input::placeholder {
    color: #94a3b8;
}

.ai-input::-webkit-scrollbar {
    width: 10px;
}

.ai-input::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 999px;
}

.ai-input::-webkit-scrollbar-thumb {
    background-color: transparent;
    background-image: linear-gradient(
        to bottom,
        transparent 0,
        transparent 20%,
        rgba(148, 163, 184, 0.45) 20%,
        rgba(148, 163, 184, 0.55) 80%,
        transparent 80%,
        transparent 100%
    );
    border-radius: 999px;
    border-right: 3px solid transparent;
    background-clip: padding-box;
}

.ai-input::-webkit-scrollbar-thumb:hover {
    background-image: linear-gradient(
        to bottom,
        transparent 0,
        transparent 20%,
        rgba(148, 163, 184, 0.75) 20%,
        rgba(148, 163, 184, 0.85) 80%,
        transparent 80%,
        transparent 100%
    );
}

.ai-send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--btn-fill-start), var(--btn-fill-end));
    color: #0f172a;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    box-shadow: 0 6px 18px rgba(59, 130, 246, 0.25);
    position: relative;
    overflow: hidden;
}

.ai-send-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.ai-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 10px 24px rgba(59, 130, 246, 0.35);
}

.ai-send-btn:hover::before {
    width: 100%;
    height: 100%;
}

.ai-send-btn:active {
    transform: scale(0.95);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: scale(1);
}

.ai-send-btn:disabled::before {
    display: none;
}

.ai-send-btn.ai-cancel-armed {
    background: linear-gradient(135deg, #f97316, #ef4444);
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.7), 0 10px 24px rgba(239, 68, 68, 0.45);
}

.ai-send-btn.ai-cancel-armed svg {
    opacity: 0;
}

.ai-send-btn.ai-cancel-armed::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 14px;
    height: 14px;
    transform: translate(-50%, -50%);
    border-radius: 3px;
    background: transparent;
    box-shadow: inset 0 0 0 2px #b91c1c;
}

html.dark-mode .ai-send-btn.ai-cancel-armed {
    box-shadow: 0 0 0 2px rgba(248, 113, 113, 0.9), 0 10px 28px rgba(248, 113, 113, 0.65);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
html.dark-mode .ai-assistant-container {
    background: linear-gradient(145deg, rgba(17, 24, 39, 0.72), rgba(11, 20, 36, 0.68));
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Dark mode adjustments for content elements */
html.dark-mode .message-bubble a { color: var(--accent-primary); }
html.dark-mode .message-bubble code {
    background: rgba(30, 41, 59, 0.6);
    border-color: rgba(148, 163, 184, 0.25);
}
html.dark-mode .message-bubble pre {
    background: rgba(30, 41, 59, 0.55);
    border-color: rgba(148, 163, 184, 0.25);
}

/* Dark mode blockquote and hr */
html.dark-mode .message-bubble blockquote {
    border-left-color: rgba(148, 163, 184, 0.5);
    background: rgba(30, 41, 59, 0.3);
}
html.dark-mode .message-bubble hr {
    border-top-color: rgba(148, 163, 184, 0.35);
}

/* Dark mode table styles */
html.dark-mode .message-bubble thead {
    background: rgba(30, 41, 59, 0.5);
}
html.dark-mode .message-bubble th {
    background: rgba(30, 41, 59, 0.4);
    border-color: rgba(148, 163, 184, 0.3);
}
html.dark-mode .message-bubble td {
    border-color: rgba(148, 163, 184, 0.25);
}
html.dark-mode .message-bubble tbody tr:nth-child(even) {
    background: rgba(30, 41, 59, 0.2);
}
html.dark-mode .message-bubble tbody tr:hover {
    background: rgba(30, 41, 59, 0.35);
}

html.dark-mode .ai-assistant-header {
    background: linear-gradient(180deg, rgba(30, 41, 59, 0.5), rgba(15, 23, 42, 0.45));
    color: #e2e8f0;
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .ai-assistant-header::after {
    background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.45), transparent);
}

html.dark-mode .ai-assistant-close {
    color: #cbd5f5;
}

html.dark-mode .ai-assistant-close:hover {
    background: rgba(59, 130, 246, 0.12);
    color: #f8fafc;
}

html.dark-mode .ai-header-icon-btn {
    background: rgba(17, 24, 39, 0.72);
    border-color: rgba(148, 163, 184, 0.32);
    color: #cbd5f5;
}

html.dark-mode .ai-header-icon-btn:hover {
    background: rgba(59, 130, 246, 0.25);
    color: #f8fafc;
    border-color: rgba(96, 165, 250, 0.45);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

html.dark-mode .ai-assistant-messages {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.45), rgba(17, 24, 39, 0.5));
}

html.dark-mode .message-bubble {
    background: rgba(17, 24, 39, 0.65);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.25),
        0 1px 4px rgba(0, 0, 0, 0.15);
}

html.dark-mode .ai-message .message-bubble {
    background: rgba(20, 27, 45, 0.7);
    border-color: rgba(255, 255, 255, 0.12);
    color: #cbd5f5;
}

html.dark-mode .ai-message .message-bubble::before {
    background: linear-gradient(90deg, transparent, rgba(96, 165, 250, 0.4), transparent);
}

html.dark-mode .user-message .message-bubble {
    color: #f8fafc;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45);
}

html.dark-mode .message-avatar {
    box-shadow:
        0 10px 24px rgba(2, 6, 23, 0.6),
        0 0 0 3px rgba(255, 255, 255, 0.1),
        0 0 20px rgba(99, 102, 241, 0.2);
}

html.dark-mode .message-avatar::after {
    border-color: rgba(255, 255, 255, 0.15);
}

html.dark-mode .user-avatar {
    color: #e2e8f0;
    box-shadow:
        0 10px 24px rgba(2, 6, 23, 0.6),
        0 0 0 3px rgba(118, 200, 250, 0.25),
        0 0 28px rgba(118, 200, 250, 0.3);
}

html.dark-mode .ai-avatar {
    box-shadow:
        0 10px 24px rgba(2, 6, 23, 0.6),
        0 0 0 3px rgba(99, 102, 241, 0.25),
        0 0 28px rgba(99, 102, 241, 0.3);
}

html.dark-mode .message-bubble.message-system {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.94), rgba(15, 23, 42, 0.9));
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

html.dark-mode .ai-thinking-box,
html.dark-mode .ai-thinking-indicator {
    background: linear-gradient(135deg, rgba(39, 72, 199, 0.22), rgba(30, 64, 175, 0.2));
    border-color: rgba(96, 165, 250, 0.35);
    color: #cbd5f5;
}

html.dark-mode .thinking-text {
    color: #cbd5f5;
}

html.dark-mode .ai-lang-toggle {
    background: rgba(17, 24, 39, 0.9);
    border-color: rgba(148, 163, 184, 0.3);
    color: #e2e8f0;
}

html.dark-mode .ai-lang-toggle:hover {
    border-color: rgba(96, 165, 250, 0.35);
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.4);
}

html.dark-mode .ai-input {
    background: rgba(17, 24, 39, 0.6);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    scrollbar-color: rgba(148, 163, 184, 0.8) transparent;
}

html.dark-mode .ai-input:focus {
    background: rgba(17, 24, 39, 0.75);
    border-color: rgba(96, 165, 250, 0.55);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

html.dark-mode .ai-input::placeholder {
    color: #94a3b8;
}

html.dark-mode .ai-input::-webkit-scrollbar-track {
    background: transparent;
}

html.dark-mode .ai-input::-webkit-scrollbar-thumb {
    background-color: transparent;
    background-image: linear-gradient(
        to bottom,
        transparent 0,
        transparent 20%,
        rgba(203, 213, 225, 0.7) 20%,
        rgba(203, 213, 225, 0.7) 80%,
        transparent 80%,
        transparent 100%
    );
}

html.dark-mode .ai-input::-webkit-scrollbar-thumb:hover {
    background-image: linear-gradient(
        to bottom,
        transparent 0,
        transparent 20%,
        rgba(226, 232, 240, 0.96) 20%,
        rgba(226, 232, 240, 0.96) 80%,
        transparent 80%,
        transparent 100%
    );
}

html.dark-mode .ai-assistant-input-area {
    background: linear-gradient(180deg, rgba(24, 34, 54, 0.5), rgba(17, 24, 39, 0.45));
    border-top-color: rgba(255, 255, 255, 0.08);
}

html.dark-mode .ai-send-btn {
    color: #f8fafc;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45);
}


html.dark-mode .ai-send-btn::before {
    background: rgba(255, 255, 255, 0.1);
}

html.dark-mode .thinking-dots span {
    background: var(--btn-fill-start);
}

.float-btn.ai-assistant-toggle {
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease, opacity 0.18s ease;
    color: #ffffff;
    --ai-icon-stroke: currentColor;
    opacity: 1;
}

.float-btn.ai-assistant-toggle::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s ease, height 0.5s ease;
}

.float-btn.ai-assistant-toggle .ai-icon {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}
.float-btn.ai-assistant-toggle .ai-icon svg {
    display: block;
    width: 30px;
    height: 30px;
}

.float-btn.ai-assistant-toggle:hover {
    transform: translateY(-6px) scale(1.06);
}

.float-btn.ai-assistant-toggle:hover::before {
    width: 115%;
    height: 115%;
}


.float-btn.ai-assistant-toggle.is-hidden {
    visibility: hidden;
    opacity: 0;
    transform: translateY(6px) scale(0.9);
    pointer-events: none;
}

html.dark-mode .float-btn.ai-assistant-toggle {
    color: #f8fafc;
    --ai-icon-stroke: #f8fafc;
}

html.dark-mode .float-btn.ai-assistant-toggle::before {
    background: rgba(255, 255, 255, 0.15);
}
@media (max-width: 768px) {
    .ai-assistant-container {
        width: 100%;
        max-width: 100%;
        right: 0;
        left: 0;
        bottom: 0;
        height: 75vh;
        border-radius: 24px 24px 0 0;
        transform: translateY(100%) scale(0.9);
    }
    .ai-assistant-container.active {
        transform: translateY(0) scale(1);
    }
    .ai-assistant-header {
        cursor: default;
    }
    .ai-resize-handle {
        display: none;
    }
    .message-bubble { 
        max-width: 90%; 
        font-size: 0.9rem;
        padding: 12px 16px;
    }
    .ai-assistant-header {
        padding: 14px 18px;
    }
    .ai-assistant-header h3 {
        font-size: 1.1rem;
    }
    .ai-input-wrapper {
        gap: 8px;
    }
    .ai-lang-toggle,
    .ai-send-btn {
        width: 40px;
        height: 40px;
    }
    .ai-lang-toggle span {
        font-size: 0.8rem;
    }
}
