/* Вынесено из includes/app_nav.php (31.10.2026): общий блок оболочки — кэшируется браузером, а не
   качается заново с каждой страницей. */
  /* App / installed PWA: drop the web top header (bottom .mobnav via .is-pwa). */
  html.app-mode .topnav { display: none !important; }
  /* contentInset=never + viewport-fit=cover: контент сам отступает от
     статус-бара/чёлки (нативная вставка дёргала fixed-элементы — убрана). */
  html.app-mode body { padding-top: calc(env(safe-area-inset-top, 0px) + 8px); }
  /* Раньше здесь было `html.native-app body { padding-top: 8px }` — считалось, что
     обёртка сама сажает webview под статус-бар. Это давно не так: обёртка отдаёт
     webview на весь экран, поэтому в приложении отступ съедался и шапка страницы
     уезжала под часы (а на iOS её ещё и закрывала «шторка» body::before той же
     высоты). Вставку теперь считает env() — на iOS, где webview всё же смещён,
     env() = 0 и отступ сам вырождается в те же 8px. Класс `native-app` остаётся
     как хук в topnav.php, но правил на нём больше нет. */
  /* Android-приложение/PWA: у системы своя навигация «назад» — нижняя панель
     дублирует её и съедает место. (Звезда «в избранное» жила в панели —
     на Android её пока нет; вернём в FAB, если понадобится.) */
  html.app-mode.is-android .mobnav { display: none !important; }
  html.app-mode.is-android body { padding-bottom: 24px; }
  /* «Шторка» под статус-баром: прокручиваемый контент не просвечивает
     под часами (фон + блюр, как в нативных приложениях). */
  html.app-mode body::before { content: ''; position: fixed; top: 0; left: 0; right: 0;
    height: env(safe-area-inset-top, 0px); z-index: 8990;
    background: rgba(245,240,235,.88); -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px); }
  /* A plain browser keeps its header — hide this app-only UI there. */
  html:not(.app-mode) .appfab,
  html:not(.app-mode) .appsheet-back,
  html:not(.app-mode) .appsheet,
  html:not(.app-mode) .appsearch { display: none !important; }

  /* Кнопка меню — в правом верхнем углу. Опускать её ниже пробовали: место под
     ней тоже занято контентом, лучше не стало. Вместо этого страницы сами
     оставляют ей угол (см. html.app-mode .steps в детективе). */
  .appfab { position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); right: 14px; z-index: 9000; height: 52px; }
  .appfab-btn { position: absolute; top: 0; right: 0; border: none; padding: 0; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
    -webkit-appearance: none; appearance: none; }
  .appfab-main { width: 52px; height: 52px; background: #d97757; box-shadow: 0 4px 14px rgba(217,119,87,.4);
    z-index: 2; opacity: .6; transition: opacity .2s ease; }
  .appfab.open .appfab-main { opacity: 1; }
  .appfab-main .bar { position: absolute; left: 15px; right: 15px; height: 2.5px; border-radius: 2px;
    background: #fff; transition: transform .25s ease, opacity .2s ease; }
  .appfab-main .bar.b1 { transform: translateY(-6px); }
  .appfab-main .bar.b3 { transform: translateY(6px); }
  .appfab.open .appfab-main .bar.b1 { transform: rotate(45deg); }
  .appfab.open .appfab-main .bar.b2 { opacity: 0; }
  .appfab.open .appfab-main .bar.b3 { transform: rotate(-45deg); }

  .appfab-ball { width: 46px; height: 46px; top: 3px; background: #fff; color: #d97757;
    box-shadow: 0 3px 12px rgba(20,20,19,.18);
    opacity: 0; transform: translateX(0) scale(.4); pointer-events: none;
    transition: transform .28s cubic-bezier(.2,.9,.3,1.25), opacity .18s ease; }
  .appfab.open .appfab-ball { opacity: 1; pointer-events: auto; }
  .appfab.open .appfab-ball.n1 { transform: translateX(-58px)  scale(1); transition-delay: .03s; }
  .appfab.open .appfab-ball.n2 { transform: translateX(-116px) scale(1); transition-delay: .06s; }
  .appfab.open .appfab-ball.n3 { transform: translateX(-174px) scale(1); transition-delay: .09s; }
  .appfab.open .appfab-ball.n4 { transform: translateX(-232px) scale(1); transition-delay: .12s; }
  /* Вне контента звезда скрыта — «⋯» подтягивается на её место. */
  #appfab-star[hidden] { display: none !important; }
  .appfab.open #appfab-star[hidden] ~ .appfab-ball.n4 { transform: translateX(-174px) scale(1); transition-delay: .09s; }
  #appfab-star.is-active { background: #d97757; color: #fff; }
  #appfab-star.is-active svg polygon { fill: currentColor; }
  .appfab-ball svg { width: 22px; height: 22px; }
  .appfab-ball .lbl { font-weight: 800; font-size: 17px; line-height: 1; }
  .appfab-ball .lbl small { font-size: 11px; }

  .appsheet-back { position: fixed; top:0;right:0;bottom:0;left:0; background: rgba(20,20,19,.35); z-index: 9400;
    opacity: 0; pointer-events: none; transition: opacity .2s ease; }
  .appsheet-back.open { opacity: 1; pointer-events: auto; }
  .appsheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9600; background: #fff;
    border-radius: 20px 20px 0 0; padding: 18px 20px calc(env(safe-area-inset-bottom, 0px) + 18px);
    transform: translateY(105%); transition: transform .28s cubic-bezier(.2,.8,.2,1);
    box-shadow: 0 -8px 30px rgba(20,20,19,.18); max-width: 560px; margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif; }
  .appsheet.open { transform: translateY(0); }
  .appsheet-h { font-weight: 700; color: #141413; font-size: 1.05rem; margin-bottom: 16px; text-align: center; }
  .appmenu-item { display: block; padding: 14px 12px; border-radius: 12px; text-decoration: none; color: #141413; font-size: 1rem; }
  .appmenu-item:active { background: #f5f0eb; }
  .appmenu-item.danger { color: #a64a32; }
  .appmenu-item { display: flex; align-items: center; gap: 12px; }   /* иконки; без :has() — Android 9 WebView */
  .appmenu-item .mi-ic { width: 28px; height: 28px; flex: none; margin: -4px 0; }

  .appfont-slider { margin-bottom: 16px; }
  .appfont-slider .lab { display: flex; justify-content: space-between; align-items: baseline;
    font-size: .95rem; color: #141413; margin-bottom: 8px; }
  .appfont-slider .lab b { font-weight: 600; }
  .appfont-slider .lab span { color: #6b6560; font-size: .85rem; }
  .appfont-slider input[type=range] { width: 100%; accent-color: #d97757; height: 26px; }
  .appfont-pytop { display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 14px; border-radius: 12px; background: #f5f0eb; color: #141413; font-size: .95rem; margin-top: 4px; }
  .appfont-pytop input { width: 46px; height: 28px; accent-color: #d97757; }

  /* Search as a top overlay (not a separate page) */
  .appsearch { position: fixed; top: 0; left: 0; right: 0; z-index: 9600; background: #fffdfb;
    border-bottom: 1px solid #e7dfd6; box-shadow: 0 6px 20px rgba(20,20,19,.12);
    padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 12px;
    transform: translateY(-108%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif; }
  .appsearch.open { transform: translateY(0); }
  .appsearch form { display: flex; align-items: center; gap: 8px; max-width: 640px; margin: 0 auto; }
  .appsearch input { flex: 1; min-width: 0; font-size: 1rem; padding: 12px 14px; border: 2px solid #e7dfd6; border-radius: 12px; outline: none; }
  .appsearch input:focus { border-color: #d97757; }
  .appsearch .asr-go { flex: 0 0 auto; width: 46px; height: 46px; border: none; border-radius: 12px; background: #d97757; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
  .appsearch .asr-go svg { width: 22px; height: 22px; display: block; }
  .appsearch .asr-close { flex: 0 0 auto; width: 40px; height: 46px; border: none; background: transparent; color: #6b6560; font-size: 20px; cursor: pointer; }

  /* Section menu — drops DOWN below the FAB on open (alongside the leftward balls). */
  .appfab-sections { position: absolute; top: 60px; right: 0; display: flex; flex-direction: column;
    align-items: flex-end; gap: 8px; opacity: 0; pointer-events: none; transform: translateY(-6px);
    transition: opacity .18s ease, transform .25s cubic-bezier(.2,.9,.3,1.2); }
  .appfab.open .appfab-sections { opacity: 1; pointer-events: auto; transform: none; }
  .appfab-sections a { width: 46px; height: 46px; border-radius: 50%; background: #fff; color: #d97757;
    display: flex; align-items: center; justify-content: center; text-decoration: none;
    box-shadow: 0 3px 12px rgba(20,20,19,.18); }
  .appfab-sections a.is-active { background: #d97757; color: #fff; }
  .appfab-sections a svg { width: 24px; height: 24px; }
