/* BioStudio AI — phone + tablet compact shell.
   iOS compact keeps the existing iOS tokens. Windows/Android compact gets a
   Windows 11-inspired shell. Tablet adds split views and denser app grids. */

#os.shell-mobile {
  --compact-tab-h: calc(52px + env(safe-area-inset-bottom, 0px));
}

#os.shell-compact-win {
  --ios-accent: #2f6bff;
  --ios-bg: #f3f3f3;
  --ios-grouped: #ffffff;
  --ios-separator: rgba(0, 0, 0, 0.08);
  --ios-label: #1b1b1f;
  --ios-secondary: #5d6470;
  --ios-nav-h: 48px;
  --ios-touch: 44px;
  --ios-radius: 8px;
  --ios-sheet-radius: 12px;
  --ios-tab-h: var(--compact-tab-h);
  --ios-status-h: env(safe-area-inset-top, 0px);
  --font: "Segoe UI Variable Text", "Segoe UI", "Roboto", system-ui, sans-serif;
  --accent: var(--ios-accent);
  background: var(--ios-bg);
  color: var(--ios-label);
  font-family: var(--font);
  -webkit-font-smoothing: auto;
}

#os.shell-compact-win.dark {
  --ios-bg: #1c1c1c;
  --ios-grouped: #2c2c2c;
  --ios-separator: rgba(255, 255, 255, 0.1);
  --ios-label: #f3f3f5;
  --ios-secondary: #a9b0bd;
}

#os.shell-compact-win .mobile-tab-bar {
  background: rgba(243, 243, 243, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--ios-separator);
}

#os.shell-compact-win.dark .mobile-tab-bar {
  background: rgba(32, 32, 32, 0.96);
}

#os.shell-compact-win .mobile-tab.active {
  color: var(--ios-accent);
}

#os.shell-compact-win .mobile-app-tile-icon {
  border-radius: 12px;
}

#os.shell-compact-win .mobile-stack-nav {
  background: var(--ios-grouped);
}

#os.shell-compact-win .mobile-apps-title {
  font-size: 28px;
  letter-spacing: -0.02em;
}

/* Phone app grid */
#os.shell-phone .mobile-apps-grid {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 360px) {
  #os.shell-phone .mobile-apps-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Tablet app library */
#os.shell-tablet .mobile-apps-pane {
  padding: 16px 24px calc(var(--ios-tab-h) + 20px);
}

#os.shell-tablet .mobile-apps-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 18px 12px;
}

#os.shell-tablet .mobile-app-tile-icon {
  width: 68px;
  height: 68px;
  border-radius: 16px;
}

#os.shell-tablet .mobile-app-tile-label {
  font-size: 12px;
  max-width: 88px;
}

@media (min-width: 1100px) {
  #os.shell-tablet .mobile-apps-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

/* Windows/Android tablet: left app rail in landscape */
@media (orientation: landscape) and (min-width: 900px) {
  #os.shell-tablet.shell-compact-win .mobile-shell {
    flex-direction: row;
  }

  #os.shell-tablet.shell-compact-win .mobile-tab-bar {
    flex: 0 0 84px;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    height: auto;
    width: 84px;
    padding: 10px 6px max(10px, env(safe-area-inset-bottom));
    border-top: none;
    border-right: 1px solid var(--ios-separator);
    order: -1;
  }

  #os.shell-tablet.shell-compact-win .mobile-tab {
    min-height: 64px;
    padding: 8px 4px;
  }

  #os.shell-tablet.shell-compact-win .mobile-apps-pane,
  #os.shell-tablet.shell-compact-win .mobile-stack-body,
  #os.shell-tablet.shell-compact-win .mobile-stack-nav {
    padding-bottom: 0;
  }

  #os.shell-tablet.shell-compact-win .mobile-apps-pane {
    padding: 16px 24px 24px;
  }
}

/* Tablet messages: keep master-detail instead of a stacked push. */
#os.shell-tablet .msg-root {
  grid-template-columns: minmax(260px, 36%) minmax(0, 1fr) !important;
  position: relative;
}

#os.shell-tablet .msg-left {
  width: auto;
  border-right: 1px solid var(--ios-separator, rgba(0, 0, 0, 0.08));
}

#os.shell-tablet .msg-right {
  position: relative !important;
  inset: auto !important;
  transform: none !important;
  background: var(--ios-grouped, #fff);
}

#os.shell-tablet .msg-back {
  display: none;
}

/* Tablet studios keep sidebars; phone studios stay stacked. */
#os.shell-tablet .studio.studio-tablet .st-sidebar,
#os.shell-tablet .studio.studio-tablet .st-inspector,
#os.shell-tablet .studio.studio-tablet .st-ai {
  display: flex;
}

#os.shell-tablet .studio.studio-tablet .st-mobile-bar {
  display: none;
}

@media (max-width: 900px) and (orientation: portrait) {
  #os.shell-tablet .studio.studio-tablet .st-sidebar,
  #os.shell-tablet .studio.studio-tablet .st-inspector,
  #os.shell-tablet .studio.studio-tablet .st-ai {
    display: none !important;
  }
  #os.shell-tablet .studio.studio-tablet .st-mobile-bar {
    display: flex;
  }
}

#os.shell-mobile .window-body,
#os.shell-mobile .mobile-apps-pane,
#os.shell-mobile .mobile-stack-body {
  overscroll-behavior: contain;
}

#os.shell-mobile input,
#os.shell-mobile select,
#os.shell-mobile textarea {
  font-size: 16px;
}

#os.shell-mobile .toast-layer {
  right: 12px;
  left: 12px;
  bottom: calc(var(--ios-tab-h, 52px) + 12px);
  align-items: stretch;
}

#os.shell-mobile .toast {
  width: auto;
  max-width: none;
}

#os.shell-tablet .toast-layer {
  left: auto;
  width: min(380px, calc(100vw - 24px));
}
