/**
 * AiChat (LibreChat) — CSS стили
 * Извлечено из librechat/index.html при рефакторинге
 */

[x-cloak] { display: none !important; }
body { font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; }

/* Custom Scrollbar */
.scrollbar-thin::-webkit-scrollbar { width: 6px; height: 6px; }
.scrollbar-thin::-webkit-scrollbar-track { background: transparent; }
.scrollbar-thin::-webkit-scrollbar-thumb { background-color: rgba(156, 163, 175, 0.5); border-radius: 3px; transition: background-color 0.2s; }
.scrollbar-thin::-webkit-scrollbar-thumb:hover { background-color: rgba(107, 114, 128, 0.8); }

/* Prose Overrides */
.prose pre { padding: 0; background: transparent; border: none; margin: 0; }
.prose pre code { background: #f3f4f6; color: #1f2937; padding: 1em; display: block; border-radius: 0.5em; }
.dark .prose pre code { background: #111827; color: #e5e7eb; }
.dark .prose strong { color: white; }
.dark .prose a { color: #60a5fa; }

/* Smooth transitions */
button, a, .cursor-pointer { transition: all 0.2s ease-in-out; }
.message-bubble {
    animation: slideIn 0.3s ease-out;
    max-width: 85%;
    min-width: 0;
}

.chat-message-list {
    max-width: min(100%, 48rem);
    transition: max-width 0.2s ease;
}

.chat-message-list--wide {
    max-width: min(96vw, 88rem);
}

.message-bubble--wide {
    width: 100%;
    max-width: 100%;
}

.message-markdown {
    min-width: 0;
}

/* Send button rotation */
.send-btn svg { transform: rotate(90deg); }

/* Remove focus outline from input */
.chat-input:focus { outline: none !important; box-shadow: none !important; border-color: transparent !important; }
.chat-input-container:focus-within { box-shadow: none !important; }
/* Hide scrollbar and arrows in textarea */
.chat-input { scrollbar-width: none; -ms-overflow-style: none; }
.chat-input::-webkit-scrollbar { display: none; }
.chat-input::-webkit-inner-spin-button, .chat-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Hide scrollbar utility (for consciousness tabs on mobile) */
.scrollbar-hide { -ms-overflow-style: none; scrollbar-width: none; }
.scrollbar-hide::-webkit-scrollbar { display: none; }

/* Mobile: raise input area 5px, safe-area bottom padding */
@media (max-width: 767px) {
    #chat-input-area { margin-bottom: -5px; }
}

/* ====================================================================
   PHONE MODAL LAYOUT (≤640px)
   Compact padding, safe-area, full-width modals
   ==================================================================== */
@media (max-width: 640px) {
    /* Consciousness tabs: whitespace-nowrap for horizontal scroll */
    .scrollbar-hide > button { white-space: nowrap; flex-shrink: 0; }

    /* Details sections: tighter padding on mobile */
    details .px-4 { padding-left: 0.75rem; padding-right: 0.75rem; }
    details summary.px-4 { padding-left: 0.75rem; padding-right: 0.75rem; }
}

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

/* AI Speaking Animation */
@keyframes aiSpeaking {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
    50% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); }
}
.ai-speaking {
    animation: aiSpeaking 1.5s ease-in-out infinite;
}

/* === Reasoning Stream Animation === */
@keyframes reasoningPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.5); }
    50% { box-shadow: 0 0 0 8px rgba(168, 85, 247, 0); }
}
.reasoning-pulse {
    animation: reasoningPulse 2s ease-in-out infinite;
}

@keyframes reasoningSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
.reasoning-spin {
    animation: reasoningSpin 3s linear infinite;
}

.reasoning-stream-block {
    animation: slideIn 0.3s ease-out;
    background: linear-gradient(135deg, rgba(168,85,247,0.03), rgba(139,92,246,0.06));
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}
.dark .reasoning-stream-block {
    background: linear-gradient(135deg, rgba(168,85,247,0.08), rgba(139,92,246,0.12));
}

@keyframes reasoningDots {
    0%, 20% { opacity: 0; }
    40% { opacity: 1; }
    60% { opacity: 0; }
}
.reasoning-dots span {
    animation: reasoningDots 1.4s infinite;
    font-weight: bold;
}
.reasoning-dots span:nth-child(2) { animation-delay: 0.2s; }
.reasoning-dots span:nth-child(3) { animation-delay: 0.4s; }

/* === Deep Research Live Status === */
@keyframes researchStepPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.research-step-active {
    animation: researchStepPulse 1.5s ease-in-out infinite;
}

/* Typing Dots Animation - Hypnotic Wave Effect */
@keyframes typingDotWave {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px) scale(1.2);
        opacity: 1;
    }
}

@keyframes typingDotGlow {
    0%, 100% {
        filter: brightness(1) drop-shadow(0 0 2px currentColor);
    }
    50% {
        filter: brightness(1.4) drop-shadow(0 0 8px currentColor);
    }
}

.typing-dot {
    display: inline-block;
    font-size: 1.2rem;
    margin: 0 2px;
    color: #10b981; /* green-500 */
    animation: typingDotWave 1.4s ease-in-out infinite, typingDotGlow 2s ease-in-out infinite;
    transform-origin: center;
    transition: all 0.3s ease;
}

.dark .typing-dot {
    color: #34d399; /* green-400 */
}

.typing-dot:nth-child(1) {
    animation-delay: 0s, 0s;
}

.typing-dot:nth-child(2) {
    animation-delay: 0.2s, 0.3s;
}

.typing-dot:nth-child(3) {
    animation-delay: 0.4s, 0.6s;
}

/* Enhanced Loading Avatar Pulse */
@keyframes loadingAvatarPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    25% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 12px rgba(16, 185, 129, 0);
    }
    75% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

.animate-pulse:has(svg) {
    animation: loadingAvatarPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Model Selector Styles */
.model-selector {
    position: relative;
    min-width: 180px;
}
.model-selector select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 0.75rem;
    padding: 0.5rem 2.5rem 0.5rem 1rem;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}
.model-selector select:hover {
    background: rgba(0,0,0,0.05);
    border-radius: 0.75rem;
}
.dark .model-selector select:hover {
    background: rgba(255,255,255,0.1);
}
.model-selector select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
    border-radius: 0.75rem;
}
.model-selector select option {
    padding: 0.75rem 1rem;
    background: white;
    color: #1f2937;
    border-radius: 0.5rem;
    margin: 2px 4px;
}
.model-selector select option:hover {
    background: #f3f4f6;
}
.dark .model-selector select option {
    background: #1f2937;
    color: #e5e7eb;
}
.dark .model-selector select option:hover {
    background: #374151;
}

/* Recording Animation */
@keyframes pulse-record {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}
.recording-pulse {
    animation: pulse-record 1s ease-in-out infinite;
}

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

/* ==========================================================================
    PREMIUM DESIGN SYSTEM (AiChat Pro)
   ========================================================================== */

/* 1. Glassmorphism */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.dark .glass-panel {
    background: rgba(31, 41, 55, 0.7); /* gray-800 with opacity */
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

.glass-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid rgba(229, 231, 235, 0.5);
    z-index: 40;
}

.dark .glass-header {
    background: rgba(17, 24, 39, 0.85);
    border-bottom: 1px solid rgba(55, 65, 81, 0.5);
}

/* 2.1 AiChat Generation Inputs — works in both standalone pages and inline mode */
.AiChat-field {
    padding: 0.75rem 1rem;
    outline: none !important;
    box-shadow: none !important;
}

.AiChat-field:focus {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* Legacy selector for standalone pages */
.librechat-form-page .AiChat-field {
    padding: 0.75rem 1rem;
    outline: none;
}

.librechat-form-page .AiChat-field:focus {
    outline: none !important;
}

/* 2. Premium Inputs */
.input-premium {
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(209, 213, 219, 0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dark .input-premium {
    background: rgba(31, 41, 55, 0.5);
    border: 1px solid rgba(75, 85, 99, 0.8);
    color: #f3f4f6;
}

.input-premium:focus {
    background: #ffffff;
    border-color: #6366f1;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15), 0 1px 2px rgba(0, 0, 0, 0.05);
}

.dark .input-premium:focus {
    background: #1f2937;
    border-color: #818cf8;
    box-shadow: 0 0 0 4px rgba(129, 140, 248, 0.15), 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* 3. Gradient Text */
.text-gradient-primary {
    background: linear-gradient(135deg, #4f46e5 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-purple {
    background: linear-gradient(135deg, #c026d3 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-gradient-blue {
    background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.dark .text-gradient-primary {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
}

.dark .text-gradient-blue {
    background: linear-gradient(135deg, #60a5fa 0%, #22d3ee 100%);
}

/* 4. Animated Background Helpers */
.bg-animated-gradient {
    background: linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
    background-size: 400% 400%;
    animation: gradientBG 15s ease infinite;
}

@keyframes gradientBG {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* 5. Better Scrollbars (Refined) */
.scrollbar-premium::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.scrollbar-premium::-webkit-scrollbar-track {
    background: transparent;
}

.scrollbar-premium::-webkit-scrollbar-thumb {
    background-color: rgba(156, 163, 175, 0.3);
    border-radius: 4px;
    border: 2px solid transparent;
    background-clip: content-box;
    transition: background-color 0.2s;
}

.scrollbar-premium::-webkit-scrollbar-thumb:hover {
    background-color: rgba(107, 114, 128, 0.6);
}

.dark .scrollbar-premium::-webkit-scrollbar-thumb:hover {
    background-color: rgba(156, 163, 175, 0.5);
}

/* 6. Card Hover Effects */
.hover-card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.hover-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.dark .hover-card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.3);
    border-color: rgba(255, 255, 255, 0.1);
}

/* Utility Animations */
@keyframes pulse-subtle {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.8; }
}

.animate-pulse-subtle {
    animation: pulse-subtle 3s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.animate-float {
    animation: float 6s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

/* ==================== Enhanced Formatting Styles ==================== */

/* Prose enhancements for formatted output */
.prose h1, .prose h2, .prose h3 {
    margin-top: 1.2em;
    margin-bottom: 0.5em;
    font-weight: 700;
    line-height: 1.3;
}

.prose h2 {
    border-bottom: 1px solid rgba(156, 163, 175, 0.3);
    padding-bottom: 0.3em;
}

.prose blockquote {
    border-left: 4px solid #6366f1;
    background: rgba(99, 102, 241, 0.05);
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    border-radius: 0 0.5rem 0.5rem 0;
}

.dark .prose blockquote {
    background: rgba(99, 102, 241, 0.1);
    border-left-color: #818cf8;
}

.prose hr {
    border-color: rgba(156, 163, 175, 0.3);
    margin: 1.5rem 0;
}

/* Chart container */
.chart-container {
    max-width: 600px;
    margin: 1rem auto;
}

/* Generated image container */
.generated-image-container {
    max-width: 512px;
}

.generated-image-container img {
    max-height: 512px;
    object-fit: contain;
}

/* Mermaid diagrams */
.mermaid {
    background: transparent !important;
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 0.75rem;
    border: 1px solid rgba(156, 163, 175, 0.2);
}

.dark .mermaid {
    background: rgba(17, 24, 39, 0.5) !important;
}

/* KaTeX formulas */
.katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.5rem 0;
}

/* Enhanced table styles */
.table-scroll-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin: 1rem 0;
    border-radius: 0.5rem;
    border: 1px solid rgba(156, 163, 175, 0.3);
    background: rgba(255, 255, 255, 0.92);
}

.dark .table-scroll-wrapper {
    background: rgba(17, 24, 39, 0.88);
}

.table-export-bar {
    display: flex;
    justify-content: flex-end;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: rgba(99, 102, 241, 0.05);
    border-bottom: 1px solid rgba(156, 163, 175, 0.15);
}

.dark .table-export-bar {
    background: rgba(99, 102, 241, 0.1);
}

.table-export-btn {
    font-size: 0.7rem;
    padding: 0.2rem 0.5rem;
    border-radius: 0.25rem;
    color: #6366f1;
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.table-export-btn:hover {
    background: rgba(99, 102, 241, 0.1);
}

.dark .table-export-btn {
    color: #a5b4fc;
}

.dark .table-export-btn:hover {
    background: rgba(99, 102, 241, 0.2);
}

.prose table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    font-size: 0.875rem;
    overflow: hidden;
    margin: 0;
}

.prose thead th {
    background: rgba(99, 102, 241, 0.08);
    font-weight: 600;
    text-align: left;
    vertical-align: bottom;
    white-space: nowrap;
    padding: 0.625rem 0.75rem;
    border-bottom: 2px solid rgba(99, 102, 241, 0.2);
}

.dark .prose thead th {
    background: rgba(99, 102, 241, 0.15);
}

.prose tbody td {
    padding: 0.5rem 0.75rem;
    vertical-align: top;
    border-bottom: 1px solid rgba(156, 163, 175, 0.15);
}

.prose tbody tr:hover {
    background: rgba(99, 102, 241, 0.03);
}

.dark .prose tbody tr:hover {
    background: rgba(99, 102, 241, 0.08);
}

/* Code block enhancement */
.code-block-wrapper {
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Lists enhancement */
.prose ul {
    list-style-type: disc;
    padding-left: 1.5rem;
}

.prose ol {
    list-style-type: decimal;
    padding-left: 1.5rem;
}

.prose li {
    margin-bottom: 0.25rem;
}

/* Inline code */
.prose code:not([class]) {
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875em;
    font-weight: 500;
}

.dark .prose code:not([class]) {
    background: rgba(129, 140, 248, 0.15);
    color: #a5b4fc;
}

/* ====================================================================
   WATCH / SMARTWATCH LAYOUT (≤280px)
   OLED-optimized: pure black backgrounds, compact layout, voice-first
   ==================================================================== */
@media (max-width: 280px) {
    /* -- OLED Black Theme Override (saves battery on OLED) -- */
    body, body.dark,
    .bg-white, .dark\:bg-gray-800,
    .bg-gray-100, .dark\:bg-\[\#212121\] {
        background-color: #000000 !important;
    }
    .dark\:bg-gray-800, .bg-white {
        background-color: #000000 !important;
    }
    /* Cards / panels */
    .dark\:bg-gray-700, .bg-gray-50,
    .dark\:bg-\[\#212121\] {
        background-color: #111111 !important;
    }
    /* Borders dimmed */
    .border-gray-200, .dark\:border-white\/10,
    .border-gray-300, .dark\:border-gray-700,
    .dark\:border-gray-600 {
        border-color: #1a1a1a !important;
    }

    /* -- Hide sidebars completely -- */
    .md\:hidden { display: none !important; }

    /* -- Top toolbar: ultra-compact -- */
    .flex.items-center.justify-between.px-4.py-2 {
        padding: 2px 6px !important;
        gap: 2px !important;
        min-height: 24px !important;
        border-bottom: none !important;
        background: transparent !important;
    }
    /* Hide model selector details, keep only icon */
    .model-selector button span.text-sm { display: none !important; }
    .model-selector button svg.h-4 { display: none !important; }
    .model-selector button span[x-show="attachedAgent"] { display: none !important; }
    .model-selector { min-width: unset !important; }
    .model-selector button { padding: 2px 4px !important; gap: 2px !important; }
    /* Hide share button & settings */
    button[title="Поделиться"],
    button[title="Настройки"] { display: none !important; }

    /* -- Chat scroll area -- */
    #scroll-container {
        padding: 4px 12px 100px !important;
    }

    /* -- Messages: compact, no avatars -- */
    .message-bubble {
        padding: 5px 8px !important;
        font-size: 10px !important;
        line-height: 1.35 !important;
        border-radius: 10px !important;
        max-height: 80px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    /* User bubble: right-aligned feel */
    .message-bubble:has(+ .flex-shrink-0) {
        margin-left: 10% !important;
    }
    /* Avatar icons: hide on watch */
    .flex-shrink-0 .w-8.h-8,
    .flex-shrink-0 .w-10.h-10 {
        width: 16px !important;
        height: 16px !important;
        font-size: 8px !important;
    }
    /* Message row gap */
    .flex.gap-4, .flex.gap-3 {
        gap: 3px !important;
    }

    /* -- Greeting: compact -- */
    .text-2xl, .md\:text-3xl {
        font-size: 12px !important;
    }
    .mb-8 { margin-bottom: 8px !important; }

    /* -- Input area: compact, transparent, voice-first -- */
    #chat-input-area {
        padding: 3px 6px !important;
        padding-bottom: max(3px, env(safe-area-inset-bottom)) !important;
        background: transparent !important;
        border-top: none !important;
    }
    /* Input container */
    .chat-input-container {
        padding: 4px !important;
        gap: 3px !important;
        border-radius: 16px !important;
        background: #111111 !important;
    }
    /* Textarea */
    .chat-input {
        font-size: 11px !important;
        min-height: 20px !important;
        line-height: 20px !important;
    }
    /* Attach button: smaller */
    .chat-input-container .flex-shrink-0 button.w-8 {
        width: 24px !important;
        height: 24px !important;
    }
    .chat-input-container .flex-shrink-0 button.w-8 svg {
        width: 14px !important;
        height: 14px !important;
    }
    /* Voice button: hero size — primary input on watch */
    button[title="Голосовой ввод"],
    button[title="Остановить запись"] {
        width: 36px !important;
        height: 36px !important;
        background: #f85149 !important;
        color: #fff !important;
        box-shadow: 0 2px 12px rgba(248, 81, 73, 0.4) !important;
        order: -1; /* Move mic to the left */
    }
    button[title="Голосовой ввод"] svg,
    button[title="Остановить запись"] svg {
        width: 18px !important;
        height: 18px !important;
    }
    /* Send button: compact */
    .chat-input-container button.bg-black,
    .chat-input-container button.dark\:bg-white {
        width: 24px !important;
        height: 24px !important;
    }
    .chat-input-container button.bg-black svg,
    .chat-input-container button.dark\:bg-white svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* -- Attached files: smaller -- */
    .mb-3.flex.flex-wrap { gap: 3px !important; }
    .mb-3 .h-20 { height: 36px !important; width: 36px !important; }

    /* -- Voice mode settings: hide on watch -- */
    .bg-blue-50.dark\:bg-blue-900\/20.rounded-lg { display: none !important; }

    /* -- Agent preview: compact -- */
    .inline-flex.items-center.gap-3.px-4 {
        gap: 3px !important;
        padding: 4px 6px !important;
        font-size: 9px !important;
    }
    .inline-flex .w-10.h-10 { width: 20px !important; height: 20px !important; font-size: 12px !important; }

    /* -- Model dropdown: compact -- */
    .model-selector .absolute {
        width: 160px !important;
        max-height: 180px !important;
        font-size: 10px !important;
    }
    .model-selector .absolute .px-4.py-3 {
        padding: 4px 8px !important;
    }
    .model-selector .absolute .w-8.h-8 {
        width: 16px !important;
        height: 16px !important;
    }

    /* -- Hide premium indicator, reasoning panels on watch -- */
    .input-premium { display: none !important; }

    /* -- Scrollbar hide -- */
    #scroll-container::-webkit-scrollbar,
    .message-bubble::-webkit-scrollbar {
        display: none;
    }
    #scroll-container,
    .message-bubble {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    /* -- Ambient circular glow (decorative) -- */
    body::after {
        content: '';
        position: fixed;
        top: 2px; left: 2px; right: 2px; bottom: 2px;
        border-radius: 50%;
        border: 1px solid rgba(88, 166, 255, 0.06);
        pointer-events: none;
        z-index: 9998;
    }
}

/* ===== Watch: Round screen enhancements (iChat) ===== */
body.watch-round-ichat {
    border-radius: 50%;
    overflow: hidden;
}
body.watch-round-ichat .flex.items-center.justify-between.px-4.py-2 {
    padding-top: 18px !important;
    padding-left: 36px !important;
    padding-right: 36px !important;
    justify-content: center !important;
}
body.watch-round-ichat #scroll-container {
    padding-left: 24px !important;
    padding-right: 24px !important;
}
body.watch-round-ichat #chat-input-area {
    padding-bottom: max(18px, env(safe-area-inset-bottom)) !important;
    padding-left: 32px !important;
    padding-right: 32px !important;
}
body.watch-round-ichat .message-bubble {
    max-height: 56px;
}

/* ===== Ultra-tiny watch (≤200px, iChat) ===== */
@media (max-width: 200px) {
    /* Hide toolbar completely */
    .flex.items-center.justify-between.px-4.py-2 {
        display: none !important;
    }
    #scroll-container {
        padding: 2px 18px 80px !important;
    }
    .message-bubble {
        font-size: 8px !important;
        padding: 3px 5px !important;
        max-height: 48px;
    }
    .text-2xl { font-size: 10px !important; }
    /* Voice-only: hide textarea */
    .chat-input { display: none !important; }
    /* Hide attach + send, keep only mic */
    .chat-input-container .flex-shrink-0:not(:has(button[title="Голосовой ввод"]):not(:has(button[title="Остановить запись"]))) {
        display: none !important;
    }
    .chat-input-container {
        justify-content: center !important;
        background: transparent !important;
        border: none !important;
    }
}

/* ========================= Source Link Tooltips ========================= */
.prose .source-link {
    text-decoration: none !important;
    border-bottom: 1.5px dotted rgba(59, 130, 246, 0.5);
    transition: border-color 0.15s ease, color 0.15s ease;
}
.prose .source-link:hover {
    border-bottom-color: rgba(59, 130, 246, 0.9);
}
.dark .prose .source-link {
    border-bottom-color: rgba(96, 165, 250, 0.4);
}
.dark .prose .source-link:hover {
    border-bottom-color: rgba(96, 165, 250, 0.8);
}
.source-tooltip {
    background: #1f2937;
    color: #f3f4f6;
    font-size: 12px;
    line-height: 1.4;
    padding: 6px 10px;
    border-radius: 8px;
    max-width: 280px;
    word-break: break-word;
    box-shadow: 0 4px 12px rgba(0,0,0,0.25);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.source-tooltip.visible {
    opacity: 1;
}
.source-tooltip .source-tooltip-domain {
    font-weight: 600;
    color: #93c5fd;
}
.source-tooltip .source-tooltip-hint {
    color: #9ca3af;
    font-size: 10px;
    margin-top: 2px;
}
.source-tooltip .source-tooltip-arrow,
.source-tooltip .source-tooltip-arrow::before {
    position: absolute;
    width: 8px;
    height: 8px;
    background: inherit;
}
.source-tooltip .source-tooltip-arrow {
    visibility: hidden;
}
.source-tooltip .source-tooltip-arrow::before {
    visibility: visible;
    content: '';
    transform: rotate(45deg);
}
.source-tooltip[data-popper-placement^='top'] > .source-tooltip-arrow {
    bottom: -4px;
}
.source-tooltip[data-popper-placement^='bottom'] > .source-tooltip-arrow {
    top: -4px;
}
.source-tooltip[data-popper-placement^='left'] > .source-tooltip-arrow {
    right: -4px;
}
.source-tooltip[data-popper-placement^='right'] > .source-tooltip-arrow {
    left: -4px;
}
