/* ────────────────────────────────────────────
   ПАНЕЛЬ ДОСТУПНОСТИ
   ──────────────────────────────────────────── */

/* Кнопка-триггер в шапке */
.kg-access-trigger {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    background: transparent;
    border: 1.5px solid rgba(87,59,177,.3);
    border-radius: 6px;
    color: #573bb1;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
    font-family: inherit;
    text-decoration: none;
    line-height: 1;
}
.kg-access-trigger:hover {
    background: #573bb1;
    color: #fff;
    border-color: #573bb1;
    text-decoration: none;
}
.kg-access-trigger svg { flex-shrink: 0; }

/* Панель */
.kg-access-panel {
    position: fixed;
    top: 50px;
    right: 0;
    width: 380px;
    max-width: 100vw;
    max-height: calc(100vh - 50px);
    background: #fff;
    z-index: 99999;
    box-shadow: -4px 0 32px rgba(0,0,0,.18);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-size: 14px;
}
.kg-access-panel:not([hidden]) {
    transform: translateX(0);
    display: block !important;
}
.kg-access-panel[hidden] {
    display: block; /* override hidden so transition works */
}

.kg-access-panel__inner { padding: 0 0 24px; }

/* Заголовок */
.kg-access-panel__header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, #0d0a1e, #3a2480);
    color: #fff;
}
.kg-access-panel__logo {
    font-size: 24px;
    flex-shrink: 0;
}
.kg-access-panel__title {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
    color: #fff;
    padding: 0;
    border: none;
}
.kg-access-panel__sub {
    font-size: 12px;
    color: rgba(255,255,255,.65);
    margin: 2px 0 0;
}
.kg-access-panel__close {
    margin-left: auto;
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    border-radius: 6px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 14px;
    flex-shrink: 0;
    transition: background .15s;
}
.kg-access-panel__close:hover { background: rgba(255,255,255,.3); }

/* Секции */
.kg-access-section {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
}
.kg-access-section:last-of-type { border-bottom: none; }
.kg-access-section__title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: #9ca3af;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Профили */
.kg-access-profiles {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.kg-access-profile {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    background: #f9fafb;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    text-align: center;
}
.kg-access-profile:hover {
    border-color: #573bb1;
    background: #ede9f9;
}
.kg-access-profile[aria-pressed="true"],
.kg-access-profile.active {
    border-color: #573bb1;
    background: #ede9f9;
    box-shadow: 0 0 0 3px rgba(87,59,177,.15);
}
.kg-access-profile--reset { border-style: dashed; }
.kg-access-profile__icon { font-size: 22px; margin-bottom: 4px; }
.kg-access-profile__name { font-size: 12px; font-weight: 700; color: #1f2937; line-height: 1.2; }
.kg-access-profile__desc { font-size: 10px; color: #6b7280; margin-top: 3px; line-height: 1.3; }

/* Кнопки настроек */
.kg-access-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.kg-access-btn {
    padding: 6px 12px;
    background: #f3f4f6;
    border: 1.5px solid #e5e7eb;
    border-radius: 7px;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
    color: #374151;
    transition: all .15s;
}
.kg-access-btn:hover { border-color: #573bb1; color: #573bb1; }
.kg-access-btn--active,
.kg-access-btn[aria-pressed="true"] {
    background: #573bb1;
    color: #fff;
    border-color: #573bb1;
}
.kg-access-btn--scheme-bw  { background: #000; color: #fff; border-color: #000; }
.kg-access-btn--scheme-yb  { background: #000; color: #ff0; border-color: #ff0; }
.kg-access-btn--scheme-bly { background: #ff0; color: #00f; border-color: #00f; }
.kg-access-btn--scheme-dark{ background: #1f2937; color: #f9fafb; border-color: #4b5563; }

/* Переключатели */
.kg-access-toggles { display: flex; flex-direction: column; gap: 10px; }
.kg-access-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}
.kg-access-toggle input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.kg-access-toggle__track {
    width: 38px;
    height: 22px;
    background: #d1d5db;
    border-radius: 11px;
    position: relative;
    flex-shrink: 0;
    transition: background .2s;
}
.kg-access-toggle__track::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    background: #fff;
    border-radius: 50%;
    top: 3px; left: 3px;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.kg-access-toggle input:checked ~ .kg-access-toggle__track { background: #573bb1; }
.kg-access-toggle input:checked ~ .kg-access-toggle__track::after { transform: translateX(16px); }
.kg-access-toggle input:focus ~ .kg-access-toggle__track {
    box-shadow: 0 0 0 3px rgba(87,59,177,.3);
}
.kg-access-toggle__label { font-size: 13px; color: #374151; line-height: 1.4; }
.kg-access-tag {
    display: inline-block;
    background: #ede9f9;
    color: #573bb1;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* Инфо */
.kg-access-info {
    margin: 12px 20px 4px;
    padding: 12px 14px;
    background: #f8fafc;
    border-left: 3px solid #573bb1;
    border-radius: 0 8px 8px 0;
    font-size: 12px;
    color: #6b7280;
    line-height: 1.65;
}
.kg-access-info kbd {
    background: #e5e7eb;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 11px;
    font-family: monospace;
    color: #374151;
}

/* Визуальный алерт (для слабослышащих) */
.kg-visual-alert {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e40af;
    color: #fff;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    z-index: 99998;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    transition: opacity .3s;
    pointer-events: none;
    max-width: 90vw;
    text-align: center;
}

/* ────────────────────────────────────────────
   РЕЖИМЫ ДОСТУПНОСТИ (применяются к <html>)
   ──────────────────────────────────────────── */

/* --- Размеры шрифта --- */
html.kg-font-125 body { font-size: 112.5% !important; }
html.kg-font-150 body { font-size: 125% !important; }
html.kg-font-175 body { font-size: 137.5% !important; }
html.kg-font-125 p, html.kg-font-125 li, html.kg-font-125 a,
html.kg-font-150 p, html.kg-font-150 li, html.kg-font-150 a,
html.kg-font-175 p, html.kg-font-175 li, html.kg-font-175 a { line-height: 1.8 !important; }

/* --- Цветовые схемы --- */

/* Чёрно-белая */
html.kg-contrast-bw *:not(.kg-access-panel):not(.kg-access-panel *) {
    color: #000 !important;
    background-color: #fff !important;
    border-color: #000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
html.kg-contrast-bw img { filter: grayscale(100%) contrast(120%) !important; }
html.kg-contrast-bw a { color: #000 !important; text-decoration: underline !important; }

/* Жёлтое на чёрном */
html.kg-contrast-yb body,
html.kg-contrast-yb main,
html.kg-contrast-yb .site-content,
html.kg-contrast-yb #page,
html.kg-contrast-yb section,
html.kg-contrast-yb article,
html.kg-contrast-yb header,
html.kg-contrast-yb footer,
html.kg-contrast-yb div:not(.kg-access-panel):not(.kg-access-panel *) {
    background-color: #000 !important;
    color: #ff0 !important;
}
html.kg-contrast-yb *:not(.kg-access-panel):not(.kg-access-panel *) {
    color: #ff0 !important;
    border-color: #ff0 !important;
    box-shadow: none !important;
}
html.kg-contrast-yb a { color: #fa0 !important; text-decoration: underline !important; }
html.kg-contrast-yb img { filter: grayscale(100%) brightness(0.6) !important; }

/* Синее на жёлтом */
html.kg-contrast-bly body,
html.kg-contrast-bly div:not(.kg-access-panel):not(.kg-access-panel *) {
    background-color: #ff0 !important;
    color: #00f !important;
}
html.kg-contrast-bly *:not(.kg-access-panel):not(.kg-access-panel *) {
    color: #00f !important;
    border-color: #00f !important;
    box-shadow: none !important;
}
html.kg-contrast-bly a { color: #06c !important; }

/* Тёмная тема */
html.kg-contrast-dark body,
html.kg-contrast-dark div:not(.kg-access-panel):not(.kg-access-panel *) {
    background-color: #1f2937 !important;
    color: #f9fafb !important;
}
html.kg-contrast-dark *:not(.kg-access-panel):not(.kg-access-panel *) {
    color: #f9fafb !important;
    border-color: #374151 !important;
}
html.kg-contrast-dark a { color: #93c5fd !important; }
html.kg-contrast-dark img { filter: brightness(0.85) !important; }

/* --- Шрифт --- */
html.kg-family-arial * { font-family: Arial, Helvetica, sans-serif !important; }
html.kg-family-serif  * { font-family: Georgia, 'Times New Roman', serif !important; }

/* --- Межбуквенный интервал --- */
html.kg-spacing-medium p, html.kg-spacing-medium li,
html.kg-spacing-medium span, html.kg-spacing-medium a { letter-spacing: 0.12em !important; }
html.kg-spacing-large p, html.kg-spacing-large li,
html.kg-spacing-large span, html.kg-spacing-large a { letter-spacing: 0.22em !important; }

/* --- Межстрочный интервал --- */
html.kg-lineheight-medium * { line-height: 1.9 !important; }
html.kg-lineheight-large   * { line-height: 2.4 !important; }

/* --- Курсор --- */
html.kg-cursor-large  * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='32' height='32'%3E%3Ccircle cx='6' cy='6' r='5' fill='%23573bb1'/%3E%3C/svg%3E") 6 6, auto !important; }
html.kg-cursor-xlarge * { cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Ccircle cx='8' cy='8' r='7' fill='%23573bb1' stroke='%23fff' stroke-width='2'/%3E%3C/svg%3E") 8 8, auto !important; }

/* --- Подчёркивание ссылок --- */
html.kg-underline a { text-decoration: underline !important; }

/* --- Скрыть изображения --- */
html.kg-noimages img:not([alt*="логотип"]):not([alt*="logo"]) {
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* --- Усиленный фокус --- */
html.kg-focus *:focus {
    outline: 3px solid #ff8c00 !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 0 6px rgba(255,140,0,.3) !important;
}

/* --- Нет анимаций --- */
html.kg-noanimations *, html.kg-noanimations *::before, html.kg-noanimations *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
}

/* --- Режим слабослышащих --- */

/* Статус-бар вверху страницы */
.kg-hearing-bar {
    position: fixed;
    top: 50px;
    left: 0; right: 0;
    z-index: 99990;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    background: linear-gradient(90deg, #1d4ed8, #2563eb);
    color: #fff;
    font-size: 13px;
    font-family: -apple-system, Arial, sans-serif;
    box-shadow: 0 2px 12px rgba(37,99,235,.4);
    flex-wrap: wrap;
}
.kg-hearing-bar__icon { font-size: 18px; flex-shrink: 0; }
.kg-hearing-bar__text { font-weight: 600; }
.kg-hearing-bar__status {
    background: rgba(255,255,255,.18);
    border-radius: 20px;
    padding: 2px 10px;
    font-size: 12px;
    margin-left: auto;
}
.kg-hearing-bar__close {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    flex-shrink: 0;
}
.kg-hearing-bar__close:hover { background: rgba(255,255,255,.35); }

/* Отступ body когда hearing-bar виден */
body.kg-hearing-active { padding-top: 38px !important; }

/* Оверлей вокруг видео */
.kg-media-wrap {
    position: relative;
    display: block;
}
.kg-media-caption-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    background: #1e3a5f;
    color: #e0f2fe;
    font-size: 13px;
    font-family: Arial, sans-serif;
    border-radius: 0 0 8px 8px;
    flex-wrap: wrap;
}
.kg-media-caption-icon { font-size: 16px; flex-shrink: 0; }
.kg-media-caption-hint {
    margin-left: auto;
    font-size: 12px;
    color: #93c5fd;
}

/* GigaChat-бейдж доступности */
.kg-access-ai-badge {
    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    margin: 14px 0 20px;
    line-height: 1.5;
    border: 2px solid transparent;
}
.kg-access-ai-badge--loading {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #64748b;
    animation: kg-pulse 1.5s ease-in-out infinite;
}
@keyframes kg-pulse { 0%,100%{opacity:1} 50%{opacity:.55} }
.kg-access-ai-badge--green  { background: #f0fdf4; border-color: #86efac; }
.kg-access-ai-badge--yellow { background: #fefce8; border-color: #fde047; }
.kg-access-ai-badge--red    { background: #fff1f2; border-color: #fca5a5; }
.kg-access-ai-badge__icon   { font-weight: 700; flex-shrink: 0; }
.kg-access-ai-badge__verdict { font-weight: 700; font-size: 15px; }
.kg-access-ai-badge__sub-info {
    display: block;
    width: 100%;
    font-size: 13px;
    color: #475569;
    margin-top: 2px;
}
.kg-access-ai-badge__tip {
    display: block;
    width: 100%;
    font-size: 13px;
    color: #334155;
    margin-top: 4px;
    font-style: italic;
}

/* --- Скрыть панель на печати --- */
@media print {
    .kg-access-panel, .kg-access-trigger-wrap { display: none !important; }
}
@media (max-width: 480px) {
    .kg-access-panel { top: 0; max-height: 100vh; width: 100vw; }
}
