/* =====================================================
   Кнопка «Версия для слабовидящих» — компактная «пилюля»
   ===================================================== */
.av-toggle-wrap { margin: 8px 0; }
.av-toggle-wrap--left   { text-align: left; }
.av-toggle-wrap--right  { text-align: right; }
.av-toggle-wrap--center { text-align: center; }

.av-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    padding: 3px 13px 3px 3px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.15;
    font-weight: 700;

    color: #fff;
    background: #1f1f1f;
    border: none;
    border-radius: 999px;
    cursor: pointer;

    text-align: left;
    text-decoration: none;
    transition: background .15s ease, transform .15s ease;
}

.av-toggle:hover  { background: #000; }
.av-toggle:active { transform: translateY(1px); }

.av-toggle:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* Круглый бейдж с иконкой */
.av-toggle__badge {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 36px;
    height: 36px;
    border-radius: 50%;

    background: #fff;
    color: #1f1f1f;
}

.av-toggle__icon { display: block; }

/* Текст: аккуратный перенос, максимум две строки */
.av-toggle__text {
    display: block;
    max-width: 160px;
    white-space: normal;
    word-break: keep-all;
}

/* Вариант-ссылка — без «пилюли» */
.av-toggle--link {
    background: transparent;
    color: inherit;
    padding: 4px 6px;
    border-radius: 4px;
    text-decoration: underline;
}
.av-toggle--link:hover { background: transparent; }
.av-toggle--link .av-toggle__badge {
    background: transparent;
    color: inherit;
    width: auto;
    height: auto;
    border-radius: 0;
}

/* =====================================================
   ПАНЕЛЬ управления (внутри версии для слабовидящих)
   ===================================================== */
.av-panel {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 999999;
    background: #1a1a1a;
    color: #fff;
    font-family: Arial, sans-serif;
    font-size: 15px;
    border-bottom: 3px solid #ffd700;
    box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.av-panel__inner {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    max-width: 1400px;
    margin: 0 auto;
}
.av-panel__group {
    display: flex;
    align-items: center;
    gap: 6px;
}
.av-panel__label { font-weight: 700; white-space: nowrap; }
.av-panel__btn {
    min-width: 40px;
    min-height: 40px;
    padding: 6px 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    background: #2b2b2b;
    color: #fff;
    border: 2px solid #fff;
    border-radius: 4px;
}
.av-panel__btn:hover { background: #444; }
.av-panel__btn:focus-visible { outline: 3px solid #ffd700; outline-offset: 2px; }
.av-panel__btn[aria-pressed="true"] {
    background: #ffd700;
    color: #000;
    border-color: #ffd700;
}
.av-panel__btn:disabled {
    opacity: .4;
    cursor: not-allowed;
}
.av-panel__btn--reset { border-color: #ff7b7b; color: #ffb3b3; }
.av-panel__btn--reset:hover { background: #4a1010; }
.av-panel__schemes { display: flex; gap: 6px; flex-wrap: wrap; }
.av-panel__scheme {
    width: 44px; height: 40px;
    border: 2px solid #fff;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
}
.av-panel__scheme:focus-visible { outline: 3px solid #ffd700; outline-offset: 2px; }
.av-panel__scheme[aria-pressed="true"] { outline: 3px solid #ffd700; outline-offset: 1px; }

/* =====================================================
   ПРИМЕНЕНИЕ РЕЖИМА
   ===================================================== */

/* Маркер до инициализации JS — снимается в init() */
html.av-preload { /* намеренно пусто */ }

/* =====================================================
   ЦВЕТОВЫЕ СХЕМЫ
   ===================================================== */

/* Чёрным по белому */
html.av-mode.av-scheme-bw body,
html.av-mode.av-scheme-bw body *:not(.av-panel):not(.av-panel *):not(.av-toggle):not(.av-toggle *) {
    background-color: #fff !important;
    color: #000 !important;
    border-color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.av-mode.av-scheme-bw a,
html.av-mode.av-scheme-bw a * { color: #0055b3 !important; text-decoration: underline !important; }

/* Белым по чёрному */
html.av-mode.av-scheme-wb body,
html.av-mode.av-scheme-wb body *:not(.av-panel):not(.av-panel *):not(.av-toggle):not(.av-toggle *) {
    background-color: #000 !important;
    color: #fff !important;
    border-color: #fff !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.av-mode.av-scheme-wb a,
html.av-mode.av-scheme-wb a * { color: #ffd700 !important; text-decoration: underline !important; }

/* Тёмно-коричневым по бежевому */
html.av-mode.av-scheme-beige body,
html.av-mode.av-scheme-beige body *:not(.av-panel):not(.av-panel *):not(.av-toggle):not(.av-toggle *) {
    background-color: #f7edd5 !important;
    color: #3d2d10 !important;
    border-color: #3d2d10 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.av-mode.av-scheme-beige a,
html.av-mode.av-scheme-beige a * { color: #5c3b00 !important; }

/* Тёмно-синим по голубому */
html.av-mode.av-scheme-blue body,
html.av-mode.av-scheme-blue body *:not(.av-panel):not(.av-panel *):not(.av-toggle):not(.av-toggle *) {
    background-color: #a7d9f5 !important;
    color: #062b4d !important;
    border-color: #062b4d !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.av-mode.av-scheme-blue a,
html.av-mode.av-scheme-blue a * { color: #043a66 !important; }

/* Тёмно-зелёным по салатовому */
html.av-mode.av-scheme-green body,
html.av-mode.av-scheme-green body *:not(.av-panel):not(.av-panel *):not(.av-toggle):not(.av-toggle *) {
    background-color: #b6e6a9 !important;
    color: #0e2c0e !important;
    border-color: #0e2c0e !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.av-mode.av-scheme-green a,
html.av-mode.av-scheme-green a * { color: #0d4d0d !important; }

/* =====================================================
   ПАНЕЛЬ — всегда контрастная, независимо от схемы
   ===================================================== */
html.av-mode .av-panel,
html.av-mode .av-panel * {
    background-color: #1a1a1a !important;
    color: #fff !important;
    border-color: #fff !important;
}
html.av-mode .av-panel__btn[aria-pressed="true"] {
    background-color: #ffd700 !important;
    color: #000 !important;
    border-color: #ffd700 !important;
}
html.av-mode .av-panel__btn--reset { color: #ffb3b3 !important; border-color: #ff7b7b !important; }

/* =====================================================
   КНОПКА-ПЕРЕКЛЮЧАТЕЛЬ — всегда контрастная
   ===================================================== */
html.av-mode .av-toggle,
html.av-mode .av-toggle * {
    background-color: #1f1f1f !important;
    color: #fff !important;
    border-color: #1f1f1f !important;
}
html.av-mode .av-toggle:hover,
html.av-mode .av-toggle:hover * {
    background-color: #000 !important;
}
html.av-mode .av-toggle__badge,
html.av-mode .av-toggle__badge * {
    background-color: #fff !important;
    color: #1f1f1f !important;
    fill: #1f1f1f !important;
}
html.av-mode .av-toggle__badge svg,
html.av-mode .av-toggle__badge svg path {
    fill: #1f1f1f !important;
}

/* =====================================================
   ИЗОБРАЖЕНИЯ
   ===================================================== */
html.av-mode.av-images-grayscale img { filter: grayscale(100%) !important; }
html.av-mode.av-hide-images img { display: none !important; }
html.av-mode.av-hide-images picture { display: none !important; }

/* =====================================================
   ШРИФТ
   ===================================================== */
html.av-mode.av-font-sans  body * { font-family: Arial, Helvetica, sans-serif !important; }
html.av-mode.av-font-serif body * { font-family: Georgia, "Times New Roman", serif !important; }
html.av-mode.av-font-mono  body * { font-family: "Courier New", Consolas, monospace !important; }

/* Исключаем панель и кнопку из смены шрифта */
html.av-mode.av-font-serif .av-panel *,
html.av-mode.av-font-serif .av-toggle *,
html.av-mode.av-font-mono .av-panel *,
html.av-mode.av-font-mono .av-toggle * {
    font-family: Arial, Helvetica, sans-serif !important;
}

/* =====================================================
   ИНТЕРВАЛЫ
   ===================================================== */
html.av-mode.av-spacing body * { letter-spacing: .06em !important; }
html.av-mode.av-lineheight body * { line-height: 1.8 !important; }

/* Исключаем панель и кнопку из изменения интервалов */
html.av-mode.av-spacing .av-panel *,
html.av-mode.av-spacing .av-toggle * { letter-spacing: normal !important; }
html.av-mode.av-lineheight .av-panel *,
html.av-mode.av-lineheight .av-toggle * { line-height: 1.15 !important; }

/* =====================================================
   РАЗМЕР ШРИФТА
   ===================================================== */
html.av-mode { font-size: var(--av-font-size, 20px); }
html.av-mode body { font-size: 1rem; }

/* =====================================================
   ОТКЛЮЧЕНИЕ АНИМАЦИЙ (WCAG 2.3.3)
   ===================================================== */
html.av-mode *,
html.av-mode *::before,
html.av-mode *::after {
    animation: none !important;
    transition: none !important;
}

/* =====================================================
   ВИДИМЫЙ ФОКУС (WCAG 2.4.7)
   ===================================================== */
html.av-mode a:focus,
html.av-mode button:focus,
html.av-mode input:focus,
html.av-mode select:focus,
html.av-mode textarea:focus,
html.av-mode [tabindex]:focus {
    outline: 3px solid #ffd700 !important;
    outline-offset: 2px !important;
}

/* Уважаем системные настройки */
@media (prefers-reduced-motion: reduce) {
    html.av-mode * { animation: none !important; transition: none !important; }
}

/* =====================================================
   АДАПТИВ
   ===================================================== */
@media (max-width: 782px) {
    .av-panel__inner { padding: 8px; gap: 8px; }
    .av-panel__label { font-size: 13px; }
    .av-panel__btn { min-width: 36px; min-height: 36px; padding: 4px 8px; }

    .av-toggle { font-size: 13px; padding: 5px 14px 5px 5px; gap: 8px; }
    .av-toggle__badge { width: 32px; height: 32px; }
    .av-toggle__icon { width: 20px; height: 20px; }
    .av-toggle__text { max-width: 130px; }
}

@media (max-width: 480px) {
    .av-toggle__text { max-width: 110px; font-size: 12px; }
    .av-toggle__badge { width: 28px; height: 28px; }
    .av-toggle__icon { width: 18px; height: 18px; }
}