:root {
    --a4ai-bg-primary: #080808;
    --a4ai-bg-secondary: #050505;
    --a4ai-bg-glass: rgba(12, 12, 12, 0.8);
    --a4ai-text-primary: #ffffff;
    --a4ai-text-secondary: #8e8e93;
    --a4ai-border: rgba(255, 255, 255, 0.1);
    --a4ai-accent: #fe00ca;
    --a4ai-accent-hover: #cc00a0;
    --a4ai-accent-glow: rgba(254, 0, 202, 0.5);
    --a4ai-success: #30d158;
    --a4ai-error: #ff3b3b;
    --a4ai-warning: #ff9500;
    --a4ai-info: #007aff;
    --a4ai-radius: 16px;
    --a4ai-radius-lg: 24px;
    --a4ai-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --a4ai-smooth: cubic-bezier(0.33, 1, 0.68, 1);
    --a4ai-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
    --a4ai-shadow-glow: 0 0 40px var(--a4ai-accent-glow);
}

[data-theme="light"] {
    --a4ai-bg-primary: #ffffff;
    --a4ai-bg-secondary: #f8f9fa;
    --a4ai-bg-glass: rgba(255, 255, 255, 0.95);
    --a4ai-text-primary: #1a1a1a;
    --a4ai-text-secondary: #6c757d;
    --a4ai-border: rgba(0, 0, 0, 0.1);
    --a4ai-accent: #fe00ca;
    --a4ai-accent-hover: #cc00a0;
    --a4ai-shadow-md: 0 8px 32px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Montserrat Alternates', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--a4ai-bg-primary);
    color: var(--a4ai-text-primary);
    display: flex;
    height: 100vh;
    overflow: hidden;
    transition: all 0.5s var(--a4ai-smooth);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    transition: background 0.3s;
}

[data-theme="light"] ::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--a4ai-accent);
}

.a4ai-sidebar {
    width: 320px;
    min-width: 280px;
    background: var(--a4ai-bg-glass);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-right: 1px solid var(--a4ai-border);
    display: flex;
    flex-direction: column;
    animation: a4ai-slideInLeft 0.6s var(--a4ai-spring);
}

@keyframes a4ai-slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.a4ai-sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid var(--a4ai-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--a4ai-bg-glass);
}

[data-theme="light"] .a4ai-sidebar-header {
    background: var(--a4ai-bg-glass);
}

.a4ai-sidebar-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.a4ai-sidebar-title-link {
    background: linear-gradient(35deg, var(--a4ai-accent) 0%, var(--a4ai-accent) 30%, rgba(254, 128, 214, 0.9) 42%, rgba(255, 150, 220, 0.8) 46%, rgba(255, 180, 235, 0.9) 49%, rgba(255, 200, 245, 1) 50%, rgba(255, 180, 235, 0.9) 51%, rgba(255, 150, 220, 0.8) 54%, rgba(254, 128, 214, 0.9) 58%, var(--a4ai-accent-hover) 70%, var(--a4ai-accent) 100%);
    background-size: 300% 300%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    display: inline-block;
    transition: all 0.4s ease;
    cursor: pointer;
    font-weight: 700;
    animation: a4ai-titleFlow 12s ease-in-out infinite;
    filter: drop-shadow(0 0 6px rgba(254, 128, 214, 0.25));
    will-change: background-position, filter;
}

.a4ai-sidebar-title-link:hover {
    transform: scale(1.03);
    filter: drop-shadow(0 0 12px var(--a4ai-accent-glow));
    transition: all 0.4s ease;
    animation-duration: 6s;
    animation-timing-function: linear;
}

.a4ai-btn-new-chat-round {
    width: 42px;
    height: 42px;
    background: var(--a4ai-accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--a4ai-spring);
    box-shadow: 0 0 20px var(--a4ai-accent-glow);
    flex-shrink: 0;
}

.a4ai-btn-new-chat {
    width: 42px;
    height: 42px;
    background: var(--a4ai-accent);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.4s var(--a4ai-spring);
    box-shadow: 0 0 20px var(--a4ai-accent-glow);
    flex-shrink: 0;
}

.a4ai-btn-new-chat:hover,
.a4ai-btn-new-chat-round:hover {
    transform: scale(1.15) rotate(90deg);
    box-shadow: 0 0px 25px var(--a4ai-accent-glow);
}

.a4ai-btn-new-chat:active,
.a4ai-btn-new-chat-round:active {
    transform: scale(0.95) rotate(90deg);
}

.a4ai-list {
    list-style: none;
    padding-left: 0;
    margin: 10px 0;
}

.a4ai-list li {
    margin-bottom: 2px;
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.a4ai-list li::before {
    content: '•';
    position: absolute;
    left: 0;
    color: var(--a4ai-accent);
    font-weight: bold;
}

ol.a4ai-list {
    list-style: decimal;
    padding-left: 25px;
    counter-reset: list-counter;
}

ol.a4ai-list li {
    list-style: decimal;
    padding-left: 5px;
}

ol.a4ai-list li::before {
    display: none;
}

.a4ai-processing-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
}

.a4ai-processing-text {
    font-weight: 700;
    background: linear-gradient(90deg, var(--a4ai-text-primary) 0%, var(--a4ai-accent) 50%, var(--a4ai-text-primary) 100%);
    background-size: 200% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: a4ai-textShimmer 3.5s ease-in-out infinite;
}

.a4ai-processing-dots {
    display: inline-flex;
    gap: 3px;
    align-items: center;
    margin-left: 2px;
    vertical-align: baseline;
    margin-top: 2px;
}

.a4ai-processing-dots span {
    width: 5px;
    height: 5px;
    background: var(--a4ai-accent);
    border-radius: 50%;
    animation: a4ai-processingDot 1.4s ease-in-out infinite;
    box-shadow: 0 0 6px var(--a4ai-accent-glow);
    display: inline-block;
}

.a4ai-processing-dots span:nth-child(1) {
    animation-delay: 0s;
}

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

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

@keyframes a4ai-processingDot {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px) scale(1.15);
        opacity: 1;
    }
}

@keyframes a4ai-textPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
}

@keyframes a4ai-textShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

@keyframes a4ai-titleFlow {
    0% {
        background-position: -150% -150%;
        filter: drop-shadow(0 0 6px rgba(254, 128, 214, 0.25));
    }
    25% {
        background-position: -75% -75%;
        filter: drop-shadow(0 0 10px rgba(254, 128, 214, 0.4));
    }
    50% {
        background-position: 0% 0%;
        filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.3));
    }
    75% {
        background-position: 75% 75%;
        filter: drop-shadow(0 0 10px rgba(254, 128, 214, 0.4));
    }
    100% {
        background-position: 150% 150%;
        filter: drop-shadow(0 0 6px rgba(254, 128, 214, 0.25));
    }
}

.a4ai-sidebar-search {
    padding: 15px 20px;
    border-bottom: 1px solid var(--a4ai-border);
}

.a4ai-sidebar-search input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--a4ai-border);
    border-radius: 12px;
    color: var(--a4ai-text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s var(--a4ai-spring);
}

[data-theme="light"] .a4ai-sidebar-search input {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-sidebar-search input:focus {
    border-color: var(--a4ai-accent);
    transform: scale(1.02);
    box-shadow: 0 4px 15px var(--a4ai-accent-glow);
}

.a4ai-sidebar-search input::placeholder {
    color: var(--a4ai-text-secondary);
}

.a4ai-chats-list {
    flex: 1;
    overflow-y: auto;
    padding: 15px 12px;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.a4ai-chat-item {
    padding: 15px;
    margin-bottom: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--a4ai-border);
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    opacity: 1;
}

.a4ai-chat-item[data-chat-id] {
    animation: none;
}

[data-theme="light"] .a4ai-chat-item {
    background: rgba(0, 0, 0, 0.03);
}

@keyframes a4ai-fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.a4ai-chat-item-new {
    animation: a4ai-fadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) forwards;
    opacity: 0;
}

.a4ai-chat-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--a4ai-accent);
    transform: translateX(2px);
}

[data-theme="light"] .a4ai-chat-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-chat-item.active {
    background: linear-gradient(135deg, rgba(254, 0, 202, 0.2), rgba(204, 0, 160, 0.15));
    border-color: var(--a4ai-accent);
    box-shadow: 0 0px 15px var(--a4ai-accent-glow);
    transform: translateX(2px);
}

[data-theme="light"] .a4ai-chat-item.active {
    background: linear-gradient(135deg, rgba(254, 0, 202, 0.1), rgba(204, 0, 160, 0.08));
}

.a4ai-chat-item-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.a4ai-chat-item-preview {
    font-size: 13px;
    color: var(--a4ai-text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 6px;
}

.a4ai-chat-item-date {
    font-size: 11px;
    color: var(--a4ai-text-secondary);
    opacity: 0.7;
}

.a4ai-chat-item-delete {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background: rgba(255, 59, 59, 0.2);
    border: 1px solid rgba(255, 59, 59, 0.3);
    border-radius: 8px;
    color: var(--a4ai-error);
    font-size: 14px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.a4ai-chat-item:hover .a4ai-chat-item-delete {
    display: flex;
}

.a4ai-chat-item-delete:hover {
    background: var(--a4ai-error);
    color: white;
    transform: scale(1.1);
}

.a4ai-sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--a4ai-border);
    gap: 3px;
    display: flex;
    flex-direction: column;
}

.a4ai-copyright {
    font-size: 11px;
    color: var(--a4ai-text-secondary);
    font-family: 'Montserrat Alternates', sans-serif;
    margin: 0;
    margin-top: 12px;
    padding: 0;
    text-align: center;
    line-height: 1.4;
}

.a4ai-copyright-link {
    color: var(--a4ai-text-secondary);
    text-decoration: none;
    transition: none;
}

.a4ai-copyright-link:hover,
.a4ai-copyright-link:visited,
.a4ai-copyright-link:active {
    color: var(--a4ai-text-secondary);
    text-decoration: none;
}

.a4ai-copyright strong {
    color: var(--a4ai-text-secondary);
    font-weight: 600;
}

.a4ai-btn-clear-all {
    width: 100%;
    padding: 12px;
    margin-top: -1px;
    background: rgba(255, 59, 59, 0.1);
    border: 1px solid rgba(255, 59, 59, 0.3);
    border-radius: 12px;
    color: var(--a4ai-error);
    font-size: 14px;
    font-weight: 600;
    font-family: 'Montserrat Alternates', sans-serif;
    cursor: pointer;
    transition: all 0.3s var(--a4ai-spring);
}

.a4ai-btn-clear-all:hover {
    background: var(--a4ai-error);
    color: white;
    transform: translateY(-2px);
}

.a4ai-main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    animation: a4ai-fadeIn 0.8s var(--a4ai-smooth);
}

@keyframes a4ai-fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.a4ai-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--a4ai-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--a4ai-bg-glass);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    animation: a4ai-slideInDown 0.6s var(--a4ai-spring);
}

@keyframes a4ai-slideInDown {
    from {
        opacity: 0;
        transform: translateY(-40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.a4ai-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.a4ai-header h1 {
    font-size: 1.4rem;
    font-weight: 600;
    letter-spacing: -1px;
    background: linear-gradient(135deg, var(--a4ai-accent), var(--a4ai-accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: a4ai-glow 3s ease-in-out infinite;
}

@keyframes a4ai-glow {
    0%, 100% {
        filter: drop-shadow(0 0 3px var(--a4ai-accent-glow));
    }
    50% {
        filter: drop-shadow(0 0 8px var(--a4ai-accent-glow));
    }
}

.a4ai-badge-mode {
    padding: 6px 12px;
    background: var(--a4ai-success);
    color: white;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    animation: a4ai-pulse 2s ease-in-out infinite;
    margin-right: 20px;
}

@keyframes a4ai-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

.a4ai-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.a4ai-btn-icon {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--a4ai-border);
    border-radius: 12px;
    color: var(--a4ai-text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s var(--a4ai-spring);
}

[data-theme="light"] .a4ai-btn-icon {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-btn-icon:hover {
    background: var(--a4ai-accent);
    border-color: var(--a4ai-accent);
    transform: scale(1.15) rotate(10deg);
    box-shadow: 0 8px 25px var(--a4ai-accent-glow);
}

.a4ai-btn-icon:active {
    transform: scale(0.95);
}

.a4ai-chat-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.a4ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.a4ai-message {
    display: flex;
    gap: 15px;
    animation: a4ai-messageSlideIn 0.5s var(--a4ai-spring) backwards;
    opacity: 0;
    animation-fill-mode: forwards;
}

@keyframes a4ai-messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.a4ai-message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    animation: a4ai-avatarPop 0.4s var(--a4ai-spring) backwards;
}

@keyframes a4ai-avatarPop {
    0% {
        transform: scale(0) rotate(-180deg);
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0);
    }
}

.a4ai-message.user .a4ai-message-avatar {
    background: linear-gradient(135deg, var(--a4ai-accent), var(--a4ai-accent-hover));
    box-shadow: 0 4px 15px var(--a4ai-accent-glow);
}

.a4ai-message.bot .a4ai-message-avatar {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .a4ai-message.bot .a4ai-message-avatar {
    background: rgba(0, 0, 0, 0.1);
}

.a4ai-message-content {
    flex: 1;
    max-width: 75%;
    min-width: 0;
}

.a4ai-message-bubble {
    padding: 16px 20px;
    border-radius: 20px;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    position: relative;
    overflow: hidden;
    max-width: 100%;
    box-sizing: border-box;
}

.a4ai-message-bubble br {
    line-height: 0.8;
    margin: 0;
    display: block;
}

.a4ai-message-bubble br + br {
    margin-top: 8px;
    display: block;
}

.a4ai-message-bubble p {
    margin: 0;
    line-height: 1.4;
}

.a4ai-message-bubble p + p {
    margin-top: 10px;
}

.a4ai-message-bubble ul + br,
.a4ai-message-bubble br + ul,
.a4ai-message-bubble ul + p,
.a4ai-message-bubble p + ul {
    margin-top: 10px;
}

.a4ai-message.user .a4ai-message-bubble {
    background: linear-gradient(135deg, var(--a4ai-accent) 0%, var(--a4ai-accent-hover) 100%);
    color: white;
    border-bottom-right-radius: 12px;
    box-shadow: 0 4px 15px var(--a4ai-accent-glow);
}

.a4ai-message.bot .a4ai-message-bubble {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--a4ai-border);
    border-bottom-left-radius: 12px;
}

[data-theme="light"] .a4ai-message.bot .a4ai-message-bubble {
    background: rgba(0, 0, 0, 0.03);
}

.a4ai-message-bubble pre {
    margin: 10px 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    position: relative;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

[data-theme="light"] .a4ai-message-bubble pre {
    background: rgba(0, 0, 0, 0.05);
}

@keyframes a4ai-codeBlockSlide {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.a4ai-message-bubble pre code {
    display: block;
    padding: 20px;
    overflow-x: auto;
    overflow-wrap: break-word;
    word-wrap: break-word;
    font-family: 'Fira Code', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    max-width: 100%;
    white-space: pre;
}

.a4ai-code-copy-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.3s;
    z-index: 10;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.a4ai-code-copy-btn:hover {
    background: var(--a4ai-accent);
    border-color: var(--a4ai-accent);
    transform: scale(1.1);
}

[data-theme="light"] .a4ai-code-copy-btn {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(0, 0, 0, 0.2);
    color: var(--a4ai-text-primary);
}

.a4ai-inline-code {
    background: rgba(254, 0, 202, 0.15);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: 'Fira Code', monospace;
    font-size: 0.9em;
    color: var(--a4ai-accent);
}

.a4ai-message-bubble strong {
    font-weight: 700;
}

.a4ai-message-bubble em {
    font-style: italic;
}

.a4ai-message-time {
    font-size: 11px;
    color: var(--a4ai-text-secondary);
    margin-top: 6px;
    opacity: 0;
    animation: a4ai-fadeIn 0.5s 0.3s forwards;
}

.a4ai-typing-indicator {
    display: none;
    gap: 4px;
    align-items: center;
}

.a4ai-typing-indicator.active {
    display: flex;
}

.a4ai-typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--a4ai-accent);
    border-radius: 50%;
    animation: a4ai-typingDot 1.4s ease-in-out infinite;
    box-shadow: 0 0 8px var(--a4ai-accent-glow);
}

.a4ai-typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.a4ai-typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.a4ai-typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes a4ai-typingDot {
    0%, 60%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-8px) scale(1.2);
        opacity: 1;
    }
}

.a4ai-input-container {
    padding: 20px 30px;
    border-top: 1px solid var(--a4ai-border);
    background: var(--a4ai-bg-glass);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    animation: a4ai-slideInUp 0.6s var(--a4ai-spring);
}

@keyframes a4ai-slideInUp {
    from {
        opacity: 0;
        transform: translateY(40px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.a4ai-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

#attachBtn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

#a4ai-message-input {
    flex: 1;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--a4ai-border);
    border-radius: 14px;
    color: var(--a4ai-text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.3s var(--a4ai-spring);
    max-height: 150px;
}

[data-theme="light"] #a4ai-message-input {
    background: rgba(0, 0, 0, 0.05);
}

#messageInput:focus {
    border-color: var(--a4ai-accent);
    box-shadow: 0 0 30px var(--a4ai-accent-glow);
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="light"] #messageInput:focus {
    background: rgba(0, 0, 0, 0.08);
}

#messageInput::placeholder {
    color: var(--a4ai-text-secondary);
}

.a4ai-input-actions {
    display: flex;
    gap: 8px;
}

.a4ai-btn-secondary,
.a4ai-btn-primary {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--a4ai-spring);
}

.a4ai-btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--a4ai-border);
    color: var(--a4ai-text-primary);
}

[data-theme="light"] .a4ai-btn-secondary {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

[data-theme="light"] .a4ai-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

.a4ai-btn-primary {
    background: linear-gradient(135deg, var(--a4ai-accent), var(--a4ai-accent-hover));
    color: white;
    box-shadow: 0 4px 15px var(--a4ai-accent-glow);
}

.a4ai-btn-primary:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px var(--a4ai-accent-glow);
}

.a4ai-btn-primary:active,
.a4ai-btn-secondary:active {
    transform: scale(0.95);
}

.a4ai-input-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    font-size: 12px;
    color: var(--a4ai-text-secondary);
}

.a4ai-char-count {
    font-size: 12px;
}

.a4ai-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: a4ai-overlayFadeIn 0.3s;
    cursor: pointer;
    padding: 20px;
    overflow-y: auto;
}

.a4ai-popup-overlay.closing {
    animation: a4ai-overlayFadeOut 0.3s forwards;
}

@keyframes a4ai-overlayFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes a4ai-overlayFadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.a4ai-popup {
    background: var(--a4ai-bg-glass);
    border: 1px solid var(--a4ai-border);
    border-radius: var(--a4ai-radius-lg);
    max-width: 500px;
    width: 90%;
    max-height: calc(100vh - 80px);
    animation: a4ai-modalPop 0.4s var(--a4ai-spring);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
    cursor: default;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.a4ai-popup-overlay.closing .a4ai-popup {
    animation: a4ai-modalPopOut 0.3s var(--a4ai-smooth) forwards;
}

@keyframes a4ai-modalPop {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(30px);
    }
    60% {
        transform: scale(1.05) translateY(-5px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes a4ai-modalPopOut {
    0% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
    100% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
}

.a4ai-popup-header {
    padding: 25px;
    border-bottom: 1px solid var(--a4ai-border);
    flex-shrink: 0;
    background: var(--a4ai-bg-glass);
}

.a4ai-popup-header h3 {
    font-size: 1.3rem;
    background: linear-gradient(135deg, var(--a4ai-accent), var(--a4ai-accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.a4ai-popup-body {
    padding: 25px;
    overflow: hidden;
    flex: 1;
    min-height: 0;
    background: var(--a4ai-bg-glass);
    display: flex;
    flex-direction: column;
}

.a4ai-popup-body::-webkit-scrollbar {
    width: 6px;
}

.a4ai-popup-body::-webkit-scrollbar-track {
    background: transparent;
}

.a4ai-popup-body::-webkit-scrollbar-thumb {
    background: var(--a4ai-border);
    border-radius: 3px;
}

.a4ai-popup-body::-webkit-scrollbar-thumb:hover {
    background: var(--a4ai-accent);
}

.a4ai-popup-body p {
    margin-bottom: 20px;
    color: var(--a4ai-text-primary);
    font-size: 0.9rem;
    flex-shrink: 0;
}

.a4ai-popup-input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--a4ai-border);
    border-radius: 12px;
    color: var(--a4ai-text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: all 0.3s;
}

[data-theme="light"] .a4ai-popup-input {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-popup-input:focus {
    border-color: var(--a4ai-accent);
    box-shadow: 0 0 15px var(--a4ai-accent-glow);
}

.a4ai-popup-textarea {
    width: 100%;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1.5px solid var(--a4ai-border);
    border-radius: 12px;
    color: var(--a4ai-text-primary);
    font-size: 14px;
    font-family: 'Monaco', 'Courier New', monospace;
    outline: none;
    transition: all 0.3s;
    resize: vertical;
    min-height: 200px;
    margin-top: 0;
}

[data-theme="light"] .a4ai-popup-textarea {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-popup-textarea:focus {
    border-color: var(--a4ai-accent);
    box-shadow: 0 0 15px var(--a4ai-accent-glow);
}

.a4ai-popup-footer {
    padding: 20px 25px;
    border-top: 1px solid var(--a4ai-border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-shrink: 0;
    background: var(--a4ai-bg-glass);
}

.a4ai-popup-footer button {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--a4ai-spring);
    font-family: inherit;
    border: none;
}

.a4ai-popup-footer .a4ai-btn-secondary {
    width: auto;
    height: auto;
    background: rgba(255, 255, 255, 0.05);
    color: var(--a4ai-text-primary);
}

[data-theme="light"] .a4ai-popup-footer .a4ai-btn-secondary {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-popup-footer .a4ai-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

[data-theme="light"] .a4ai-popup-footer .a4ai-btn-secondary:hover {
    background: rgba(0, 0, 0, 0.1);
}

.a4ai-popup-footer .a4ai-btn-primary {
    width: auto;
    height: auto;
    background: linear-gradient(135deg, var(--a4ai-accent), var(--a4ai-accent-hover));
    color: white;
}

.a4ai-popup-footer .a4ai-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--a4ai-accent-glow);
}

.a4ai-notification-container {
    position: fixed;
    top: 103px;
    right: 20px;
    z-index: 10001;
    display: flex;
    flex-direction: column;
    gap: 0;
    pointer-events: none;
}

.a4ai-model-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
    max-height: 400px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
    margin-top: 20px;
}

.a4ai-model-item {
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--a4ai-border);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.3s var(--a4ai-smooth);
    box-shadow: none;
        width: 100%;
    box-sizing: border-box;
}

[data-theme="light"] .a4ai-model-item {
    background: rgba(0, 0, 0, 0.03);
}

.a4ai-model-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--a4ai-accent);
    transform: none;
    box-shadow: 0 0 20px rgba(254, 0, 202, 0.2);
}

.a4ai-model-item.active {
    background: linear-gradient(135deg, rgba(254, 0, 202, 0.2), rgba(204, 0, 160, 0.15));
    border-color: var(--a4ai-accent) !important;
    box-shadow: inset 0 0 15px rgba(254, 0, 202, 0.3), 0 0 10px rgba(254, 0, 202, 0.2);
}

.a4ai-model-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.a4ai-model-delete-btn {
    width: 28px;
    height: 28px;
    background: rgba(255, 59, 59, 0.1);
    border: 1px solid rgba(255, 59, 59, 0.3);
    border-radius: 6px;
    color: var(--a4ai-error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.a4ai-model-delete-btn:hover {
    background: var(--a4ai-error);
    color: white;
    transform: scale(1.1);
}

.a4ai-model-item-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--a4ai-text-primary);
    margin: 0;
}

.a4ai-model-size {
    font-size: 0.85rem;
    color: var(--a4ai-text-secondary);
    background: rgba(255, 255, 255, 0.1);
    padding: 4px 10px;
    border-radius: 8px;
}

.a4ai-model-description {
    font-size: 0.9rem;
    color: var(--a4ai-text-secondary);
    margin: 0;
}

.a4ai-model-selected {
    display: inline-block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--a4ai-accent);
    font-weight: 600;
}

.a4ai-model-downloaded-badge {
    font-size: 0.75rem;
    color: var(--a4ai-success);
    margin-left: 8px;
    font-weight: 600;
}

.a4ai-model-item.downloaded:not(.active) {
    border-color: var(--a4ai-success);
}

.a4ai-model-list::-webkit-scrollbar {
    width: 6px;
}

.a4ai-model-list::-webkit-scrollbar-track {
    background: transparent;
}

.a4ai-model-list::-webkit-scrollbar-thumb {
    background: var(--a4ai-border);
    border-radius: 3px;
}

.a4ai-model-list::-webkit-scrollbar-thumb:hover {
    background: var(--a4ai-accent);
}

.a4ai-attached-file {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--a4ai-border);
    border-radius: 12px;
    margin-bottom: 10px;
}

[data-theme="light"] .a4ai-attached-file {
    background: rgba(0, 0, 0, 0.05);
}

.a4ai-attached-file-name {
    font-size: 0.9rem;
    color: var(--a4ai-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.a4ai-attached-file-remove {
    width: 24px;
    height: 24px;
    background: rgba(255, 59, 59, 0.2);
    border: 1px solid rgba(255, 59, 59, 0.3);
    border-radius: 50%;
    color: var(--a4ai-error);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 10px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.a4ai-attached-file-remove:hover {
    background: var(--a4ai-error);
    color: white;
    transform: scale(1.1);
}

.a4ai-btn-secondary.a4ai-recording {
    background: var(--a4ai-error);
    animation: a4ai-pulse 1.5s ease-in-out infinite;
}

@keyframes a4ai-pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
}

.a4ai-notification {
    padding: 12px 18px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    max-width: 350px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    transform: translateX(400px);
    transition: transform 0.3s ease, opacity 0.3s ease;
    opacity: 0;
    pointer-events: auto;
    position: relative;
    margin-bottom: 0;
}

.a4ai-notification-show {
        transform: translateX(0);
    opacity: 1;
    }

.a4ai-notification-hide {
    transform: translateX(400px);
        opacity: 0;
}

.a4ai-notification-info {
    background: var(--a4ai-accent);
}

.a4ai-notification-success {
    background: var(--a4ai-success);
}

.a4ai-notification-error {
    background: var(--a4ai-error);
}

.a4ai-notification-warning {
    background: var(--a4ai-warning);
}

.a4ai-welcome-section {
    padding: 15px;
    line-height: 1.6;
}

.a4ai-welcome-section h2 {
    font-size: 1.3rem;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--a4ai-accent), var(--a4ai-accent-hover));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.a4ai-welcome-section h3 {
    font-size: 1.1rem;
    margin-top: 15px;
    margin-bottom: 8px;
}

.a4ai-welcome-list {
    margin: 10px 0;
    padding-left: 20px;
}

.a4ai-welcome-list li {
    margin-bottom: 6px;
    font-size: 0.9rem;
}

.a4ai-welcome-footer {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--a4ai-text-secondary);
    font-style: italic;
}

.a4ai-welcome-section ul {
    margin-left: 20px;
    margin-bottom: 15px;
}

.a4ai-welcome-section li {
    margin-bottom: 8px;
}

.a4ai-welcome-link {
    color: var(--a4ai-accent);
    font-weight: bold;
    text-decoration: none;
    transition: color 0.2s ease;
}

.a4ai-welcome-link:hover {
    color: var(--a4ai-accent-hover);
    text-decoration: underline;
}

.a4ai-loading-message {
    text-align: center;
    padding: 20px;
}

.a4ai-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(254, 0, 202, 0.2);
    border-top-color: var(--a4ai-accent);
    border-radius: 50%;
    animation: a4ai-spin 1s linear infinite;
    margin: 0 auto 15px;
}

@keyframes a4ai-spin {
    to {
        transform: rotate(360deg);
    }
}

.a4ai-btn-install {
    width: 100%;
    padding: 14px 20px;
    margin-bottom: 12px;
    background: rgba(40, 40, 40, 0.8);
    color: var(--a4ai-text-primary);
    border: 1.5px solid rgba(150, 150, 150, 0.4);
    border-radius: var(--a4ai-radius);
    font-size: 15px;
    font-weight: 600;
    font-family: 'Montserrat Alternates', sans-serif;
    cursor: pointer;
    transition: all 0.3s var(--a4ai-spring);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.a4ai-btn-install:hover {
    transform: translateY(-2px);
    background: rgba(50, 50, 50, 0.9);
    border-color: rgba(180, 180, 180, 0.6);
}

.a4ai-btn-install:active {
    transform: scale(0.98);
}

.a4ai-btn-install span:first-child {
    font-size: 18px;
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }

    .a4ai-sidebar {
        width: 100%;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--a4ai-border);
    }

    .a4ai-chats-list {
        max-height: 25vh;
    }

    .a4ai-header h1 {
        font-size: 1.3rem;
        font-weight: 600;
    }

    .a4ai-messages {
        padding: 12px 10px;
        gap: 15px;
    }

    .a4ai-message {
        gap: 10px;
        padding: 0 5px;
    }

    .a4ai-message-content {
        max-width: calc(100% - 50px);
        min-width: 0;
    }

    .a4ai-message-bubble {
        padding: 12px 16px;
        border-radius: 18px;
        font-size: 14px;
    }

    .a4ai-message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
        flex-shrink: 0;
    }

    .a4ai-input-container {
        padding: 12px 10px;
    }

    #a4ai-message-input {
        font-size: 16px;
        padding: 12px 16px;
    }

    .a4ai-sidebar-footer {
        padding: 12px 15px;
    }

    .a4ai-btn-install,
    .a4ai-btn-clear-all {
        padding: 12px 16px;
        font-size: 14px;
    }
}
