.app-frame {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--color-bg);
}
.app-sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: var(--color-bg-elevated);
  border-inline-end: 1px solid var(--color-border-subtle);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 40;
}
.app-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border-subtle);
  font-weight: 700;
  font-size: 1rem;
  color: var(--color-text);
  text-decoration: none;
}
.app-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.app-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-sm) 0;
}
.nav-group { margin-bottom: var(--space-md); }
.nav-group-title {
  padding: 0.35rem var(--space-md);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem var(--space-md);
  min-height: var(--touch-min);
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background var(--transition-fast), color var(--transition-fast);
  border-inline-start: 3px solid transparent;
}
.nav-link:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}
.nav-link.is-active {
  background: var(--color-primary-muted);
  color: #dbeafe;
  border-inline-start-color: var(--color-primary);
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.85; }
.app-sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--color-border-subtle);
}
.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.app-content {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}
@media (min-width: 901px) {
  body.messenger-page .app-sidebar { display: none; }
}
body.messenger-page .app-frame { min-height: 100vh; }
body.messenger-page .app-mobile-bar { display: flex; }
@media (min-width: 901px) {
  body.messenger-page .app-mobile-bar { display: none; }
}
body.messenger-page .app-content {
  max-width: none;
  padding: 0.65rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
  overflow: hidden;
}
body.hide-nav .app-frame { display: block; }
body.hide-nav .app-content { max-width: 1100px; margin: 0 auto; }

.app-mobile-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem var(--space-md);
  background: var(--color-bg-elevated);
  border-bottom: 1px solid var(--color-border-subtle);
  min-height: var(--topbar-height);
}
.app-mobile-bar .btn-icon {
  min-height: var(--touch-min);
  min-width: var(--touch-min);
  padding: 0;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text);
  cursor: pointer;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 35;
}
.sidebar-backdrop.open { display: block; }

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-mobile-bar { display: flex; }
  .app-frame { flex-direction: column; }
  .app-sidebar { height: 100%; }
}

/* Legacy topbar hidden when shell active */
.topbar { display: none !important; }
