.sidebar-shell {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: none;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-top {
  padding: var(--sidebar-top-padding);
}

.brand {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-8);
  padding: var(--sidebar-brand-padding);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-toggle {
  position: relative;
  z-index: 2;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-gray-800);
  border-radius: var(--r-md);
  width: var(--sidebar-toggle-size);
  height: var(--sidebar-toggle-size);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-toggle--top {
  margin: 10px 12px 0 auto;
}

.sidebar-toggle:hover {
  border-color: var(--color-gray-400);
}

.sidebar-toggle__icon {
  display: inline-flex;
}

.sidebar-toggle__icon--expand {
  display: none;
}

.brand__icon {
  color: var(--color-primary);
  width: var(--sidebar-brand-icon-size);
  height: var(--sidebar-brand-icon-size);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand__text {
  display: grid;
  gap: 2px;
}

.brand__text strong {
  font-size: var(--text-2xl);
  line-height: 1;
}

.brand__text small {
  color: var(--color-text-muted);
  font-size: var(--text-base);
}

.sidebar-nav {
  padding-top: var(--space-6);
  display: grid;
  gap: 2px;
}

.sidebar-nav__group {
  margin: 14px 0 6px;
  padding: 0 var(--sidebar-item-padding-x);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.sidebar-nav__group:first-child {
  margin-top: 8px;
}

.sidebar-nav__item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: var(--space-6);
  padding: var(--sidebar-item-padding-y) var(--sidebar-item-padding-x);
  border-radius: var(--r-lg);
  color: var(--color-gray-900);
  transition: background 160ms ease, color 160ms ease;
}

.sidebar-nav__item:hover {
  background: var(--bg-blue-subtle);
  color: var(--color-primary);
}

.sidebar-nav__item.is-active {
  background: var(--gradient-primary);
  color: var(--color-surface);
  box-shadow: 0 6px 14px rgba(37, 99, 235, 0.24);
}

.sidebar-nav__item .icon {
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-nav__label {
  font-size: var(--text-base3);
  font-weight: 600;
}

.sidebar-bottom {
  padding: var(--sidebar-bottom-padding);
  border-top: 1px solid var(--color-border);
  display: grid;
  gap: 12px;
}

.dev-context-switcher {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--r-lg);
  background: var(--color-gray-50);
}

.dev-context-switcher__head {
  display: grid;
  gap: 2px;
}

.dev-context-switcher__head strong {
  font-size: var(--text-base3);
}

.dev-context-switcher__head small {
  color: var(--color-text-muted);
  font-size: var(--text-sm2);
}

.dev-context-switcher__form {
  display: grid;
  gap: 8px;
}

.dev-context-switcher__field {
  display: grid;
  gap: 6px;
}

.dev-context-switcher__field span {
  color: var(--color-text-muted);
  font-size: var(--text-sm2);
  font-weight: 600;
}

.dev-context-switcher__select {
  width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--color-surface);
  color: var(--color-gray-900);
  font: inherit;
}

.dev-context-switcher__button {
  border: none;
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--gradient-primary);
  color: var(--color-surface);
  font-weight: 700;
  cursor: pointer;
}

.dev-context-switcher__button:hover {
  filter: brightness(1.02);
}

.profile-card {
  border: none;
  border-radius: 0;
  background: var(--color-surface);
}

.profile-card__main {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  padding: 10px 2px 8px;
  color: inherit;
  text-decoration: none;
}

.profile-card__avatar {
  width: var(--sidebar-avatar-size);
  height: var(--sidebar-avatar-size);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm2);
  font-weight: 700;
  color: var(--color-surface);
  background: var(--gradient-primary);
}

.profile-card__meta {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.profile-card__meta strong {
  font-size: var(--text-base3);
}

.profile-card__meta small {
  color: var(--color-text-muted);
  font-size: var(--text-sm2);
}

.profile-card__plan {
  font-size: var(--text-base4);
}

.profile-card__quota {
  color: var(--color-gray-700);
}

.profile-card__chevron {
  margin-left: auto;
  color: var(--color-text-muted);
  display: inline-flex;
}

.profile-card__logout {
  border: none;
  border-top: 0;
  width: 100%;
  padding: 10px 2px 2px;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--color-gray-800);
  cursor: pointer;
}

.profile-card__logout:hover {
  color: var(--color-primary);
  background: var(--color-gray-50);
}

@media (min-width: 1200px) {
  body.is-sidebar-collapsed .sidebar-top {
    padding: 10px;
  }

  body.is-sidebar-collapsed .brand {
    padding: 14px 0 12px;
    border-bottom: 1px solid var(--color-border);
  }

  body.is-sidebar-collapsed .brand__text {
    display: none;
  }

  body.is-sidebar-collapsed .sidebar-toggle {
    width: 42px;
    height: 42px;
  }

  body.is-sidebar-collapsed .sidebar-toggle--top {
    margin: 10px auto 0;
  }

  body.is-sidebar-collapsed .sidebar-toggle__icon--collapse {
    display: none;
  }

  body.is-sidebar-collapsed .sidebar-toggle__icon--expand {
    display: inline-flex;
  }

  body.is-sidebar-collapsed .sidebar-nav__item {
    grid-template-columns: 1fr;
    justify-items: center;
    padding: 12px 0;
  }

  body.is-sidebar-collapsed .sidebar-nav__label {
    display: none;
  }

  body.is-sidebar-collapsed .sidebar-nav__group {
    display: none;
  }

  body.is-sidebar-collapsed .sidebar-bottom {
    padding: 10px;
  }

  body.is-sidebar-collapsed .dev-context-switcher {
    display: none;
  }

  body.is-sidebar-collapsed .profile-card__meta {
    display: none;
  }

  body.is-sidebar-collapsed .profile-card__chevron {
    display: none;
  }

  body.is-sidebar-collapsed .profile-card__main {
    justify-content: center;
  }

  body.is-sidebar-collapsed .profile-card__logout {
    justify-content: center;
  }

  body.is-sidebar-collapsed .profile-card__logout span:last-child {
    display: none;
  }
}
