@font-face {
    font-family: 'AcPlus_IBM_BIOS';
    src: url('fonts/AcPlus_IBM_BIOS.ttf') format('truetype');
}

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

body {
    background-color: #232323;
    color: #CACACA;
    font-family: 'AcPlus_IBM_BIOS', monospace;
    font-size: 14px;
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    padding: 8px;
    overflow: hidden;
    user-select: text; /* Разрешаем выделение и копирование текста */
}

/* Цвет выделения текста мышью в ретро-стиле */
::selection {
    background-color: #536e3d; /* Зеленый оливковый фон при выделении */
    color: #ffffff;            /* Белый текст при выделении */
}

/* Для браузеров Mozilla */
::-moz-selection {
    background-color: #536e3d;
    color: #ffffff;
}

/* Сетка интерфейса (как на скриншотах) */
.workspace {
    display: flex;
    flex-grow: 1;
    gap: 8px;
    height: calc(100vh - 42px);
}

.left-column {
    display: flex;
    flex-direction: column;
    width: 220px;
    gap: 8px;
}

.box {
    border: 1px solid #3d4f2c;
    background-color: #232323;
    padding: 6px 8px;
}

.cmd-helper {
    height: 25%;
    color: #CACACA;
}

.HUI-box {
    height: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    letter-spacing: 2px;
    color: #CACACA;
}

.multi-window {
    height: 25%;
    color: #CACACA;
}

/* Центральная рабочая консоль */
.terminal-main {
    flex-grow: 1;
    border: 1px solid #3d4f2c;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 12px;
    overflow: hidden;
    position: relative;
}

#terminal-logs {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
    word-break: break-all;
    white-space: pre-wrap;
}

/* Строка ввода (общий контейнер) */
.input-row {
    display: block !important; 
    position: relative; 
    width: 100%;
    line-height: 1.2;
    word-break: break-all; /* Разрешаем перенос длинных строк в любом месте */
}

/* Ярлык с никнеймом */
.prompt-label {
    display: inline !important; 
    color: #CACACA;
    white-space: pre-wrap !important; /* Защищаем пробел на конце от обрезки браузером */
    margin-right: 0 !important; /* Убираем margin, чтобы текст начинался сразу за ником */
}

/* Контейнер строки ввода */
.input-container {
    display: inline !important; /* Главный фикс: сливаем контейнер с никнеймом в один абзац */
}

/* Наш кастомный текст */
#typed-text {
    color: #CACACA;
    display: inline !important;
    white-space: pre-wrap !important; 
    word-break: break-all !important; 
}

/* Скрываем стандартный инпут, но оставляем его функциональным */
#cli-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0; /* Полностью прозрачный */
    cursor: text;
    border: none;
    outline: none;
}

/* Подвал сайта (нижняя тонкая рамка) */
.bottom-bar {
    height: 20px;
    border: 1px solid #3d4f2c;
    margin-top: 6px;
}

/* Классы подсветки цветов */
.color-normal { color: #CACACA; }
.color-sys { color: #536e3d; }
.color-err { color: #a32929; }
.color-action { 
    color: #7eb356; 
    cursor: pointer; 
    text-decoration: underline;
}
.color-action:hover {
    color: #a4e670;
}

/* Карточка документа в консоли (как на скриншотах) */
.document-frame {
    border: 1px solid #536e3d;
    padding: 8px;
    margin: 6px 0;
    max-width: 760px;
}
.document-title {
    color: #536e3d;
    margin-bottom: 6px;
}
.document-body {
    color: #CACACA;
    line-height: 1.25;
}
.document-footer {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 8px;
    color: #536e3d;
}

/* Видео плеер */
.video-frame {
    width: 260px;
    height: 180px;
    background: #111;
    border: 1px solid #536e3d;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #CACACA;
    margin: 6px 0;
}
.media-controls {
    color: #7eb356;
    margin-top: 4px;
    display: flex;
    gap: 8px;
}

/* =========================================
   КАСТОМНЫЙ СКРОЛЛБАР (HTML + JS)
   ========================================= */

/* Обертка для позиционирования */
.scroll-wrapper {
    display: flex;
    flex-grow: 1;
    position: relative;
    overflow: hidden;
    margin-bottom: 8px;
}

#terminal-logs {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    word-break: break-all;
    white-space: pre-wrap;
    padding-right: 16px; /* Отступ от нашего скроллбара */
    
    /* ПОЛНОСТЬЮ СКРЫВАЕМ НАТИВНЫЕ СКРОЛЛБАРЫ */
    scrollbar-width: none; /* Для Firefox */
    -ms-overflow-style: none; /* Для старого Edge */
}

/* Скрываем нативный скроллбар для Chrome/Edge/Safari */
#terminal-logs::-webkit-scrollbar {
    display: none;
}

/* Наш кастомный трек (фон) */
#custom-scrollbar {
    width: 12px;
    background: #232323;
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
}

/* Наш кастомный ползунок */
#custom-thumb {
    width: 100%;
    background: #536e3d;
    cursor: pointer;
    position: absolute;
    top: 0;
    border-radius: 0; /* Строго прямоугольный */
}

#custom-thumb:hover {
    background: #7eb356;
}

/* =========================================
   НОВЫЙ БЛОЧНЫЙ МИГАЮЩИЙ КУРСОР
   ========================================= */
.term-cursor {
    display: inline-block;
    min-width: 10px; /* Ширина квадрата */
    animation: cursorBlink 1s step-end infinite;
}

@keyframes cursorBlink {
    0%, 100% {
        background-color: #405430; /* Цвет выделения (синий) */
        color: #1c1c1c;            /* Цвет текста внутри блока (темный) */
    }
    50% {
        background-color: transparent;
        color: inherit;
    }
}

.audio-player {
    border: 1px solid #8ba870; /* Цвет рамки терминала */
    padding: 8px 12px;
    margin: 8px 0;
    display: inline-block;
    font-family: 'AcPlus_IBM_BIOS', monospace;
    color: #8ba870;
    line-height: 1.5;
    background: transparent;
    user-select: none;
}

.audio-row {
    display: flex;
    align-items: center;
    gap: 16px;
    white-space: pre;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ascii-slider-container {
    position: relative;
    display: inline-block;
}

.ascii-slider-text {
    display: inline-block;
    pointer-events: none;
}

/* Делаем стандартный ползунок невидимым, но кликабельным поверх текста */
.ascii-slider-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
}

.play-pause-btn {
    cursor: pointer;
}
.play-pause-btn:hover {
    color: #ffffff;
}

/* =========================================
   АУДИО ПЛЕЕР (БАЗА - КАК БЫЛО НА ПК)
   ========================================= */
.audio-player-container {
    border: 1px solid #536e3d;
    padding: 6px 12px;
    margin: 6px 0;
    font-family: 'AcPlus_IBM_BIOS', monospace;
    color: #7eb356;
    user-select: none;
    
    /* ФИКС "РАЗЪЕХАВШЕГОСЯ" ИНТЕРФЕЙСА: отменяем переносы от терминала */
    white-space: normal !important; 
    word-break: normal !important;
    
    /* ЖЕСТКИЕ РАЗМЕРЫ: отменяем растягивание */
    width: max-content !important;
    max-width: 100%;
    align-self: flex-start !important;
    display: block !important;
    box-sizing: border-box;
}

.audio-layout {
    display: flex; /* Возвращаем Flexbox для ПК, он работал идеально */
    gap: 2ch;
    align-items: center;
    margin-bottom: 4px;
}

.audio-filename { width: 14ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audio-time-box { width: 9ch; text-align: center; }
.audio-vol-box { display: flex; gap: 1ch; align-items: center; }
.audio-play-box { width: 2ch; text-align: right; cursor: pointer; }

/* Прячем стандартные системные ползунки, оставляя только ASCII-символы */
.slider-wrapper { position: relative; display: inline-block; }
.audio-prog-box { position: relative; display: block; width: 100%; overflow: hidden; }

.vol-input, .prog-input {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
    opacity: 0; cursor: pointer; margin: 0;
}

@media screen and (max-width: 768px) {
    .left-column {
        display: none !important;
    }

    body {
        height: 100dvh; 
        padding: 4px;
    }

    .workspace {
        /* Заменили height: auto на flex-ограничения, чтобы заработал скролл */
        flex: 1 1 0%;
        min-height: 0;
    }

    #cli-input, #typed-text, .prompt-label {
        font-size: 16px !important;
    }

    .terminal-main {
        padding: 8px;
        /* Запираем терминал в ширину экрана */
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    /* Жестко блокируем сдвиги по горизонтали и разрешаем скролл по вертикали */
    #terminal-logs {
        overflow-x: hidden !important; 
        overflow-y: auto !important;
    }
    
    .forum-message img.avatar {
        width: 24px !important;
        height: 24px !important;
    }

    /* =========================================
       МОБИЛЬНЫЙ АУДИО ПЛЕЕР (КВАДРАТ)
       ========================================= */
    .audio-player-container {
        width: 100%; /* На телефоне растягиваем на всю ширину */
    }
    
    .audio-layout {
        display: grid; /* Включаем сетку только на телефонах */
        grid-template-columns: 1fr auto; 
        grid-template-rows: auto auto auto; 
        gap: 8px 0;
    }

    .audio-filename { 
        width: auto; /* Сбрасываем жесткую ширину для мобилок */
        grid-column: 1 / 3; 
        grid-row: 1; 
    }
    
    .audio-vol-box { 
        grid-column: 1; 
        grid-row: 2; 
    }
    
    .audio-play-box { 
        width: auto;
        grid-column: 2; 
        grid-row: 2; 
    }
    
    .audio-time-box { 
        width: auto;
        grid-column: 1 / 3; 
        grid-row: 3; 
        text-align: right; 
    }
}