/* AFTERCLASS — application shell, navigation and responsive layout. */

.app {
  min-height: 100dvh;
}

/* --- Desktop sidebar ------------------------------------------------------ */
.sidebar {
  display: none;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand { font-weight: 700; letter-spacing: 0.14em; font-size: var(--fs-sm); }
.topbar .page-title { font-weight: 600; font-size: var(--fs-base); }
.topbar .spacer { flex: 1; }

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 700;
  letter-spacing: 0.16em;
  font-size: var(--fs-sm);
  color: var(--text);
  text-transform: uppercase;
}

.main {
  padding: var(--sp-4) var(--sp-4) calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--sp-5));
  max-width: 100%;
}
.content-narrow { max-width: var(--content-max); margin: 0 auto; }
.content-wide { max-width: 1080px; margin: 0 auto; }

/* --- Bottom navigation (mobile) ------------------------------------------ */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottomnav a,
.bottomnav button {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 0.65rem;
  font-weight: 560;
  text-decoration: none;
  cursor: pointer;
  min-width: 0;
  padding: 0 var(--sp-1);
}
.bottomnav a .icon,
.bottomnav button .icon { width: 22px; height: 22px; }
.bottomnav a.active { color: var(--accent); }
.bottomnav .nav-badge {
  position: absolute;
  transform: translate(14px, -12px);
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 0.6rem;
  min-width: 16px; height: 16px;
  padding: 0 4px;
  display: inline-flex; align-items: center; justify-content: center;
}

/* --- Mobile menu sheet ---------------------------------------------------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: flex-end;
  animation: fade-in 0.15s ease;
}
.sheet {
  width: 100%;
  background: var(--bg-elev);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  border-top: 1px solid var(--border-strong);
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  animation: sheet-up 0.2s ease;
}
@keyframes sheet-up { from { transform: translateY(20px); opacity: 0; } }
.sheet-header { display: flex; align-items: center; gap: var(--sp-3); padding-bottom: var(--sp-3);
  border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); }
.sheet nav { display: grid; gap: 2px; }
.sheet nav a {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0.75rem 0.65rem; border-radius: var(--radius-md);
  color: var(--text); text-decoration: none; font-weight: 540;
}
.sheet nav a .icon { color: var(--text-dim); }
.sheet nav a.active, .sheet nav a:hover { background: var(--bg-elev-3); text-decoration: none; }

/* --- Nav list (shared) ---------------------------------------------------- */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-dim);
  text-decoration: none;
  font-weight: 540;
  font-size: var(--fs-base);
}
.nav-link .icon { color: var(--text-faint); }
.nav-link:hover { background: var(--bg-elev-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active .icon { color: var(--accent); }
.nav-section { margin-top: var(--sp-4); }
.nav-section-title {
  font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.14em;
  color: var(--text-faint); padding: 0 var(--sp-3); margin-bottom: var(--sp-2);
}

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .topbar { display: none; }
  .bottomnav { display: none; }
  .sidebar {
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100dvh;
    padding: var(--sp-4);
    border-right: 1px solid var(--border);
    background: var(--bg-elev);
    overflow-y: auto;
  }
  .sidebar .brand { padding: var(--sp-2) var(--sp-3) var(--sp-4); }
  .sidebar nav { display: grid; gap: 2px; }
  .sidebar .sidebar-footer { margin-top: auto; padding-top: var(--sp-4); }
  .main {
    padding: var(--sp-6) var(--sp-6) var(--sp-7);
    min-height: 100dvh;
  }
  .user-chip {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-2); border-radius: var(--radius-md);
    text-decoration: none; color: var(--text);
  }
  .user-chip:hover { background: var(--bg-elev-2); text-decoration: none; }
}

/* Page header used inside content */
.page-head { display: flex; align-items: flex-end; justify-content: space-between;
  gap: var(--sp-4); margin-bottom: var(--sp-5); flex-wrap: wrap; }
.page-head h1 { margin-bottom: var(--sp-1); }
.page-head .sub { color: var(--text-dim); font-size: var(--fs-sm); }
