/* Public section navigation. Keep layout rules scoped to this shell. */
.sidebar.app-navigation {
  width: 252px;
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  padding: 20px 18px 14px;
  background: #202330;
  color: #bbc0d3;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  z-index: 10;
}
.app-navigation[hidden], .navigation-mobile-bar[hidden],
.navigation-backdrop[hidden], .navigation-close[hidden] { display: none; }
.app-navigation > * { flex-shrink: 0; }
.app-navigation .brand {
  width: 186px;
  max-width: 100%;
  margin: 0 0 15px;
  padding: 7px 9px;
  gap: 3px;
  border-radius: 10px;
}
.app-navigation .brand .brand-wordmark { width: 159px; height: auto; }
.app-navigation .brand .brand-caption { font-size: 10px; line-height: 14px; margin-left: 3px; }
.app-navigation .navigation-groups {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 13px;
  margin: 0 0 12px;
  padding: 0;
  overflow: visible;
}
.app-navigation .navigation-group { display: grid; gap: 0; margin: 0; min-width: 0; }
.app-navigation .navigation-group h2 {
  margin: 0 0 5px 12px;
  font-size: 10px;
  line-height: 14px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #a3a9bc;
  font-weight: 650;
}
.app-navigation .navigation-link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  min-width: 0;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 9px;
  font-size: 13px;
  line-height: 20px;
  font-weight: 600;
  white-space: normal;
  transition: background .18s, color .18s;
}
.app-navigation .navigation-link span { min-width: 0; overflow-wrap: anywhere; }
.app-navigation .navigation-link .icon { width: 20px; height: 20px; }
.app-navigation .navigation-link:hover { background: #2b2d41; color: #fff; }
.app-navigation .navigation-link[aria-current="page"] {
  background: #3b3256;
  color: #e7ddff;
  box-shadow: inset 3px 0 #b399ff;
}
.app-navigation .navigation-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 10px;
  margin-top: auto;
  padding: 10px 10px 0;
  border-top: 1px solid #393b4b;
  color: #bbc0d3;
  font-size: 11px;
  line-height: 18px;
}
.app-navigation .navigation-footer a { padding: 3px 0; }
.app-navigation .navigation-footer a:hover { color: #fff; }
.app-navigation a:focus-visible, .app-navigation button:focus-visible,
.navigation-mobile-bar a:focus-visible, .navigation-mobile-bar button:focus-visible {
  outline: 3px solid #b7a5ff;
  outline-offset: 2px;
}
.workspace.navigation-workspace { margin-left: 252px; }
.navigation-mobile-bar, .navigation-backdrop, .navigation-close { display: none; }

/* Ten links stay in one column at a 600 px desktop height. */
@media (min-width: 721px) and (max-height: 700px) {
  .sidebar.app-navigation { padding: 12px 18px; }
  .app-navigation .brand { margin-bottom: 10px; padding: 6px 9px; }
  .app-navigation .brand .brand-wordmark { width: 136px; }
  .app-navigation .navigation-groups { gap: 8px; margin-bottom: 8px; }
  .app-navigation .navigation-group h2 { margin-bottom: 4px; }
  .app-navigation .navigation-link { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
  .app-navigation .navigation-footer { padding-top: 8px; }
}

/* Short desktop windows trade a little width for two visible columns. */
@media (min-width: 721px) and (max-height: 580px) {
  .sidebar.app-navigation { width: 288px; padding: 12px 16px; }
  .workspace.navigation-workspace { margin-left: 288px; }
  .app-navigation .brand { width: 144px; margin-bottom: 10px; padding: 5px 10px; }
  .app-navigation .brand .brand-wordmark { width: 124px; }
  .app-navigation .brand .brand-caption { display: none; }
  .app-navigation .navigation-group { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 5px; }
  .app-navigation .navigation-group h2 { grid-column: 1 / -1; margin: 0 0 2px 7px; }
  .app-navigation .navigation-link { min-height: 40px; padding: 6px 7px; font-size: 12px; line-height: 17px; gap: 7px; }
  .app-navigation .navigation-link .icon { width: 17px; height: 17px; }
}

@media (max-width: 720px) {
  .workspace.navigation-workspace { margin-left: 0; }
  .navigation-workspace > .topbar { flex-wrap: wrap; }
  .navigation-workspace > .topbar .topbar-title { min-width: min-content; }
  .navigation-workspace > .topbar .topbar-meta { max-width: 100%; flex-wrap: wrap; }
  /* Without JavaScript the full menu remains part of the document. */
  .sidebar.app-navigation {
    position: relative;
    inset: auto;
    width: auto;
    max-height: none;
    padding: 17px 16px 15px;
    overflow: visible;
  }
  .app-navigation .brand { width: 154px; margin-bottom: 15px; padding: 5px 10px; }
  .app-navigation .brand .brand-wordmark { width: 134px; }
  .app-navigation .brand .brand-caption { display: none; }
  .app-navigation .navigation-groups { gap: 12px; margin-bottom: 12px; }
  .app-navigation .navigation-group { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px 8px; }
  .app-navigation .navigation-group h2 { grid-column: 1 / -1; margin: 0 0 3px 6px; }
  .app-navigation .navigation-link { min-height: 44px; padding: 6px 8px; gap: 8px; font-size: 12px; line-height: 17px; }
  .app-navigation .navigation-link .icon { width: 17px; height: 17px; }
  .app-navigation .navigation-footer { padding-top: 9px; margin-top: 0; }
  .navigation-mobile-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 70px;
    padding: 10px 18px;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }
  .navigation-mobile-brand { display: block; flex: 0 1 136px; min-width: 80px; }
  .navigation-mobile-brand img { display: block; width: 136px; height: auto; }
  .navigation-toggle {
    display: flex;
    flex: none;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #dedbe7;
    border-radius: 9px;
    background: #fff;
    color: #59457c;
    font-size: 12px;
    line-height: 20px;
  }
  .navigation-toggle .icon { width: 18px; height: 18px; }
  .navigation-enhanced .app-navigation {
    position: fixed;
    z-index: 50;
    inset: 12px 12px auto;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    overflow-x: hidden;
    overflow-y: auto;
    border-radius: 16px;
    box-shadow: 0 15px 50px #20233040;
  }
  .navigation-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 49;
    background: #14132685;
  }
  .navigation-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 20px;
    right: 16px;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid #59566d;
    border-radius: 9px;
    background: #2b2b40;
    color: #fff;
  }
}
@media (prefers-reduced-motion: reduce) {
  .app-navigation .navigation-link { transition: none; }
}
