/* Навигация МоиТесты.рф: телефон — панель снизу, десктоп — строка сверху */
:root {
    --bn-h: 56px;
    --bn-accent: #667eea;
    --bn-accent-2: #764ba2;
    --bn-ink: #1f2430;
    --bn-line: #e5e7eb;
    --bn-safe: env(safe-area-inset-bottom, 0px);
    --bn-total: calc(var(--bn-h) + var(--bn-safe));
}

.bn {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: var(--bn-total); padding: 0 6px var(--bn-safe);
    display: flex; align-items: center; justify-content: space-around;
    background: rgba(255,255,255,.97);
    -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border-top: 1px solid var(--bn-line);
    transition: transform .22s ease; will-change: transform;
}
.bn.bn-hidden { transform: translateY(100%); }
.bn-spacer { height: var(--bn-total); }

.bn-btn {
    position: relative; flex: 1; max-width: 80px; height: var(--bn-h);
    display: flex; align-items: center; justify-content: center;
    background: none; border: 0; padding: 0; cursor: pointer; text-decoration: none;
    color: var(--bn-ink); -webkit-tap-highlight-color: transparent; border-radius: 12px;
    font-family: inherit;
}
.bn-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.bn-btn:active { background: #f1f2f6; }
.bn-btn:disabled { opacity: .3; cursor: default; }
.bn-btn:disabled:active { background: none; }
.bn-logo img { display: block; width: 30px; height: 30px; }
.bn-btn.is-active { color: var(--bn-accent); }
.bn-logo.is-active::after { content: ""; position: absolute; bottom: 6px; width: 16px; height: 3px; border-radius: 2px; background: var(--bn-accent); }

/* кнопка пользователя: Войти · кружок с буквой · иконка */
.bn-user > * { display: none; }
.bn-user[data-state="guest"]  .bn-user-text   { display: block; font-size: 14px; font-weight: 700; color: var(--bn-accent); }
.bn-user[data-state="icon"]   .bn-user-icon   { display: block; color: var(--bn-accent); }
.bn-user[data-state="letter"] .bn-user-letter {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%; color: #fff; font-size: 16px; font-weight: 700;
    background: linear-gradient(135deg, var(--bn-accent), var(--bn-accent-2));
}

/* шторка */
.bn-overlay { position: fixed; inset: 0; z-index: 950; background: rgba(15,18,30,.45); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; }
.bn-overlay.open { opacity: 1; visibility: visible; }
.bn-sheet {
    position: fixed; z-index: 960; left: 0; right: 0; bottom: 0; max-height: 80vh;
    overflow-y: auto; overscroll-behavior: contain; background: #fff;
    border-radius: 20px 20px 0 0; padding: 0 16px calc(16px + var(--bn-safe));
    transform: translateY(105%); visibility: hidden;
    transition: transform .25s cubic-bezier(.2,.8,.2,1), visibility .25s;
    box-shadow: 0 -8px 30px rgba(0,0,0,.15);
}
.bn-sheet.open { transform: translateY(0); visibility: visible; }
.bn-sheet.dragging { transition: none; }
.bn-handle { display: flex; justify-content: center; padding: 10px 0 6px; touch-action: none; }
.bn-handle span { width: 40px; height: 4px; border-radius: 2px; background: #d1d5db; }
.bn-greeting { padding: 4px 4px 12px; font-size: 1rem; font-weight: 600; color: var(--bn-ink); }
.bn-install { display: flex; flex-direction: column; gap: 8px; }
.bn-install-btn {
    display: none; width: 100%; padding: 12px 16px; cursor: pointer;
    border: 2px solid var(--bn-accent); background: transparent; color: var(--bn-accent);
    border-radius: 10px; font-size: 14px; font-weight: 600; font-family: inherit;
}
.bn-install-btn:active { background: var(--bn-accent); color: #fff; }

/* идёт прохождение теста — панели нет совсем */
body.bn-off .bn, body.bn-off .bn-spacer, body.bn-off .bn-overlay, body.bn-off .bn-sheet,
body.bn-disabled .bn, body.bn-disabled .bn-spacer, body.bn-disabled .bn-overlay, body.bn-disabled .bn-sheet,
body.bn-pending .bn, body.bn-pending .bn-spacer, body.bn-pending .bn-overlay, body.bn-pending .bn-sheet { display: none !important; }
body.bn-off::before, body.bn-disabled::before, body.bn-pending::before { display: none !important; }

/* кнопки «На главную» / «В меню», дублирующие панель: прячем, пока панель реально есть.
   Если панели нет (супер-админ, сбой загрузки скрипта) — кнопка остаётся, выхода не лишаемся. */
body.has-bn:not(.bn-disabled) .bn-dup-home { display: none !important; }

/* старая плавающая кнопка поддержки скрыта; её окно (то же самое) открывается из панели */
body.has-bn:not(.bn-disabled) #supportBtn { display: none !important; }

/* ---------- телефон ---------- */
@media (max-width: 767px) {
    body.has-bn #supportPanel { bottom: calc(var(--bn-total) + 10px) !important; right: 12px !important; max-width: calc(100vw - 24px); max-height: calc(100vh - var(--bn-total) - 30px); }
    body.has-bn:has(.bn.bn-hidden) #supportPanel { bottom: 10px !important; }
}

/* ---------- десктоп: строка сверху ---------- */
@media (min-width: 768px) {
    .bn {
        top: 0; bottom: auto; height: var(--bn-h); padding: 0 max(12px, calc((100vw - 1200px) / 2));
        justify-content: flex-start; gap: 4px; border-top: 0; border-bottom: 1px solid var(--bn-line);
    }
    .bn.bn-hidden { transform: none; }
    .bn-btn { flex: none; width: 48px; max-width: none; }
    .bn-btn.bn-user { width: auto; min-width: 48px; padding: 0 12px; }
    #bnMenu { margin-left: auto; }
    .bn-spacer { display: none; }
    body.has-bn::before { content: ""; display: block; height: var(--bn-h); }   /* место под строку, не трогая padding body */

    /* шторка — выпадающая карточка под строкой справа */
    .bn-overlay { background: transparent; }
    .bn-sheet {
        top: calc(var(--bn-h) + 6px); right: max(12px, calc((100vw - 1200px) / 2)); left: auto; bottom: auto;
        width: 340px; border-radius: 14px; padding-top: 12px; max-height: calc(100vh - var(--bn-h) - 24px);
        transform: translateY(-8px); opacity: 0; box-shadow: 0 10px 30px rgba(0,0,0,.18); border: 1px solid var(--bn-line);
        transition: transform .18s ease, opacity .18s ease, visibility .18s;
    }
    .bn-sheet.open { transform: translateY(0); opacity: 1; }
    .bn-handle { display: none; }
    body.has-bn #supportPanel { top: calc(var(--bn-h) + 10px) !important; bottom: auto !important; right: 12px !important; }
}
@media (prefers-reduced-motion: reduce) { .bn, .bn-sheet, .bn-overlay { transition: none; } }

/* ---------- иконки соцсетей (MAX, VK) ---------- */
.bn-soc svg { stroke: none; }
.bn-soc-vk svg { fill: #0077ff; width: 24px; height: 24px; }
.bn-soc-max svg { width: 25px; height: 25px; }

/* очень узкие телефоны: в панели 7 кнопок */
@media (max-width: 359px) {
    .bn { padding-left: 2px; padding-right: 2px; }
    .bn-user[data-state="guest"] .bn-user-text { font-size: 12px; }
    .bn-btn svg { width: 24px; height: 24px; }
}
