html {
    overflow-y: scroll;
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* === ТЕМНАЯ ТЕМА (Dark Mode Engine) === */
html.dark body { background-color: #0a0a0a !important; color: #f3f4f6 !important; }
html.dark .bg-white { background-color: #141414 !important; }
html.dark .bg-gray-50 { background-color: #0a0a0a !important; }
html.dark .bg-gray-100 { background-color: #1f1f1f !important; }
html.dark .text-gray-900, html.dark .text-primary { color: #f9fafb !important; }
html.dark .text-gray-700 { color: #d1d5db !important; }
html.dark .text-gray-600 { color: #9ca3af !important; }
html.dark .text-gray-500 { color: #6b7280 !important; }
html.dark .border-gray-100 { border-color: #1f1f1f !important; }
html.dark .border-gray-200 { border-color: #262626 !important; }
html.dark .border-gray-300 { border-color: #333333 !important; }
html.dark .bg-primary, html.dark .bg-gray-900 { background-color: #ffffff !important; color: #111111 !important; }
html.dark .text-white { color: #111111 !important; }
html.dark .hover\:bg-gray-50:hover { background-color: #1f1f1f !important; }
html.dark .hover\:bg-gray-800:hover { background-color: #e5e7eb !important; }
html.dark .hover\:text-gray-900:hover { color: #ffffff !important; }
html.dark .hover\:border-gray-900:hover { border-color: #ffffff !important; }
html.dark input, html.dark select { background-color: #141414 !important; border-color: #262626 !important; color: #ffffff !important; }
html.dark nav.nav-scrolled { background-color: rgba(20, 20, 20, 0.95) !important; border-bottom-color: #262626 !important; }

/* === Монолитный Header === */
nav {
    height: 80px;
    transition: background-color 0.3s, border-color 0.3s;
}
.nav-scrolled {
    background-color: rgba(255, 255, 255, 0.98) !important;
    border-bottom-color: #e5e7eb !important;
    box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
}

/* === Анимации === */
.fade-in-up {
    opacity: 0;
    transform: translateY(40px); 
    transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1), 
                transform 0.7s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.2s ease !important;
    will-change: opacity, transform;
}
.fade-in-up.show {
    opacity: 1;
    transform: translateY(0);
}

/* === 3D Tilt === */
.tilt-element {
    transform-style: preserve-3d;
    will-change: transform;
}
.tilt-element:not(.fade-in-up) {
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.2s ease;
}
.tilt-element:hover {
    z-index: 10;
}

/* === HITBOX WRAPPER === */
.tilt-hitbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    perspective: 1000px;
    background: transparent;
}
.tilt-inner {
    transition: transform 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-style: preserve-3d;
    will-change: transform;
}

/* === Дизайн карточек === */
.text-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    padding: 2rem;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s, background-color 0.3s;
}
.text-card::before {
    content: '';
    position: absolute;
    top: 0; right: 0;
    width: 150px; height: 150px;
    background: radial-gradient(circle at top right, rgba(243, 244, 246, 0.8), transparent 70%);
    border-radius: 0 16px 0 100%;
    transition: background 0.3s;
}
html.dark .text-card::before {
    background: radial-gradient(circle at top right, rgba(31, 31, 31, 0.8), transparent 70%);
}
.text-card:hover {
    border-color: #111111;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.05);
}
html.dark .text-card:hover {
    border-color: #ffffff;
    box-shadow: 0 20px 25px -5px rgba(255, 255, 255, 0.05);
}

.feature-icon-wrapper {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: #111111;
    transition: all 0.3s;
}
html.dark .feature-icon-wrapper {
    background-color: #1a1a1a;
    color: #ffffff;
}

/* === Live-статус === */
.live-dot {
    width: 8px;
    height: 8px;
    background-color: #111111;
    border-radius: 50%;
    display: inline-block;
    position: relative;
}
html.dark .live-dot { background-color: #ffffff; }
.live-dot::after {
    content: '';
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 50%;
    background-color: rgba(17, 17, 17, 0.2);
    animation: pulse-ring 2s cubic-bezier(0.455, 0.03, 0.515, 0.955) infinite;
}
html.dark .live-dot::after { background-color: rgba(255, 255, 255, 0.2); }
@keyframes pulse-ring {
    0% { transform: scale(0.3); opacity: 1; }
    80%, 100% { transform: scale(1.5); opacity: 0; }
}

/* === Чат и модалки === */
.modal-overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.3s;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-content {
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
    opacity: 1;
}

.chat-item-enter { 
    animation: slideInLeft 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards; 
}
.chat-item-exit { 
    overflow: hidden; 
    animation: slideOutRight 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; 
}

@keyframes slideInLeft {
    0% { opacity: 0; transform: translateX(-20px); }
    100% { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
    0% { opacity: 1; transform: translateX(0); height: var(--current-height); margin-bottom: 0.25rem; }
    100% { opacity: 0; transform: translateX(20px); height: 0; margin-bottom: 0; padding: 0; border: none; }
}

/* === АВТОРИЗАЦИЯ === */
html.logged-in nav .tilt-hitbox:has(a[href="register.html"]),
html.logged-in nav a[href="register.html"] {
    display: none !important;
}

#terms-checkbox {
    accent-color: #111111; 
    cursor: pointer;
}
html.dark #terms-checkbox { accent-color: #ffffff; }

#terms-checkbox:checked {
    background-color: #111111;
    border-color: #111111;
}
html.dark #terms-checkbox:checked {
    background-color: #ffffff;
    border-color: #ffffff;
}

.registration-free-text {
    margin-top: 2rem;
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    color: #9ca3af; 
    text-transform: uppercase;
    letter-spacing: 0.25em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.registration-free-text::before,
.registration-free-text::after {
    content: '';
    width: 4px;
    height: 4px;
    background-color: #d1d5db; 
    border-radius: 50%;
}

/* === Состояния загрузки для чата (API Loading) === */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    margin-top: 4px;
}
html.dark .typing-indicator { background: rgba(255,255,255,0.1); }
.typing-dot {
    width: 4px; height: 4px; border-radius: 50%;
    background: #6b7280;
    animation: typing 1.4s infinite ease-in-out both;
}
html.dark .typing-dot { background: #9ca3af; }
.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* === Скроллбар === */
.chat-scroll::-webkit-scrollbar { width: 4px; }
.chat-scroll::-webkit-scrollbar-track { background: transparent; }
.chat-scroll::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 10px; }
.chat-scroll::-webkit-scrollbar-thumb:hover { background: #d1d5db; }
html.dark .chat-scroll::-webkit-scrollbar-thumb { background: #333333; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #e5e7eb; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #d1d5db; }
html.dark ::-webkit-scrollbar-thumb { background: #333333; }