/* RETTIX Studio v0.5.147 - fixed navigation, main-only scrolling.
   Overrides the v0.5.146 sidebar overflow regression without changing
   Story Studio, ComfyUI, agent or project logic. */
@media (min-width: 821px) {
  html, body {
    height: 100%;
    overflow: hidden;
  }
  #login.login-shell:not(.hidden) {
    height: 100dvh;
    min-height: 0;
    overflow-y: auto;
  }
  #app.app-shell:not(.hidden) {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  #app.app-shell > .sidebar {
    position: relative;
    top: auto;
    left: auto;
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
    padding: 13px 12px 9px;
    overflow: hidden;
    overscroll-behavior: none;
  }
  #app.app-shell > .sidebar .logo-row {
    flex: 0 0 auto;
    padding: 2px 6px 10px;
  }
  #app.app-shell > .sidebar #nav {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    min-height: 0;
    gap: 1px;
    overflow: hidden;
    width: 100%;
  }
  #app.app-shell > .sidebar #nav button {
    flex: 0 0 auto;
    min-height: 0;
    padding: 7px 7px;
    line-height: 1.2;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #app.app-shell > .sidebar .sidebar-foot {
    flex: 0 0 auto;
    margin-top: auto;
    padding: 9px 7px 0;
  }
  #app.app-shell > .main {
    min-width: 0;
    min-height: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
  }
}
@media (min-width: 821px) and (max-height: 820px) {
  #app.app-shell > .sidebar { padding: 9px 9px 7px; }
  #app.app-shell > .sidebar .logo-row { padding: 0 5px 5px; }
  #app.app-shell > .sidebar #nav { gap: 0; }
  #app.app-shell > .sidebar #nav button {
    padding: 5px 6px;
    font-size: 11px;
    line-height: 1.15;
  }
  #app.app-shell > .sidebar .sidebar-foot { padding: 5px 5px 0; }
}
@media (min-width: 821px) and (max-height: 620px) {
  #app.app-shell:not(.hidden) {
    grid-template-columns: 280px minmax(0, 1fr);
  }
  #app.app-shell > .sidebar { padding: 5px 7px; }
  #app.app-shell > .sidebar .logo-row { padding: 0 4px 1px; }
  #app.app-shell > .sidebar #nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: min-content;
    gap: 1px;
    align-content: start;
  }
  #app.app-shell > .sidebar #nav button {
    display: flex;
    gap: 4px;
    padding: 5px 4px;
    font-size: 10px;
    line-height: 1.1;
  }
  #app.app-shell > .sidebar #nav button span {
    width: 15px;
    flex: 0 0 15px;
    font-size: 9px;
  }
  #app.app-shell > .sidebar .sidebar-foot {
    margin-top: auto;
    padding: 4px 4px 0;
  }
}
@media (max-width: 820px) {
  html, body {
    height: auto;
    min-height: 100%;
    overflow-y: auto;
  }
  #app.app-shell:not(.hidden) {
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  #app.app-shell > .main {
    height: auto;
    max-height: none;
    min-height: 100dvh;
    overflow: visible;
  }
  #app.app-shell > .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  #app.app-shell > .sidebar #nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
  }
}

/* Restore full desktop labels in the legacy 821-1050px compact breakpoint. */
@media (min-width: 821px) and (max-width: 1050px) {
  #app.app-shell > .sidebar .logo-row > div:last-child,
  #app.app-shell > .sidebar .logo-row strong,
  #app.app-shell > .sidebar .logo-row span,
  #app.app-shell > .sidebar .sidebar-foot span,
  #app.app-shell > .sidebar .sidebar-foot .text-btn {
    display: block;
  }
  #app.app-shell > .sidebar #nav button {
    justify-content: flex-start;
  }
}
