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

:root {
    /* Windows Aero style colors - Red, Yellow, Blue with transparency */
    --red-aero: rgba(255, 105, 97, 0.7);
    --yellow-aero: rgba(255, 235, 59, 0.7);
    --blue-aero: rgba(100, 181, 246, 0.7);
    --blue-aero-solid: rgba(59, 130, 246, 1);
    
    --red-aero-light: rgba(255, 182, 193, 0.4);
    --yellow-aero-light: rgba(255, 255, 153, 0.4);
    --blue-aero-light: rgba(173, 216, 230, 0.4);
    
    --white-underlay: rgba(255, 255, 255, 0.9);
    --glass-white: rgba(255, 255, 255, 0.3);
    
    --text-primary: rgba(30, 41, 59, 0.95);
    --text-secondary: rgba(51, 65, 85, 0.85);
    --text-muted: rgba(100, 116, 139, 0.75);
    
    --border-color: rgba(148, 163, 184, 0.3);
    --border-light: rgba(203, 213, 225, 0.25);
    
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.2);
    --shadow-xl: 0 12px 40px rgba(0, 0, 0, 0.25);
    
    --backdrop-blur: blur(20px);
    --backdrop-blur-light: blur(10px);
    
    /* Modern colors */
    --success-green: rgba(34, 197, 94, 0.9);
    --warning-orange: rgba(249, 115, 22, 0.9);
    --info-blue: rgba(59, 130, 246, 0.9);
    --danger-red: rgba(239, 68, 68, 0.9);
    
    /* Button colors */
    --check-green: rgba(34, 197, 94, 1);
    --update-orange: rgba(249, 115, 22, 1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, 
        var(--red-aero) 0%, 
        var(--yellow-aero) 50%, 
        var(--blue-aero) 100%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    backdrop-filter: var(--backdrop-blur);
}

/* ===== WELCOME PAGE ===== */
.welcome-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, 
        var(--red-aero-light) 0%, 
        var(--yellow-aero-light) 50%, 
        var(--blue-aero-light) 100%);
    backdrop-filter: var(--backdrop-blur);
    z-index: 1000;
    animation: fadeIn 0.6s ease-out;
}

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

.welcome-container {
    text-align: center;
    padding: 40px;
    animation: slideUp 0.8s ease-out;
    width: 100%;
    max-width: 600px;
}

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

.logo-container {
    margin-bottom: 24px;
    animation: pulse 2s ease-in-out infinite;
}

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

.logo-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

.welcome-title {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 12px;
    background: linear-gradient(135deg, 
        rgba(239, 68, 68, 0.95), 
        rgba(255, 193, 7, 0.95), 
        rgba(59, 130, 246, 0.95));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 8px rgba(255, 255, 255, 0.5);
}

.welcome-subtitle {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 48px;
    font-weight: 300;
}

/* Key Input Window */
.key-input-window {
    background: transparent;
    border: none;
    box-shadow: none;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.key-input-body {
    padding: 0;
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
}

.key-input-field {
    flex: 1;
    padding: 16px 20px;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    outline: none;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    min-height: 50px;
}

.key-input-field:focus {
    background: rgba(255, 255, 255, 0.25);
    border-color: var(--blue-aero);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.key-input-field::placeholder {
    color: var(--text-muted);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.key-submit-button {
    padding: 16px 24px;
    background: var(--blue-aero-solid);
    border: none;
    border-radius: 12px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    font-size: 16px;
    font-weight: 600;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    min-height: 50px;
    white-space: nowrap;
}

.key-submit-button:hover {
    background: rgba(59, 130, 246, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.key-options {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
}

.key-options-title {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 14px;
}

.generate-key-button {
    padding: 14px 24px;
    background: transparent;
    border: 2px solid var(--info-blue);
    border-radius: 10px;
    color: var(--info-blue);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.3s ease;
    font-size: 15px;
    font-weight: 500;
    width: 100%;
}

.generate-key-button:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: translateY(-1px);
}

.key-error-message {
    padding: 12px 20px;
    color: var(--danger-red);
    font-size: 14px;
    display: none;
    animation: shake 0.4s ease;
    margin-top: 10px;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.key-error-message.show {
    display: block;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

/* Generate Key Window */
.generate-key-window {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    margin-top: 20px;
}

.generate-key-form .form-group {
    margin-bottom: 24px;
    text-align: left;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-weight: 500;
}

.form-input,
.form-select {
    width: 100%;
    padding: 14px 18px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.15);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s ease;
    font-family: inherit;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--blue-aero);
    background: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.form-note {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 8px;
    color: var(--info-blue);
    font-size: 14px;
    margin: 20px 0;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 30px;
}

.form-button {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.form-button.primary {
    background: var(--info-blue);
    color: white;
}

.form-button.primary:hover {
    background: rgba(59, 130, 246, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.form-button.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.form-button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--blue-aero);
}

/* Key Generated Screen */
.key-generated-window {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    margin-top: 40px;
}

.key-message {
    margin-bottom: 30px;
}

.key-icon {
    color: var(--success-green);
    margin-bottom: 15px;
}

.key-message-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.email-note {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
}

.key-display {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.key-label {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.key-value {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    margin: 15px 0;
    word-break: break-all;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.key-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.key-action-button {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.key-action-button.copy {
    background: var(--info-blue);
    color: white;
}

.key-action-button.copy:hover {
    background: rgba(59, 130, 246, 0.9);
    transform: translateY(-1px);
}

.key-action-button.close {
    background: var(--success-green);
    color: white;
}

.key-action-button.close:hover {
    background: rgba(34, 197, 94, 0.9);
    transform: translateY(-1px);
}

.key-instructions {
    margin-top: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    font-size: 14px;
    color: var(--text-secondary);
}

.key-instructions p {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.key-instructions p:last-child {
    margin-bottom: 0;
}

/* Key Expired Screen */
.key-expired-window {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 30px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    margin-top: 20px;
}

.key-expired-info {
    text-align: center;
}

.expired-icon {
    color: var(--warning-orange);
    margin-bottom: 20px;
}

.expired-message {
    color: var(--text-secondary);
    margin-bottom: 15px;
    font-size: 16px;
}

.expired-key {
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    color: var(--text-primary);
    margin: 20px 0;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.expired-options {
    margin-top: 30px;
}

.expired-note {
    background: rgba(249, 115, 22, 0.1);
    border: 1px solid rgba(249, 115, 22, 0.2);
    border-radius: 10px;
    padding: 15px;
    color: var(--warning-orange);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 20px;
}

.expired-button {
    width: 100%;
    padding: 14px 20px;
    margin-bottom: 12px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.expired-button.primary {
    background: var(--warning-orange);
    color: white;
}

.expired-button.primary:hover {
    background: rgba(249, 115, 22, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.expired-button.secondary {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.expired-button.secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--blue-aero);
}

.extend-key-form {
    text-align: left;
}

.extend-title {
    color: var(--text-primary);
    margin-bottom: 24px;
    text-align: center;
}

.welcome-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer-text {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ===== CHAT INTERFACE ===== */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.25) 0%,
        rgba(255, 255, 255, 0.15) 100%);
    backdrop-filter: var(--backdrop-blur);
    border-right: 1px solid rgba(255, 255, 255, 0.3);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.new-chat-button {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.4),
        rgba(255, 255, 255, 0.2));
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    backdrop-filter: var(--backdrop-blur-light);
    margin-top: 8px;
}

.new-chat-button:hover {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.5),
        rgba(255, 255, 255, 0.3));
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Methodology Buttons */
.methodology-buttons {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

.methodology-button {
    flex: 1;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
}

.methodology-button.check {
    background: var(--check-green);
    color: white;
}

.methodology-button.check:hover {
    background: rgba(34, 197, 94, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.methodology-button.update {
    background: var(--update-orange);
    color: white;
}

.methodology-button.update:hover {
    background: rgba(249, 115, 22, 0.9);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(249, 115, 22, 0.3);
}

.conversations-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.no-conversations-message {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
    margin: auto;
}

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

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

.conversations-list::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 3px;
}

.conversations-list::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

.conversation-item {
    padding: 10px 14px;
    margin-bottom: 4px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
    border: 1px solid transparent;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    color: var(--text-secondary);
    font-size: 13px;
    gap: 8px;
}

.conversation-item:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.conversation-item.active {
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.35),
        rgba(255, 255, 255, 0.25));
    border-color: rgba(255, 255, 255, 0.4);
    color: var(--text-primary);
}

.conversation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conversation-title-container {
    display: flex;
    align-items: center;
    gap: 6px;
}

.conversation-title {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.conversation-edit {
    opacity: 0;
    transition: opacity 0.2s;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 11px;
    border-radius: 4px;
}

.conversation-item:hover .conversation-edit {
    opacity: 1;
}

.conversation-edit:hover {
    background: rgba(255, 255, 255, 0.2);
}

.conversation-preview {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.3;
}

.conversation-time {
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conversation-delete {
    opacity: 0;
    transition: opacity 0.2s;
    padding: 4px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-muted);
}

.conversation-item:hover .conversation-delete {
    opacity: 1;
}

.conversation-delete:hover {
    background: rgba(255, 105, 97, 0.2);
    color: var(--red-aero);
}

/* Sidebar Footer - Key Management */
.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.key-management {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Для ключей 1-30 дней и бессрочных уменьшаем нижний отступ для выравнивания с верхним */
.key-management.optimized-padding {
    padding-bottom: 12px;
}

.current-key-info {
    margin-bottom: 16px;
}

/* Убираем margin-top у key-actions только для компактных ключей (НЕ для "131313") */
.current-key-info.limited-key-compact .key-actions {
    margin-top: 0 !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Для "131313" уменьшаем отступы, но не применяем компактные стили */
.current-key-info:not(.limited-key-compact) .key-actions {
    display: flex !important;
    flex-direction: column !important;
    margin-top: 0 !important; /* Убираем margin-top, чтобы отступ был только от key-display-short */
    gap: 8px !important; /* Уменьшенный gap между кнопками */
}

/* Уменьшаем отступы для "131313" - эти правила должны идти ПОСЛЕ всех общих правил */
/* Важно: эти правила должны быть самыми последними для правильного применения */
.current-key-info:not(.limited-key-compact) .key-display-short {
    margin-bottom: 8px !important; /* Отступ от "Key: 131313..." до кнопок "Generate Key", "Revoke Key" */
}

.current-key-info:not(.limited-key-compact) .key-actions-row {
    margin-bottom: 8px !important; /* Отступ от "Generate Key", "Revoke Key" до "End Session" */
}

/* Дополнительное правило для гарантии применения одинаковых отступов для "131313" */
.current-key-info:not(.limited-key-compact) #displayKey {
    margin-bottom: 8px !important;
}

.current-key-info:not(.limited-key-compact) .key-header {
    margin-bottom: 8px !important; /* Уменьшенный отступ для header */
}

.key-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

.key-header .fa-key {
    color: var(--warning-orange);
}

.key-timer {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    font-size: 12px;
    color: var(--success-green);
    margin-left: auto;
}

.key-display-short {
    display: none !important; /* Ключи полностью скрыты для безопасности */
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
    padding: 8px 12px;
    border-radius: 8px;
    /* margin-bottom устанавливается специфичными правилами */
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Компактный отступ для всех ключей, кроме "131313" */
.key-display-short.limited-key-compact {
    margin-bottom: 6px !important;
}

/* Убираем margin-top у key-actions для компактных ключей (НЕ для "131313") */
.current-key-info.limited-key-compact .key-actions {
    margin-top: 0 !important;
}

.key-actions {
    display: flex;
    flex-direction: column;
    gap: 10px !important;
}

/* Отступ между End Session и Delete All Chats */
.key-action.end-session {
    margin-bottom: 8px !important;
}

/* Унифицированные отступы для всех элементов */
.key-header {
    margin-bottom: 12px !important;
}

/* Удалено - конфликтует с правилом для "131313" */
/* .key-display-short {
    margin-bottom: 12px !important;
} */

/* Компактные отступы для всех ключей, кроме "131313" */
.current-key-info.limited-key-compact .key-actions-row {
    margin-bottom: 10px !important;
}

.key-action {
    padding: 10px 12px;
    border: none;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.key-action.end-session {
    background: var(--danger-red);
    color: white;
}

.key-action.end-session:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: translateY(-1px);
}

.key-action.delete-chats {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.key-action.delete-chats:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger-red);
    color: var(--danger-red);
}

.key-action.generate-key {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.key-action.generate-key:hover {
    background: linear-gradient(135deg, #5568d3 0%, #6a3d8f 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.key-action.revoke-key {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
}

.key-action.revoke-key:hover {
    background: linear-gradient(135deg, #c82333 0%, #bd2130 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.key-actions-row {
    display: flex;
    gap: 8px;
    /* margin-bottom устанавливается специфичными правилами для разных типов ключей */
}

.key-details {
    padding: 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
    color: var(--text-muted);
}

.key-details .key-info-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.key-details .key-info-item:last-child {
    margin-bottom: 0;
}

.key-details .key-info-label {
    font-weight: 500;
}

.key-details .key-info-value {
    font-weight: 600;
}

.key-details .key-info-value.active {
    color: var(--success-green);
}

/* Main Container */
.main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: var(--backdrop-blur);
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ===== ДЕСКТОПНЫЙ ВЕРХНИЙ БАР ===== */
.desktop-top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 64px;
    box-shadow: 0 2px 15px rgba(102, 126, 234, 0.2);
    position: relative;
    z-index: 10;
}

.desktop-brand-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.desktop-logo-small img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
}

.desktop-brand-text {
    display: flex;
    flex-direction: column;
}

.desktop-app-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    color: white;
    line-height: 1.2;
}

.desktop-app-subtitle {
    font-size: 0.85rem;
    opacity: 0.9;
    margin: 2px 0 0 0;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 400;
}

.desktop-token-section {
    display: flex;
    align-items: center;
    gap: 8px; /* Уменьшенный отступ между счетчиком и кнопками */
    justify-content: flex-end;
}

.desktop-token-counter {
    /* Убран контейнер: background, border, padding, border-radius */
    font-size: 17.5px; /* Уменьшено в 1.2 раза: 21px / 1.2 = 17.5px */
    font-weight: 600;
    color: white;
    min-width: 120px;
    text-align: center;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dialog-info-icon,
.dialog-export-icon {
    /* Убраны круглые контейнеры: background, border, border-radius */
    width: 40px; /* Уменьшено в 1.2 раза: 48px / 1.2 = 40px */
    height: 40px; /* Уменьшено в 1.2 раза: 48px / 1.2 = 40px */
    display: none; /* Скрыта по умолчанию, показывается через JS когда есть активный диалог */
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 20px; /* Уменьшено в 1.2 раза: 24px / 1.2 = 20px */
    transition: all 0.3s ease;
    padding: 0;
    flex-shrink: 0;
    background: none;
    border: none;
}

.dialog-info-icon:hover,
.dialog-export-icon:hover {
    opacity: 0.8;
    transform: scale(1.1);
}

.dialog-info-icon:active,
.dialog-export-icon:active {
    transform: scale(0.95);
}

/* Заголовок чата - скрыт на десктопе, виден на мобильных */
.chat-header {
    display: none;
}

/* На мобильных показываем chat-header */
@media (max-width: 768px) {
    .chat-header {
        display: flex !important;
        padding: 12px 16px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        align-items: center;
        height: 60px;
        min-height: 60px;
        border-bottom: 1px solid rgba(255,255,255,0.2);
        flex-shrink: 0;
        z-index: 100;
        position: relative;
    }
}

/* Увеличиваем основной контейнер */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 64px);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: var(--backdrop-blur);
    display: flex;
    flex-direction: column;
}

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.6);
}

.welcome-message {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-secondary);
    animation: fadeIn 0.6s ease-out;
}

.welcome-icon {
    font-size: 72px;
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
    color: #667eea;
}

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

.welcome-message h2 {
    font-size: 32px;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
}

.welcome-message p {
    font-size: 18px;
    color: var(--text-muted);
    font-weight: 300;
    margin-bottom: 30px;
}

.welcome-tips {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-width: 500px;
    margin: 0 auto;
}

.tip {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    text-align: left;
}

.tip i {
    font-size: 20px;
    color: var(--blue-aero);
}

.message {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.4s ease-out;
    max-width: 85%;
    align-items: flex-start;
    margin-bottom: 20px;
}

.message.user {
    align-self: flex-end;
    flex-direction: row-reverse;
    margin-left: auto;
}

.message.ai {
    align-self: flex-start;
    margin-right: auto;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    background: linear-gradient(135deg, 
        rgba(255, 255, 255, 0.4),
        rgba(255, 255, 255, 0.2));
    backdrop-filter: var(--backdrop-blur-light);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--blue-aero), var(--blue-aero-light));
}

.message.ai .message-avatar {
    background: transparent;
    padding: 0;
    overflow: hidden;
}

.message-content {
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.7;
    word-wrap: break-word;
    backdrop-filter: var(--backdrop-blur-light);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
    font-size: 15px;
}

.message.user .message-content {
    background: linear-gradient(135deg, 
        rgba(100, 181, 246, 0.4),
        rgba(173, 216, 230, 0.4));
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

.message.ai .message-content {
    background: linear-gradient(135deg, 
        rgba(255, 182, 193, 0.4),
        rgba(255, 255, 153, 0.4));
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    padding: 0 4px;
}

.message-file, .message-image {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 12px;
    margin-top: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    backdrop-filter: var(--backdrop-blur-light);
}

.message-image img {
    max-width: 300px;
    max-height: 300px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.file-icon, .image-icon {
    font-size: 20px;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 14px;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    font-size: 12px;
    color: var(--text-muted);
}

/* Input Container */
.input-container {
    padding: 20px 32px;
    background: linear-gradient(180deg,
        rgba(255, 255, 255, 0.2),
        rgba(255, 255, 255, 0.15));
    backdrop-filter: var(--backdrop-blur);
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.attached-files {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
    min-height: 0;
}

.attached-file-preview {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: linear-gradient(135deg, 
        rgba(255, 235, 59, 0.3),
        rgba(255, 193, 7, 0.3));
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 14px;
    font-size: 13px;
    backdrop-filter: var(--backdrop-blur-light);
}

.attached-file-preview .file-name {
    color: var(--text-primary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.remove-file {
    cursor: pointer;
    color: var(--red-aero);
    font-size: 18px;
    line-height: 1;
    padding: 2px;
    transition: transform 0.2s;
}

.remove-file:hover {
    transform: scale(1.2);
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: linear-gradient(135deg,
        rgba(255, 255, 255, 0.4),
        rgba(255, 255, 255, 0.3));
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 24px;
    padding: 14px 16px;
    transition: all 0.3s ease;
    backdrop-filter: var(--backdrop-blur-light);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.input-wrapper:focus-within {
    border-color: rgba(100, 181, 246, 0.6);
    box-shadow: 0 0 0 4px rgba(100, 181, 246, 0.2),
                0 4px 16px rgba(0, 0, 0, 0.15);
}

/* Input Action Buttons - Blue outlined circles */
.input-action-button {
    background: rgba(255, 255, 255, 0.3);
    border: 2px solid var(--blue-aero-solid);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--blue-aero-solid);
    transition: all 0.3s ease;
    flex-shrink: 0;
    backdrop-filter: blur(5px);
}

.input-action-button:hover {
    background: rgba(59, 130, 246, 0.1);
    transform: scale(1.1);
}

.input-action-button:active {
    transform: scale(0.95);
}

.plus-button i,
.mic-button i {
    font-size: 16px;
}

.mic-button.recording {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger-red);
    color: var(--danger-red);
    animation: pulse-recording 1.5s ease-in-out infinite;
}

@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

.message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 200px;
    overflow-y: auto;
    outline: none;
    line-height: 1.6;
    padding: 8px 0;
}

.message-input::placeholder {
    color: var(--text-muted);
}

.message-input::-webkit-scrollbar {
    width: 4px;
}

.message-input::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.4);
    border-radius: 2px;
}

.send-button {
    background: linear-gradient(135deg, var(--blue-aero-solid), rgba(59, 130, 246, 0.9));
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.3s ease;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.send-button:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(59, 130, 246, 0.5);
}

.send-button:active:not(:disabled) {
    transform: scale(0.95);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 16px 20px;
    background: linear-gradient(135deg, 
        rgba(255, 182, 193, 0.4),
        rgba(255, 255, 153, 0.4));
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    backdrop-filter: var(--backdrop-blur-light);
    border: 1px solid rgba(255, 255, 255, 0.3);
    position: relative;
    overflow: hidden;
}

.typing-indicator::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: shimmer 2s infinite;
}

.typing-text {
    color: var(--text-primary);
    font-size: 14px;
    position: relative;
    z-index: 1;
}

.typing-dots {
    color: var(--text-primary);
    font-size: 14px;
    position: relative;
    z-index: 1;
    min-width: 20px;
    display: inline-block;
}

@keyframes shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* МОДАЛЬНОЕ ОКНО МЕТОДОЛОГИИ (десктоп) */
/* Удалено специфичное правило для #methodologyModal - используем общий класс .dialog-statistics-modal */

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive для десктопа */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -280px;
        z-index: 100;
        height: 100vh;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .main-container {
        width: 100%;
    }

    .message {
        max-width: 95%;
    }

    .chat-container {
        padding: 20px;
    }

    .input-container {
        padding: 16px 20px;
    }

    .welcome-container {
        padding: 20px;
    }

    .welcome-title {
        font-size: 36px;
    }

    .welcome-subtitle {
        font-size: 16px;
    }

    .key-input-body {
        flex-direction: column;
    }

    .key-submit-button {
        width: 100%;
    }

    .form-actions {
        flex-direction: column;
    }

    .key-actions {
        flex-direction: column;
    }

    /* Скрываем десктопный верхний бар на мобильных */
    .desktop-top-bar {
        display: none;
    }
}

/* МОДАЛЬНОЕ ОКНО СТАТИСТИКИ ДИАЛОГА */
.dialog-statistics-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Максимальное размытие фона (100%) */
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(100px) saturate(200%);
    -webkit-backdrop-filter: blur(100px) saturate(200%);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 4000;
    animation: modalFadeIn 0.3s ease;
    /* Предотвращаем закрытие модального окна при клике на фон */
    pointer-events: auto;
}

/* Предотвращаем распространение событий от фона */
.dialog-statistics-modal > * {
    pointer-events: auto;
}

.dialog-statistics-content {
    /* Белая непрозрачная заливка */
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    color: #333;
    /* Предотвращаем закрытие модального окна при клике на контент */
    position: relative;
    z-index: 4001;
    pointer-events: auto;
}

.dialog-statistics-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.dialog-statistics-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #333;
}

.dialog-statistics-close {
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.dialog-statistics-close:hover {
    background: #f0f0f0;
    color: #333;
    transform: rotate(90deg);
}

.dialog-statistics-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid #e9ecef;
}

.dialog-statistics-item:last-child {
    border-bottom: none;
}

.dialog-statistics-label {
    font-size: 14px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 8px;
}

.dialog-statistics-label i {
    color: #667eea;
}

.dialog-statistics-value {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    font-family: 'Courier New', monospace;
}

/* Кнопки выбора формата экспорта */
.export-format-button {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 20px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 15px;
    color: #333;
    gap: 12px;
}

.export-format-button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
    transform: translateX(5px);
}

.export-format-button i:first-child {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

.export-format-button span {
    flex: 1;
    text-align: left;
    font-weight: 500;
}

.export-format-button i:last-child {
    font-size: 12px;
    opacity: 0.5;
}

/* СКРЫВАЕМ МОБИЛЬНЫЕ ЭЛЕМЕНТЫ НА ДЕСКТОПЕ */
@media (min-width: 769px) {
    .mobile-menu-toggle,
    .mobile-sidebar,
    .mobile-overlay,
    .mobile-token-counter,
    .mobile-app-title,
    .mobile-token-section {
        display: none !important;
    }
}

/* ===== SAFE AREA SUPPORT ДЛЯ iOS УСТРОЙСТВ ===== */
@supports (padding: max(0px)) {
    .sidebar {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .input-container {
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }
    
    .welcome-page {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* Динамическая высота viewport для мобильных */
:root {
    --vh: 1vh;
}

.welcome-page,
.app-container {
    height: 100vh;
    height: calc(var(--vh, 1vh) * 100);
}

@supports (-webkit-touch-callout: none) {
    .welcome-page,
    .app-container {
        height: -webkit-fill-available;
    }
}

/* ===== АНАЛИЗ СООБЩЕНИЯ ===== */
.message-analysis-container {
    margin-top: 15px;
    padding: 12px;
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f1f5 100%);
    border-radius: 8px;
    border-left: 4px solid #667eea;
    font-size: 13px;
    color: #333;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.message-analysis-container > div {
    margin-bottom: 10px;
    animation: slideInUp 0.3s ease-out;
}

.message-analysis-container > div:last-child {
    margin-bottom: 0;
}

.analysis-section-title {
    font-weight: 600;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.analysis-section-content {
    padding-left: 20px;
}

.analysis-item {
    padding: 4px 0;
    line-height: 1.4;
}

/* Цвета для разных типов анализа */
.analysis-fear {
    color: #e74c3c;
    border-left-color: #e74c3c;
}

.analysis-question {
    color: #3498db;
}

.analysis-nanite {
    color: #f39c12;
}

.analysis-dissonance {
    color: #9b59b6;
}

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

/* ===== TRAINING MODE MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.modal.show {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-height: 90vh;
    overflow-y: auto;
    animation: slideInDown 0.3s ease;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.modal-body {
    padding: 30px;
}

.modal-footer {
    padding: 20px;
    background: #f9f9f9;
    border-top: 1px solid #ddd;
    border-radius: 0 0 12px 12px;
}

.training-mode-option {
    padding: 20px;
    margin-bottom: 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
}

.training-mode-option:hover {
    border-color: #667eea;
    background-color: #f8f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.training-mode-option.selected {
    border-color: #667eea;
    background-color: #f0f3ff;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.training-mode-option h3 {
    margin: 0 0 8px 0;
    color: #333;
    font-size: 16px;
}

.training-mode-option p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

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

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