.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  width: 100%;
}

.app-frame {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  width: 100%;
  z-index: 0;
}

.sidebar-sticky {
  display: flex;
  flex-direction: row;
  flex-shrink: 0;
  height: 100vh;
  height: 100dvh;
  position: sticky;
  top: 0;
  z-index: 10;
}

.desktop-sidebar {
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  height: 100%;
  overflow: visible;
  position: relative;
  width: 3.25rem;
  z-index: 20;
}

.desktop-sidebar[open] {
  overflow: hidden;
  width: 16rem;
}

@media (prefers-reduced-motion: no-preference) {
  .desktop-sidebar {
    transition: width 300ms ease-in-out;
  }
}

@media (max-width: 767px) {
  .desktop-sidebar {
    display: none;
  }
}

.desktop-sidebar[open] .sidebar-collapsed {
  display: none;
}

.sidebar-collapsed {
  cursor: e-resize;
  display: flex;
  flex-direction: column;
  height: 100%;
  list-style: none;
  padding-left: 0.5rem;
  padding-right: 0.375rem;
}

.sidebar-collapsed-header {
  align-items: center;
  display: flex;
  height: 3.25rem;
  justify-content: flex-start;
  width: 100%;
}

.sidebar-collapsed-nav {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  margin-top: 0.5rem;
  width: 100%;
}

.sidebar-panel {
  background: var(--surface-muted);
  color: var(--text);
  height: 100%;
  overflow-x: clip;
  overflow-y: auto;
  text-overflow: clip;
  white-space: nowrap;
  width: 16rem;
}

.sidebar-nav {
  display: flex;
  flex: 1;
  flex-direction: column;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-y: auto;
  position: relative;
  user-select: none;
  width: 100%;
}

.sidebar-nav-header {
  background: var(--surface-muted);
  position: sticky;
  top: 0;
  z-index: 30;
}

.sidebar-nav-header-inner {
  padding-left: 0.375rem;
  padding-right: 0.375rem;
}

@media (min-width: 640px) {
  .sidebar-nav-header-inner {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
}

.sidebar-header-row {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  height: 3.25rem;
  justify-content: space-between;
  width: 100%;
}

.sidebar-nav-section {
  background: var(--surface-muted);
  padding: 0.375rem;
  position: relative;
}

.sidebar-nav-section:last-child {
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .sidebar-nav-section {
    padding: 0.5rem;
  }
}

.sidebar-footer {
  background: var(--surface-muted);
  bottom: 0;
  padding: 0.375rem;
  position: sticky;
  z-index: 30;
}

.sidebar-footer:empty {
  display: none;
}

@media (min-width: 640px) {
  .sidebar-footer {
    padding: 0.5rem;
  }
}

.sidebar-footer-collapsed {
  align-items: flex-start;
  background: var(--surface-muted);
  bottom: 0;
  display: flex;
  flex-direction: column;
  margin-top: auto;
  padding-bottom: 0.5rem;
  padding-top: 0.5rem;
  position: sticky;
  z-index: 30;
}

.sidebar-footer-collapsed:empty {
  display: none;
}

.sidebar-footer-collapsed form {
  margin: 0;
}

.sidebar-spacer {
  flex-grow: 1;
}

.sidebar-icon-button,
.mobile-menu-button {
  align-items: center;
  border-radius: var(--radius-lg);
  color: var(--text-muted);
  display: flex;
  height: 2.5rem;
  justify-content: center;
  width: 2.5rem;
}

@media (min-width: 640px) {
  .sidebar-icon-button {
    height: 2.25rem;
    width: 2.25rem;
  }
}

.sidebar-icon-button:hover,
.sidebar-icon-button:focus-visible,
.mobile-menu-button:focus {
  background: var(--surface-subtle);
  color: var(--text);
  outline: none;
}

.sidebar-icon-button--open {
  cursor: e-resize;
}

.sidebar-icon-button--close {
  cursor: w-resize;
}

.sidebar-home-link {
  color: var(--text);
  flex-shrink: 0;
  padding: 0.25rem;
  width: auto;
}

.sidebar-brand-logo {
  height: 1.75rem;
  width: auto;
}

/* Sections share the same vertical rhythm in both sidebar modes so items
   don't shift when toggling: rows are 2rem, separators are 1.5rem. */
.sidebar-nav-heading {
  color: var(--text-subtle);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 0.75rem;
  padding: 0.5rem 0.5rem 0.25rem;
  text-transform: uppercase;
}

.sidebar-nav-section > .sidebar-nav-heading:first-child {
  padding-top: 0;
}

.sidebar-nav-divider {
  height: 1.5rem;
  position: relative;
  width: 2.125rem;
}

.sidebar-nav-divider::before {
  border-top: 1px solid var(--border);
  content: "";
  left: 0;
  position: absolute;
  right: 0;
  top: 50%;
}

.nav-link {
  border-radius: var(--radius-lg);
  color: var(--text);
}

.nav-link:hover,
.nav-link:focus-visible {
  background: var(--surface-subtle);
  outline: none;
}

.nav-link.active,
.nav-link.active:hover,
.nav-link.active:focus-visible {
  background: var(--indigo-50);
  color: var(--indigo-700);
}

.nav-link-collapsed {
  align-items: center;
  display: flex;
  height: 2rem;
  justify-content: center;
  width: 2.125rem;
}

.nav-link-expanded {
  align-items: center;
  display: flex;
  font-size: 0.875rem;
  gap: 0.5rem;
  justify-content: space-between;
  line-height: 1.25rem;
  padding: 0.375rem 0.5rem;
  text-align: left;
  width: 100%;
}

.nav-link-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link-leading {
  align-items: center;
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.sidebar-avatar {
  background: rgba(115, 115, 115, 0.3);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  height: 1.5rem;
  overflow: hidden;
  width: 1.5rem;
}

.sidebar-avatar--small {
  border-radius: var(--radius-sm);
  height: 1.125rem;
  width: 1.125rem;
}

.mobile-sidebar {
  inset: 0;
  position: absolute;
  z-index: 60;
}

@media (min-width: 768px) {
  .mobile-sidebar {
    display: none;
  }
}

.mobile-sidebar-backdrop {
  background: var(--surface-overlay);
  inset: 0;
  position: absolute;
}

.mobile-sidebar-panel {
  background: var(--surface-muted);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow-xl);
  left: 0;
  overflow-y: auto;
  position: absolute;
  top: 0;
  bottom: 0;
  width: 16rem;
}

@media (prefers-reduced-motion: no-preference) {
  .mobile-sidebar-backdrop {
    transition: opacity 300ms;
  }

  .mobile-sidebar-panel {
    transition: transform 300ms ease-out;
  }
}

.app-main {
  align-items: flex-start;
  background: var(--page-bg);
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: clip;
  padding: 1rem;
  padding-top: 4rem;
  position: relative;
  width: auto;
}

@media (min-width: 768px) {
  .app-main {
    padding: 1.5rem;
  }
}

.mobile-menu-bar {
  align-items: center;
  display: flex;
  padding: 0.5rem;
  position: absolute;
  top: 0;
  width: 100%;
  z-index: 10;
}

@media (min-width: 768px) {
  .mobile-menu-bar {
    display: none;
  }
}

.centered-shell {
  align-items: center;
  background: linear-gradient(180deg, var(--indigo-50) 0%, var(--surface-muted) 45%);
  display: flex;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: 1rem;
  padding-right: 1rem;
}

.narrow-panel {
  max-width: 24rem;
  width: 100%;
}

.brand-header {
  margin-bottom: 2rem;
  text-align: center;
}

.brand-logo {
  height: 6rem;
  margin: 0 auto 1rem;
  width: 6rem;
}
