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

/* Удобнее на мобильных: убираем подсветку по тапу */
a, button, .menu-item {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.05);
}

:root {
    --primary-color: #009170;
    --accent-color: #FF6600;
    --bg-color: #F7F7F7;
    --text-color: #333;
    --white: #ffffff;
    --border-color: #ddd;
    --hover-color: #007a62;
}

html {
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
    /* padding-bottom: 80px; */
    overflow-x: hidden;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

body.page-ready {
    opacity: 1;
}

body.page-exit {
    opacity: 0;
}

.main-page {
    margin-left: 200px;
}

/* Скрыть контент до полной загрузки — показывается только индикатор */
body.page-loading > *:not(#page-loader) {
    visibility: hidden !important;
}

/* Индикатор загрузки страницы (размытый фон + логотип ч/б → цветной) */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease;
    pointer-events: none;
}
.page-loader.done {
    opacity: 0;
    pointer-events: none;
}
.page-loader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.page-loader-logo-wrap {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 0;
    transition: opacity 0.25s ease-out;
}
.page-loader.page-loader-ready .page-loader-logo-wrap {
    opacity: 1;
}
.page-loader-logo-inner {
    position: relative;
    width: 280px;
    min-height: 90px;
}
.page-loader-logo-bw,
.page-loader-logo-color {
    display: block;
    width: 100%;
    height: auto;
    vertical-align: top;
}
.page-loader-logo-bw {
    filter: grayscale(100%);
}
/* Цветной слой: заполнение цветом снизу вверх (как вода поднимается) */
.page-loader-logo-color {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    clip-path: inset(0 0 100% 0); /* вначале видно 0% снизу */
    -webkit-clip-path: inset(0 0 100% 0);
    transition: clip-path 3.2s ease-in-out, -webkit-clip-path 3.2s ease-in-out;
}
.page-loader.loaded .page-loader-logo-color {
    clip-path: inset(0 0 0 0);
    -webkit-clip-path: inset(0 0 0 0);
}
.page-loader-text {
    display: block;
    margin-top: 1rem;
    text-align: center;
    font-size: 1.9rem;
    font-weight: bold;
    color: #555;
}
/* Надпись над заголовком в лоадере (старт: «Платформа «Хранитель»») */
.page-loader-brand {
    display: block;
    margin-bottom: 0.5rem;
    text-align: center;
    font-size: 1.9rem;
    font-weight: bold;
    color: #555;
    line-height: 1.4;
}
/* Заголовок над логотипом в лоадере (главная: «Центр обучения», guide: «Руководство пользователя») */
.page-loader-title {
    display: block;
    margin-bottom: 1rem;
    text-align: center;
    font-size: 1.9rem;
    font-weight: bold;
    color: #555;
    line-height: 1.4;
}
/* Подзаголовок под «Центр обучения» в лоадере (например: «Курс: Лесохранитель. Пользователь.») */
.page-loader-subtitle {
    display: block;
    margin-bottom: 0.75rem;
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--text-color);
    line-height: 1.3;
}

/* --- Стартовая страница (плитки выбора продукта) --- */
.start-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.start-page main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: none;
    width: 100%;
    margin: 0 auto;
    padding: 0.75rem 1rem 1rem;
    text-align: center;
    box-sizing: border-box;
}
.start-page .start-title {
    font-size: 1.15rem;
    color: var(--text-color);
    margin: 0 0 0.75rem;
    font-weight: bolder;
    margin-bottom: 30px;
}
.start-page .start-enter {
    display: inline-block;
    padding: 14px 32px;
    font-size: 1.1em;
    font-weight: 600;
    background-color: var(--primary-color);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}
.start-page .start-enter:hover {
    background-color: var(--accent-color);
}
.start-page header h1 .header-text-only {
    color: var(--white);
    text-decoration: none;
    font-size: 1.2em;
}
.start-tiles {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            grid-template-rows: auto auto;
            gap: 1.84rem;
            width: 57.6vw;
            max-width: 3552px;
            margin: 0 auto;
        }
.start-tile {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    align-self: start;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.08);
    background: #eaeaea;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.start-tile:hover {
    box-shadow: 0 6px 16px rgba(0,0,0,0.18), 0 2px 4px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}
.start-tile img,
.start-tile video {
    width: 100%;
    height: auto;
    display: block;
    vertical-align: top;
    object-fit: cover;
}
.start-tile video {
    min-height: 200px;
}
.start-tile-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}
.start-tile:hover .start-tile-overlay {
    opacity: 1;
}
.start-tile-overlay-caption {
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
    text-align: center;
}
.start-tile-overlay-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}
.start-tile-overlay .btn {
    width: 250px;
    padding: 2px 2px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 8px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s;
    text-align: center;
    box-sizing: border-box;
    background: var(--primary-color);
    color: #fff;
}
.start-tile-overlay .btn:hover {
    background: var(--accent-color);
}

/* На главной странице (video-page-body) убираем общую полосу прокрутки */
.video-page-body {
    overflow: hidden;
}

.container {
    /* max-width: 1200px; */
    margin: 0 auto;
    padding: 0 40px;
}

/* На странице просмотра видео основной контент на всю ширину,
   с фиксированными отступами по краям */
.video-page-body main.container {
    max-width: none;
    width: 100%;
    padding-left: 12px;
    padding-right: 12px;
    box-sizing: border-box;
    margin-top: 12px;
    /* занимаем всю доступную высоту под контент (меньший отступ снизу до sidebar) */
    height: calc(100vh - 80px); /* header (48) + его отступ (20) + отступ main (12) */
    overflow: hidden;
    min-height: 0;
}

/* Страница руководства (guide.html) — обычная прокручиваемая страница с контентом */
body.guide-page {
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 100vh;
}
/* Скрыть авторизацию и имя пользователя в шапке на странице руководства */
.guide-page .auth-section {
    display: none !important;
}
.guide-page header .container {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}
.guide-page main.container {
    height: auto;
    min-height: auto;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    /* margin-left: 100px;
    margin-right: 0; */
    padding: 0.75rem 0.75rem 2rem;
    box-sizing: border-box;
}

/* Контент руководства (HTML из Word) */
.guide-page .guide-content .guide-fragment {
    margin: 0;
    padding: 0;
}
.guide-page .guide-content {
    font-size: 1rem;
    line-height: 1.6;
    color: #222;
    counter-reset: h1;
    overflow-wrap: break-word;
    word-wrap: break-word;
    max-width: 100%;
    min-width: 0;
}
/* Плавное появление контента руководства */
.guide-page .guide-content.guide-content-loaded {
    animation: guide-content-fade-in 0.5s ease-out forwards;
}
@keyframes guide-content-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* Крупное изображение (скриншот): отдельный блок, как в документе */
.guide-page .guide-content .guide-figure-wrap,
.guide-page .guide-content p.guide-figure-wrap {
    margin: 1rem 0;
}
.guide-page .guide-content .guide-figure-wrap img,
.guide-page .guide-content p.guide-figure-wrap img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}
/* Иконка внутри абзаца: inline, как в DOCX */
.guide-page .guide-content p:not(.guide-figure-wrap) img {
    display: inline-block;
    vertical-align: middle;
    max-height: 1.35em;
    width: auto;
    height: auto;
}
.guide-page .guide-content img {
    max-width: 100%;
    height: auto;
}
.guide-page .guide-content img:only-child {
    display: block;
}
.guide-page .guide-content pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.guide-page .guide-content table {
    table-layout: fixed;
    max-width: 100%;
    width: 100%;
}
.guide-page .guide-content table td,
.guide-page .guide-content table th {
    word-wrap: break-word;
    overflow-wrap: break-word;
}
/* Заголовки: нумерация пунктов 1., 1.1., 1.1.1. и т.д. */
.guide-page .guide-content h1 { counter-reset: h2; counter-increment: h1; font-size: 1.5rem; margin: 1.5rem 0 0.75rem; font-weight: 700; }
.guide-page .guide-content h1::before { content: counter(h1) ". "; }
.guide-page .guide-content h2 { counter-reset: h3; counter-increment: h2; font-size: 1.3rem; margin: 1.35rem 0 0.6rem; font-weight: 700; }
.guide-page .guide-content h2::before { content: counter(h1) "." counter(h2) " "; }
.guide-page .guide-content h3 { counter-reset: h4; counter-increment: h3; font-size: 1.15rem; margin: 1.2rem 0 0.5rem; font-weight: 600; }
.guide-page .guide-content h3::before { content: counter(h1) "." counter(h2) "." counter(h3) " "; }
.guide-page .guide-content h4 { counter-reset: h5; counter-increment: h4; font-size: 1.05rem; margin: 1rem 0 0.4rem; font-weight: 600; }
.guide-page .guide-content h4::before { content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) " "; }
.guide-page .guide-content h5 { counter-reset: h6; counter-increment: h5; font-size: 1.05rem; margin: 1rem 0 0.4rem; font-weight: 600; }
.guide-page .guide-content h5::before { content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " "; }
.guide-page .guide-content h6 { counter-increment: h6; font-size: 1.05rem; margin: 1rem 0 0.4rem; font-weight: 600; }
.guide-page .guide-content h6::before { content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) " "; }
.guide-page .guide-content p { margin: 0.5rem 0 0.75rem; line-height: 1.6; }
.guide-page .guide-content ul { margin: 0.5rem 0 0.75rem 1.5rem; padding-left: 1.5rem; }
.guide-page .guide-content ol { margin: 0.5rem 0 0.75rem 1.5rem; padding-left: 1.5rem; }
.guide-page .guide-content li { margin: 0.25rem 0; }
.guide-page .guide-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; font-size: 0.95rem; }
.guide-page .guide-content th, .guide-page .guide-content td { border: 1px solid #333; padding: 0.4rem 0.5rem; text-align: left; vertical-align: top; }
.guide-page .guide-content th { background: #e8e8e8; font-weight: 600; }
.guide-page .guide-content strong { font-weight: 600; }
.guide-page .guide-content a { color: #0066cc; text-decoration: underline; }
.guide-page .guide-content blockquote { margin: 0.75rem 0; padding-left: 1rem; border-left: 3px solid #ccc; color: #444; }
.guide-page .guide-content p + p { margin-top: 0.5rem; }
.guide-page .guide-content h1[id], .guide-page .guide-content h2[id], .guide-page .guide-content h3[id],
.guide-page .guide-content h4[id], .guide-page .guide-content h5[id], .guide-page .guide-content h6[id] {
    display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.35rem;
}
.guide-page .guide-heading-links { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.25rem; }
.guide-page .guide-anchor-permalink { font-size: 0.85rem; color: #999; text-decoration: none; }
.guide-page .guide-anchor-permalink:hover { color: #0066cc; }
.guide-page .guide-anchor-link { font-size: 0.75rem; font-weight: normal; }
.guide-page .guide-anchor-link a, .guide-page .guide-anchor-link button {
    background: none; border: none; color: #666; cursor: pointer; text-decoration: underline; padding: 0; font: inherit;
}
.guide-page .guide-anchor-link a:hover, .guide-page .guide-anchor-link button:hover { color: #333; }
.guide-page .guide-anchor-copied { color: green; }

/* Оранжевые сноски/пояснения к рисункам (как в DOCX) */
.guide-page .guide-content .guide-annotation,
.guide-page .guide-content p.guide-annotation,
.guide-page .guide-content li.guide-annotation {
    color: #c45c00;
    margin: 0.35rem 0 0.5rem;
}
.guide-page .guide-content .guide-annotation-num {
    font-weight: 700;
}

/* Текстовый документ (doc/guide.txt) */
.guide-page .guide-content .guide-text {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    margin: 0;
    padding: 0.5rem 0;
}

/* Header (узкий, как на старой странице видео, на всех страницах) */
header {
    background-color: var(--accent-color);
    color: var(--white);
    padding: 4px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    min-height: 48px;
    margin-bottom: 10px;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 0;
    padding-bottom: 0;
}

header h1 {
    font-size: 1.2em;
    margin: 0;
    align-items: center;
}

a {
    text-decoration: none;
}

.logo-link {
    color: var(--white);
    text-decoration: none;
}

.logo-link:hover {
    text-decoration: none;
    color: var(--text-color);
}

/* Кнопка «На главную» в шапке (lhuser и др.) */
header h1 .home-btn {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35em;
    padding: 0.5em 1em;
    font-size: 0.95em;
    font-weight: 600;
    color: var(--accent-color);
    background: var(--white);
    border-radius: 8px;
    border: none;
    transition: background-color 0.2s ease, transform 0.05s ease;
    margin-top: 2px;
    padding-bottom: 3px;
    padding-top: 2px;
}
header h1 .home-btn:hover {
    background: var(--hover-color);
    color: #fff;
}
header h1 .home-btn::before {
    content: "";
    opacity: 0.9;
}
header h1 .header-title {
    margin-left: 1rem;
    color: var(--white);
    font-weight: bold;
    font-size: 1.2em;
}
header h1 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.auth-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

#auth-status {
    font-size: 0.9em;
    opacity: 0.9;
}

.auth-name {
    font-weight: bolder;
    color: var(--text-color);
}

/* Buttons */
.btn {
    background-color: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--white);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn:hover {
    background-color: var(--accent-color);
    color: var(--white);
}

.btn-primary {
    background-color: var(--white);
    color: var(--primary-color);
    border-color: var(--primary-color);
    /* margin-left: 5px; */
    border-radius: 5px;
}

.btn-primary:hover {
    background-color: var(--accent-color);
    border-color: var(--white);
    color: var(--white);
}

.btn-primary1 {
    background-color: var(--primary-color);
    color: var(--white);
    border-color: var(--primary-color);
    margin-left: 20px;
    border-radius: 5px;
    margin-right: 400px;
}

.btn-primary1:hover {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
    color: var(--white);
}

.btn-secondary {
    background-color: #6c757d;
    color: var(--white);
    border-color: #6c757d;
}

.btn-secondary:hover {
    background-color: #5a6268;
    border-color: #5a6268;
}

.btn-danger {
    background-color: #ffffff;
    color: #dc3545;
    border-color: #dc3545;
}

.btn-danger:hover {
    background-color: #c82333;
    border-color: #c82333;
}

/* Main content */
main {
    margin-top: 30px;
}

main h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.6em;
}

.search-wrap {
    flex: 1;
    min-width: 240px;
    margin-bottom: 5px;
    margin-top: 5px;
}

.search-input {
    width: 100%;
    max-width: 420px;
    padding: 8px 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95em;
    background: var(--white);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(35, 134, 155, 0.15);
}

.search-row {
    display: flex;
    align-items: center;

}

.search-row .search-input {
    max-width: none;
}

.search-btn {
    white-space: nowrap;
    padding: 3px 14px;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    background-color: var(--bg-color);
    width: 120px;
}

.search-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: space-between;
}

.clear-search-btn {
    white-space: nowrap;
    padding: 3px 14px;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    background-color: var(--bg-color);
    width: 120px;
}

/* Menu list (оглавление книги) */
.menu-grid {
    background-color: var(--white);
    border-radius: 6px;
    padding: 5px  1px 5px 5px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    max-width: 1200px;
}

.menu-item {
    display: flex;
    align-items: flex-start;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    position: relative;
}

.menu-item-content {
    flex: 1;
    min-width: 0;
}

/* Блок кнопок «Видео» / «Текстовое руководство» рядом с пунктом меню */
.menu-item-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-left: 10px;
    margin-right: 2px;
    justify-content: flex-end;
}

.menu-item-video-btn,
.menu-item-guide-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 0.2s ease, transform 0.15s ease;
    position: relative;
    min-width: 38px;
    min-height: 38px;
}

.menu-item-video-btn:hover,
.menu-item-guide-btn:hover {
    background-color: transparent;
}

.menu-item-video-btn:active,
.menu-item-guide-btn:active {
    transform: scale(0.95);
}

.menu-item-video-btn img,
.menu-item-guide-btn img {
    display: block;
    width: 30px;
    height: 30px;
    object-fit: contain;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -15px 0 0 -15px;
    transition: opacity 0.2s ease;
}

.menu-item-video-btn .icon-hover,
.menu-item-guide-btn .icon-hover {
    opacity: 0;
    pointer-events: none;
}

.menu-item-video-btn:hover .icon-default,
.menu-item-guide-btn:hover .icon-default {
    opacity: 0;
    pointer-events: none;
}

.menu-item-video-btn:hover .icon-hover,
.menu-item-guide-btn:hover .icon-hover {
    opacity: 1;
    pointer-events: auto;
}

.menu-item-guide-btn {
    text-decoration: none;
}

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

.menu-item:hover {
    background-color: var(--bg-color);
    transform: translateX(6px);
}

.menu-item-number {
    color: var(--text-color);
    font-weight: 600;
    margin-right: 5px;
    min-width: 32px;
    font-size: 0.85em;
    text-align: left;
}

.menu-item .menu-item-content h3 {
    color: var(--primary-color);
    margin: 0;
    font-size: 0.95em;
    font-weight: 500;
    flex: 1;
    cursor: default;
}

/* Все пункты: не жирный, меньше размер, плотные строки */
.menu-item .menu-item-content h3 {
    font-size: 0.95em;
    font-weight: bolder;
    line-height: 1.15;
}

/* Минимальный вертикальный отступ между строками списка (для всех уровней) */
.menu-item {
    padding-top: 6px;
    padding-bottom: 6px;
}

/* Визуальный отступ для подпунктов */
/* "2 пробела" шага отступа ≈ 16px (можно поменять) */
.menu-item {
    --menu-indent-step: 16px;
    padding-left: calc(8px + (var(--menu-level, 0) * var(--menu-indent-step)));
    align-items: center;
    padding-right: unset;
}

.menu-item.level-0 { --menu-level: 0; cursor: pointer; }
.menu-item.level-1 { --menu-level: 1; }
.menu-item.level-2 { --menu-level: 2; }
.menu-item.level-3 { --menu-level: 3; }
.menu-item.level-4 { --menu-level: 4; }
.menu-item.level-5 { --menu-level: 5; }

.menu-item::after {
    content: "";
    color: var(--primary-color);
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-left: auto;
    font-size: 0.9em;
}

.menu-item:hover::after {
    opacity: 1;
}

/* Пункт без ссылки — не кликабельный, курсор стрелка */
.menu-item.menu-item-no-link,
.menu-item.level-0.menu-item-no-link,
.menu-item.level-1.menu-item-no-link,
.menu-item.level-2.menu-item-no-link,
.menu-item.level-3.menu-item-no-link,
.menu-item.level-4.menu-item-no-link,
.menu-item.level-5.menu-item-no-link {
    cursor: default !important;
}
.menu-item-no-link {
    opacity: 0.85;
}
.menu-item-no-link:hover,
.menu-item-no-link:hover * {
    cursor: default !important;
}
.menu-item-no-link:hover {
    background-color: transparent;
    transform: none;
}
.menu-item-no-link:hover::after {
    opacity: 0;
}
.menu-item-no-link .menu-item-content h3 {
    color: var(--text-color);
}

/* Video page — без вертикальной и горизонтальной прокрутки контента */
.video-page-layout {
    display: flex;
    gap: 12px;
    align-items: stretch;
    height: 100%;
    min-height: 0;
    overflow-x: hidden;
}

.video-sidebar {
    flex: 0 0 520px;
    max-width: 560px;
    background-color: var(--white);
    border-radius: 8px;
    padding: 16px 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
}

/* Область карусель/плеер — без прокрутки по X и Y */
.video-main-area {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 200px;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
    overflow-x: hidden;
}

.video-main-area .home-carousel,
.video-main-area .video-main,
.video-main-area .guide-inline-panel {
    position: absolute;
    inset: 0;
    transition: opacity 0.6s ease-in-out;
}

.video-main-area .video-main,
.video-main-area .guide-inline-panel {
    opacity: 0;
    pointer-events: none;
}

.video-main-area .guide-inline-panel {
    display: flex;
    flex-direction: column;
}

.video-main-area.video-area-show-player .home-carousel {
    opacity: 0;
    pointer-events: none;
}

.video-main-area.video-area-show-player .video-main {
    opacity: 1;
    pointer-events: auto;
}

.video-main-area.video-area-show-guide .home-carousel,
.video-main-area.video-area-show-guide .video-main {
    opacity: 0;
    pointer-events: none;
}

.video-main-area.video-area-show-guide .guide-inline-panel {
    opacity: 1;
    pointer-events: auto;
    padding-right: 5px;
}

/* Плавная смена контента при переключении между пунктами */
.video-main-area .video-main.video-main-updating {
    opacity: 0;
    transition-duration: 0.4s;
}

/* Карусель — компактные отступы, закруглённые края, мягкая тень, без вертикальной прокрутки */
.video-main-area .home-carousel {
    padding: 10px 0;
    box-sizing: border-box;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(0,0,0,0.06);
    display: flex;
    align-items: stretch;
    width: 100%;
    max-width: 100%;
}
.video-main-area .carousel-track {
    position: relative;
    width: 100%;
    height: 100%;
    border-radius: 16px;
    overflow: hidden;
    min-height: 0;
}
.carousel-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.6s ease;
    pointer-events: none;
    border-radius: 16px;
    overflow: hidden;
}
.carousel-slide.active {
    opacity: 1;
    pointer-events: auto;
}
.carousel-slide .slide-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
}
/* Обёртка с явными размерами — скругление и обрезка картинки */
.carousel-slide .slide-content-inner {
    position: absolute;
    inset: 0;
    border-radius: 16px;
    overflow: hidden;
    isolation: isolate;
}
.carousel-slide .slide-content-inner img,
.carousel-slide .slide-content img {
    position: absolute;
    inset: 0;
    width: 100%;
    /* height: 100%; */
    object-fit: contain;
    object-position: center;
    display: block;
    border-radius: 16px;
}

/* .download-rp-block {
    margin-bottom: 10px;
} */

.sidebar-header {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 10px;
}

.sidebar-intro {
    background-color: var(--primary-color);
    box-sizing: border-box;
    padding: 12px;
    border-radius: 10px;
    color: #ffffff;
}

.sidebar-no-items {
    padding: 18px 16px;
    margin-top: 8px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, rgba(0, 145, 112, 0.08) 0%, rgba(0, 145, 112, 0.04) 100%);
    border: 1px solid rgba(0, 145, 112, 0.25);
    border-radius: 10px;
    color: var(--text-color, #333);
    font-size: 1em;
    line-height: 1.5;
    font-weight: 500;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

/* Ссылка на скачивание РП над блоком поиска */
.download-rp-link {
    width: 100%;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 15px;
    background: var(--primary-color);
    color: #fff;
    text-decoration: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9em;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.15s ease;
    border: 1px solid rgba(255, 255, 255, 0.25);
}
.download-rp-link:hover {
    background: var(--accent-color);
    color: #fff;
    transform: translateY(-1px);
}
.download-rp-icon {
    font-size: 1.1em;
}

.video-main {
    flex: 1 1 auto;
    background-color: var(--white);
    border-radius: 8px;
    padding: 16px 0 20px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    /* чтобы блок полностью “держал” высоту на экране */
    min-height: calc(100vh - 140px);
}

/* Панель руководства рядом со списком (как видео) */
.guide-inline-panel {
    background-color: var(--white);
    border-radius: 12px;
    padding: 20px 24px 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid rgba(0,0,0,0.06);
    min-height: 200px;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}
.guide-inline-body {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 1rem;
    line-height: 1.6;
    color: #222;
    overflow-wrap: break-word;
    word-wrap: break-word;
    word-break: break-word;
    max-width: 100%;
    box-sizing: border-box;
}
.guide-inline-body .guide-fragment {
    counter-reset: h1 h2 h3 h4 h5 h6;
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}
/* Все заголовки якорного контента в стиле 1-го уровня */
.guide-inline-body .guide-fragment h1,
.guide-inline-body .guide-fragment h2,
.guide-inline-body .guide-fragment h3,
.guide-inline-body .guide-fragment h4,
.guide-inline-body .guide-fragment h5,
.guide-inline-body .guide-fragment h6 {
    font-size: 1.35rem;
    margin: 1.25rem 0 0.6rem;
    font-weight: 700;
    color: var(--primary-color);
}
.guide-inline-body .guide-fragment h1 { counter-reset: h2; counter-increment: h1; }
.guide-inline-body .guide-fragment h1::before { content: counter(h1) ". "; }
.guide-inline-body .guide-fragment h2 { counter-reset: h3; counter-increment: h2; }
.guide-inline-body .guide-fragment h2::before { content: counter(h1) "." counter(h2) " "; }
.guide-inline-body .guide-fragment h3 { counter-reset: h4; counter-increment: h3; }
.guide-inline-body .guide-fragment h3::before { content: counter(h1) "." counter(h2) "." counter(h3) " "; }
.guide-inline-body .guide-fragment h4 { counter-reset: h5; counter-increment: h4; }
.guide-inline-body .guide-fragment h4::before { content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) " "; }
.guide-inline-body .guide-fragment h5 { counter-reset: h6; counter-increment: h5; }
.guide-inline-body .guide-fragment h5::before { content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) " "; }
.guide-inline-body .guide-fragment h6 { counter-increment: h6; }
.guide-inline-body .guide-fragment h6::before { content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6) " "; }
.guide-inline-body .guide-fragment p { margin: 0.5rem 0 0.75rem; max-width: 100%; }
.guide-inline-body .guide-fragment ul, .guide-inline-body .guide-fragment ol { margin: 0.5rem 0 0.75rem 1.5rem; padding-left: 1.5rem; max-width: 100%; box-sizing: border-box; }
.guide-inline-body .guide-fragment table { border-collapse: collapse; width: 100%; max-width: 100%; font-size: 0.95rem; table-layout: fixed; box-sizing: border-box; }
.guide-inline-body .guide-fragment th, .guide-inline-body .guide-fragment td { border: 1px solid #ccc; padding: 0.4rem 0.5rem; text-align: left; overflow-wrap: break-word; word-wrap: break-word; }
.guide-inline-body .guide-fragment img { max-width: 100%; height: auto; display: block; }
.guide-inline-body .guide-fragment pre, .guide-inline-body .guide-fragment code { max-width: 100%; overflow-wrap: break-word; word-wrap: break-word; white-space: pre-wrap; word-break: break-word; }
.guide-inline-body .guide-fragment a { color: #0066cc; text-decoration: underline; }
.guide-inline-loading, .guide-inline-error { color: #666; margin: 1rem 0; }

.video-sidebar-title {
    margin-bottom: 12px;
    font-size: 1.05em;
    color: var(--primary-color);
}


#video-meta {
    display: flex;
    gap: 15px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 8px 0 18px;
    padding: 10px 12px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.video-views {
    color: #555;
    font-size: 0.95em;
}

.video-rating {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.rating-label {
    color: #555;
    font-size: 0.95em;
}

.stars {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.star {
    background: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    color: #cfcfcf;
    transition: transform 0.15s ease, color 0.15s ease;
}

.star:hover {
    transform: translateY(-1px);
}

.star.filled {
    color: #f5b301;
}

.star:disabled {
    cursor: default;
    opacity: 0.9;
}

.rating-value {
    color: #666;
    font-size: 0.9em;
}

.video-title-block {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin: 8px 20px 30px 20px;
}

.video-title-block #video-title {
    margin: 0;
    color: var(--primary-color);
    font-size: 1.2em;
}

.video-nav-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Кнопки «Предыдущее» и «Следующее» скрыты на всех экранах */
#prev-video-btn,
#next-video-btn {
    display: none !important;
}

#video-player {
    position: relative;
    width: 97%;
    max-width: 97%;
    margin: 0 auto;
    background-color: #000;
    border-radius: 8px;
    overflow: hidden;
    box-sizing: border-box;
}

#video-player video,
#video-player iframe {
    width: 100%;
    height: auto;
    min-height: 162px;
    display: block;
}

/* Место видео, когда ролик ещё не загружен — показываем картинку */
.no-video-placeholder {
    position: relative;
    padding: 0;
    background: #1a1a1a;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.no-video-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    max-width: 100%;
    max-height: 100%;
}

.no-video-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 1em;
    box-sizing: border-box;
}

/* Оверлей после окончания видео: две кнопки */
.video-ended-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 24px;
    border-radius: 8px;
    z-index: 10;
}

.video-ended-overlay.show {
    display: flex;
}

.video-ended-buttons {
    display: inline-flex;
    flex-direction: column;
    align-items: stretch;
    align-self: center;
    gap: 12px;
    max-width: 100%;
}

.video-ended-buttons .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
    padding: 8px 16px;
    font-size: 0.9em;
    font-weight: 600;
    font-family: inherit;
    text-align: center;
    border-width: 1px;
    border-radius: 6px;
    margin-left: 0;
    -webkit-font-smoothing: antialiased;
    font-smoothing: antialiased;
}

/* Список других видео справа */
.video-suggestions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.video-suggestion-item {
    display: flex;
    gap: 8px;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 6px;
    transition: background-color 0.15s ease;
}

.video-suggestion-item:hover {
    background-color: var(--bg-color);
}

.video-suggestion-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    border-radius: 6px;
    background-color: #ddd;
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.video-suggestion-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.video-suggestion-title {
    font-size: 0.9em;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 4px;
}

.video-suggestion-meta {
    font-size: 0.8em;
    color: #777;
}

.back-link {
    margin-top: 30px;
}

.back-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.1em;
    font-weight: 600;
}

.back-link a:hover {
    text-decoration: underline;
}

/* Постоянный заголовок страницы руководства */
.guide-page-title {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-color);
}

/* Ссылка «Вернуться к оглавлению» на фирменном зелёном фоне (страница руководства) */
.back-link-brand a {
    display: inline-block;
    background-color: var(--primary-color);
    color: #fff !important;
    padding: 10px 18px;
    border-radius: 8px;
    text-decoration: none !important;
    font-weight: 600;
    transition: background-color 0.2s ease;
}
.back-link-brand a:hover {
    background-color: var(--accent-color);
    text-decoration: none !important;
}

/* Якорное содержание на странице руководства — не отображаем */
.guide-page .guide-toc {
    display: none !important;
}
.guide-toc {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.guide-toc:empty {
    display: none;
}
.guide-toc .guide-toc-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0 0 0.75rem 0;
}
.guide-toc ul {
    list-style: none;
    margin: 0;
    padding: 0;
}
.guide-toc li {
    margin: 0.35rem 0;
}
.guide-toc li.toc-h3 {
    padding-left: 1rem;
    font-size: 0.95em;
}
.guide-toc a {
    color: var(--primary-color);
    text-decoration: none;
}
.guide-toc a:hover {
    text-decoration: underline;
}

/* Scroll to top button */
.scroll-top-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    padding: 0;
    background-color: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    z-index: 9000;
}

.scroll-top-btn:hover {
    background-color: var(--accent-color);
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.4);
}

.scroll-top-btn.show {
    display: flex;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: var(--white);
    margin: 10% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    position: relative;
    margin-top: 20px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
}

.close:hover {
    color: var(--text-color);
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--primary-color);
}

.form-actions-row {
  display: flex;
  justify-content: space-around;
}
/* Forms */

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.error-message {
    color: #dc3545;
    margin-top: 10px;
    font-size: 0.9em;
}

.success-message {
    color: #28a745;
    margin-top: 10px;
    font-size: 0.9em;
}

/* Messages inside modal */
#edit-modal-error,
#edit-modal-success,
#confirm-delete-error {
    margin-top: 12px;
}

/* Полоска загрузки файла в модальном окне */
.upload-progress-wrap {
    margin-top: 12px;
}
.upload-progress-label {
    margin: 0 0 6px 0;
    font-size: 0.9em;
    color: var(--text-color);
}
.upload-progress-bar {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}
.upload-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 5px;
    transition: width 0.15s ease-out;
}
.upload-progress-percent {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.85em;
    color: var(--text-muted, #6c757d);
}

/* Admin panel */
.admin-section {
    background-color: var(--white);
    border-radius: 6px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.admin-section h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
    font-size: 1.2em;
    cursor: pointer;
}

.admin-form {
    margin-top: 15px;
}

.admin-page-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.admin-page-btn {
    padding: 8px 14px;
    font-size: 0.95rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #f5f5f5;
    color: #333;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.admin-page-btn:hover {
    background: #e8e8e8;
    border-color: #999;
}

.admin-page-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}

.form-group {
    margin-bottom: 15px;
}

.form-group-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    cursor: pointer;
}
.form-group-checkbox input[type="checkbox"] {
    margin: 0;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-color);
    font-size: 0.9em;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"] {
    width: 100%;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9em;
    transition: border-color 0.3s ease;
}

/* Текстовое поле контекста в админке — как input по ширине, на ~5 строк */
.form-group textarea#edit-item-search-context {
    width: 100%;
    box-sizing: border-box;
    padding: 8px;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9em;
    line-height: 1.3;
    min-height: 6.5em; /* примерно 5 строк */
    resize: vertical;
}

.admin-menu-list {
    display: grid;
    gap: 8px;
}

.admin-list-loading,
.admin-list-error {
    padding: 1rem;
    text-align: center;
    color: #666;
}

.admin-list-error {
    color: #c00;
}

.admin-menu-item {
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
}

/* Визуальный отступ пунктов в админке по уровню */
.admin-menu-item.level-0 {
    padding-left: 12px;
}

.admin-menu-item.level-1 {
    padding-left: 28px;
}

.admin-menu-item.level-2 {
    padding-left: 44px;
}

.admin-menu-item.level-3 {
    padding-left: 60px;
}

.admin-menu-item:hover {
    border-color: var(--primary-color);
    background-color: rgba(35, 134, 155, 0.05);
}

.admin-menu-item-info {
    flex: 1;
}

.admin-menu-item-info h4 {
    color: var(--primary-color);
    margin-bottom: 2px;
    font-size: 0.9em;
    font-weight: 500;
}

.admin-menu-item-info p {
    color: #666;
    font-size: 0.8em;
    margin: 0;
}

.admin-menu-item-actions {
    display: flex;
    gap: 8px;
}

.current-video-info {
    margin-top: 15px;
    padding: 10px;
    background-color: var(--bg-color);
    border-radius: 5px;
    font-size: 0.9em;
}

/* Admin subsections */
.admin-subsection {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.admin-subsection:first-child {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

.admin-subsection h4 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-size: 1.1em;
}

.users-list {
    display: grid;
    gap: 10px;
    margin-top: 15px;
}

.user-item {
    background-color: var(--bg-color);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-item-info {
    flex: 1;
}

.user-item-info strong {
    color: var(--primary-color);
    display: block;
    margin-bottom: 5px;
}

.user-item-actions {
    display: flex;
    gap: 10px;
}

/* ========== Адаптив: планшеты и мобильные ========== */
@media (max-width: 900px) {
    .video-page-body main.container {
        height: auto;
        min-height: auto;
        overflow: visible;
    }

    .video-page-layout {
        flex-direction: column;
        height: auto;
    }

    .video-sidebar {
        flex: none;
        width: 100%;
        max-width: none;
        height: auto;
        max-height: 50vh;
    }

    .video-main-area {
        min-height: 240px;
    }

    .video-main {
        min-height: 300px;
    }

    /* Карусель на планшетах: min-height, при зуме не обрезается */
    .video-main-area .home-carousel {
        width: 100%;
        max-width: 100%;
        min-height: 220px;
        height: auto;
        flex: none;
        padding: 10px;
        box-sizing: border-box;
    }

    .video-main-area .carousel-track {
        min-height: 200px;
    }

    /* Блок «нет видео» — в границах контейнера при зуме */
    .no-video-placeholder {
        width: 100%;
        max-width: 100%;
    }

    .no-video-message {
        box-sizing: border-box;
        max-width: 100%;
        word-wrap: break-word;
    }

    /* Стартовая страница: планшеты — плитки на всю ширину, 2 колонки */
    .start-page .start-tiles {
        width: 100%;
        max-width: none;
        padding: 0 8px;
        gap: 1.25rem;
    }
    .start-page header .container {
        flex-wrap: wrap;
        gap: 8px;
    }
    .start-page header h1 .header-text-only {
        font-size: 1rem;
    }
    .start-page .start-title {
        font-size: 1.05rem;
        margin-bottom: 20px;
    }
    .page-loader-logo-inner {
        width: 200px;
    }
    .page-loader-brand,
    .page-loader-title,
    .page-loader-subtitle,
    .page-loader-text {
        font-size: 1.4rem;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0 16px;
    }

    /* Общий контент без бокового отступа на мобильных */
    .main-page {
        margin-left: 0;
    }

    /* Стартовая страница: одна колонка плиток, компактная шапка */
    .start-page header .container {
        justify-content: flex-start;
        padding-left: 12px;
        padding-right: 12px;
    }
    .start-page header img {
        width: 40px !important;
        margin-right: 16px !important;
    }
    .start-page header h1 .header-text-only {
        font-size: 0.9rem;
        line-height: 1.3;
    }
    .start-page main.container {
        padding: 0.5rem 12px 1.5rem;
    }
    .start-page .start-title {
        font-size: 1rem;
        margin-bottom: 16px;
        padding: 0 4px;
    }
    .start-page .start-tiles {
        grid-template-columns: 1fr;
        width: 100%;
        max-width: 100%;
        gap: 1rem;
        padding: 0;
    }
    .start-page .start-tile {
        min-height: 180px;
    }
    .start-page .start-tile video {
        min-height: 160px;
    }
    /* На мобильных показываем оверлей по тапу (hover не срабатывает) */
    .start-page .start-tile .start-tile-overlay {
        opacity: 1;
        background: rgba(0,0,0,0.6);
    }
    .start-page .start-tile-overlay-caption {
        font-size: 0.95rem;
    }
    .start-page .start-tile-overlay .btn {
        width: 100%;
        max-width: 260px;
        padding: 12px 16px;
        font-size: 0.95rem;
        min-height: 44px;
    }
    .start-page .start-tile-overlay-buttons {
        gap: 0.5rem;
        padding: 0 12px;
    }
    /* Лоадер на мобильных */
    .page-loader-logo-inner {
        width: 160px;
        min-height: 60px;
    }
    .page-loader-brand,
    .page-loader-title {
        font-size: 1.2rem;
    }
    .page-loader-subtitle {
        font-size: 1.1rem;
    }
    .page-loader-text {
        font-size: 1rem;
    }

    /* Руководство: отступы и таблицы */
    .guide-page main.container {
        padding: 0.5rem 12px 2rem;
    }
    .guide-page .guide-content {
        font-size: 0.95rem;
    }
    .guide-page .guide-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .guide-page .guide-content th,
    .guide-page .guide-content td {
        padding: 0.35rem 0.5rem;
        font-size: 0.9rem;
    }

    .video-page-body main.container {
        padding-left: 16px;
        padding-right: 16px;
    }

    /* На мобильных разрешаем прокрутку главной */
    .video-page-body {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }

    header {
        min-height: 44px;
        margin-bottom: 12px;
        padding: 6px 0;
    }

    header .container {
        flex-wrap: wrap;
        gap: 10px;
        padding-top: 4px;
        padding-bottom: 4px;
    }

    header h1 {
        font-size: 1em;
    }

    .logo-img {
        width: 28px;
        height: 28px;
    }

    .brand {
        gap: 6px;
    }

    .auth-section {
        gap: 6px;
        flex-wrap: wrap;
    }

    .auth-section .btn {
        padding: 6px 10px;
        font-size: 0.75em;
    }

    main {
        margin-top: 16px;
    }

    main h2 {
        font-size: 1.3em;
        margin-bottom: 14px;
    }

    /* Блок поиска на главной */
    .sidebar-intro {
        padding: 10px;
    }

    .sidebar-intro-top {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .sidebar-intro-top .btn {
        margin-left: 0;
        width: 100%;
        padding: 10px 14px;
        font-size: 1em;
    }

    .search-wrap p {
        font-size: 0.9em;
    }

    .search-input {
        max-width: none;
        padding: 10px 12px;
        font-size: 16px; /* убирает зум при фокусе на iOS */
    }

    .search-actions {
        flex-direction: column;
        gap: 8px;
    }

    .search-actions .btn {
        width: 100%;
    }

    .menu-grid {
        padding: 12px;
        margin-bottom: 16px;
    }

    .menu-item {
        padding: 10px 10px;
        min-height: 44px; /* удобная зона нажатия */
    }

    .menu-item .menu-item-content h3 {
        font-size: 0.85em;
    }

    .menu-item-number {
        min-width: 28px;
        font-size: 0.8em;
    }

    .menu-item-buttons img {
        width: 24px;
        height: 24px;
    }

    /* Карусель на мобильных: при зуме не обрезается */
    .video-main-area {
        min-height: 220px;
        max-width: 100%;
    }

    .video-main-area .home-carousel {
        width: 100%;
        max-width: 100%;
        min-height: 200px;
        height: auto;
        padding: 8px;
        box-sizing: border-box;
    }

    .video-main-area .carousel-track {
        min-height: 180px;
    }

    .video-main-area .carousel-slide .slide-content-inner {
        border-radius: 16px;
    }
    .video-main-area .carousel-slide .slide-content-inner img,
    .video-main-area .carousel-slide .slide-content img {
        object-fit: contain;
        object-position: center;
        border-radius: 16px;
    }

    /* No-video блок и сообщение — не вылезают при зуме */
    .no-video-placeholder {
        width: 100%;
        max-width: 100%;
    }

    .no-video-message {
        box-sizing: border-box;
        max-width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    /* Видео-блок */
    .video-main {
        padding: 12px 14px;
        min-width: 0;
        overflow-x: hidden;
    }

    .video-title-block {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin: 8px 0 10px;
        min-width: 0;
        width: 100%;
    }

    .video-title-block #video-title {
        font-size: 1.05em;
        text-align: center;
    }

    .video-nav-buttons {
        display: flex;
        gap: 8px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        justify-content: center;
    }

.video-nav-buttons .btn {
    flex: 1 1 0;
    min-width: 0;
    margin-left: 0;
    padding: 10px 8px;
    font-size: 0.85em;
    min-height: 44px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.video-nav-buttons .btn-video-guide {
    flex: none;
    white-space: nowrap;
}

    #video-player video,
    #video-player iframe {
        min-height: 144px;
    }

    .no-video-message {
        padding: 24px 16px;
        font-size: 1em;
        max-width: 100%;
        word-wrap: break-word;
    }

    /* Другие видео (sidebar на video.html) */
    .video-suggestions {
        gap: 8px;
    }

    .video-suggestion-item {
        padding: 8px;
        min-height: 44px;
    }

    .video-suggestion-thumb {
        width: 100px;
        height: 56px;
    }

    .video-suggestion-title {
        font-size: 0.85em;
    }

    .back-link {
        margin-top: 16px;
    }

    .back-link a {
        font-size: 1em;
        display: inline-block;
        padding: 8px 0;
    }

    .back-link-brand a {
        padding: 10px 18px;
    }

    /* Модальное окно */
    .modal-content {
        margin: 5% 12px;
        padding: 20px 16px;
        width: auto;
        max-width: none;
    }

    .close {
        right: 12px;
        top: 12px;
        font-size: 24px;
    }

    .modal-content h2 {
        font-size: 1.2em;
        margin-bottom: 16px;
    }

    .form-group input {
        padding: 10px 12px;
        font-size: 16px; /* убирает зум на iOS */
    }

    /* Кнопка «Наверх» */
    .scroll-top-btn {
        bottom: 24px;
        right: 24px;
        width: 48px;
        height: 48px;
        font-size: 22px;
    }

    /* Админка */
    .admin-section {
        padding: 14px;
        margin-bottom: 14px;
    }

    .admin-section h3 {
        font-size: 1.1em;
    }

    .admin-menu-item {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .admin-menu-item-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }

    .admin-menu-item-actions .btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }

    /* Админка: кнопки выбора страницы курса */
    .admin-page-buttons {
        gap: 6px;
    }
    .admin-page-btn {
        padding: 10px 12px;
        font-size: 0.85rem;
        min-height: 44px;
    }
    /* Формы: кнопки в колонку на узких экранах */
    .form-actions-row {
        flex-direction: column;
        gap: 10px;
    }
    .form-actions-row .btn {
        width: 100%;
        min-height: 44px;
    }
}

/* Очень маленькие экраны */
@media (max-width: 480px) {
    .container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    /* Safe area для устройств с вырезами */
    header {
        padding-left: max(0px, env(safe-area-inset-left));
        padding-right: max(0px, env(safe-area-inset-right));
    }
    header .container {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    /* Стартовая: ещё компактнее */
    .start-page header h1 .header-text-only {
        font-size: 0.8rem;
    }
    .start-page .start-title {
        font-size: 0.95rem;
    }
    .start-page .start-tile-overlay .btn {
        max-width: none;
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    .page-loader-logo-inner {
        width: 140px;
    }
    .page-loader-brand,
    .page-loader-title {
        font-size: 1rem;
    }
    .page-loader-subtitle {
        font-size: 0.95rem;
    }

    /* Админка: кнопки страниц курса в 2 колонки или стопка */
    .admin-page-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .admin-page-btn {
        font-size: 0.75rem;
        padding: 10px 8px;
        text-align: center;
        min-height: 44px;
    }

    /* Руководство */
    .guide-page .guide-content h1 {
        font-size: 1.25rem;
    }
    .guide-page .guide-content h2 {
        font-size: 1.1rem;
    }

    /* Карусель на маленьком экране: при зуме не обрезается */
    .video-main-area {
        min-height: 200px;
        max-width: 100%;
    }

    .video-main-area .home-carousel {
        width: 100%;
        max-width: 100%;
        min-height: 180px;
        height: auto;
        padding: 6px;
        box-sizing: border-box;
    }

    .video-main-area .carousel-track {
        min-height: 160px;
    }

    .no-video-placeholder {
        width: 100%;
        max-width: 100%;
    }

    header h1 .logo-link span {
        font-size: 0.9em;
    }

    .sidebar-intro-sub {
        font-size: 0.9em;
    }

    .menu-item {
        --menu-indent-step: 12px;
        padding-left: calc(6px + (var(--menu-level, 0) * var(--menu-indent-step)));
    }

    .menu-item-buttons img {
        width: 22px;
        height: 22px;
    }

    .video-nav-buttons {
        flex-direction: column;
        align-items: center;
    }

    .video-nav-buttons .btn {
        width: 100%;
    }

    .video-suggestion-item {
        flex-direction: column;
        align-items: stretch;
    }

    .video-suggestion-thumb {
        width: 100%;
        height: 100px;
        min-height: 100px;
    }

    .modal-content {
        margin: 10px 8px;
        padding: 16px 12px;
    }

    .scroll-top-btn {
        bottom: max(20px, env(safe-area-inset-bottom));
        right: max(20px, env(safe-area-inset-right));
        width: 44px;
        height: 44px;
    }

    body {
        padding-bottom: max(60px, env(safe-area-inset-bottom));
    }
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.logo-img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}