/* Sidebar override — scoped to the signed-in studio; login keeps its full canvas. */
body.studio-authenticated {
  --studio-sidebar-width: 220px;
}
body.studio-authenticated .site-header {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 28px;
  width: var(--studio-sidebar-width);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  padding: 28px 16px 18px;
  border: 0;
  border-right: 1px solid var(--line);
  background: #10100f;
  z-index: 50;
  overflow: hidden;
}
body.studio-authenticated .site-header > .brand {
  min-height: 40px;
  gap: 9px;
  padding: 0 5px;
  flex-shrink: 0;
}
body.studio-authenticated .site-header > .brand span {
  font-size: 10px;
  letter-spacing: .1em;
}
body.studio-authenticated .site-header > .brand .brand-mark {
  flex-shrink: 0;
}
body.studio-authenticated .site-header .nav,
body.studio-authenticated .site-header .primary-nav {
  position: static;
  inset: auto;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  align-items: stretch;
  align-self: stretch;
  gap: 5px;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 2px 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: transparent;
  border: 0;
  box-shadow: none;
}
body.studio-authenticated .site-header .nav a {
  position: relative;
  flex-shrink: 0;
  gap: 10px;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--muted);
}
body.studio-authenticated .site-header .nav a:hover {
  background: #1a1a18;
  color: var(--text);
}
body.studio-authenticated .site-header .nav a.active {
  background: #232320;
  border-color: #373730;
  color: var(--text);
}
body.studio-authenticated .site-header .nav a.active::before {
  content: "";
  position: absolute;
  top: 12px;
  bottom: 12px;
  left: -1px;
  width: 2px;
  background: var(--accent);
  border-radius: 2px;
}
body.studio-authenticated .site-header .nav a.active::after {
  display: none;
}
body.studio-authenticated .site-header .nav a > .icon {
  display: inline-block;
  width: 16px;
  height: 16px;
}
body.studio-authenticated .site-header .nav .counter {
  display: inline-block;
  margin-left: auto;
}
body.studio-authenticated .site-header .nav a:focus-visible {
  outline-offset: -3px;
}
body.studio-authenticated .site-header .header-end {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin: 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
body.studio-authenticated .site-header .header-end > [data-action="logout"] {
  justify-content: flex-start;
  width: 100%;
  min-height: 44px;
  padding-inline: 14px;
  color: var(--muted);
}
body.studio-authenticated .site-header .menu-toggle {
  display: none;
}
body.studio-authenticated .workspace {
  width: calc(100% - var(--studio-sidebar-width));
  min-width: 0;
  min-height: 100vh;
  margin: 0 0 0 var(--studio-sidebar-width);
}
body.studio-authenticated #topbar {
  min-height: 62px;
  padding: 10px clamp(24px, 3vw, 48px);
}
body.studio-authenticated #main {
  min-width: 0;
  min-height: calc(100vh - 138px);
  padding: 36px clamp(24px, 3vw, 48px) 48px;
}
body.studio-authenticated .workspace > footer {
  padding-inline: clamp(24px, 3vw, 48px);
}
#sidebar-toggle,
#sidebar-scrim {
  display: none;
}
body:not(.studio-authenticated) .workspace {
  width: 100%;
  margin-left: 0;
}
body:not(.studio-authenticated) #sidebar-toggle,
body:not(.studio-authenticated) #sidebar-scrim {
  display: none !important;
}
@media (min-width: 761px) and (max-width: 1050px) {
  body.studio-authenticated { --studio-sidebar-width: 200px; }
  body.studio-authenticated .site-header { padding-inline: 12px; }
  body.studio-authenticated #main { padding-inline: 24px; }
  body.studio-authenticated .connection-grid { grid-template-columns: minmax(0, 1fr); }
  body.studio-authenticated .settings-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; }
}
@media (max-width: 760px) {
  body.studio-authenticated .site-header {
    width: min(286px, calc(100vw - 56px));
    padding: max(70px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
    gap: 24px;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform .18s ease, visibility .18s;
    box-shadow: none;
  }
  body.studio-authenticated .site-header.open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
    box-shadow: 18px 0 50px #0007;
  }
  body.studio-authenticated .site-header > .brand span { font-size: 11px; }
  body.studio-authenticated .site-header .nav a { font-size: 14px; min-height: 48px; }
  body.studio-authenticated .workspace {
    width: 100%;
    min-height: 100vh;
    margin-left: 0;
  }
  body.studio-authenticated #sidebar-toggle:not([hidden]) {
    position: fixed;
    top: max(10px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    z-index: 60;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--strong);
    border-radius: 5px;
    background: #121211;
    color: var(--text);
    font-size: 20px;
    line-height: 1;
    box-shadow: 0 2px 10px #0003;
  }
  body.studio-authenticated #sidebar-scrim:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 45;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #0009;
    touch-action: manipulation;
  }
  body.studio-authenticated #topbar {
    min-height: 64px;
    padding: max(10px, env(safe-area-inset-top)) 16px 10px 70px;
    gap: 10px;
  }
  body.studio-authenticated #topbar .breadcrumb { min-width: 0; }
  body.studio-authenticated #topbar .breadcrumb strong { overflow-wrap: anywhere; }
  body.studio-authenticated #topbar .top-actions { flex-shrink: 0; }
  body.studio-authenticated #main { padding: 27px 20px 32px; }
  body.studio-authenticated .workspace > footer { padding-inline: 20px; }
}
@media (max-width: 380px) {
  body.studio-authenticated #main { padding-inline: 15px; }
  body.studio-authenticated #topbar { padding-right: 10px; gap: 6px; }
  body.studio-authenticated #topbar [data-action="refresh"] { padding-inline: 6px; font-size: 11px; }
}
@media (prefers-reduced-motion: reduce) {
  body.studio-authenticated .site-header { transition: none; }
}
