/* 📁НАЧАЛО ФАЙЛА style.css v1.6 (адаптивная версия) */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.3; 
    background-color: #f0f2f5;
    color: #212529;
    font-size: 11.5px; 
}

.container {
    width: 100%;
    height: 100%;
    max-width: 1250px;
    margin: 0 auto;
    background: #ffffff;
    padding: 6px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column; 
    box-sizing: border-box;
}

.main-header {
    flex-shrink: 0; 
}
.main-header h1 {
    color: #172b4d;
    text-align: center;
    border-bottom: 1px solid #dfe4ea;
    padding-bottom: 5px;
    margin: 0 0 6px 0;
    font-size: 1.3em;
}

.simulation-layout { 
    display: flex;       
    flex-direction: row; 
    gap: 6px;
    flex-grow: 1;        
    overflow: hidden; 
}

.sidebar-mcu-state {
    display: flex;
    flex-direction: column; 
    gap: 4px; 
    width: 190px; 
    flex-shrink: 0; 
    padding: 4px; 
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    overflow-y: auto; 
}

/* MCU Block Styles */
.mcu-internal-block { border: none; padding: 0; margin-bottom: 0; }
.mcu-internal-block h3 { margin-top: 0; margin-bottom: 3px; color: #0056b3; font-size: 0.85em; text-align: left; border-bottom: 1px solid #e0e0e0; padding-bottom: 2px;}
.mcu-component { display: flex; justify-content: space-between; align-items: center; padding: 0px 3px; margin-bottom: 1px; border-radius: 2px; background-color: #fff; border: 1px solid #f1f3f5; font-size: 0.70em; min-height: 14px; }
.mcu-component .name { font-weight: normal; color: #495057; white-space: nowrap; margin-right: 2px; }
.mcu-component .status { color: #0056b3; font-family: 'Courier New', Courier, monospace; font-weight: bold; white-space: normal; text-align: right; line-height: 1.1; }
hr.mcu-divider { border: none; border-top: 1px solid #e9ecef; margin: 2px 0; }

/* Fuse Bits Block Styles */
.fuse-bits-block {
    border: 1px solid #ced4da;
    border-radius: 3px;
    padding: 5px;
    background-color: #f8f9fa;
    box-sizing: border-box;
}
.additional-info-area > .fuse-bits-block {
     margin-bottom: 0; 
}
.fuse-bits-block h3 {
    margin-top: 0; margin-bottom: 4px; 
    color: #0056b3; font-size: 0.8em; 
    text-align: left; border-bottom: 1px solid #e0e0e0; padding-bottom: 1px;
}
.fuse-item {
    font-size: 0.68em; 
    line-height: 1.2;
    margin-bottom: 1px;
    display: flex;
    align-items: baseline;
}
.fuse-item .fuse-name {
    font-weight: bold;
    color: #495057;
    white-space: nowrap;
    margin-right: 3px;
    flex-shrink: 0;
}
.fuse-item .fuse-value {
    font-family: 'Courier New', Courier, monospace;
    font-weight: bold;
    color: #007bff;
    margin-right: 4px;
    flex-shrink: 0;
}
.fuse-item .fuse-desc {
    color: #6c757d;
    white-space: normal; 
}

/* OLED Display Styles */
.oled-display-block { border: 1px solid #495057; border-radius: 3px; padding: 3px; background-color: #343a40; flex-shrink: 0;}
.oled-display-block h3 { margin-top: 0; margin-bottom: 2px; color: #f8f9fa; font-size: 0.85em; text-align: left; border-bottom: 1px solid #6c757d; padding-bottom: 1px;}
#oled-screen { font-family: 'Courier New', Courier, monospace; background-color: #000000; color: #20c997; padding: 2px; height: 84px; font-size: 10px; line-height: 10px; white-space: pre; overflow: hidden; border-radius: 1px; transition: opacity 0.2s;}
#oled-screen.powersave-on { opacity: 0.2; }

/* Speed Control Area */
.speed-control-area { padding: 4px 3px; text-align: center; font-size: 0.78em; color: #052c65; background-color: #cfe2ff; border-radius: 3px; border: 1px solid #9ec5fe; flex-shrink: 0; }
.speed-control-area label { display: block; margin-bottom: 2px; font-weight: 600; }
.speed-slider-controls { display: flex; align-items: center; gap: 4px; margin: 0 4px 1px 4px; }
.speed-adj-btn { padding: 0px 5px; font-size: 1em; line-height: 1; min-width: 20px; height: 20px; background-color: #ffffff; border: 1px solid #adb5bd; color: #052c65; border-radius: 3px; cursor: pointer; flex-shrink: 0; }
#sim-speed-slider { width: 100%; height: 8px; -webkit-appearance: none; appearance: none; background: #ffffff; outline: none; border-radius: 3px; border: 1px solid #adb5bd; flex-grow: 1; }
#sim-speed-value { display: block; font-size: 0.85em; color: #0056b3; font-weight: bold; margin-top: 1px; }

/* Step Counter in Sidebar */
#step-counter.step-counter-sidebar { font-size: 0.78em; text-align: center; padding: 2px; border: 1px solid #ced4da; background-color: #f8f9fa; border-radius: 2px; color: #495057; flex-shrink: 0; }
.sidebar-mcu-state .controls-area { flex-shrink: 0; display: flex; gap: 3px; }
.sidebar-mcu-state .controls-area button { padding: 3px 0; margin: 0; font-size: 0.8em; flex: 1; min-width: 30px; background-color: #cfe2ff; border: 1px solid #9ec5fe; color: #052c65; }


/* --- ОСНОВНАЯ КОНТЕНТНАЯ ОБЛАСТЬ --- */
.main-content-area { 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    overflow: hidden;
    flex-grow: 1; 
}

.top-row-layout { 
    display: flex; 
    gap: 6px; 
    flex-shrink: 0; 
}
.top-row-layout > .pin-visualization-wrapper { 
    border: 1px solid #ced4da; 
    border-radius: 3px; 
    padding: 5px; 
    background-color: #f8f9fa; 
    display: flex; 
    flex-direction: column; 
    overflow: hidden; 
    max-height: 190px;
}
.focus-pin-wrapper { flex-basis: 0; flex-grow: 1; flex-shrink: 1; min-width: 120px; }
.isp-pins-wrapper { 
    flex-basis: 50%; 
    flex-grow: 0; 
    flex-shrink: 0; 
    overflow-x: hidden; 
}

.all-pins-table-block { 
    display: flex; 
    flex-direction: column; 
    border: 1px solid #ced4da; 
    border-radius: 3px; 
    padding: 5px; 
    background-color: #f8f9fa;
    flex-shrink: 0; 
}

.all-pins-table-block > h3 { 
    margin-top: 0; 
    margin-bottom: 5px; 
    color: #0056b3; 
    font-size: 0.9em; 
    text-align: center; 
    border-bottom: 1px solid #e0e0e0; 
    padding-bottom: 2px; 
    flex-shrink: 0; 
}
.pins-table-sides-wrapper { 
    display: flex; 
    gap: 6px; 
}
.pins-table-side-column { 
    flex-basis: 50%; 
    display: flex; 
    flex-direction: column; 
    border: 1px solid #e0e6ed; 
    border-radius: 2px; 
}
.pins-table-side-column > table { 
    background-color: #ffffff;
}

/* Дополнительная информационная область (Fuse Bits и Заглушки) */
.additional-info-area {
    display: flex;       
    flex-direction: row; 
    justify-content: space-between; 
    align-items: flex-start; 
    gap: 10px; 
    padding: 5px;
    background-color: #e9ecef;
    border: 1px solid #dee2e6;
    border-radius: 3px;
    flex-shrink: 0; 
    flex-wrap: wrap; 
}
.additional-info-area > .fuse-bits-block,
.additional-info-area > .info-placeholder-block {
    flex-grow: 1; 
    flex-basis: 0; 
    min-width: 150px;
    box-sizing: border-box;
}
.info-placeholder-block { 
    border: 1px solid #dde2e6;
    border-radius: 3px;
    padding: 5px;
    background-color: #f0f2f5; 
    font-size: 0.75em;
    color: #6c757d;
    text-align: center;
    min-height: 30px; 
    display: flex; 
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
.info-placeholder-block h3 { margin-top: 0; margin-bottom: 2px; font-size: 0.9em; color: #0056b3; }
.info-placeholder-block p { margin: 0; }

/* ФУТЕР */
.step-info-footer-wrapper { 
    flex-shrink: 0; 
    padding: 6px 8px; 
    background-color: #f1f3f5; 
    border-top: 1px solid #ced4da; 
    display: flex; 
    align-items: center; 
    gap: 10px; 
    min-height: 40px; 
    box-sizing: border-box;
}
#current-step-title { 
    font-size: 0.9em; 
    font-weight: 600; color: #172b4d; 
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; 
    flex-shrink: 0; 
    margin-right: auto; 
}
#current-step-description { 
    font-size: 0.75em; 
    color: #42526e; 
    overflow: hidden; white-space: nowrap; 
    text-overflow: ellipsis;
    line-height: 1.3; 
    flex-shrink: 1; 
    text-align: left; 
}
#current-step-description p { margin: 0; } 

#multimeter-sim { 
    font-size: 0.75em; 
    font-weight: 600; color: #344563; 
    white-space: nowrap; 
    flex-shrink: 0; 
}
#multimeter-sim strong { color: #1e7e34; }


/* Стили таблиц пинов */
.pin-visualization-wrapper > h3 { margin-top: 0; margin-bottom: 4px; color: #0056b3; font-size: 0.85em; text-align: left; border-bottom: 1px solid #e0e0e0; padding-bottom: 2px; flex-shrink: 0; }
.isp-pins-wrapper > h3.pins-table-section-header { background-color: #cfe2ff !important; color: #052c65 !important; border-bottom: 1px solid #9ec5fe !important; text-align: center !important; }
.pin-detail { margin-bottom: 2px; padding: 1px 3px; border-radius: 2px; background-color: #fff; border: 1px solid #f1f3f5; font-size: 0.75em; display: flex; justify-content: space-between; }
.pin-detail .label { font-weight: normal; color: #555; white-space: nowrap; margin-right: 4px;}
.pin-detail .value { color: #004aad; font-weight: bold; text-align: right; }
.pin-connection { margin-top:4px; text-align:center; font-weight:bold; font-size: 0.78em;}
.pins-table-section-header { font-size: 0.82em; font-weight: bold; margin: 0 0 3px 0; padding: 2px 4px; text-align: center; border-radius: 2px 2px 0 0; flex-shrink: 0; background-color: #cfe2ff !important; color: #052c65 !important; border-bottom: 1px solid #9ec5fe !important; }
table { width: 100%; border-collapse: collapse; font-size: 0.72em; }
table th, table td { 
    border: 1px solid #e9ecef; 
    padding: 1px 2px;
    text-align: left; 
    white-space: nowrap; 
}
table th { 
    background-color: #f1f3f5; 
    font-weight: 600; 
    z-index: 10; 
}
.pins-table-subgroup-header td { background-color: #e2e3e5 !important; font-weight: bold; color: #495057; text-align: left !important; padding-left: 5px !important; border-top: 1px solid #adb5bd !important; border-bottom: 1px solid #adb5bd !important; }

/* Изменения для первой колонки таблицы пинов */
.pin-alt-name { 
    font-size: 0.85em; 
    color: #6c757d; 
    margin-left: 3px;
}
table td:nth-child(1) { 
    min-width: auto;
    white-space: nowrap;
}


.pin-non-mcu td:nth-child(n+4) { background-color: #f8f9fa; color: #adb5bd; text-align: center !important; }
.pin-level-indicator { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 1px solid #adb5bd; margin-right: 2px; vertical-align: middle; transition: background-color 0.1s ease-in-out, border-color 0.1s ease-in-out; }
.level-high { background-color: #28a745; border-color: #1e7e34;}
.level-low { background-color: #dc3545; border-color: #b02a37;}
.level-hiz { background-color: #f8f9fa; border-color: #ced4da;}
.level-pullup { background-color: #ffc107; border-color: #d39e00;}

table td:nth-child(2) { max-width: 110px; white-space: normal; }
table td:nth-child(3), table td:nth-child(4), table td:nth-child(5), table td:nth-child(6) { font-family: 'Courier New', Courier, monospace; text-align: center; min-width: 22px; }
table td:nth-child(8) { text-align: right; min-width: 40px; }
.active-mcu-comp { background-color: #ffeeba !important; border-color: #ffdb8b !important; }
.active-mcu-comp .status { color: #856404 !important; font-weight: bold; }
.sleep-mcu-comp { background-color: #e9ecef !important; border-color: #dee2e6 !important; opacity: 0.7; }
.sleep-mcu-comp .status { color: #6c757d !important; }
.pin-active-high { color: #20c997 !important; font-weight: bold; }
.pin-active-low { color: #e74c3c !important; font-weight: bold; }
.pin-hi-z { color: #6c757d !important; font-style: italic; }
.pin-pullup { color: #fd7e14 !important; }


/* === НАЧАЛО: Стили для мобильных устройств === */
@media (max-width: 850px) {
    html, body {
        overflow: auto; /* Разрешаем прокрутку всей страницы */
        font-size: 13px; /* Немного увеличим базовый шрифт */
        height: auto;
    }

    .container {
        height: auto;
        min-height: 100%;
        padding: 0;
        box-shadow: none;
    }
    .main-header h1 { font-size: 1.2em; padding: 10px 5px; }

    .simulation-layout {
        flex-direction: column; /* Все блоки в одну колонку */
        overflow: visible;
        gap: 10px;
        padding: 0 5px;
    }

    /* Сайдбар теперь будет вверху, растянутый на всю ширину */
    .sidebar-mcu-state {
        width: 100%;
        box-sizing: border-box;
        overflow-y: visible; /* Убираем внутреннюю прокрутку */
        order: 1; /* Порядок: 1.Сайдбар */
    }

    .main-content-area {
        overflow: visible;
        order: 2; /* Порядок: 2.Основной контент */
    }

    /* Перестраиваем блоки внутри основного контента */
    .top-row-layout,
    .pins-table-sides-wrapper,
    .additional-info-area {
        flex-direction: column;
    }

    .top-row-layout > .pin-visualization-wrapper {
        max-height: none; /* Снимаем ограничение по высоте */
    }

    /* Футер становится вертикальным */
    .step-info-footer-wrapper {
        order: 3; /* Порядок: 3.Футер */
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        gap: 5px;
        padding: 8px;
        position: relative; /* Чтобы не был приклеен к низу экрана */
    }

    /* Разрешаем перенос текста в футере */
    #current-step-title {
        white-space: normal;
        margin-right: 0;
    }
    #current-step-description, #multimeter-sim {
        white-space: normal;
    }
    
    /* Делаем таблицы скроллящимися по горизонтали, если не влезают */
    .pins-table-side-column, .isp-pins-wrapper {
        overflow-x: auto;
    }
}
/* === КОНЕЦ: Стили для мобильных устройств === */

/* 📁КОНЕЦ ФАЙЛА style.css v1.6 (адаптивная версия) */