/* Central Orbit Production v5.50.25
   Responsive single shell: reuse the real vNext dashboard + real module runtime on phones.
   The legacy mobile-full application is intentionally not mounted in the outer shell. */

@media (max-width: 820px) {
  html,
  body,
  body,
  body #app {
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100% !important;
    height: auto !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    background: #031016 !important;
  }

  body {
    padding: 0 !important;
  }

  body #app {
    display: block !important;
    padding: 68px 0 calc(70px + env(safe-area-inset-bottom)) !important;
    box-sizing: border-box !important;
  }

  /* Desktop topbar disappears; its real mobile counterpart remains as the one shell. */
  body .topbar-shell,
  body .vnext-global-header {
    display: none !important;
  }

  /* Reuse only header / bottom-nav / All sheet from the existing mobile shell.
     The old duplicate mobile dashboard content is removed from the visual tree. */
  body .mobile-vnext {
    display: contents !important;
  }
  body .mobile-vnext-scroll {
    display: none !important;
  }
  body .mobile-vnext-header {
    display: flex !important;
    position: fixed !important;
    inset: 0 0 auto 0 !important;
    z-index: 65000 !important;
    height: 68px !important;
  }
  body .mobile-bottom-nav {
    display: grid !important;
    position: fixed !important;
    inset: auto 0 0 0 !important;
    z-index: 65000 !important;
  }
  body .mobile-all-backdrop,
  body .mobile-all-sheet {
    z-index: 66000 !important;
  }

  /* Dashboard: same vNext cards/data as desktop, arranged for a phone instead of
     falling back to the old independent mobile dashboard. */
  body:not(.co-index-module-mode) > #app > .shell-wrap {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 9px !important;
    box-sizing: border-box !important;
  }

  body:not(.co-index-module-mode) .top-grid,
  body:not(.co-index-module-mode) .row-grid,
  body:not(.co-index-module-mode) .row-two,
  body:not(.co-index-module-mode) .row-three,
  body:not(.co-index-module-mode) .bottom-grid {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-auto-flow: row !important;
    grid-auto-rows: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 9px !important;
    margin: 0 0 9px !important;
  }

  body:not(.co-index-module-mode) .top-grid > *,
  body:not(.co-index-module-mode) .row-grid > *,
  body:not(.co-index-module-mode) .bottom-grid > *,
  body:not(.co-index-module-mode) .card,
  body:not(.co-index-module-mode) [data-card-size] {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
  }

  body:not(.co-index-module-mode) .hero-card {
    min-height: 184px !important;
  }
  body:not(.co-index-module-mode) .hero-content {
    padding: 18px !important;
  }
  body:not(.co-index-module-mode) .hero-time {
    font-size: 42px !important;
  }
  body:not(.co-index-module-mode) .ai-card,
  body:not(.co-index-module-mode) .system-card,
  body:not(.co-index-module-mode) .weather-card-prominent,
  body:not(.co-index-module-mode) .home-card,
  body:not(.co-index-module-mode) .now-card,
  body:not(.co-index-module-mode) .music-card,
  body:not(.co-index-module-mode) .tasks-card,
  body:not(.co-index-module-mode) .calendar-card,
  body:not(.co-index-module-mode) .notes-card,
  body:not(.co-index-module-mode) .shopping-card,
  body:not(.co-index-module-mode) .routines-card,
  body:not(.co-index-module-mode) .fitness-card,
  body:not(.co-index-module-mode) .therapy-card,
  body:not(.co-index-module-mode) .news-card {
    min-height: 150px !important;
  }

  body:not(.co-index-module-mode) .fitness-main {
    grid-template-columns: 92px minmax(0, 1fr) !important;
    gap: 8px !important;
    padding: 8px 10px !important;
  }
  body:not(.co-index-module-mode) .fitness-ring {
    width: 82px !important;
    height: 82px !important;
  }
  body:not(.co-index-module-mode) .fitness-metric {
    min-width: 0 !important;
  }
  body:not(.co-index-module-mode) .fitness-footer {
    grid-template-columns: 1fr 1fr !important;
    height: auto !important;
    min-height: 0 !important;
    gap: 7px !important;
    padding: 8px 10px 10px !important;
  }
  body:not(.co-index-module-mode) .training-next {
    grid-column: 1 / -1 !important;
  }

  /* Module mode: same mobile shell, but the inner surface is the real vNext module
     renderer. No legacy mobile renderer, no second page, no visible URL jump. */
  body.co-index-module-mode > #app {
    overflow: hidden !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
  }
  body.co-index-module-mode > #app > .mobile-vnext {
    display: contents !important;
  }
  body.co-index-module-mode > #app > main.shell-wrap,
  body.co-index-module-mode > #app > #dashboardEditor {
    display: none !important;
  }
  body.co-index-module-mode .index-module-surface {
    display: block !important;
    position: fixed !important;
    top: 68px !important;
    right: 0 !important;
    bottom: calc(68px + env(safe-area-inset-bottom)) !important;
    left: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    z-index: 100 !important;
    background: #021117 !important;
    overflow: hidden !important;
  }
  body.co-index-module-mode .index-module-surface iframe {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    border: 0 !important;
    background: #021117 !important;
  }

  /* Dashboard editor remains usable above the responsive shell. */
  body .dashboard-editor-backdrop {
    z-index: 67000 !important;
  }
}

@media (max-width: 480px) {
  body:not(.co-index-module-mode) .shell-wrap {
    padding: 7px !important;
  }
  body:not(.co-index-module-mode) .top-grid,
  body:not(.co-index-module-mode) .row-grid,
  body:not(.co-index-module-mode) .bottom-grid {
    gap: 7px !important;
    margin-bottom: 7px !important;
  }
  body:not(.co-index-module-mode) .fitness-main {
    grid-template-columns: 1fr !important;
  }
  body:not(.co-index-module-mode) .fitness-ring {
    margin: 2px auto 8px !important;
  }
}
