.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-3);
}

.app-banner {
  padding: var(--space-2);
  margin-bottom: var(--space-2);
}

.app-layout {
  display: grid;
  grid-template-columns: 304px 1fr;
  gap: var(--space-3);
  align-items: start;
}

.sidebar-toggle {
  display: none;
  margin-bottom: var(--space-2);
}

.sidebar-backdrop {
  display: none;
  pointer-events: none;
}

.app-sidebar {
  position: sticky;
  top: var(--space-3);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - (var(--space-3) * 2));
  min-height: 560px;
  padding: 14px;
  color: #f3f8fc;
  border: 1px solid #0f4f6b;
  border-radius: 20px;
  background:
    radial-gradient(circle at 90% -10%, rgba(124, 216, 210, 0.34), transparent 38%),
    radial-gradient(circle at -18% 20%, rgba(106, 185, 255, 0.28), transparent 42%),
    linear-gradient(165deg, #0f3146 0%, #0f4f6b 52%, #115a72 100%);
  box-shadow:
    0 18px 35px rgba(12, 43, 65, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

@supports (height: 100dvh) {
  .app-sidebar {
    max-height: calc(100dvh - (var(--space-3) * 2));
  }
}

.sb-scroll {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  gap: 12px;
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.sb-scroll::-webkit-scrollbar {
  width: 9px;
}

.sb-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(204, 237, 255, 0.35);
  border: 2px solid transparent;
  background-clip: padding-box;
}

.sb-group {
  border: 1px solid rgba(206, 236, 255, 0.2);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.06));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  overflow: clip;
}

.sb-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 12px;
  cursor: pointer;
  user-select: none;
  color: #dcf2ff;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  border-bottom: 1px solid transparent;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}

.sb-summary::-webkit-details-marker {
  display: none;
}

.sb-summary::marker {
  content: "";
}

.sb-summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid rgba(220, 242, 255, 0.88);
  border-bottom: 2px solid rgba(220, 242, 255, 0.88);
  transform: rotate(45deg);
  transition: transform 150ms ease, border-color 150ms ease;
}

.sb-group[open] .sb-summary {
  background: rgba(9, 31, 44, 0.33);
  border-bottom-color: rgba(208, 236, 255, 0.2);
  color: #ffffff;
}

.sb-group[open] .sb-summary::after {
  transform: rotate(-135deg);
  border-color: #f1fbff;
}

.sb-summary:hover {
  background: rgba(14, 51, 72, 0.34);
}

.sb-summary-label {
  min-width: 0;
}

.sb-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(214, 239, 255, 0.42);
  background: rgba(231, 247, 255, 0.24);
  color: #f7fdff;
  font-size: 0.75rem;
  line-height: 1;
}

.sb-links {
  display: grid;
  gap: 7px;
  padding: 9px;
}

.app-sidebar .nav-link.sb-link {
  position: relative;
  display: block;
  padding: 9px 10px 9px 13px;
  border: 1px solid rgba(203, 233, 251, 0.32);
  border-radius: 10px;
  text-decoration: none;
  color: #f4fbff;
  background: rgba(245, 252, 255, 0.09);
  transition: transform 130ms ease, border-color 130ms ease, background 130ms ease;
}

.app-sidebar .nav-link.sb-link:hover {
  transform: translateX(2px);
  border-color: rgba(228, 246, 255, 0.64);
  background: rgba(249, 253, 255, 0.18);
}

.app-sidebar .nav-link.sb-link.active {
  border-color: #f0faff;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(115deg, #1c9f94 0%, #1ea08f 42%, #217fb0 100%);
  box-shadow: 0 8px 16px rgba(9, 28, 43, 0.32);
}

.app-sidebar .nav-link.sb-link.active::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.94);
}

.sb-summary:focus-visible,
.app-sidebar .nav-link.sb-link:focus-visible,
.sidebar-toggle:focus-visible {
  outline: 2px solid #9ce4ff;
  outline-offset: 2px;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(222, 241, 254, 0.22);
}

.app-sidebar .sb-link-logout {
  border-color: rgba(255, 210, 205, 0.58);
  color: #fff5f3;
  background: linear-gradient(120deg, rgba(181, 70, 58, 0.52), rgba(116, 38, 33, 0.44));
}

.app-sidebar .sb-link-logout:hover {
  border-color: rgba(255, 223, 220, 0.88);
  background: linear-gradient(120deg, rgba(203, 86, 70, 0.58), rgba(134, 46, 39, 0.5));
}

.app-main {
  min-width: 0;
}

.app-main-anon {
  margin-top: var(--space-2);
}

@media (max-width: 980px) {
  .app-shell {
    padding: var(--space-2);
  }

  .sidebar-toggle {
    display: inline-block;
  }

  .app-layout {
    display: block;
  }

  .app-sidebar {
    position: relative;
    top: 0;
    max-height: none;
    min-height: 0;
    overflow: visible;
    margin-bottom: var(--space-2);
  }

  .app-main {
    width: 100%;
  }

  .js-sidebar-ready .app-layout {
    position: relative;
  }

  .js-sidebar-ready .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: min(88vw, 344px);
    height: 100vh;
    margin: 0;
    border-radius: 0;
    z-index: 40;
    transform: translateX(-106%);
    transition: transform 180ms ease;
    max-height: none;
    overflow: hidden;
  }

  @supports (height: 100dvh) {
    .js-sidebar-ready .app-sidebar {
      height: 100dvh;
    }
  }

  .js-sidebar-ready .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(6, 19, 31, 0.5);
    z-index: 30;
  }

  .js-sidebar-ready .app-layout.sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .js-sidebar-ready .app-layout.sidebar-open .sidebar-backdrop {
    display: block;
    pointer-events: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sb-summary,
  .sb-summary::after,
  .app-sidebar .nav-link.sb-link,
  .js-sidebar-ready .app-sidebar {
    transition: none !important;
  }
}

body.sidebar-lock {
  overflow: hidden;
}
