/* lib/app-shell/mobile-nav.css — мобильная навигация v1 (Законы 15.22 brand-palette + 15.28 breakpoints). Изоляция: .ft-shell-root[data-mobile-nav="v1"]. Активно на ≤768. */

/* =========================================================
   6.1. Variables
   ========================================================= */
.ft-shell-root[data-mobile-nav="v1"] {
  --mn-topbar-h: 54px;
  --mn-bottomnav-h: 64px;
  --mn-sheet-radius: 16px;
  --mn-z-bottomnav: 60;
  --mn-z-sheet-backdrop: 70;
  --mn-z-sheet: 71;
}

/* =========================================================
   6.5 (база). На >768 bottom-nav скрыт по умолчанию
   ========================================================= */
.ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav {
  display: none;
}

/* =========================================================
   ≤768: мобильная шапка + bottom-nav + sheet
   ========================================================= */
@media (max-width: 768px) {

  /* ---- 6.2. Мобильная шапка ---- */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar {
    height: var(--mn-topbar-h);
    min-height: var(--mn-topbar-h);
    padding: 0 8px;
    gap: 6px;
    display: flex;
    align-items: center;
    grid-template-rows: var(--mn-topbar-h);
  }

  /* Скрываем десктопные элементы топбара */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-search,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-term-bar,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-spacer,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-balance,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar #ft-tb-ai,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar #ft-tb-notif,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-lang,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-theme,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-acc,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-nav,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-btn[aria-label*="Donate"],
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar .ft-tb-btn[aria-label*="donate"] {
    display: none !important;
  }

  /* Мобильные кнопки топбара (инжектит bottom-nav.js) */
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-mobile-notif,
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-mobile-overflow {
    height: 44px;
    width: 44px;
    background: transparent;
    color: var(--text);
    border: none;
    border-radius: 10px;
    position: relative;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin-left: auto;
  }
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-mobile-overflow { margin-left: 0; }

  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-mobile-notif:focus-visible,
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-mobile-overflow:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: -2px;
  }

  /* Бейдж счётчика на колокольчике */
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-mobile-notif[data-count]:not([data-count="0"])::after {
    content: attr(data-count);
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    background: var(--red, #ef4444);
    color: #fff;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    padding: 0 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  /* ---- 6.3. main padding под bottom-nav ---- */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-main {
    padding-bottom: calc(var(--mn-bottomnav-h) + env(safe-area-inset-bottom, 0px)) !important;
  }
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-route {
    padding-bottom: calc(var(--mn-bottomnav-h) + env(safe-area-inset-bottom, 0px));
  }

  /* ---- 6.4. Bottom-nav ---- */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mn-bottomnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--bg2);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    z-index: var(--mn-z-bottomnav);
    margin: 0;
  }

  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    font-size: 11px;
    color: var(--text);
    opacity: 0.55;
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    padding: 6px 4px;
    min-height: 44px;
    position: relative;
    font-family: inherit;
  }

  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item .mn-ic {
    font-size: 20px;
    line-height: 1;
  }

  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item[aria-current="page"] {
    color: var(--green);
    opacity: 1;
  }

  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item:active {
    background: rgba(255, 255, 255, 0.04);
  }

  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: -2px;
    border-radius: 8px;
  }

  /* Индикатор обновлений на кнопке Виджеты */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item--widgets[data-has-updates="1"]::after {
    content: "";
    position: absolute;
    top: 10px;
    right: calc(50% - 16px);
    width: 8px;
    height: 8px;
    background: var(--green-accent, var(--green));
    border-radius: 50%;
    box-shadow: 0 0 6px var(--green-accent, var(--green));
  }

  /* Bottom-nav показан на мобиле */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav {
    display: flex;
  }

  /* ---- 6.6. Bottom-sheet ---- */
  .ft-mobile-sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: var(--mn-z-sheet-backdrop, 70);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .ft-mobile-sheet-backdrop[data-open="1"] {
    opacity: 1;
    pointer-events: auto;
  }

  .ft-mobile-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 85vh;
    max-height: 85vh;
    background: var(--bg2);
    border-top-left-radius: var(--mn-sheet-radius, 16px);
    border-top-right-radius: var(--mn-sheet-radius, 16px);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    z-index: var(--mn-z-sheet, 71);
    transform: translateY(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
  }
  .ft-mobile-sheet[data-open="1"] {
    transform: translateY(0);
  }

  .ft-mobile-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--text);
    opacity: 0.3;
    border-radius: 2px;
    margin: 8px auto 4px;
    cursor: grab;
    touch-action: none;
  }

  .ft-mobile-sheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    color: var(--text);
  }

  .ft-mobile-sheet-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .ft-mobile-sheet-close:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: -2px;
  }

  .ft-mobile-sheet-content {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 12px 16px;
    -webkit-overflow-scrolling: touch;
  }
}

/* =========================================================
   6.7. ≤480 — компакт
   ========================================================= */
@media (max-width: 480px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item .mn-ic {
    font-size: 22px;
  }
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item {
    font-size: 10px;
    gap: 2px;
  }
}

/* =========================================================
   6.8. body lock когда sheet открыт
   ========================================================= */
body.ft-mobile-sheet-open {
  overflow: hidden;
}

/* === FIX1 (2026-06-04): whitelist topbar children + brand stretch === */
@media (max-width: 768px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar > *:not(.ft-tb-menu):not(.ft-tb-brand):not(.ft-tb-mobile-notif):not(.ft-tb-mobile-overflow) {
    display: none !important;
  }
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-brand {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 600;
    font-size: 14px;
  }
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-brand span,
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-brand b,
  .ft-shell-root[data-mobile-nav="v1"] .ft-tb-brand strong {
    display: inline !important;
  }
}

/* === FIX2 (2026-06-04): hide-all + show-whitelist hardstop === */
@media (max-width: 768px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar > * { display: none !important; }
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar > .ft-tb-menu,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar > .ft-tb-brand,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar > .ft-tb-mobile-notif,
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar > .ft-tb-mobile-overflow { display: flex !important; }
}

/* === FIX3 (2026-06-04): nuke old topbar + render new ft-mobile-topbar === */
@media (max-width: 768px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-topbar { display: none !important; }
  /* NCM4 2026-07-21: areas shell-bundle на <=768 держат 2 строки ("topbar" "main") —
     единственный 1fr уходил ПУСТОЙ topbar-строке, и на коротких страницах весь
     свободный остаток висел пустотой НАД main (кейс /notifications/ 127px).
     auto-строка со скрытым топбаром = 0, контенту 1fr. */
  .ft-shell-root[data-mobile-nav="v1"] { grid-template-rows: auto 1fr !important; }
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-main { padding-top: var(--mn-topbar-h, 54px) !important; }

  .ft-mobile-topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--mn-topbar-h, 54px);
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: 0 8px; gap: 6px;
    z-index: 65;
  }
  .ft-mobile-topbar .ft-mt-menu,
  .ft-mobile-topbar .ft-mt-notif,
  .ft-mobile-topbar .ft-mt-msg,
  .ft-mobile-topbar .ft-mt-overflow {
    height: 40px; min-width: 40px;
    border: none; background: transparent;
    color: var(--text);
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    position: relative;
  }
  .ft-mobile-topbar button:active { background: rgba(255,255,255,0.06); }
  .ft-mobile-topbar .ft-mt-brand {
    flex: 1 1 auto;
    display: flex; align-items: center; gap: 10px;
    min-width: 0;
    overflow: hidden; white-space: nowrap;
    padding-left: 4px;
  }
  .ft-mobile-topbar .ft-mt-logo {
    width: 26px; height: 26px; border-radius: 7px;
    background: linear-gradient(135deg, var(--green), var(--blue));
    color: #fff; font-weight: 700; font-size: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    flex-shrink: 0;
  }
  .ft-mobile-topbar .ft-mt-title {
    font-size: 14px; font-weight: 600; color: var(--text);
    overflow: hidden; text-overflow: ellipsis;
  }
  .ft-mobile-topbar .ft-mt-notif[data-count]:not([data-count="0"])::after {
    content: attr(data-count);
    position: absolute; top: 4px; right: 4px;
    min-width: 16px; height: 16px;
    background: var(--red, #ef4444);
    color: #fff; border-radius: 8px;
    font-size: 10px; font-weight: 700;
    padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
  }
  /* MOBMSG 2026-06-16: бейдж непрочитанных сообщений (зелёный бренд-акцент,
     чтобы визуально отличался от красного колокола уведомлений) */
  .ft-mobile-topbar .ft-mt-msg[data-count]:not([data-count="0"])::after {
    content: attr(data-count);
    position: absolute; top: 4px; right: 4px;
    min-width: 16px; height: 16px;
    background: var(--green, #0d9488);
    color: #fff; border-radius: 8px;
    font-size: 10px; font-weight: 700;
    padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
  }
  .ft-mobile-topbar button:focus-visible {
    outline: 2px solid var(--green); outline-offset: -2px;
  }
}
@media (min-width: 769px) {
  .ft-mobile-topbar { display: none !important; }
}

/* === FIX4 (2026-06-04): raise z-index above page-level modals/banners === */
@media (max-width: 768px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav { z-index: 1000 !important; }
  .ft-mobile-topbar { z-index: 1001 !important; }
  .ft-mobile-sheet-backdrop { z-index: 1100 !important; }
  .ft-mobile-sheet { z-index: 1101 !important; }
}

/* === FIX5 (2026-06-04): bottom-nav and topbar above onboarding tour overlay === */
@media (max-width: 768px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav { z-index: 999999 !important; }
  .ft-mobile-topbar { z-index: 999998 !important; }
  .ft-mobile-sheet-backdrop { z-index: 1000000 !important; }
  .ft-mobile-sheet { z-index: 1000001 !important; }
}

/* === FIX6 (2026-06-04): полноэкранный overflow tile-grid === */
@media (max-width: 768px) {
  .ft-mobile-overflow {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 999999;
    display: none;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .ft-mobile-overflow[data-open="1"] { display: flex; animation: ft-mo-in .2s ease; }
  @keyframes ft-mo-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
  }
  .ft-mo-header {
    display: flex; justify-content: space-between; align-items: center;
    height: 54px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
  }
  .ft-mo-title { font-size: 17px; font-weight: 600; color: var(--text); }
  .ft-mo-close {
    width: 44px; height: 44px;
    background: transparent; border: none; color: var(--text);
    border-radius: 10px; cursor: pointer; font-size: 22px;
  }
  .ft-mo-close:active { background: rgba(255,255,255,0.06); }
  .ft-mo-grid {
    flex: 1; overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px;
    align-content: start;
  }
  .ft-mo-tile {
    aspect-ratio: 1 / 1;
    min-height: 96px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    cursor: pointer;
    font-size: 12px;
    padding: 10px 6px;
    position: relative;
  }
  .ft-mo-tile:active { background: rgba(255,255,255,0.06); border-color: var(--green); }
  .ft-mo-tile i { font-size: 26px; color: var(--green); }
  .ft-mo-tile span { font-weight: 500; text-align: center; line-height: 1.2; }
  .ft-mo-tile-value {
    position: absolute; top: 6px; right: 8px;
    font-size: 10px; font-weight: 700; font-style: normal;
    color: var(--text); opacity: .55;
  }
  .ft-mo-tile:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
  .ft-mo-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--border); }
  .ft-mo-logout {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: #ef4444;
    font-size: 14px; font-weight: 600;
    cursor: pointer;
  }
  .ft-mo-logout:active { background: rgba(239,68,68,0.08); }
  body.ft-mobile-overflow-open { overflow: hidden; }
}

/* === FIX7 (2026-06-04): tile grid shrink — overflow tiles must fit 3 cols on 390px viewport === */
@media (max-width: 768px) {
  .ft-mo-tile { min-width: 0 !important; min-height: 88px !important; aspect-ratio: auto !important; }
  .ft-mo-tile span { font-size: 11px !important; overflow: hidden; text-overflow: ellipsis; width: 100%; }
}

/* === LEVEL-2 (2026-06-04) WCAG touch-target ≥44px === */
@media (max-width: 768px) {
  .ft-mobile-topbar .ft-mt-menu,
  .ft-mobile-topbar .ft-mt-notif,
  .ft-mobile-topbar .ft-mt-msg,
  .ft-mobile-topbar .ft-mt-overflow {
    height: 44px !important;
    min-width: 44px !important;
  }
}

/* === V2 layout (2026-06-04): третья кнопка "Доп. меню" в правом углу шапки === */
@media (max-width: 768px) {
  .ft-mobile-topbar .ft-mt-widgets {
    height: 44px !important;
    min-width: 44px !important;
    border: none;
    background: transparent;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    position: relative;
  }
  .ft-mobile-topbar .ft-mt-widgets:active { background: rgba(255,255,255,0.06); }
  .ft-mobile-topbar .ft-mt-widgets:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
}

/* === V4 (2026-06-04): right-panel внутри sheet видим даже на мобиле === */
@media (max-width: 768px) {
  .ft-mobile-sheet .ft-shell-right[data-in-sheet="1"] { display: block !important; width: 100% !important; height: auto !important; }
}

/* =========================================================
   === W2 (2026-07-18-MOBW2): каркас v3 — шапка «Вариант A» + единое правое меню ===
   Append-only слой: существующие блоки FIX1-FIX7/V2/V4 не изменяются.
   Классы правого меню — префикс ft-mr-* (изоляция §4 дизайн-системы).
   Палитра только через var() (Закон 15.22); брейкпоинты 480/768 (15.28).
   ========================================================= */

@media (max-width: 768px) {
  /* ---- Правая ☰ (.ft-mt-right) — зеркало левой (.ft-mt-menu). Полное самодостаточное
         описание: FIX3 не включает .ft-mt-right в whitelist, поэтому стилизуем целиком. */
  .ft-mobile-topbar .ft-mt-right {
    height: 44px;
    min-width: 44px;
    border: none;
    background: transparent;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    position: relative;
    padding: 0;
  }
  .ft-mobile-topbar .ft-mt-right:active { background: rgba(255, 255, 255, 0.06); }
  .ft-mobile-topbar .ft-mt-right:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

  /* ---- Логотип-ссылка (название страницы убрано, п.5 INTAKE). Ссылка сжата по контенту,
         чтобы пустой зазор бренда не был кликабелен. C-N (QA fix-1 2026-07-19): hit-area
         доведена до 44×44 (центрируем глиф), визуальный квадрат .ft-mt-logo остаётся 26×26. */
  .ft-mobile-topbar .ft-mt-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    text-decoration: none;
    flex-shrink: 0;
    border-radius: 8px;
  }
  .ft-mobile-topbar .ft-mt-logo-link:focus-visible { outline: 2px solid var(--green); outline-offset: 2px; }

  /* =========================================================
     Единое правое меню-шторка (FT.RightMenu). Bottom-sheet, z-index по §5.
     ========================================================= */
  .ft-mr-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }
  .ft-mr-backdrop[data-open="1"] { opacity: 1; pointer-events: auto; }

  .ft-mr-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 85vh;
    max-height: 85vh;
    background: var(--bg2);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.5);
    z-index: 1000001;
    transform: translateY(100%);
    transition: transform 0.25s ease;
    display: flex;
    flex-direction: column;
  }
  .ft-mr-sheet[data-open="1"] { transform: translateY(0); }

  .ft-mr-handle {
    width: 40px;
    height: 4px;
    background: var(--text);
    opacity: 0.3;
    border-radius: 2px;
    margin: 8px auto 4px;
    cursor: grab;
    touch-action: none;
    flex-shrink: 0;
  }

  .ft-mr-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 12px 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .ft-mr-title { font-weight: 600; font-size: 16px; color: var(--text); }
  .ft-mr-close {
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--text);
    border-radius: 10px;
    cursor: pointer;
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .ft-mr-close:active { background: rgba(255, 255, 255, 0.06); }
  .ft-mr-close:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

  .ft-mr-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 12px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  }

  .ft-mr-section { margin-bottom: 20px; }
  .ft-mr-section[hidden] { display: none; }
  .ft-mr-section-title {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text);
    opacity: 0.55;
  }

  /* Секция «Виджеты страницы» — сюда переносится реальный узел .ft-shell-right */
  .ft-mr-widgets-body { display: block; }
  .ft-mr-widgets-body .ft-shell-right[data-in-sheet="1"] {
    display: block !important;
    width: 100% !important;
    height: auto !important;
  }

  /* Секция «Сервис» — шапка тарифа подписки (зеркало десктоп-dropdown топбара).
     Бейдж переиспользует десктоп-класс .ft-tb-dd-tier-badge (цвета из shell-bundle.css). */
  .ft-mr-tier {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
  }
  .ft-mr-tier[hidden] { display: none; }
  .ft-mr-tier-date {
    font-size: 13px;
    color: var(--text);
    opacity: 0.7;
  }
  .ft-mr-tier-upgrade {
    font-size: 13px;
    font-weight: 600;
    color: var(--green);
    text-decoration: none;
  }
  .ft-mr-tier-upgrade i { font-size: 10px; opacity: 0.7; }

  /* Секция «Сервис» — плитки (сетка 3 колонки, как в бывшем overflow) */
  .ft-mr-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    align-content: start;
  }
  .ft-mr-tile {
    min-width: 0;
    min-height: 88px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    color: var(--text);
    cursor: pointer;
    font-size: 11px;
    padding: 10px 6px;
    position: relative;
    font-family: inherit;
  }
  .ft-mr-tile:active { background: rgba(255, 255, 255, 0.06); border-color: var(--green); }
  .ft-mr-tile i { font-size: 26px; color: var(--green); }
  .ft-mr-tile span {
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
  }
  .ft-mr-tile:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
  .ft-mr-tile-value {
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 10px;
    font-weight: 700;
    font-style: normal;
    color: var(--text);
    opacity: 0.55;
  }

  .ft-mr-logout-wrap { margin-top: 12px; }
  .ft-mr-logout-wrap[hidden] { display: none; }
  .ft-mr-logout {
    width: 100%;
    padding: 14px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--red, #ef4444);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
  }
  .ft-mr-logout:active { background: rgba(239, 68, 68, 0.08); }
  .ft-mr-logout:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }
}

/* body-lock когда правое меню открыто (глобально, вне медиазапроса — как ft-mobile-sheet-open) */
body.ft-mr-open { overflow: hidden; }

/* prefers-reduced-motion — гасим анимации шторки/затемнения (Закон 15 / дизайн-система §13) */
@media (prefers-reduced-motion: reduce) {
  .ft-mr-backdrop,
  .ft-mr-sheet { transition: none !important; }
}

/* =========================================================
   === W3 (2026-07-18-MOBW3): bottom-nav из данных — горизонтальный скролл ===
   Append-only слой: существующие блоки (6.4 bottom-nav, FIX*, W2) НЕ изменяются.
   Панель рендерится из БД-состава (может быть >5 слотов) → горизонтальная промотка,
   первый экран = важные 5, хвост доступен свайпом (§B.4 дизайн-системы).
   Тот же селектор что в 6.4 — здесь НИЖЕ по файлу → переопределяет при равной
   специфичности. Палитра только var() (15.22); брейкпоинты 480/768 (15.28).
   safe-area / высота / z-index — из 6.4 и FIX-блоков, здесь не дублируются.
   ========================================================= */
@media (max-width: 768px) {
  /* Панель: горизонтальный скролл вместо равномерного распределения (space-around). */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav {
    flex-wrap: nowrap;
    justify-content: flex-start;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;              /* Firefox — скрытый скроллбар */
    -webkit-overflow-scrolling: touch;  /* инерционный скролл iOS */
    scroll-behavior: smooth;
  }
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav::-webkit-scrollbar {
    display: none;                      /* WebKit/Blink — скрытый скроллбар */
    width: 0;
    height: 0;
  }

  /* Слот: 5 видимых на первом экране (flex-basis 20%). flex-grow:1 — если пунктов
     МЕНЬШЕ 5, они заполняют ширину (без пустого хвоста справа); при БОЛЬШЕ 5 grow
     не срабатывает (нет свободного места) → панель переполняется и скроллится. */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item {
    flex: 1 0 20%;
  }

  /* Fade-хинт у правого края: только при переполнении (data-scrollable=1) и пока не
     доскроллено до конца (data-at-end!=1). Флаги ставит bottom-nav.js. */
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav[data-scrollable="1"]:not([data-at-end="1"]) {
    -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
            mask-image: linear-gradient(to right, #000 calc(100% - 26px), transparent);
  }
}

/* ≤480 — компактный телефон: слот шире (22%) → влезает ~4.5 с явным хинтом промотки. */
@media (max-width: 480px) {
  .ft-shell-root[data-mobile-nav="v1"] .ft-shell-bottom-nav .mn-item {
    flex: 1 0 22%;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   W4 (mobile-structure-v3) — редактор персональной нижней навигации.
   Классы .ft-navset-* (изоляция §4 дизайн-системы). НЕ scoped на data-mobile-nav:
   редактор работает и в модалке (мобила, shell-страницы) и инлайн на десктоп-вкладке
   /cabinet/settings/?section=mobile-nav (где нет мобильного каркаса). Только токены.
   Инжекции CSS из JS нет (Законы 15.11/15.20) — стили здесь, не в nav-settings.js.
   ═══════════════════════════════════════════════════════════════════════════ */
.ft-navset { display: flex; flex-direction: column; gap: 18px; }
.ft-navset-caption { margin: 0; font-size: var(--text-sm, 13px); color: var(--muted); line-height: 1.5; }
.ft-navset-sec { display: flex; flex-direction: column; gap: 8px; }
.ft-navset-h {
  margin: 0; font-size: var(--text-sm, 13px); font-weight: 700;
  color: var(--strong, var(--text)); text-transform: uppercase; letter-spacing: .03em;
}
.ft-navset-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ft-navset-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; min-height: 44px;
  background: var(--bg3, var(--bg2)); border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
}
.ft-navset-row.is-hidden { opacity: .55; }
.ft-navset-row.is-locked { opacity: .6; }
.ft-navset-ic { width: 20px; text-align: center; color: var(--muted); flex-shrink: 0; }
.ft-navset-label {
  flex: 1 1 auto; min-width: 0; font-size: var(--text-sm, 13px); color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ft-navset-fs {
  flex-shrink: 0; font-size: 10px; font-weight: 700; line-height: 1;
  padding: 3px 6px; border-radius: 999px;
  color: var(--green-text, var(--green)); background: var(--green-dim, rgba(13,148,136,.12));
  border: 1px solid var(--green-border, rgba(13,148,136,.3));
}
.ft-navset-lock { flex-shrink: 0; color: var(--muted); font-size: 12px; }
.ft-navset-row-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ft-navset-mini {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  background: none; border: 1px solid transparent; border-radius: var(--radius, 8px);
  color: var(--muted); font-size: 13px; cursor: pointer;
  transition: background var(--transition, .15s), color var(--transition, .15s);
}
.ft-navset-mini:hover:not([disabled]) { background: var(--bg2); color: var(--text); }
.ft-navset-mini:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.ft-navset-mini[disabled] { opacity: .35; cursor: default; }
.ft-navset-mini[aria-pressed="true"] { color: var(--green); }
.ft-navset-add:not([disabled]) { color: var(--green); }
.ft-navset-rm:hover:not([disabled]) { background: var(--red-dim, rgba(220,38,38,.12)); color: var(--red, #dc2626); }
.ft-navset-empty { list-style: none; padding: 10px; font-size: var(--text-sm, 13px); color: var(--muted); text-align: center; }
.ft-navset-start { width: 100%; }
.ft-navset-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  padding-top: 6px; flex-wrap: wrap;
}
.ft-navset-loading, .ft-navset-error { padding: 24px; text-align: center; color: var(--muted); font-size: var(--text-sm, 13px); }
.ft-navset-error { color: var(--red, #dc2626); }
@media (prefers-reduced-motion: reduce) {
  .ft-navset-mini { transition: none; }
}
/* C-N (QA fix-1 2026-07-19): на тач-ширинах (≤768) hit-area мини-кнопок редактора панели
   доведена до 44×44 (базовый 36px оставлен для десктоп-вкладки настроек с мышью). */
@media (max-width: 768px) {
  .ft-navset-mini { width: 44px; height: 44px; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   === W7 (2026-07-19-MOBW7) — три доработки каркаса + DRAWER справа ===
   Append-only слой: НИ ОДНО существующее правило выше НЕ изменяется — только
   переопределяется ниже по файлу при равной специфичности (изоляция §4, префиксы
   ft-navset-* / ft-mr-* / ft-mt-*). Только токены (Закон 15.22), брейкпоинты
   480/768 (15.28). prefers-reduced-motion — гашение анимаций в конце блока.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── W7 П.7: канонический пикер стартовой страницы (замена нативного <select>).
   Не scoped на data-mobile-nav — редактор работает и в модалке (мобила) и инлайн
   на десктоп-вкладке настроек, как остальные .ft-navset-*. Строки в стиле секций
   редактора: 44px, тёмная тема (токены), выбранная — рамка+галка; скролл при длинном
   списке. role=radiogroup/radio + aria-checked задаёт JS (nav-settings.js). */
.ft-navset-startpicker {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 264px; overflow-y: auto;      /* ~6 строк × 44px, дальше — скролл */
  -webkit-overflow-scrolling: touch;
}
.ft-navset-startopt {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; min-height: 44px;
  background: var(--bg3, var(--bg2)); border: 1px solid var(--border);
  border-radius: var(--radius, 8px);
  color: var(--text); cursor: pointer;
  transition: background var(--transition, .15s), border-color var(--transition, .15s);
}
.ft-navset-startopt:hover { background: var(--bg2); }
.ft-navset-startopt:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
.ft-navset-startopt-ic { width: 20px; text-align: center; color: var(--muted); flex-shrink: 0; }
.ft-navset-startopt-label {
  flex: 1 1 auto; min-width: 0; font-size: var(--text-sm, 13px);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ft-navset-startopt-check { flex-shrink: 0; color: var(--green); font-size: 13px; opacity: 0; }
.ft-navset-startopt[aria-checked="true"] {
  border-color: var(--green);
  background: var(--green-dim, rgba(13, 148, 136, .12));
}
.ft-navset-startopt[aria-checked="true"] .ft-navset-startopt-ic { color: var(--green); }
.ft-navset-startopt[aria-checked="true"] .ft-navset-startopt-check { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .ft-navset-startopt { transition: none; }
}

@media (max-width: 768px) {
  /* ── W7 П.8: кнопка ⚙ «Сервис» в шапке (между 💬 и правой ☰). FIX3/LEVEL-2 не
        включают .ft-mt-gear в whitelist — стилизуем целиком, зеркально .ft-mt-right. */
  .ft-mobile-topbar .ft-mt-gear {
    height: 44px;
    min-width: 44px;
    border: none;
    background: transparent;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    position: relative;
    padding: 0;
  }
  .ft-mobile-topbar .ft-mt-gear:active { background: rgba(255, 255, 255, 0.06); }
  .ft-mobile-topbar .ft-mt-gear:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

  /* ═══════════════ W7-DRAWER: правое меню = боковой drawer справа ═══════════════
     Переопределяет раскладку листа-снизу из W2 (.ft-mr-backdrop / .ft-mr-sheet):
     панель выезжает СПРАВА (translateX), зеркально левому сайдбару .ft-shell-side.
     Ширина — по утверждённому макету 682b2c8d (~84%vw, ~330 на 390): min(330px, 88vw) —
     шире десктоп-native правой панели (комфорт для таблиц/графиков/чатов в drawer).
     Тайминг — --sh-transition (.28s cubic-bezier), зеркально левому сайдбару .ft-shell-side.
     Топбар остаётся видимым: drawer и backdrop начинаются от нижней грани шапки. */
  .ft-mr-backdrop {
    top: var(--mn-topbar-h, 54px);   /* было inset:0 → топбар не затемняется (как у левого) */
  }
  .ft-mr-sheet {
    top: var(--mn-topbar-h, 54px);
    left: auto;                       /* было left:0 → откалываемся от левого края */
    right: 0;
    bottom: 0;
    width: min(330px, 88vw);          /* W7 MAJOR-1: макет 682b2c8d ~84%vw (~330 на 390) — шире десктоп-native */
    max-width: 90vw;                  /* всегда оставить полоску backdrop для тапа-закрытия */
    height: auto;                     /* было 85vh — теперь тянется top→bottom */
    max-height: none;
    border-radius: 0;                 /* флаш-край, как у левого сайдбара */
    box-shadow: 0 0 24px rgba(0, 0, 0, 0.4);   /* мягкая тень как у .ft-shell-side */
    transform: translateX(100%);      /* было translateY(100%) — теперь выезд справа */
    transition: transform var(--sh-transition, .28s cubic-bezier(.4, 0, .2, 1));
    padding-right: env(safe-area-inset-right, 0px);  /* горизонтальный инсет landscape-выемки */
  }
  .ft-mr-sheet[data-open="1"] { transform: translateX(0); }

  /* W7 MINOR-3: вестигиальный grabber-handle (горизонтальная «ручка свайпа-вниз») в
     боковом drawer семантически неверен — свайп-закрытие переехал вправо на весь sheet.
     Прячем его в drawer-режиме. */
  .ft-mr-handle { display: none; }

  /* Шапка drawer: только крестик (слово «Меню» убрано, П.9a) — прижать вправо. */
  .ft-mr-header { justify-content: flex-end; }

  /* Сервис-плитки в узкой колонке drawer: 2 столбца (в листе-снизу было 3). */
  .ft-mr-grid { grid-template-columns: repeat(2, 1fr); }

  /* Пустое состояние секции «Виджеты» (когда на странице нет правой панели, а открыт
     режим 'widgets' — иначе шторка была бы пустой). */
  .ft-mr-widgets-empty {
    padding: 32px 12px;
    text-align: center;
    color: var(--text);
    opacity: 0.55;
    font-size: var(--text-sm, 13px);
  }
  .ft-mr-widgets-empty[hidden] { display: none; }
}

/* prefers-reduced-motion — drawer без анимации выезда (W2-правило уже гасит
   .ft-mr-backdrop/.ft-mr-sheet transition; дублируем явно для надёжности W7). */
@media (prefers-reduced-motion: reduce) {
  .ft-mr-sheet { transition: none !important; }
}

/* =========================================================
   W8 (2026-07-19) П.10b — значок ЦУТ (гейдж-спидометр) в брендовом
   квадрате шапки вместо букв «FT». Иконка наследует белый цвет от
   .ft-mt-logo (color:#fff на градиенте); задаём читаемый размер глифа
   в 26px-квадрате (текстовый font-size:11px был под 2 буквы «FT»).
   Append-only, scoped к .ft-mobile-topbar (виден только ≤768).
   ========================================================= */
@media (max-width: 768px) {
  .ft-mobile-topbar .ft-mt-logo i { font-size: 15px; line-height: 1; }
}

/* =========================================================
   W9 (2026-07-19) П.11 — кнопка мини-терминала в шапке (между значком
   ЦУТ и колокольчиком). FIX3/LEVEL-2 whitelist не включает .ft-mt-term —
   стилизуем целиком, зеркально .ft-mt-gear/.ft-mt-notif. Стартует hidden
   (снимается gateTermButton при доступе page.terminal). Цветная точка
   знака суммарного P&L — ::after по data-pnl-sign (пишет updateTopbar виджета:
   'pos' зелёная / 'neg' красная / '' нет точки). Append-only, scoped ≤768.
   ========================================================= */
@media (max-width: 768px) {
  .ft-mobile-topbar .ft-mt-term {
    height: 44px;
    min-width: 44px;
    border: none;
    background: transparent;
    color: var(--text);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    position: relative;
    padding: 0;
    flex-shrink: 0;
  }
  /* hidden-атрибут должен побеждать display:inline-flex (иначе гейт не скрыл бы). */
  .ft-mobile-topbar .ft-mt-term[hidden] { display: none !important; }
  .ft-mobile-topbar .ft-mt-term:active { background: rgba(255, 255, 255, 0.06); }
  .ft-mobile-topbar .ft-mt-term:focus-visible { outline: 2px solid var(--green); outline-offset: -2px; }

  /* Точка знака P&L — маленький кружок в правом-верхнем углу (не меняет ширину кнопки).
     Обводка под фон шапки, чтобы читалась на любом фоне карточки. */
  .ft-mobile-topbar .ft-mt-term[data-pnl-sign="pos"]::after,
  .ft-mobile-topbar .ft-mt-term[data-pnl-sign="neg"]::after {
    content: '';
    position: absolute; top: 7px; right: 7px;
    width: 8px; height: 8px; border-radius: 50%;
    border: 1.5px solid var(--bg2);
    box-sizing: content-box;
  }
  .ft-mobile-topbar .ft-mt-term[data-pnl-sign="pos"]::after { background: var(--green-accent, #0d9488); }
  .ft-mobile-topbar .ft-mt-term[data-pnl-sign="neg"]::after { background: var(--red, #f6465d); }
}

/* ═══════════════ W10C (2026-07-19-MOBW10C): правое меню без крестика ═══════════════
   Крестик-шапка (.ft-mr-header/.ft-mr-close) убрана из разметки right-menu.js — правое
   меню закрывается как левое (тап-мимо/ESC/свайп-вправо/повторный тап кнопки-триггера).
   ДЕФЕНСИВ окна деплоя: если браузер во время бампа отдал старый кэш JS с ещё живой шапкой —
   гасим её (display:none), чтобы полоса с бордюром не мелькала. Контент секций поднимаем
   вплотную под мобильную шапку. Append-only: ни одно правило выше не изменено. Изоляция §4
   (префикс ft-mr-*), ≤768 (Закон 15.28), только токены. */
@media (max-width: 768px) {
  .ft-mr-sheet .ft-mr-header { display: none !important; }
  .ft-mr-sheet .ft-mr-body { padding-top: 14px; }

  /* W10C (2026-07-19, решение Founder по скрину) + W10D size-align (приёмка Founder:
     квадрат был визуально крупнее домика — некрасиво): кнопка мини-терминала .ft-mt-term —
     градиентный FT-квадрат СТРОГО 1:1 с логотипом-домиком .ft-mt-logo: 26×26, border-radius 7px,
     linear-gradient(135deg, var(--green)→var(--blue)), белый глиф 15px (метрики глифа = W8-правилу
     .ft-mt-logo i). Стилизуем внутренний <i> (глиф-бокс), кнопка остаётся прозрачной 44×44
     (тач-цель не тронута). */
  .ft-mobile-topbar .ft-mt-term i {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--green), var(--blue));
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 15px; line-height: 1;
    flex-shrink: 0;
  }
  /* P&L-точка поверх градиентного квадрата — белая обводка для читаемости на градиенте
     (была под фон шапки var(--bg2)). W10D: позиция точки 9px = угол 26×26-квадрата в 44px-кнопке
     ((44−26)/2; базовые 7px были под старую геометрию). Цвет заливки (pos/neg) — из базовых правил. */
  .ft-mobile-topbar .ft-mt-term[data-pnl-sign="pos"]::after,
  .ft-mobile-topbar .ft-mt-term[data-pnl-sign="neg"]::after {
    border-color: #fff;
    top: 9px; right: 9px;
  }
}

/* JRNMOB2 (2026-07-21) — Узкие экраны (Z Fold 5 внешний ~344, малые телефоны):
   уместить все иконки шапки, не обрезая мини-терминал. Селекторы scoped .ft-mobile-topbar
   — совпасть по специфичности с базовыми правилами (0,2,0), выигрыш порядком источника (append). */
@media (max-width: 380px) {
  .ft-mobile-topbar { gap: 3px; padding-left: 5px; padding-right: 5px; }
  .ft-mobile-topbar .ft-mt-brand { gap: 4px; flex-shrink: 0; }
}
@media (max-width: 340px) {
  .ft-mobile-topbar { gap: 2px; padding-left: 3px; padding-right: 3px; }
  .ft-mobile-topbar .ft-mt-menu,
  .ft-mobile-topbar .ft-mt-notif,
  .ft-mobile-topbar .ft-mt-msg,
  .ft-mobile-topbar .ft-mt-gear,
  .ft-mobile-topbar .ft-mt-right,
  .ft-mobile-topbar .ft-mt-logo-link,
  .ft-mobile-topbar .ft-mt-term { width: 40px; min-width: 40px; }
}
