/* =============================================
   HUB LAYOUT FIX — iframe height & sizing
   ============================================= */

/* === DESKTOP: full-screen fixed layout === */
body.sov-theme-hub {
  overflow: hidden !important;
}

body.sov-theme-hub .site-shell {
  position: fixed !important;
  inset: 0 !important;
  width: 100dvw !important;
  height: 100dvh !important;
  min-height: 0 !important;
  margin: 0 !important;
  padding: clamp(.45rem, .8vw, .75rem) !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
  gap: clamp(.45rem, .75vw, .65rem) !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
}

body.sov-theme-hub .stage-shell {
  min-height: 0 !important;
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
}

body.sov-theme-hub .browser-frame {
  flex: 1 1 0 !important;
  min-height: 0 !important;
  height: 100% !important;
  display: grid !important;
  grid-template-rows: auto minmax(0, 1fr) !important;
}

body.sov-theme-hub .frame-stage {
  position: relative !important;
  min-height: 0 !important;
  height: 100% !important;
}

body.sov-theme-hub #theme-frame {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  border: 0 !important;
  display: block !important;
}

/* === TABLET / MEDIUM (≤1100px): scroll layout === */
@media (max-width: 1100px) {
  body.sov-theme-hub {
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }

  body.sov-theme-hub .site-shell {
    position: relative !important;
    inset: auto !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100svh !important;
    overflow: visible !important;
    /* grid still works because explicit row heights below */
    grid-template-rows: auto 80svh !important;
  }

  body.sov-theme-hub .stage-shell {
    height: 80svh !important;
    min-height: 80svh !important;
    display: block !important;
  }

  body.sov-theme-hub .browser-frame {
    height: 100% !important;
    min-height: 80svh !important;
    display: grid !important;
    grid-template-rows: auto minmax(0, 1fr) !important;
  }

  body.sov-theme-hub .frame-stage {
    height: 100% !important;
    min-height: 0 !important;
  }

  body.sov-theme-hub #theme-frame {
    position: absolute !important;
    inset: 0 !important;
    height: 100% !important;
    width: 100% !important;
  }
}

/* === MOBILE (≤720px): bottom-fixed tabs === */
@media (max-width: 720px) {
  body.sov-theme-hub .site-shell {
    padding-bottom: calc(5rem + env(safe-area-inset-bottom)) !important;
    grid-template-rows: auto 76svh !important;
  }

  body.sov-theme-hub .stage-shell {
    height: 76svh !important;
    min-height: 76svh !important;
  }

  body.sov-theme-hub .browser-frame {
    min-height: 76svh !important;
  }
}

/* === SMALL MOBILE (≤460px) === */
@media (max-width: 460px) {
  body.sov-theme-hub .browser-frame__chrome {
    display: none !important;
  }

  body.sov-theme-hub .site-shell {
    grid-template-rows: auto 78svh !important;
  }

  body.sov-theme-hub .stage-shell {
    height: 78svh !important;
    min-height: 78svh !important;
  }

  body.sov-theme-hub .browser-frame {
    min-height: 78svh !important;
  }
}

/* === Topbar responsive grid === */
body.sov-theme-hub .switcher-topbar {
  grid-template-columns: minmax(13rem, auto) minmax(0, 1fr) auto !important;
}

@media (max-width: 1100px) {
  body.sov-theme-hub .switcher-topbar {
    grid-template-columns: auto 1fr auto !important;
  }
}

@media (max-width: 720px) {
  body.sov-theme-hub .switcher-topbar {
    grid-template-columns: auto 1fr auto !important;
    padding: .5rem .65rem !important;
    border-radius: .9rem !important;
  }
}
