html, body {
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: linear-gradient(rgba(10,10,10,0.7), rgba(10,10,10,0.9)), url('image.jpg') no-repeat center/cover fixed;
    color: #e8e8e8;
}

.chat-app {
    display: flex;
    width: 100vw;
    height: 100vh;
    background: transparent;
}

/* Sidebar */
.sidebar {
    pointer-events: auto;
    background: rgba(10,10,10,0.95);
    backdrop-filter: blur(20px);
    width: 280px;
}

.sidebar-brand {
    padding: 20px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #141414;
    background: linear-gradient(180deg, #121212 0%, #0a0a0a 100%);
}

.brand-logo { display: flex; align-items: center; gap: 10px; }
.brand-text { display: flex; flex-direction: column; gap: 1px; }
.brand-name { font-size: 15px; font-weight: 700; color: #e8e8e8; letter-spacing: 0.5px; }
.brand-sub { font-size: 10px; color: #707070; letter-spacing: 1.5px; text-transform: uppercase; opacity: 0.8; }
.brand-badge {
    font-size: 9px; font-weight: 700; letter-spacing: 1px; color: #707070;
    border: 1px solid #333; border-radius: 4px; padding: 2px 6px; background: #1a1a1a;
}

.sidebar-new-chat { padding: 12px 10px 8px; }
.new-chat-btn {
    width: 100%; display: flex; align-items: center; gap: 8px;
    background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px;
    padding: 9px 14px; color: #a0a0a0; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.2s; text-align: left;
}
.new-chat-btn:hover { background: #222; border-color: #404040; }
.new-chat-icon { font-size: 18px; line-height: 1; color: #a0a0a0; }

.sidebar-section { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding-top: 6px; }
.section-label {
    padding: 8px 16px 4px; font-size: 10px; font-weight: 600;
    letter-spacing: 1.2px; text-transform: uppercase; color: #505050;
}

.conversations-list {
    flex: 1; overflow-y: auto; padding: 4px 8px 8px;
}
.conversations-list::-webkit-scrollbar { width: 3px; }
.conversations-list::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

.conversation-item {
    position: relative;
    padding: 10px 36px 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #707070;
    margin-bottom: 2px;
}
.conversation-item::before {
    content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
    width: 2px; height: 0; background: #a0a0a0; border-radius: 0 2px 2px 0; transition: height 0.2s;
}
.conversation-item:hover { background: #1a1a1a; color: #b0b0b0; }
.conversation-item:hover::before { height: 60%; }
.conversation-item.active { background: #1a1a1a !important; color: #e8e8e8 !important; }
.conversation-item.active::before { height: 70% !important; }

.conversation-item .more-dots {
    position: absolute;
    right: 8px; top: 50%;
    transform: translateY(-50%);
    font-size: 18px;
    color: #505050;
    opacity: 0;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.conversation-item:hover .more-dots {
    opacity: 1;
    color: #a0a0a0;
    background: rgba(26,26,26,0.8);
}

.conversation-item:hover .more-dots:hover {
    background: #1a1a1a;
    color: #e8e8e8;
}

.conversation-item.active .more-dots {
    opacity: 1;
    color: #a0a0a0;
}

.empty-convs { padding: 32px 16px; text-align: center; color: #505050; font-size: 13px; }

/* Chat main */
.chat-main {
    flex: 1;
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(20px);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 20px;
    position: relative;
}

.chat-main .messages.empty + .input-area {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: calc(100% - 40px);
    z-index: 10;
    background: rgba(15,15,15,0.95);
    backdrop-filter: blur(20px);
    border-top: 1px solid #151515;
    padding: 14px 20px;
    border-radius: 12px;
}

.chat-main.empty-chat {
    align-items: center;
    justify-content: center;
}

.header {
    padding: 20px 20px; display: flex; align-items: center; gap: 12px;
}
.header h1 {
    font-size: 14px; font-weight: 500; flex: 1; color: #707070;
    letter-spacing: 0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Model dropdown */
.model-dropdown {
    position: relative;
    display: flex;
    align-items: center;
}

.model-button {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #141414 !important;
    color: #b0b0b0 !important;
    border: 1px solid #1e1e1e !important;
    border-radius: 8px !important;
    padding: 6px 12px !important;
    font-size: 12px !important;
    cursor: pointer !important;
    min-height: 32px;
    transition: all 0.15s;
    outline: none;
}

.model-button:hover {
    border-color: #333 !important;
    background: #151515 !important;
    color: #e8e8e8 !important;
}

.model-button:focus {
    border-color: #505050 !important;
    box-shadow: 0 0 0 2px rgba(80, 80, 80, 0.3);
}

.dropdown-arrow {
    transition: transform 0.2s;
    margin-left: auto;
}

.model-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    min-width: 200px;
    background: #151515;
    border: 1px solid #1e1e1e;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: all 0.2s ease;
    max-height: 300px;
    overflow-y: auto;
}

.model-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-menu::-webkit-scrollbar { width: 4px; }
.model-menu::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

.model-item {
    padding: 10px 14px;
    font-size: 13px;
    color: #b0b0b0;
    cursor: pointer;
    border-bottom: 1px solid #1a1a1a;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.15s;
    white-space: nowrap;
}

.model-item:hover {
    background: #1a1a1a;
    color: #e8e8e8;
}

.model-item:last-child {
    border-bottom: none;
    border-radius: 0 0 8px 8px;
}

.model-button.active .dropdown-arrow {
    transform: rotate(180deg);
}

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

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 20px;
}

.messages.empty > .empty-state {
    visibility: hidden;
    position: absolute;
    left: -9999px;
}

.chat-main.empty-chat .input-area {
    position: unset;
    align-self: center;
}

.messages:not(.empty) ~ .input-area {
    margin-top: auto;
}

.messages.empty > .empty-state {
    display: none;
}

.messages::-webkit-scrollbar { width: 4px; }
.messages::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 2px; }

.message { display: flex; flex-direction: column; max-width: 80%; width: fit-content; }
.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }
.message .label {
    font-size: 10px; color: #505050; margin-bottom: 4px;
    padding: 0 6px 0 0; letter-spacing: 0.8px; text-transform: uppercase;
    font-weight: 500; line-height: 1; white-space: nowrap;
}
.message .bubble {
    padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.6;
    white-space: pre-wrap; word-break: break-word; max-width: 100%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
.message.user .bubble {
    background: linear-gradient(135deg, #1a1a1a 0%, #0f0f0f 100%);
    border: 1px solid #2a2a2a; border-bottom-right-radius: 4px; color: #d8d8d8;
}
.message.assistant .bubble {
    background: #151515; border: 1px solid #1a1a1a;
    border-bottom-left-radius: 4px; color: #c0c0c0;
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.empty-state-inner { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty-state-inner p { color: #505050; font-size: 14px; letter-spacing: 0.3px; }

/* Attachments buffer */
.attachments-buffer {
    background: #151515;
    border: 1px solid #1e1e1e;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 20px 8px;
}

.buffer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 12px;
    color: #a0a0a0;
    font-weight: 500;
}

.clear-btn {
    background: none;
    border: none;
    color: #707070;
    font-size: 16px;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-btn:hover {
    background: #1a1a1a;
    color: #e8e8e8;
}

.attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: 80px;
    overflow-y: auto;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    color: #b0b0b0;
    max-width: 200px;
}

.attachment-remove {
    background: none;
    border: none;
    color: #707070;
    font-size: 14px;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 4px;
}

.attachment-remove:hover {
    background: #333;
    color: #e8e8e8;
}

.input-area {
    padding: 14px 20px; display: flex; flex-direction: column; gap: 10px;
    border-top: 1px solid #151515; background: rgba(15,15,15,0.95);
}

.input-left {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex: 1;
}

.attach-btn {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 48px;
    height: 48px;
}

.attach-btn:hover {
    background: #222;
    border-color: #404040;
}

.attach-btn svg path {
    transition: fill 0.15s;
}

.attach-btn:hover svg path {
    fill: #d8d8d8;
}

textarea {
    flex: 1; background: #141414; color: #e8e8e8; border: 1px solid #1e1e1e;
    border-radius: 10px; padding: 12px 16px; font-size: 14px; resize: none;
    outline: none; font-family: inherit; max-height: 120px; min-height: 46px;
    line-height: 1.5; transition: border-color 0.15s;
}
textarea:focus { border-color: #505050; }
textarea::placeholder { color: #505050; }

button:not(.attach-btn):not(.clear-btn):not(.attachment-remove):not(.more-btn) {
    background: #1a1a1a; color: #a0a0a0; border: 1px solid #2a2a2a;
    border-radius: 10px; padding: 12px 18px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
button:not(.attach-btn):not(.clear-btn):not(.attachment-remove):not(.more-btn):hover {
    background: #222; border-color: #404040; color: #d8d8d8;
}
button:not(.attach-btn):not(.clear-btn):not(.attachment-remove):not(.more-btn):disabled {
    background: #141414; color: #505050; border-color: #1e1e1e; cursor: not-allowed;
}

/* Screen и Login */
.screen {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 1000; background: rgb(17 17 17 / 100%);
}

.login-form {
    background: #0f0f0f; border: 1px solid #1a1a1a; border-radius: 14px;
    padding: 28px 24px; display: flex; flex-direction: column; gap: 12px; width: 300px;
}

.login-logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; }
.login-logo-text {
    font-size: 22px; font-weight: 800;
    background: linear-gradient(135deg, #e8e8e8 0%, #a0a0a0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-form h2 { font-size: 14px; color: #606060; text-align: center; font-weight: 400; margin-bottom: 4px; }
.login-form input {
    background: #141414; color: #e8e8e8; border: 1px solid #1e1e1e;
    border-radius: 8px; padding: 11px 14px; font-size: 14px; outline: none;
    transition: border-color 0.15s;
}
.login-form input:focus { border-color: #505050; }
.login-form input::placeholder { color: #505050; }

.login-form button {
    background: #1a1a1a; color: #a0a0a0; border: 1px solid #2a2a2a;
    border-radius: 8px; padding: 11px 14px; font-size: 14px; font-weight: 600;
    cursor: pointer; transition: all 0.15s;
}
.login-form button:hover { background: #222; border-color: #404040; color: #d8d8d8; }

/* LOGO "C" */
.logo-c {
    display: block;
    cursor: pointer;
}

.login-logo .logo-c { width: 50px; height: 50px; }
.sidebar-brand .logo-c { width: 28px; height: 28px; }
.empty-state .logo-c { width: 70px; height: 70px; opacity: 0.5; }

.logo-c path {
    animation: spin 25s linear infinite;
    transform-origin: center;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.logo-c:hover path {
    stroke: #7dcfff !important;
    stroke-width: 4.5 !important;
    filter: drop-shadow(0 0 4px rgba(125, 207, 255, 0.5))
            drop-shadow(0 0 8px rgba(125, 207, 255, 0.3));
}

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

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

/* Chat type tabs */
.chat-type-tabs {
    display: flex;
    gap: 2px;
    background: #141414;
    border: 1px solid #1e1e1e;
    border-radius: 8px;
    padding: 2px;
}

.chat-type-tab {
    background: transparent !important;
    border: none !important;
    border-radius: 6px !important;
    padding: 5px 12px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    color: #707070 !important;
    cursor: pointer !important;
    transition: all 0.15s !important;
    min-height: unset !important;
}

.chat-type-tab:hover {
    color: #b0b0b0 !important;
    background: #1a1a1a !important;
}

.chat-type-tab.active {
    background: #1e1e1e !important;
    color: #e8e8e8 !important;
}

/* Conversation type badge */
.conv-type-badge {
    margin-right: 4px;
    font-size: 12px;
}

/* Inline media in messages */
.attachment-media {
    margin-top: 8px;
}

.attachment-image {
    max-width: 400px;
    max-height: 400px;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.15s;
    display: block;
}

.attachment-image:hover {
    opacity: 0.85;
}

.attachment-video {
    max-width: 480px;
    max-height: 360px;
    border-radius: 8px;
    display: block;
    background: #000;
}

.message-attachments {
    margin-top: 6px;
}
