body,
html {
    margin: 0;
    padding: 0;
    font-family: 'SF Pro', sans-serif;
    color: #000000;
    overscroll-behavior-y: contain;
    height: 100%;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* ФОРСИРОВАННОЕ переопределение background для чата */
body.page-chat {
    background-color: transparent !important;
}

.chat-container {
    width: 100%;
    max-width: min(90vw, 500px);
    margin: 0 auto;
    background: transparent;
    overflow: hidden;
    box-sizing: border-box;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding-left: 20px;
    padding-right: 20px;
    position: relative;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0 10px 0;
    background: transparent;
    z-index: 10;
    flex-shrink: 0;
    position: relative;
}

.burger-menu-button {
    position: absolute;
    left: 0;
    top: 58%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 12px;
    cursor: pointer;
    border-radius: 12px;
    transition: background-color 0.2s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.burger-menu-button:hover {
    background-color: rgba(127, 86, 217, 0.1);
}

.burger-line {
    height: 2px;
    background-color: #7F56D9;
    border-radius: 1px;
    transition: all 0.3s ease;
}

.burger-line.long {
    width: 20px;
    margin-left: auto;
}

.burger-line.short {
    width: 16px;
}

.chat-title {
    font-size: 20px;
    font-weight: 600;
    color: #4A2A7B;
    margin: 0;
    text-align: center;
}

.chat-history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Предотвращение просвечивания содержимого */
    box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: opacity, visibility;
    /* Дополнительная изоляция */
    isolation: isolate;
    -webkit-isolation: isolate;
    /* Стабилизация backdrop-filter */
    filter: blur(0px);
    -webkit-filter: blur(0px);
}


.chat-history-overlay.open {
    opacity: 1;
    visibility: visible;
}

.chat-history-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 400px;
    height: 100%;
    background: transparent;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}


.chat-history-menu.open {
    transform: translateX(0);
}

.chat-history-header {
    padding: 20px;
    background: transparent;
    margin-bottom: 15px;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    flex-shrink: 0;
    gap: 12px;
}

.chat-history-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: rgba(87, 72, 148, 0.92);
    margin: 0;
}

.header-buttons {
    display: flex;
    gap: 3px;
    align-items: center;
}

.info-button {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: rgba(87, 72, 148, 0.8);
    transition: all 0.2s ease;
}

.info-button:hover {
    color: rgba(87, 72, 148, 1);
    transform: scale(1.05);
}

.info-button svg {
    transition: transform 0.2s ease;
}

.info-button:hover svg {
    transform: scale(1.1);
}

.close-history-button {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
    background: transparent;
    border: none;
    padding: 10px;
    cursor: pointer;
    color: rgba(87, 72, 148, 0.92);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.chat-history-overlay.open ~ .close-history-button {
    opacity: 1;
    visibility: visible;
}


.chat-history-list {
    padding: 10px 15px 15px 15px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.chat-history-list::-webkit-scrollbar {
    display: none;
}

.chat-history-footer {
    padding: 15px;
    display: flex;
    justify-content: flex-start;
    gap: 12px;
    background: transparent;
    margin: 0 10px;
    flex-shrink: 0;
    min-height: 20px;
}

.new-chat-button {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #8c52ff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}


.delete-chats-button {
    background: transparent;
    border: none;
    padding: 12px;
    cursor: pointer;
    color: #ff5252;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}


.chat-history-item {
    background: transparent;
    border-radius: 10px;
    padding: 10px 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border: none;
}

.chat-history-item.active {
    background: radial-gradient(rgba(89, 74, 128, 0.5), rgba(62, 47, 104, 0.5)) !important;
}

.chat-preview {
    flex: 1;
    min-width: 0;
}

.chat-preview h3 {
    font-size: 14px;
    font-weight: 600;
    color: rgba(87, 72, 148, 0.92);
    margin: 0 0 4px 0;
}

.chat-preview p {
    font-size: 12px;
    color: rgba(87, 72, 148, 0.75);
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-time {
    font-size: 11px;
    color: rgba(87, 72, 148, 0.6);
    margin-left: 12px;
    flex-shrink: 0;
}

.empty-history-message {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: rgba(87, 72, 148, 0.6);
    font-size: 16px;
    font-weight: 400;
    text-align: center;
    min-height: 100px;
}

body.menu-open {
    overflow: hidden;
}


body.modal-open {
    overflow: hidden;
}

.delete-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.delete-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.delete-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 320px;
    background: rgba(245, 243, 255, 0.3);
    border-radius: 20px;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(127, 86, 217, 0.2);
    overflow: hidden;
}

.delete-modal::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom right, rgba(245, 243, 255, 0.08), rgba(236, 230, 252, 0.08));
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: -1;
    border-radius: 20px;
}

.delete-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.delete-modal-content {
    padding: 25px 20px 20px 20px;
    text-align: center;
}

.delete-modal-content h3 {
    font-size: 18px;
    font-weight: 600;
    color: #4A2A7B;
    margin: 0 0 8px 0;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}

.delete-modal-content p {
    font-size: 14px;
    color: rgba(87, 72, 148, 0.75);
    margin: 0 0 25px 0;
}

.delete-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.delete-modal-buttons-row {
    display: flex;
    gap: 10px;
}

.delete-modal-buttons-row .delete-modal-button {
    flex: 1;
}

.delete-modal-button {
    padding: 12px 20px;
    border: none;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'SF Pro', sans-serif;
}

.confirm-button {
    background: rgba(255, 82, 82, 0.4);
    color: white;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 82, 82, 0.3);
}


.cancel-button {
    background: rgba(255, 255, 255, 0.4);
    color: #7F56D9;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(127, 86, 217, 0.3);
}


.delete-all-button {
    background: rgba(255, 152, 0, 0.4);
    color: white;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 152, 0, 0.3);
}

/* Info Modal Styles */
.info-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.info-modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.info-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    max-width: 420px;
    width: 90%;
    max-height: 80vh;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid rgba(127, 86, 217, 0.2);
    overflow: hidden;
}

.info-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom right, rgba(245, 243, 255, 0.1), rgba(236, 230, 252, 0.1));
    border-radius: 20px;
    z-index: -1;
}

.info-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.info-modal-content {
    padding: 30px 25px 25px 25px;
    position: relative;
    overflow-y: auto;
    max-height: calc(80vh - 60px);
}

.info-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: rgba(87, 72, 148, 0.6);
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 50%;
    z-index: 10001;
}

.info-modal-close:hover {
    background: rgba(127, 86, 217, 0.1);
    color: rgba(87, 72, 148, 1);
    transform: scale(1.1);
}


.info-text p {
    margin: 0 0 15px 0;
    line-height: 1.6;
    color: #4A2A7B;
    font-size: 14px;
}

.info-text p:last-child {
    margin-bottom: 0;
}

.info-text strong {
    color: #3E2F68;
    font-weight: 600;
}

.info-text ul {
    margin: 10px 0 15px 0;
    padding-left: 20px;
}

.info-text li {
    margin: 8px 0;
    line-height: 1.5;
    color: #4A2A7B;
    font-size: 14px;
}


.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -ms-overflow-style: none;
    mask-image: linear-gradient(to bottom, transparent 0%, black 15px, black calc(100% - 30px), transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, transparent 0%, black 15px, black calc(100% - 30px), transparent 100%);
    /* Стабилизация рендеринга для предотвращения мигания */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: transform;
}

.chat-messages-area::-webkit-scrollbar {
    display: none;
}

.message {
    margin-bottom: 15px;
    display: flex;
    animation: slideUp 0.3s ease;
    transition: all 0.2s ease-out;
}

.message.bot-message {
    justify-content: flex-start;
}

.message.user-message {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 20px;
    word-wrap: break-word;
    position: relative;
    overflow: hidden;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.message-bubble::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
}

.bot-message .message-bubble {
    background: rgba(245, 243, 255, 0.7);
    color: #4A2A7B;
    border-bottom-left-radius: 8px;
    border: 1px solid rgba(127, 86, 217, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.bot-message .message-bubble::before {
    background: linear-gradient(to bottom right, rgba(245, 243, 255, 0.08), rgba(236, 230, 252, 0.08));
}

.user-message .message-bubble {
    background: rgba(140, 82, 255, 0.7);
    color: white;
    border-bottom-right-radius: 8px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.user-message .message-bubble::before {
    background: linear-gradient(to bottom right, rgba(140, 82, 255, 0.2), rgba(127, 86, 217, 0.2));
}

.message-bubble p,
.message-text {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    transition: all 0.15s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Стили для markdown элементов */
.message-text h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 10px 0 6px 0;
    color: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text h4 {
    font-size: 14px;
    font-weight: 600;
    margin: 8px 0 4px 0;
    color: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text strong {
    font-weight: 600;
    color: inherit;
    white-space: pre-wrap;
}

.message-text em {
    font-style: italic;
    color: inherit;
    white-space: pre-wrap;
}

.message-text code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text pre {
    background: rgba(0, 0, 0, 0.1);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    white-space: pre-wrap;
}

.message-text pre code {
    background: none;
    padding: 0;
    font-size: 12px;
    display: block;
    white-space: pre;
}

.message-text ul {
    margin: 8px 0;
    padding-left: 20px;
    white-space: pre-wrap;
}

.message-text li {
    margin: 4px 0;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text blockquote {
    border-left: 3px solid rgba(127, 86, 217, 0.3);
    padding-left: 12px;
    margin: 8px 0;
    font-style: italic;
    color: inherit;
    opacity: 0.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text a {
    color: #7F56D9;
    text-decoration: underline;
    text-decoration-color: rgba(127, 86, 217, 0.4);
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text a:hover {
    text-decoration-color: #7F56D9;
}

.message-image {
    max-width: 100%;
    max-height: 300px;
    border-radius: 12px;
    object-fit: cover;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 4px;
}

.message-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.message-bubble.has-image {
    padding: 8px;
}

.message-bubble.has-image p {
    margin-bottom: 8px;
}

.file-upload-area {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 200px;
    background: rgba(245, 243, 255, 0.9);
    border: 2px dashed rgba(127, 86, 217, 0.3);
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.file-upload-area.dragover {
    background: rgba(127, 86, 217, 0.2);
    border-color: rgba(127, 86, 217, 0.6);
    transform: translate(-50%, -50%) scale(1.05);
}

.file-upload-text {
    font-size: 16px;
    color: #4A2A7B;
    text-align: center;
    margin-bottom: 10px;
    font-weight: 500;
}

.file-upload-hint {
    font-size: 12px;
    color: rgba(74, 42, 123, 0.6);
    text-align: center;
}

.attachment-input {
    display: none;
}

.file-preview {
    position: relative;
    width: 80px;
    height: 80px;
    background: transparent;
    border-radius: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    animation: slideUp 0.3s ease;
}

.preview-image-container {
    position: relative;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid rgba(127, 86, 217, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.remove-preview-btn {
    position: absolute;
    top: -6px;
    right: -6px;
    background: rgba(255, 82, 82, 0.9);
    border: none;
    color: white;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(255, 82, 82, 0.3);
    z-index: 20;
}

.remove-preview-btn:hover {
    background: rgba(255, 82, 82, 1);
    transform: scale(1.1);
}

.remove-preview-btn:active {
    transform: scale(0.95);
}

body.dark-theme .file-preview {
    background: transparent;
}

body.dark-theme .file-preview img {
    border-color: rgba(230, 223, 255, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

body.dark-theme .remove-preview-btn {
    background: rgba(255, 82, 82, 0.85);
    color: white;
    box-shadow: 0 2px 8px rgba(255, 82, 82, 0.4);
}

body.dark-theme .remove-preview-btn:hover {
    background: rgba(255, 82, 82, 1);
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    transition: opacity 0.08s ease-out;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: #7F56D9;
    animation: typing 1.5s infinite;
    opacity: 0.6;
    box-shadow: 0 0 8px rgba(127, 86, 217, 0.3);
}

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

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

.streaming-message .typing-indicator {
    margin-top: 4px;
    padding-top: 0;
    border-top: none;
    opacity: 0.7;
    /* Добавляем плавный переход для исчезновения typing indicator */
    transition: opacity 1.0s cubic-bezier(0.23, 1, 0.32, 1),
                transform 1.0s cubic-bezier(0.23, 1, 0.32, 1),
                margin 0.8s cubic-bezier(0.23, 1, 0.32, 1);
}

.streaming-message .message-text {
    position: relative;
    transition: opacity 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-height: 0;
    overflow: visible;
    word-wrap: break-word;
    word-break: break-word;
}

.streaming-message .message-bubble {
    /* Очень плавный переход для размеров bubble - увеличиваем до 1.5 секунд */
    transition: width 1.5s cubic-bezier(0.23, 1, 0.32, 1), 
                max-width 1.5s cubic-bezier(0.23, 1, 0.32, 1), 
                height 1.2s cubic-bezier(0.23, 1, 0.32, 1),
                padding 1.0s cubic-bezier(0.23, 1, 0.32, 1);
    will-change: width, height, transform;
    /* Принудительно стабилизируем */
    contain: layout;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* ВАЖНО: Когда только typing indicator - убираем bubble */
.streaming-message.typing-only .message-bubble {
    background: none !important;
    border: none !important;
    padding: 0 !important;
    backdrop-filter: none !important;
}

/* Стилизуем typing indicator в компактном режиме */
.streaming-message.typing-only .typing-indicator {
    margin: 0;
    padding: 8px 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

/* Когда есть текст - нормальная ширина */
.streaming-message.has-text .message-bubble {
    width: 100%;
    max-width: 80%;
    min-width: 100px;
    display: block;
    /* Добавляем плавный переход для этого состояния */
    transition: width 1.5s cubic-bezier(0.23, 1, 0.32, 1), 
                max-width 1.5s cubic-bezier(0.23, 1, 0.32, 1), 
                min-width 1.0s cubic-bezier(0.23, 1, 0.32, 1),
                display 0.8s ease;
}

/* Оптимизация для плавного стриминга */
.streaming-message {
    contain: layout;
}

.streaming-message .message-text {
    contain: layout style;
    will-change: auto;
    /* ФИКСИРОВАННАЯ ширина для предотвращения перестройки */
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.streaming-new-text {
    opacity: 0;
    transition: opacity 0.2s ease-out;
    /* Предотвращение сдвигов */
    display: inline;
    vertical-align: baseline;
    white-space: pre-wrap;
}

.streaming-new-text.show {
    opacity: 1;
}

/* Предотвращение перерисовки при финализации */
.message.bot-message[data-finalized="true"] .message-text {
    /* Стабилизация после финализации */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: auto;
    /* Стабильные переносы */
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
    -webkit-hyphens: none;
    word-break: normal;
    text-align: left;
    text-rendering: optimizeSpeed;
}

/* Общие стили для стабильного отображения текста */
.message-text {
    /* Стабилизация переносов строк */
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: none;
    -webkit-hyphens: none;
    word-break: normal;
    text-align: left;
    /* Оптимизация рендеринга */
    text-rendering: optimizeSpeed;
    font-kerning: normal;
    -webkit-font-kerning: normal;
    font-feature-settings: "kern" 1;
    -webkit-font-feature-settings: "kern" 1;
    /* Предотвращение перестройки layout */
    contain: layout;
    will-change: contents;
}

/* Стили для анимации новых слов */
.streaming-new-word {
    opacity: 0;
    transform: translateY(8px) scale(0.95);
    transition: opacity 0.8s cubic-bezier(0.23, 1, 0.32, 1), 
                transform 0.8s cubic-bezier(0.23, 1, 0.32, 1);
    display: inline;
    animation: streamingWordAppear 0.8s cubic-bezier(0.23, 1, 0.32, 1) forwards;
}

.streaming-new-word.animate-in {
    opacity: 1;
    transform: translateY(0) scale(1);
}

@keyframes streamingWordAppear {
    0% {
        opacity: 0;
        transform: translateY(12px) scale(0.9);
    }
    60% {
        opacity: 0.7;
        transform: translateY(-2px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Стили для <br> тегов чтобы они не влияли на переносы */
.message-text br {
    display: block;
    line-height: inherit;
    margin: 0;
    padding: 0;
    content: '';
}

/* Стили для сохранения структуры при наличии HTML */
.message-text p {
    margin: 0 0 1em 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text p:last-child {
    margin-bottom: 0;
}




.user-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
}

.user-typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: white;
    animation: typing 1.5s infinite;
    opacity: 0.8;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

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

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

.suggested-questions {
    padding: 10px 0 15px 0;
    flex-shrink: 0;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 10px;
    will-change: opacity, transform;
}

.suggested-question {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(127, 86, 217, 0.2);
    border-radius: 18px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 8px;
}

.suggested-question::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.1), rgba(248, 246, 255, 0.15));
    z-index: -1;
    border-radius: 18px;
}

.suggested-question:hover {
    background: rgba(127, 86, 217, 0.1);
    transform: translateY(-1px);
    border-color: rgba(127, 86, 217, 0.3);
}

.suggested-question:active {
    transform: translateY(0);
}

.question-icon {
    font-size: 14px;
    flex-shrink: 0;
}

.question-text {
    font-size: 12px;
    font-weight: 500;
    color: #4A2A7B;
    line-height: 1.3;
    flex: 1;
}

.chat-input-area {
    padding: 0px 0 20px 0;
    flex-shrink: 0;
    background: transparent;
}

.back-button {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(127, 86, 217, 0.2);
    padding: 4px;
    cursor: pointer;
    color: #7F56D9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 1;
    pointer-events: auto;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
}

.back-button:hover {
    background: rgba(127, 86, 217, 0.15);
}

.back-button.hidden {
    display: none;
}

.input-container {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 25px;
    padding: 5px;
    border: 1px solid rgba(127, 86, 217, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
    width: 100%;
}

.input-container::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom right, rgba(255, 255, 255, 0.1), rgba(248, 246, 255, 0.15));
    z-index: -1;
    border-radius: 25px;
}

.attachment-button {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #7F56D9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
}

.attachment-button:hover {
    background: rgba(127, 86, 217, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    color: #4A2A7B;
    font-family: 'SF Pro', sans-serif;
    min-width: 0;
}

.message-input::placeholder {
    color: rgba(74, 42, 123, 0.6);
}

.send-button {
    background: rgba(140, 82, 255, 0.4);
    border: none;
    padding: 6px;
    cursor: pointer;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease, opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    border: 1px solid rgba(127, 86, 217, 0.2);
    position: relative;
    overflow: hidden;
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
    flex-shrink: 0;
}

.send-button.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

.send-button.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    visibility: hidden;
}

.send-button::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    background: linear-gradient(to bottom right, rgba(140, 82, 255, 0.2), rgba(127, 86, 217, 0.2));
    z-index: -1;
    border-radius: 50%;
}

.send-button:hover {
    background: rgba(140, 82, 255, 0.6);
}

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

.send-button svg {
    display: block;
    margin: 0 auto;
    width: 20px;
    height: 20px;
}

/* Стили только для мобильных устройств */

.input-wrapper {
    width: 100%;
}

.mic-button {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #7F56D9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    min-width: 40px;
    min-height: 40px;
}

.mic-button.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

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

.mic-button.hidden {
    display: none;
}

.mic-button.recording {
    background: rgba(255, 82, 82, 0.6) !important;
    transform: scale(1.1) !important;
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 82, 82, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 82, 82, 0);
    }
}

.recording-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 82, 82, 0.9);
    color: white;
    padding: 20px;
    border-radius: 15px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 8px 32px rgba(255, 82, 82, 0.3);
}

.recording-indicator.active {
    display: flex;
}

.recording-dot {
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

.scroll-to-bottom-btn {
    position: fixed;
    left: 50%;
    bottom: 120px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, rgba(140, 82, 255, 0.6), rgba(127, 86, 217, 0.2));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateX(-50%) scale(0.8) translateY(10px);
}

.scroll-to-bottom-btn.visible {
    opacity: 1;
    transform: translateX(-50%) scale(1) translateY(0);
}

.scroll-to-bottom-btn:hover {
    transform: translateX(-50%) scale(1.1) translateY(-2px);
}

.scroll-to-bottom-btn:active {
    transform: translateX(-50%) scale(0.95);
}


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

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

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

@keyframes fadeOut {
    from { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
    to { 
        opacity: 0; 
        transform: translateY(-10px) scale(0.95); 
    }
}

.image-modal {
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.image-modal-close {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(1.1) !important;
}

.image-modal-close:active {
    transform: scale(0.95) !important;
}


.animate-fade-in {
    animation: fadeIn 0.8s ease forwards;
    opacity: 0;
}

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }

body.dark-theme {
    color: #E6DFFF;
}

body.dark-theme .chat-container {
    background-color: transparent;
}

body.dark-theme .chat-title {
    color: #E6DFFF;
}

body.dark-theme .burger-line {
    background-color: #D9CFFF;
}

body.dark-theme .burger-menu-button:hover {
    background-color: rgba(230, 223, 255, 0.1);
}

body.dark-theme .chat-history-overlay {
    background-color: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    /* Предотвращение просвечивания в dark теме */
    box-shadow: 0 0 0 10000px rgba(0, 0, 0, 0.1);
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    will-change: opacity, visibility;
    isolation: isolate;
    -webkit-isolation: isolate;
    /* Стабилизация backdrop-filter */
    filter: blur(0px);
    -webkit-filter: blur(0px);
}


body.dark-theme .chat-history-menu {
    background: transparent;
}

body.dark-theme .chat-history-header {
    background: transparent;
}

body.dark-theme .chat-history-header h2 {
    color: #E6DFFF;
}

body.dark-theme .close-history-button {
    background: transparent;
    color: rgb(230, 223, 255);
}


body.dark-theme .chat-history-item {
    background: transparent;
}

body.dark-theme .chat-history-item.active {
    background: radial-gradient(rgba(89, 74, 128, 0.5), rgba(62, 47, 104, 0.5)) !important;
}

body.dark-theme .chat-preview h3 {
    color: #E6DFFF;
}

body.dark-theme .chat-preview p {
    color: #F5F3FF;
}

body.dark-theme .chat-time {
    color: rgba(245, 243, 255, 0.7);
}

body.dark-theme .empty-history-message {
    color: rgba(230, 223, 255, 0.6);
}


body.dark-theme .bot-message .message-bubble {
    background: rgba(58, 46, 92, 0.7);
    color: #E6DFFF;
    border: 1px solid rgba(230, 223, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.dark-theme .bot-message .message-bubble::before {
    background: linear-gradient(to bottom right, rgba(58, 46, 92, 0.1), rgba(44, 31, 74, 0.1));
}

body.dark-theme .user-message .message-bubble {
    background: rgba(140, 82, 255, 0.7);
    color: white;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.dark-theme .user-message .message-bubble::before {
    background: linear-gradient(to bottom right, rgba(140, 82, 255, 0.2), rgba(127, 86, 217, 0.2));
}

/* Стили markdown для темной темы */
body.dark-theme .message-text code {
    background: rgba(255, 255, 255, 0.1);
    color: #E6DFFF;
}

body.dark-theme .message-text pre {
    background: rgba(255, 255, 255, 0.1);
}

body.dark-theme .message-text pre code {
    color: #E6DFFF;
}

body.dark-theme .message-text blockquote {
    border-left-color: rgba(230, 223, 255, 0.3);
    color: #E6DFFF;
}

body.dark-theme .message-text a {
    color: #B794F6;
    text-decoration-color: rgba(183, 148, 246, 0.4);
}

body.dark-theme .message-text a:hover {
    text-decoration-color: #B794F6;
}

body.dark-theme .input-container {
    background: rgba(42, 30, 61, 0.2);
    border: 1px solid rgba(230, 223, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

body.dark-theme .input-container::before {
    background: linear-gradient(to bottom right, rgba(42, 30, 61, 0.1), rgba(31, 22, 53, 0.12));
}

body.dark-theme .back-button {
    background: rgba(42, 30, 61, 0.3);
    border: 1px solid rgba(230, 223, 255, 0.1);
    color: #D9CFFF;
    opacity: 1;
    pointer-events: auto;
}

body.dark-theme .back-button:hover {
    background: rgba(230, 223, 255, 0.12);
}

body.dark-theme .back-button.hidden {
    display: none;
}

body.dark-theme .attachment-button {
    color: #D9CFFF;
}

body.dark-theme .attachment-button:hover {
    background: rgba(230, 223, 255, 0.12);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.dark-theme .send-button {
    background: rgba(140, 82, 255, 0.3);
    border: 1px solid rgba(230, 223, 255, 0.1);
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

body.dark-theme .send-button::before {
    background: linear-gradient(to bottom right, rgba(140, 82, 255, 0.2), rgba(127, 86, 217, 0.2));
}

body.dark-theme .send-button:hover {
    background: rgba(140, 82, 255, 0.5);
}

body.dark-theme .send-button.visible {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
}

body.dark-theme .send-button.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
    visibility: hidden;
}

body.dark-theme .message-input {
    color: #E6DFFF;
}

body.dark-theme .message-input::placeholder {
    color: rgba(230, 223, 255, 0.6);
}

body.dark-theme .typing-indicator .dot {
    background-color: #D9CFFF;
    box-shadow: 0 0 8px rgba(217, 207, 255, 0.4);
}

body.dark-theme .user-typing-indicator .dot {
    background-color: white;
    opacity: 0.9;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
}

body.dark-theme .mic-button {
    background: transparent;
    color: #D9CFFF;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.dark-theme .mic-button.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.dark-theme .mic-button.hidden {
    display: none;
}

body.dark-theme .mic-button.recording {
    background: rgba(255, 82, 82, 0.6) !important;
    transform: scale(1.1) !important;
    animation: pulse-recording 1.5s infinite;
}

body.dark-theme .recording-indicator {
    background: rgba(255, 82, 82, 0.9);
    color: white;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(255, 82, 82, 0.4);
}

body.dark-theme .scroll-to-bottom-btn {
    background: linear-gradient(135deg, rgba(140, 82, 255, 0.5), rgba(127, 86, 217, 0.1));
}

body.dark-theme .suggested-question {
    background: rgba(42, 30, 61, 0.3);
    border: 1px solid rgba(230, 223, 255, 0.15);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

body.dark-theme .suggested-question::before {
    background: linear-gradient(to bottom right, rgba(42, 30, 61, 0.1), rgba(31, 22, 53, 0.12));
}

body.dark-theme .suggested-question:hover {
    background: rgba(140, 82, 255, 0.2);
    border-color: rgba(230, 223, 255, 0.3);
}

body.dark-theme .question-text {
    color: #E6DFFF;
}

body.dark-theme .file-upload-area {
    background: rgba(58, 46, 92, 0.9);
    border-color: rgba(230, 223, 255, 0.3);
}

body.dark-theme .file-upload-area.dragover {
    background: rgba(140, 82, 255, 0.2);
    border-color: rgba(230, 223, 255, 0.6);
}

body.dark-theme .file-upload-text {
    color: #E6DFFF;
}

body.dark-theme .file-upload-hint {
    color: rgba(230, 223, 255, 0.6);
}


body.dark-theme .chat-history-footer {
    background: transparent;
    min-height: 20px;
}

body.dark-theme .new-chat-button {
    background: transparent;
    color: #a78bfa;
}


body.dark-theme .delete-chats-button {
    background: transparent;
    color: #ff6b6b;
}


body.dark-theme .delete-modal-overlay {
    background: linear-gradient(45deg, 
        rgba(19, 15, 44, 0.85) 0%, 
        rgba(36, 27, 67, 0.8) 30%, 
        rgba(19, 15, 44, 0.9) 70%, 
        rgba(0, 0, 0, 0.85) 100%
    );
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.dark-theme .delete-modal {
    background: rgba(58, 46, 92, 0.33);
    border: 1px solid rgba(230, 223, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

body.dark-theme .delete-modal::before {
    background: linear-gradient(to bottom right, rgba(58, 46, 92, 0.1), rgba(44, 31, 74, 0.1));
}

body.dark-theme .delete-modal-content {
    padding: 30px 25px 25px 25px;
}

body.dark-theme .delete-modal-content h3 {
    color: #E6DFFF;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

body.dark-theme .delete-modal-content p {
    color: rgba(230, 223, 255, 0.85);
    font-size: 15px;
    line-height: 1.5;
    margin: 0 0 30px 0;
}

body.dark-theme .cancel-button {
    background: rgba(127, 86, 217, 0.2);
    color: #D9CFFF;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(217, 207, 255, 0.2);
}


body.dark-theme .confirm-button {
    background: rgba(255, 82, 82, 0.4);
    color: white;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 82, 82, 0.3);
}


body.dark-theme .delete-all-button {
    background: rgba(255, 152, 0, 0.4);
    color: white;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 152, 0, 0.3);
}

/* Dark theme styles for info modal */
body.dark-theme .info-button {
    color: rgba(230, 223, 255, 0.8);
    border-color: rgba(230, 223, 255, 0.3);
}

body.dark-theme .info-button:hover {
    color: rgba(230, 223, 255, 1);
}

body.dark-theme .info-modal {
    background: rgba(42, 30, 61, 0.95);
    border-color: rgba(230, 223, 255, 0.2);
}

body.dark-theme .info-modal::before {
    background: linear-gradient(to bottom right, rgba(58, 46, 92, 0.1), rgba(44, 31, 74, 0.1));
}

body.dark-theme .info-modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

body.dark-theme .info-modal-close {
    color: rgba(230, 223, 255, 0.6);
}

body.dark-theme .info-modal-close:hover {
    background: rgba(230, 223, 255, 0.1);
    color: rgba(230, 223, 255, 1);
}


body.dark-theme .info-text p {
    color: #E6DFFF;
}

body.dark-theme .info-text strong {
    color: #F5F3FF;
}

body.dark-theme .info-text li {
    color: #E6DFFF;
}


body.dark-theme .delete-modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

body.dark-theme .delete-modal-buttons-row {
    display: flex;
    gap: 12px;
}

body.dark-theme .delete-modal-button {
    padding: 15px 24px;
    border: none;
    border-radius: 18px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'SF Pro', sans-serif;
    position: relative;
    overflow: hidden;
}



@media (max-width: 430px) {
    .chat-container {
        max-width: 390px;
    }
    
    .chat-history-menu {
        width: 360px;
    }
    
    .burger-menu-button {
        padding: 10px;
    }
    
    .burger-line.long {
        width: 18px;
        margin-left: auto;
    }
    
    .burger-line.short {
        width: 14px;
    }
    
    .delete-modal {
        max-width: 280px;
    }
    
    .delete-modal-content {
        padding: 20px 15px 15px 15px;
    }
    
    .delete-modal-content h3 {
        font-size: 16px;
    }
    
    .delete-modal-button {
        padding: 10px 16px;
        font-size: 15px;
    }
    
    
    .suggested-question {
        padding: 10px 14px;
    }
    
    .question-text {
        font-size: 11px;
    }
    
    
    .file-preview {
        width: 70px;
        height: 70px;
        margin-bottom: 8px;
    }
    
    .preview-image-container {
        width: 70px;
        height: 70px;
    }
    
    .file-preview img {
        width: 70px;
        height: 70px;
        border-radius: 10px;
    }
    
    .remove-preview-btn {
        width: 20px;
        height: 20px;
        padding: 4px;
        top: -4px;
        right: -4px;
    }
    
    .image-modal-close {
        top: 15px !important;
        right: 15px !important;
        padding: 10px !important;
    }
    
    .image-modal-close svg {
        width: 20px;
        height: 20px;
    }
    
    .chat-time {
        margin-left: 0;
    }
    
    
    .attachment-button {
        margin-right: 0;
    }
    
}

@media (min-width: 431px) {
    .chat-container {
        max-width: min(85vw, 480px);
        padding-left: max(4vw, 24px);
        padding-right: max(4vw, 24px);
    }
    
    .chat-header {
        padding: 24px 0 18px 0;
    }
    
    .chat-title {
        font-size: 24px;
    }
    
    .message-bubble {
        padding: 14px 18px;
        border-radius: 22px;
    }
    
    .message-bubble p,
    .message-text {
        font-size: 15px;
        line-height: 1.45;
    }
    
    .message-text h2 {
        font-size: 18px;
        margin: 14px 0 10px 0;
    }
    
    .message-text h3 {
        font-size: 17px;
        margin: 12px 0 8px 0;
    }
    
    .message-text h4 {
        font-size: 16px;
        margin: 10px 0 6px 0;
    }
    
    .message-text code {
        font-size: 13px;
        padding: 3px 8px;
    }
    
    .message-text pre {
        padding: 14px;
        margin: 10px 0;
    }
    
    .message-text pre code {
        font-size: 13px;
    }
    
    .message-text ul {
        margin: 10px 0;
        padding-left: 24px;
    }
    
    .message-text li {
        margin: 6px 0;
    }
    
    .message-text blockquote {
        padding-left: 16px;
        margin: 10px 0;
    }
    
    .input-container {
        padding: 14px 18px;
        border-radius: 28px;
    }
    
    .message-input {
        font-size: 17px;
    }
    
    .send-button {
        padding: 12px;
    }
    
    
    .suggested-question {
        padding: 14px 18px;
        border-radius: 20px;
    }
    
    .question-text {
        font-size: 13px;
    }
    
    .file-preview {
        width: 90px;
        height: 90px;
        margin-bottom: 12px;
    }
    
    .preview-image-container {
        width: 90px;
        height: 90px;
    }
    
    .file-preview img {
        width: 90px;
        height: 90px;
        border-radius: 14px;
    }
    
    .remove-preview-btn {
        width: 28px;
        height: 28px;
        padding: 8px;
        top: -8px;
        right: -8px;
    }
    
    .image-modal-close {
        top: 25px !important;
        right: 25px !important;
        padding: 14px !important;
    }
    
    .image-modal-close svg {
        width: 26px;
        height: 26px;
    }
    
}

@media (min-width: 430px) and (max-width: 500px) {
    .chat-container {
        transform: scale(1.13) !important;
        height: 100vh !important;
    }
    
}

@media (min-width: 500px) and (max-width: 600px) {
    .chat-container {
        transform: scale(1.2) !important;
        height: 100vh !important;
    }
    
}

@media (min-width: 600px) {
    .chat-container {
        transform: scale(1.3) !important;
        height: 100vh !important;
    }
    
}

@media (max-height: 660px) {
    .chat-input-area {
        padding: 0px 0 15px 0;
    }
}
