/* ============================================================
   ПОДКЛЮЧЕНИЕ ЛОКАЛЬНОГО ШРИФТА PRESS START 2P
   ============================================================ */
@font-face {
    font-family: 'Press Start 2P';
    src: url('/font/PressStart2P-Regular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* ============================================================
   ГЛОБАЛЬНЫЕ СБРОСЫ
   ============================================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: #050505;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
}

/* ============================================================
   ОСНОВНОЙ КОНТЕЙНЕР
   ============================================================ */
#app {
    width: 100%;
    max-width: 700px;
    height: 90vh;
    background: #0f0f0f;
    border-radius: 20px;
    display: flex;
    flex-direction: row;
    overflow: visible;
    border: 2px solid #2a6b4a;
    box-shadow: 0 0 100px rgba(51, 255, 51, 0.35);
    position: relative;
}

/* ============================================================
   ЭКРАН ЗАГРУЗКИ
   ============================================================ */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #0a0a0a;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: flex-start;
    padding: 40px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    color: #33ff33;
    font-size: 14px;
    line-height: 2.2;
    opacity: 1;
    transition: opacity 0.8s ease;
    text-shadow: 0 0 6px rgba(51, 255, 51, 0.3);
}

#boot-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#boot-log {
    max-width: 100%;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-all;
}

#boot-cursor {
    display: inline-block;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    color: #33ff33;
    font-size: inherit;
    animation: blink 0.8s step-end infinite;
}

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

/* ============================================================
   СЛОЙ 0: ПРИВЕТСТВИЕ (поверх всего)
   ============================================================ */
#welcome-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    background: #0a0a0a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.2s ease;
    border-radius: 20px;
}

#welcome-screen.active {
    opacity: 1;
    pointer-events: auto;
}

#welcome-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

#welcome-logo {
    max-width: 240px;
    border-radius: 16px;
    box-shadow: 0 0 40px rgba(51, 255, 51, 0.2);
}

#welcome-screen h2 {
    color: #33ff33;
    font-size: 22px;
    margin-top: 20px;
    letter-spacing: 2px;
}

#startBtn {
    margin-top: 24px;
    padding: 12px 40px;
    background: transparent;
    border: 2px solid #33ff33;
    border-radius: 30px;
    color: #33ff33;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
}

#startBtn:hover {
    background: #33ff33;
    color: #000;
}

/* ============================================================
   СЛОЙ 1: ФЛАЖОК (скрыт на приветствии)
   ============================================================ */
#sidebar-layer {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    z-index: 30;
    pointer-events: none;
    width: 0;
}

#welcome-screen.active ~ #sidebar-layer {
    display: none;
}

.sidebar-toggle {
    position: absolute;
    left: -24px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 44px;
    background: #0d0d0d;
    border: none;
    border-right: 2px solid #2a6b4a;
    border-radius: 8px 0 0 8px;
    color: #33ff33;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    text-shadow: 0 0 10px rgba(51, 255, 51, 0.2);
    pointer-events: auto;
    z-index: 31;
    box-shadow: -2px 0 15px rgba(0, 0, 0, 0.3);
}

.sidebar-toggle:hover {
    background: rgba(51, 255, 51, 0.1);
    border-right-color: #33ff33;
    text-shadow: 0 0 20px rgba(51, 255, 51, 0.4);
    width: 26px;
}

.sidebar-toggle .toggle-icon {
    display: inline-block;
    transition: transform 0.3s ease;
    font-size: 16px;
    line-height: 1;
}

.sidebar-toggle .toggle-icon.open {
    transform: rotate(180deg);
}

/* ============================================================
   СЛОЙ 2: КОНТЕЙНЕР ПАНЕЛИ
   ============================================================ */
#sidebar-panel-container {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 300px;
    z-index: 25;
    overflow: hidden;
    pointer-events: none;
    border-radius: 20px 0 0 20px;
}

/* ============================================================
   СЛОЙ 3: ПАНЕЛЬ ИСТОРИИ ЧАТОВ
   ============================================================ */
.sidebar-panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 300px;
    height: 100%;
    background: #0d0d0d;
    border-right: 2px solid #2a6b4a;
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(-100%);
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    border-radius: 20px 0 0 20px;
}

.sidebar-panel.open {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
}

.sidebar-panel.hidden {
    display: none;
}

.sidebar-header {
    padding: 16px 20px;
    justify-content: center;
    border-bottom: 2px solid #2a6b4a;
    display: flex;
    flex-shrink: 0;
    background: #0d0d0d;
}

.sidebar-header h3 {
    color: #33ff33;
    font-size: 13px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    margin: 0;
    letter-spacing: 1px;
    text-shadow: 0 0 10px rgba(51, 255, 51, 0.15);
}

.sidebar-close {
    background: transparent;
    border: none;
    color: #33ff33;
    font-size: 22px;
    cursor: pointer;
    padding: 0 8px;
    transition: all 0.3s ease;
}

.sidebar-close:hover {
    color: #ff3333;
    transform: scale(1.1);
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
    background: #0a0a0a;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

.chat-list::-webkit-scrollbar-thumb {
    background: #2a6b4a;
    border-radius: 3px;
    opacity: 0.5;
}

.chat-list::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

.chat-list-loading {
    color: #33ff33;
    opacity: 0.5;
    text-align: center;
    padding: 40px 20px;
    font-size: 13px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
}

.chat-group {
    margin-bottom: 4px;
}

.chat-group-date {
    color: #33ff33;
    opacity: 0.6;
    font-size: 11px;
    font-family: 'Press Start 2P', 'Courier New', monospace;
    padding: 12px 16px 6px 16px;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(51, 255, 51, 0.05);
}

.chat-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(51, 255, 51, 0.05);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-item:hover {
    background: rgba(51, 255, 51, 0.05);
}

.chat-item.active {
    background: rgba(51, 255, 51, 0.1);
    border-left: 3px solid #33ff33;
}

.chat-item-title {
    color: #d0d0d0;
    font-size: 14px;
    font-weight: normal;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-item-title .chat-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.chat-item-title .chat-time {
    color: #33ff33;
    opacity: 0.5;
    font-size: 11px;
    font-family: 'Courier New', monospace;
    flex-shrink: 0;
}

.chat-item-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.chat-delete-btn {
    background: transparent;
    border: none;
    color: #888;
    font-size: 14px;
    padding: 0 2px;
    margin: 0;
    cursor: pointer;
    opacity: 0.4;
    transition: opacity 0.2s ease, color 0.2s ease;
    line-height: 1;
    flex-shrink: 0;
}

.chat-delete-btn:hover {
    color: #ff3333;
    opacity: 1;
}

.chat-item-preview {
    color: #888;
    font-size: 12px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-count {
    color: #A9A9A9;
    opacity: 0.6;
    font-size: 10px;
    margin-top: 2px;
}

/* ============================================================
   СЛОЙ 4: ОСНОВНОЙ ЧАТ
   ============================================================ */
#chatContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
    background: #0f0f0f;
    border-radius: 20px;
    overflow: hidden;
    position: relative;
}

/* ============================================================
   ЗАГОЛОВОК
   ============================================================ */
header {
    position: relative;
    padding: 12px 20px;
    background: #0d0d0d;
    border-bottom: 2px solid #2a6b4a;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    z-index: 10;
}

.header-left {
    width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(51, 255, 51, 0.25) 0%, rgba(51, 255, 51, 0) 70%);
    box-shadow: 0 0 30px rgba(51, 255, 51, 0.15);
}

.header-logo {
    height: 28px;
    width: auto;
    filter: brightness(1.2);
}

.header-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.header-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 2px solid #2a6b4a;
    object-fit: cover;
}

.header-center h1 {
    color: #33ff33;
    font-size: 16px;
    margin-top: 2px;
    letter-spacing: 2px;
    text-shadow: 0 0 12px rgba(51, 255, 51, 0.3);
}

.header-right {
    display: flex;
    gap: 10px;
    align-items: center;
    width: 48px;
    justify-content: flex-end;
}

/* ============================================================
   УНИВЕРСАЛЬНЫЕ КНОПКИ
   ============================================================ */
.header-btn,
.tool-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    position: relative;
    flex-shrink: 0;
}

.header-btn.glow-green,
.tool-btn.glow-green {
    box-shadow: 0 0 20px rgba(51, 255, 51, 0.4),
                0 0 40px rgba(51, 255, 51, 0.15),
                inset 0 0 20px rgba(51, 255, 51, 0.05);
    animation: pulse-green 2s ease-in-out infinite;
}

.header-btn.glow-red,
.tool-btn.glow-red {
    box-shadow: 0 0 20px rgba(255, 51, 51, 0.4),
                0 0 40px rgba(255, 51, 51, 0.15),
                inset 0 0 20px rgba(255, 51, 51, 0.05);
    animation: pulse-red 2s ease-in-out infinite;
}

.header-btn:hover,
.tool-btn:hover {
    background: rgba(51, 255, 51, 0.05);
    transform: scale(1.05);
}

.header-btn:active,
.tool-btn:active {
    transform: scale(0.95);
}

.header-icon,
.tool-icon {
    width: 30px;
    height: 30px;
    object-fit: contain;
    display: block;
    filter: brightness(1.1);
    transition: filter 0.3s ease;
}

@keyframes pulse-green {
    0%, 100% {
        box-shadow: 0 0 20px rgba(51, 255, 51, 0.4),
                    0 0 40px rgba(51, 255, 51, 0.15);
    }
    50% {
        box-shadow: 0 0 30px rgba(51, 255, 51, 0.6),
                    0 0 60px rgba(51, 255, 51, 0.25);
    }
}

@keyframes pulse-red {
    0%, 100% {
        box-shadow: 0 0 20px rgba(255, 51, 51, 0.4),
                    0 0 40px rgba(255, 51, 51, 0.15);
    }
    50% {
        box-shadow: 0 0 30px rgba(255, 51, 51, 0.6),
                    0 0 60px rgba(255, 51, 51, 0.25);
    }
}

/* ============================================================
   НОВЫЙ СЛОЙ: ОКОШКО С ИМЕНЕМ ЧАТА
   ============================================================ */
#chat-name-layer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

#chat-name-box {
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 60%;
    min-width: 140px;
    max-width: 400px;
    padding: 0 20px;
    height: 20px;
    border-radius: 20px;
    background: linear-gradient(90deg, #0d3d0d, #051a05, #0d3d0d);
    border: 1px solid #2a6b4a;
    box-shadow: 0 0 25px rgba(51, 255, 51, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    white-space: nowrap;
    z-index: 51;
}

#chat-name-box span {
    font-size: 10px;
    font-weight: bold;
    color: #ffffff;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    line-height: 1;
}

/* ============================================================
   ЧАТ (Контейнер: только тень и геометрия)
   ============================================================ */
#chat {
    flex: 1;
    position: relative;
    z-index: 1;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0;
    box-sizing: border-box;
    min-height: 0;
}

#chat::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-shadow: inset 0 0 16px 6px rgba(0, 0, 0, 0.9);
    z-index: 0;
    pointer-events: none;
    border-radius: inherit;
}

/* ============================================================
   СОДЕРЖИМОЕ ЧАТА (СКРОЛЛ + ФОН)
   ============================================================ */
.chat-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1a1a1a;
    padding: 12px 0 12px 0;
    box-sizing: border-box;
    min-height: 0;
    border-radius: 16px;
}

.chat-content::-webkit-scrollbar {
    width: 6px;
}
.chat-content::-webkit-scrollbar-track {
    background: transparent;
    padding: 10px 0;
}
.chat-content::-webkit-scrollbar-thumb {
    background: #33ff33;
    border-radius: 3px;
    opacity: 0.5;
}
.chat-content::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

/* ============================================================
   СООБЩЕНИЯ
   ============================================================ */
.message {
    max-width: 80%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 15px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 10px;
}

.message.user {
    align-self: flex-end;
    background: #1a2a22;
    color: #d0d0d0;
    border: 1px solid #2a6b4a;
    text-align: left;
}

.message.aina {
    align-self: flex-start;
    background: #141414;
    color: #e0e0e0;
    border: 1px solid #2a6b4a;
    text-align: left;
}

.message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #2a6b4a;
    flex-shrink: 0;
}

.message-content {
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
}

/* ============================================================
   СИСТЕМНЫЕ СООБЩЕНИЯ
   ============================================================ */
.system-message {
    text-align: center;
    color: #33ff33;
    font-size: 13px;
    opacity: 0.6;
    padding: 8px 0;
    font-family: 'Courier New', monospace;
    letter-spacing: 1px;
}

.system-message.info {
    color: #33ff33;
    opacity: 0.7;
}

.system-message.error {
    color: #ff3333;
    opacity: 0.8;
}

/* ============================================================
   ПОЛЕ ВВОДА
   ============================================================ */
#input-area {
    padding: 12px 20px;
    background: #0d0d0d;
    border-top: 2px solid #2a6b4a;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.input-tools {
    display: flex;
    gap: 4px;
    align-items: center;
}

#input-area textarea {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #2a6b4a;
    border-radius: 20px;
    background: #111;
    color: #d0d0d0;
    font-size: 15px;
    outline: none;
    resize: none;
    min-height: 42px;
    max-height: 150px;
    font-family: 'Courier New', monospace;
    line-height: 1.5;
    overflow-y: auto;
}

#input-area textarea::placeholder {
    color: #33ff33;
    opacity: 0.3;
}

#input-area button {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid #2a6b4a;
    border-radius: 20px;
    color: #33ff33;
    cursor: pointer;
    white-space: nowrap;
}

#input-area button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ============================================================
   POPUP СМАЙЛИКОВ
   ============================================================ */
.emoji-popup {
    position: absolute;
    bottom: 70px;
    left: 20px;
    background: #1a1a1a;
    border: 1px solid #2a6b4a;
    border-radius: 12px;
    padding: 12px;
    max-width: 320px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
}

.emoji-popup.hidden {
    display: none;
}

.emoji-popup::-webkit-scrollbar {
    width: 6px;
}
.emoji-popup::-webkit-scrollbar-track {
    background: transparent;
    padding: 10px 0;
}
.emoji-popup::-webkit-scrollbar-thumb {
    background: #2a6b4a;
    border-radius: 3px;
    opacity: 0.5;
}
.emoji-popup::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-item {
    font-size: 22px;
    cursor: pointer;
    text-align: center;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s ease;
    user-select: none;
}

.emoji-item:hover {
    background: rgba(51, 255, 51, 0.15);
    transform: scale(1.15);
}

.emoji-item:active {
    transform: scale(0.9);
}

/* ============================================================
   УВЕЛИЧЕННОЕ ФОТО
   ============================================================ */
.photo-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.photo-viewer.active {
    opacity: 1;
    pointer-events: auto;
}

.photo-viewer.hidden {
    display: none;
}

#photo-viewer-img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 16px;
    box-shadow: 0 0 60px rgba(51, 255, 51, 0.15);
    object-fit: contain;
}

/* ============================================================
   МОДАЛЬНОЕ ОКНО СПРАВКИ
   ============================================================ */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #111;
    padding: 30px;
    border-radius: 20px;
    max-width: 500px;
    color: #d0d0d0;
    border: 1px solid #2a6b4a;
    position: relative;
}

.modal-content .close {
    position: absolute;
    top: 10px;
    right: 16px;
    font-size: 24px;
    color: #33ff33;
    cursor: pointer;
}

.help-photos {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.help-photos img {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    object-fit: cover;
    border: 1px solid #2a6b4a;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.help-photos img:hover {
    transform: scale(1.05);
}

/* ============================================================
   БАЛАНС В БОКОВОЙ ПАНЕЛИ
   ============================================================ */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(51, 255, 51, 0.15);
    background: #0a0a0a;
    flex-shrink: 0;
}

.balance-display {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #33ff33;
    opacity: 0.7;
}

.balance-value {
    font-weight: bold;
    color: #33ff33;
    opacity: 1;
}

/* ============================================================
   ПРОГРЕСС-БАР
   ============================================================ */
.progress-container {
    background: rgba(0, 20, 0, 0.85);
    border: 1px solid #33ff33;
    border-radius: 8px;
    padding: 15px 20px;
    margin: 10px auto;
    box-shadow: 0 0 20px rgba(51, 255, 51, 0.15);
    animation: progressFadeIn 0.3s ease-out;
    width: 70%;
    max-width: 70%;
    min-width: 200px;
    box-sizing: border-box;
    overflow: hidden;
    margin-left: auto;
    margin-right: auto;
}

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

.progress-bar-wrapper {
    width: 100%;
    height: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(51, 255, 51, 0.2);
    margin-bottom: 8px;
    box-sizing: border-box;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #00cc00, #33ff33, #66ff66);
    border-radius: 10px;
    transition: width 0.3s ease-out;
    box-shadow: 0 0 15px rgba(51, 255, 51, 0.3);
    width: 0%;
}

.progress-text {
    color: #33ff33;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.5px;
    text-shadow: 0 0 8px rgba(51, 255, 51, 0.2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    box-sizing: border-box;
    display: block;
    text-align: center;
}

.progress-bar.pulse {
    animation: pulseBar 0.8s ease-in-out infinite alternate;
}

@keyframes pulseBar {
    from {
        opacity: 0.7;
    }
    to {
        opacity: 1;
    }
}

/* ============================================================
   БЛОКИ КОДА (ШАПКА + КНОПКА)
   ============================================================ */
.message-content .code-block-wrapper {
    margin: 16px 0;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #2a6b4a;
    background: #0a0a0a;
    max-width: 100%;
}

.message-content .code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #141414;
    border-bottom: 1px solid #1a3a2a;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #33ff33;
    opacity: 1;
}

.message-content .code-header .lang-label {
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.message-content .code-header .copy-btn {
    background: transparent;
    border: none;
    color: #33ff33;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-family: 'Courier New', monospace;
}

.message-content .code-header .copy-btn:hover {
    background: rgba(51, 255, 51, 0.1);
    color: #66ff66;
}

.message-content .code-header .copy-btn.copied {
    color: #69db7c;
}

.message-content pre {
    margin: 0 !important;
    padding: 16px !important;
    background: #0d0d0d !important;
    border: none !important;
    border-radius: 0 !important;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    overflow-x: hidden;
    max-width: 100%;
}

.message-content pre code {
    font-size: 14px !important;
    line-height: 1.6 !important;
    font-family: 'Courier New', monospace !important;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* ============================================================
   ДОПОЛНИТЕЛЬНАЯ ЗАЩИТА ОТ ВЫЛЕЗАЮЩЕГО КОНТЕНТА
   ============================================================ */
.message-content img,
.message-content table,
.message-content blockquote {
    max-width: 100%;
    height: auto;
}

.message-content table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    word-break: normal;
}
