/* Diário de Pressão v25.8.1.2 | Viewport integral e espaços livres corrigidos.
   Escopo: shell, tab bar, espaçamento; sem alteração em valores clínicos ou Sync. */
@media screen and (max-width:1023px) {
  :root{
    --dp-last-nav-safe:clamp(0px,env(safe-area-inset-bottom),14px);
    --dp-last-nav-items:62px;
    --dp-last-nav-height:calc(var(--dp-last-nav-items) + var(--dp-last-nav-safe));
  }
  html,body{
    margin:0!important;padding:0!important;overflow:hidden!important;
    background:#320f22!important;
  }
  html[data-theme="dark"],html[data-theme="dark"] body{background:#18090e!important}
  .app-shell-frame{
    display:grid!important;grid-template-rows:auto minmax(0,1fr) var(--dp-last-nav-height)!important;
    width:100%!important;max-width:100vw!important;
    height:100dvh!important;min-height:100dvh!important;max-height:100dvh!important;
    overflow:hidden!important;box-sizing:border-box!important;
  }
  html[data-ios-standalone="true"] .app-shell-frame{
    height:var(--dp-app-height,100dvh)!important;
    min-height:var(--dp-app-height,100dvh)!important;
    max-height:var(--dp-app-height,100dvh)!important;
  }
  .app-scroll-region{
    min-height:0!important;max-height:none!important;overflow-y:auto!important;overflow-x:clip!important;
    overscroll-behavior-y:contain!important;
    padding:0!important;scroll-padding-block:12px!important;
  }
  /* A própria região de conteúdo é rolável; não reserve outra tab bar dentro do main. */
  main.app{
    min-height:0!important;height:auto!important;max-height:none!important;
    padding-top:12px!important;padding-bottom:16px!important;
    margin-top:0!important;margin-bottom:0!important;
  }
  html.context-nav-visible main.app{padding-top:10px!important}
  main.app>.grid{margin-top:0!important;margin-bottom:0!important;align-items:start!important}
  .app-page.active{height:auto!important;min-height:0!important;margin-bottom:0!important}
  .app-page:not(.active){display:none!important;position:static!important;height:0!important;min-height:0!important;margin:0!important;padding:0!important;visibility:hidden!important}
  /* Legados escondidos não devem ocupar área nem quando receberam display!important. */
  html body #inicio#inicio [data-home-legacy="retired"]{
    display:none!important;visibility:hidden!important;height:0!important;min-height:0!important;
    margin:0!important;padding:0!important;border:0!important;overflow:hidden!important;
  }
  /* Exceção funcional: busca global avançada, aberta pelo Spotlight, ainda pode aparecer sob demanda. */
  html body #inicio#inicio #globalSearchCard[data-home-legacy="retired"]:not(.is-open){display:none!important}
  html body #inicio#inicio #globalSearchCard[data-home-legacy="retired"].is-open:not([hidden]){
    display:block!important;visibility:visible!important;height:auto!important;min-height:0!important;
    margin:12px 0!important;padding:12px!important;overflow:visible!important;
  }
  #inicio #home12Command{display:grid!important;min-height:0!important;margin-bottom:0!important}
  /* O aviso clínico e informações técnicas seguem no DOM e na tela Sobre, não no fim de cada rota. */
  main.app>.note,main.app>.page-credit,.app-footer{display:none!important}
  /* Tab bar de borda a borda: safe-area só é incluída uma vez e recebe o MESMO fundo. */
  .bottom-nav{
    position:relative!important;inset:auto!important;transform:none!important;grid-row:3!important;
    display:grid!important;grid-template-columns:repeat(5,minmax(0,1fr))!important;
    width:100%!important;min-width:0!important;max-width:100%!important;
    height:var(--dp-last-nav-height)!important;min-height:var(--dp-last-nav-height)!important;max-height:var(--dp-last-nav-height)!important;
    margin:0!important;padding:3px max(4px,env(safe-area-inset-right)) var(--dp-last-nav-safe) max(4px,env(safe-area-inset-left))!important;
    box-sizing:border-box!important;align-items:stretch!important;align-content:stretch!important;justify-items:stretch!important;
    border:0!important;border-top:1px solid rgba(255,255,255,.10)!important;border-radius:0!important;
    background:#320f22!important;box-shadow:0 -5px 20px rgba(26,3,12,.12)!important;
    overflow:hidden!important;z-index:8600!important;
  }
  html[data-theme="dark"] .bottom-nav{background:#18090e!important}
  .bottom-nav::before,.bottom-nav::after{display:none!important;content:none!important}
  .bottom-nav>a{
    display:flex!important;position:relative!important;flex-direction:column!important;
    justify-content:center!important;align-items:center!important;
    width:100%!important;max-width:none!important;min-width:0!important;
    height:56px!important;min-height:56px!important;max-height:56px!important;
    padding:2px 1px!important;margin:0!important;gap:2px!important;
    border-radius:12px!important;overflow:hidden!important;
  }
  .bottom-nav .nav-icon-box{
    display:grid!important;place-items:center!important;
    width:32px!important;height:30px!important;min-height:30px!important;
    margin:0!important;border-radius:10px!important;
  }
  .bottom-nav .nav-icon-box svg{width:21px!important;height:21px!important}
  .bottom-nav .nav-label{font-size:clamp(.5rem,2vw,.59rem)!important;line-height:1.08!important;white-space:nowrap!important}
  .bottom-nav a.active{background:#FAF6ED!important;color:#48152d!important;box-shadow:none!important}
  .bottom-nav a.active .nav-icon-box{background:linear-gradient(135deg,#87304e,#58192f)!important;color:#fff!important}
  html[data-theme="dark"] .bottom-nav a.active{background:#e8e4de!important;color:#48152d!important}
  /* Cards de resumo/agenda e rotas comuns devem usar apenas sua altura intrínseca. */
  #inicio .home12-overview,#inicio .home12-lower,#inicio .home12-agenda-block,#inicio .home12-favorites-block{
    min-height:0!important;align-items:start!important;
  }
  #historyHub,#settingsHub,#analysisHub{height:auto!important;min-height:0!important}
  #screenHead.show{margin-bottom:12px!important}
  /* Ações e mensagens temporárias nunca ficam atrás do menu. */
  :where(.undo-toast,.undo-toast13,.app-toast-stack,.pwa-status-float,.offline-queue-float,.sync-toast2570,.sync-remote-refresh2570){
    bottom:calc(var(--dp-last-nav-height) + 9px)!important;
  }
}
@media screen and (max-width:359px){
  :root{--dp-last-nav-items:59px}
  .bottom-nav>a{height:53px!important;min-height:53px!important;max-height:53px!important}
  main.app{padding-inline:10px!important}
}
@media screen and (orientation:landscape) and (max-height:600px) and (max-width:1023px){
  :root{--dp-last-nav-items:52px;--dp-last-nav-safe:clamp(0px,env(safe-area-inset-bottom),8px)}
  .bottom-nav>a{height:46px!important;min-height:46px!important;max-height:46px!important;flex-direction:row!important;gap:4px!important}
}
@media print {main.app>.note,main.app>.page-credit,.app-footer{display:block!important}.bottom-nav{display:none!important}}
