/* One shared brand and one navigation geometry for every root page. */
html.telegram-webapp #moplano-app #page.page {
  padding-top: calc(var(--moplano-header-top) + 10px) !important;
}
html:not(.telegram-webapp) #moplano-app #page.page { padding-top:58px !important; }
#moplano-app .app-shell > .bottom-nav .nav-item {
  display:grid !important; grid-template-rows:24px 16px !important;
  align-content:center !important; justify-items:center !important;
  gap:5px !important; min-width:0 !important; min-height:50px !important;
  padding:4px 2px !important; font-weight:500 !important;
  color:#78736c !important; background:transparent !important;
  box-shadow:none !important; transform:none !important;
  transition:color .15s ease !important;
}
#moplano-app .app-shell > .bottom-nav .nav-item .nav-icon {
  display:grid !important; place-items:center !important;
  width:24px !important; height:24px !important; flex-shrink:0 !important;
  border-radius:9px !important; background:transparent !important;
  box-shadow:none !important; transform:none !important;
}
#moplano-app .app-shell > .bottom-nav .nav-item .nav-icon svg {
  width:23px !important; height:23px !important; transform:none !important;
}
#moplano-app .app-shell > .bottom-nav .nav-item small {
  display:block !important; font-size:11px !important; line-height:16px !important;
  font-weight:500 !important; letter-spacing:normal !important; white-space:nowrap !important;
  transform:none !important;
}
#moplano-app .app-shell > .bottom-nav .nav-item.active { color:var(--sage-dark) !important; }
#moplano-app .app-shell > .bottom-nav .nav-item.active .nav-icon {
  background:rgba(143,159,138,.10) !important; box-shadow:0 0 0 4px rgba(143,159,138,.10) !important;
}
#moplano-app .app-shell > .bottom-nav .nav-item:focus-visible { outline:2px solid var(--sage-dark); outline-offset:2px; }
@media (prefers-reduced-motion:reduce) { #moplano-app .app-shell > .bottom-nav .nav-item { transition:none !important; } }

/* One compact wordmark across all five root pages. Keep native controls clear. */
#moplano-app #page .home-scroll-brand {
  position:fixed !important; inset:0 0 auto !important; z-index:88 !important;
  display:flex !important; align-items:center !important; justify-content:center !important;
  box-sizing:border-box !important; width:100% !important; max-width:none !important;
  height:48px !important; min-height:0 !important; margin:0 !important;
  padding:0 16px !important; overflow:visible !important;
  background:rgba(246,242,236,.975) !important;
  backdrop-filter:blur(18px) saturate(1.03) !important;
  -webkit-backdrop-filter:blur(18px) saturate(1.03) !important;
  border:0 !important; box-shadow:none !important; pointer-events:none !important;
  font-size:0 !important; letter-spacing:0 !important;
  user-select:none !important; -webkit-user-select:none !important;
}
html.telegram-webapp #moplano-app #page .home-scroll-brand {
  height:calc(var(--moplano-header-top) + 4px) !important;
  padding:var(--moplano-safe-top) 96px 0 !important;
}
#moplano-app #page .home-scroll-brand::before { content:none !important; }
#moplano-app #page .home-scroll-brand::after {
  content:"" !important; position:absolute !important; inset:auto 0 -6px !important;
  height:6px !important; pointer-events:none !important;
  background:linear-gradient(to bottom,rgba(246,242,236,.975),rgba(246,242,236,0)) !important;
}
#moplano-app #page .home-scroll-brand .home-brand-wordmark {
  display:block !important; flex:0 0 116px !important;
  width:116px !important; min-width:116px !important; max-width:116px !important;
  height:21px !important; min-height:21px !important; max-height:21px !important;
  margin:0 !important; padding:0 !important; object-fit:contain !important;
  border:0 !important; filter:none !important; transform:none !important;
}

/* Identity transforms also trap fixed descendants in the scrolling page.
   Keep root chrome viewport-fixed; editor transition states retain their styles. */
#moplano-app .app-shell:not(.entity-form-active):not(.entity-form-closing) > #page.page {
  transform:none !important;
  will-change:auto !important;
}

/* PWA tablet: align the dock with its shell and reserve its full touch/safe area.
   Short landscape phone viewports retain the existing mobile geometry. */
@media (min-width:768px) and (max-width:1023px) and (min-height:500px) {
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell {
    width:min(calc(100vw - 32px),720px);
    padding-bottom:calc(96px + env(safe-area-inset-bottom,0px));
  }
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell > .bottom-nav {
    width:min(calc(100vw - 32px),720px);
    bottom:0;
    border-radius:0;
  }
}

/* PWA desktop: an in-flow top row, using the same five buttons/listeners.
   An explicit row preserves the underlying layout when editors hide the nav. */
@media (min-width:1024px) {
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    grid-template-rows:56px auto;
    align-content:start;
    padding-top:20px;
    padding-bottom:24px;
  }
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell > .bottom-nav {
    grid-column:1;
    grid-row:1;
    position:static;
    inset:auto;
    transform:none;
    width:100%;
    height:56px;
    padding:6px 10px;
    border-top:0;
    border-bottom:1px solid var(--line);
    border-radius:0;
    box-shadow:none;
  }
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell > .bottom-nav .nav-item {
    grid-template-columns:24px max-content !important;
    grid-template-rows:24px !important;
    justify-content:center;
    align-items:center;
    gap:8px !important;
    min-height:44px !important;
    padding:8px 10px !important;
  }
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell > .bottom-nav .nav-item small {
    font-size:13px !important;
  }
  html:not(.telegram-webapp):not(.pwa-login-active) #moplano-app .app-shell > #page.page {
    grid-column:1;
    grid-row:2;
    align-self:start;
    padding-top:16px !important;
  }
}

#moplano-app .today-task-empty-add {
  min-height:44px; margin-top:8px; padding:8px 16px; border:1px solid #a8b09f;
  border-radius:10px; background:#fff; color:#435940; font:inherit; font-weight:600; cursor:pointer;
}
#moplano-app .today-task-empty-add:focus-visible { outline:2px solid #526b4f; outline-offset:3px; }
#moplano-app .profile-install-note h2 { font-size:17px; margin:0 0 8px; }
#moplano-app .profile-install-note p { margin:0; line-height:1.55; }

html:not(.telegram-webapp) { scroll-behavior:auto; }

/* Paint only the active route over the solid app surface. */
#moplano-app .navigation-opaque { background-color:#eeeeea !important; opacity:1 !important; }
#moplano-app :is(.navigation-preparing,.navigation-covered) { visibility:hidden !important; pointer-events:none; }
#moplano-app .app-shell:has(> .navigation-opaque:not(.navigation-preparing,.navigation-covered)) > :is(#page,.topbar,.bottom-nav),
#moplano-app:has(> .navigation-opaque:not(.navigation-preparing,.navigation-covered)) > .app-shell { visibility:hidden !important; }
@media (min-width:1024px) {
  html:not(.telegram-webapp) #moplano-app .app-shell:has(> .profile-detail-screen[data-section="methods"]:not(.navigation-preparing,.navigation-covered)) > #page .home-scroll-brand { visibility:visible; }
}

/* A full-screen route scrolls within the viewport even when the page beneath it is long. */
html:not(.telegram-webapp) #moplano-app .app-shell:has(> .navigation-opaque:not(.navigation-preparing,.navigation-covered)) {
  height:100dvh;
  overflow:clip;
}

#moplano-app[data-moplano-standalone="1"] .pwa-form-keyboard .entity-form-scroll::after {
  content:"";
  display:block;
  flex:none;
  min-height:var(--pwa-form-keyboard-overlap,0px);
}
