.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* Header */
.app-header {
  flex-shrink: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-12);
  height: var(--header-height);
  padding: 0 var(--space-12);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  box-shadow: var(--shadow-none);
}

.app-header__start,
.app-header__end {
  display: flex;
  align-items: center;
  gap: var(--space-8);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  color: var(--text-primary);
}

.app-brand__mark {
  display: grid;
  place-items: center;
  width: var(--avatar-size);
  height: var(--avatar-size);
  border-radius: var(--radius-8);
  background: var(--brand-primary);
  color: var(--text-inverse);
  font-size: var(--text-l);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  flex-shrink: 0;
}

.app-brand__text {
  display: flex;
  flex-direction: column;
  line-height: var(--leading-tight);
}

.app-brand__name {
  font-size: var(--text-m);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
}

.app-brand__subtitle {
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

/* Body: sidebar + workspace */
.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow-y: auto;
  transition: width var(--duration-base) var(--ease-standard),
    transform var(--duration-base) var(--ease-standard);
}

.app-sidebar-overlay {
  display: none;
}

.app-workspace {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  background: var(--bg-page);
}

.workspace {
  padding: var(--page-padding);
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
  max-width: 1440px;
  margin: 0 auto;
  animation: workspace-in var(--duration-base) var(--ease-standard);
}

@keyframes workspace-in {
  from {
    opacity: 0;
    transform: translateY(var(--space-4));
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .workspace {
    animation: none;
  }
}

.workspace-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-12);
}

/* Footer */
.app-footer {
  height: var(--footer-height);
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--space-12);
  /* Same side padding as the page content above it. */
  padding: 0 var(--page-padding);
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  line-height: var(--leading-relaxed);
  color: var(--text-muted);
}

/* All three footer columns centre their item on the same line. */
.app-footer__start,
.app-footer__center,
.app-footer__end {
  display: flex;
  align-items: center;
}

.app-footer__center {
  justify-self: center;
}

.app-footer__end {
  display: flex;
  justify-self: end;
  gap: var(--space-12);
}

.app-footer__meta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  line-height: 1;
}

.app-footer__meta .material-symbols-rounded {
  font-size: var(--icon-size-s);
  color: var(--text-muted);
}

/* Collapsed sidebar state (desktop) */
.app-shell.is-sidebar-collapsed .app-sidebar {
  width: var(--sidebar-collapsed-width);
}

.app-shell.is-sidebar-collapsed .app-nav__text,
.app-shell.is-sidebar-collapsed .app-nav__soon {
  display: none;
}

.app-shell.is-sidebar-collapsed .app-nav__link {
  justify-content: center;
}

/* Responsive breakpoints */
@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 45;
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }

  .app-shell.is-sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-shell.is-sidebar-open .app-sidebar-overlay {
    display: block;
    position: fixed;
    inset: var(--header-height) 0 0 0;
    background: var(--overlay-scrim);
    z-index: 44;
  }

  .app-shell.is-sidebar-collapsed .app-sidebar {
    width: var(--sidebar-width);
  }

  .app-shell.is-sidebar-collapsed .app-nav__text {
    display: initial;
  }
}

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

  .workspace {
    padding: var(--space-8);
    gap: var(--space-8);
  }
}
