@layer layout {
html {
  min-width: 320px;
  background: var(--bg-2);
  scroll-behavior: auto;
  scrollbar-gutter: stable;
}

body {
  font-family: var(--lumi-font-body);
  font-size: var(--lumi-font-size-base);
  line-height: 1.55;
  background:
    radial-gradient(circle at 8% 0%, var(--bg-1) 0, transparent 34rem),
    radial-gradient(circle at 100% 100%, var(--bg-3) 0, transparent 38rem),
    var(--bg-2);
  background-attachment: scroll;
}

.app-shell {
  grid-template-columns: var(--lumi-sidebar-expanded) minmax(0, 1fr);
}

.sidebar {
  width: var(--lumi-sidebar-expanded);
  gap: var(--lumi-space-4);
  padding: var(--lumi-space-4);
  background: color-mix(in srgb, var(--lumi-surface) 94%, transparent);
  border-color: var(--lumi-border);
  box-shadow: var(--lumi-shadow-sm);
  backdrop-filter: blur(18px);
  z-index: var(--lumi-z-navigation);
}

.sidebar-brand {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: var(--lumi-space-2);
}

.brand-link {
  min-height: 3rem;
  padding: var(--lumi-space-2);
}

.sidebar-toggle {
  align-self: center;
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--lumi-radius-pill);
  background: var(--lumi-surface-subtle);
  color: var(--lumi-text-muted);
}

.sidebar-toggle:hover {
  background: var(--lumi-surface-raised);
  color: var(--lumi-text);
}

.sidebar-nav {
  gap: var(--lumi-space-2);
  scrollbar-width: thin;
  scrollbar-color: var(--lumi-border) transparent;
}

.nav-section {
  padding: var(--lumi-space-2);
  border-radius: var(--lumi-radius-md);
  background: transparent;
}

.nav-section[open] {
  background: var(--lumi-surface-subtle);
}

.nav-section summary {
  min-height: 2.5rem;
  padding: var(--lumi-space-2);
  border-radius: var(--lumi-radius-sm);
}

.nav-section summary:hover {
  background: var(--lumi-surface-raised);
}

.nav-links {
  gap: var(--lumi-space-1);
  padding: var(--lumi-space-2) 0 0 1.75rem;
}

.nav-link {
  min-height: 2.5rem;
  padding: var(--lumi-space-2) var(--lumi-space-3);
  border: 1px solid transparent;
  border-radius: var(--lumi-radius-sm);
}

.nav-link:hover {
  border-color: var(--lumi-border);
}

.nav-link.active {
  background: color-mix(in srgb, var(--lumi-primary) 14%, var(--lumi-surface));
  border-color: color-mix(in srgb, var(--lumi-primary) 28%, var(--lumi-border));
  color: var(--lumi-text);
}

.page {
  min-width: 0;
}

.content {
  width: 100%;
  max-width: var(--lumi-content-max);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2.5rem);
  gap: var(--lumi-space-5);
}

.content.content-prose,
.content[data-content-width="prose"] { max-width: var(--lumi-content-prose); }
.content.content-form,
.content[data-content-width="form"] { max-width: var(--lumi-content-form); }
.content.content-standard,
.content[data-content-width="standard"] { max-width: var(--lumi-content-standard); }
.content.content-wide,
.content[data-content-width="wide"] { max-width: var(--lumi-content-wide); }
.content.content-workspace,
.content[data-content-width="workspace"] { max-width: var(--lumi-content-workspace); }

.content > * {
  min-width: 0;
}

.site-footer {
  width: 100%;
  max-width: var(--lumi-content-max);
  margin: auto auto 0;
  padding: var(--lumi-space-5) clamp(1rem, 2.5vw, 2.5rem);
  font-size: 0.875rem;
}

.grid,
.lumi-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: var(--lumi-space-4);
}

.lumi-stack {
  display: flex;
  flex-direction: column;
  gap: var(--lumi-space-4);
}

.lumi-cluster,
.button-group,
.page-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--lumi-space-2);
}

.lumi-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--lumi-space-4);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--lumi-space-4);
}

.page-header > div:first-child {
  min-width: min(100%, 18rem);
}

.page-header h1,
.section-header h1,
.section-header h2 {
  margin-bottom: 0;
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(5, 10, 12, 0.52);
  backdrop-filter: blur(2px);
  z-index: calc(var(--lumi-z-navigation) - 1);
}

.standalone-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--lumi-space-4);
}

.standalone-card {
  width: min(100%, 45rem);
}

.standalone-detail {
  margin-top: var(--lumi-space-4);
}

@media (min-width: 901px) {
  body.sidebar-collapsed .app-shell {
    grid-template-columns: var(--lumi-sidebar-collapsed) minmax(0, 1fr);
  }

  body.sidebar-collapsed .sidebar {
    width: var(--lumi-sidebar-collapsed);
  }

  body.sidebar-collapsed .sidebar-brand {
    flex-direction: column;
  }

  body.sidebar-collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
  }
}

@media (max-width: 1100px) and (min-width: 901px) {
  .app-shell {
    grid-template-columns: 14rem minmax(0, 1fr);
  }

  .sidebar {
    width: 14rem;
  }
}

@media (max-width: 900px) {
  body.sidebar-collapsed .app-shell,
  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  body.sidebar-collapsed .sidebar,
  .sidebar {
    width: min(19rem, 88vw);
    height: 100dvh;
    max-height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-top: var(--lumi-space-3);
    scrollbar-width: thin;
    scrollbar-color: var(--lumi-border) transparent;
  }

  .sidebar-nav {
    min-height: 0;
    overflow-y: visible;
  }

  .sidebar-footer {
    flex-shrink: 0;
  }

  .sidebar-brand {
    align-items: center;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  body.sidebar-open .sidebar-scrim {
    display: block;
  }

  .mobile-topbar {
    min-height: var(--lumi-mobile-header-height);
    padding: var(--lumi-space-3) var(--lumi-space-4);
    background: color-mix(in srgb, var(--lumi-surface) 92%, transparent);
    backdrop-filter: blur(18px);
  }

  .content {
    padding: var(--lumi-space-4);
  }
}

@media (max-width: 600px) {
  .mobile-topbar {
    min-height: 3.5rem;
    padding: var(--lumi-space-2) var(--lumi-space-3);
  }

  .content {
    gap: var(--lumi-space-3);
    padding: max(0.75rem, env(safe-area-inset-top)) max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  }

  .site-footer {
    padding: var(--lumi-space-5) var(--lumi-space-4);
  }

  .section-header,
  .page-header,
  .commands-header,
  .stats-header,
  .lumi-split {
    align-items: stretch;
    flex-direction: column;
  }

  .section-header > *,
  .page-header > *,
  .commands-header > *,
  .stats-header > * {
    width: 100%;
  }

  .button-group,
  .page-actions {
    align-items: stretch;
  }

  .button-group .button,
  .page-actions .button {
    flex: 1 1 auto;
  }
}
}
