/* App shell: sidebar on desktop, top bar + bottom nav on mobile */

.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100dvh; }

.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 22px;
  padding: 26px 16px 18px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 40%);
  backdrop-filter: blur(10px);
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 0 10px; color: var(--text); text-decoration: none;
}
.brand-mark { width: 34px; height: 34px; flex: none; filter: drop-shadow(0 4px 14px rgba(242, 181, 68, 0.35)); }
.brand-name { font-family: var(--font-display); font-size: 1.4rem; letter-spacing: -0.01em; line-height: 1; }
.brand-name span { color: var(--gold-text); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  color: var(--text-2); text-decoration: none; font-weight: 500; font-size: 0.95rem;
  transition: background 0.2s var(--ease), color 0.2s var(--ease);
}
.nav-link svg { width: 19px; height: 19px; flex: none; opacity: 0.85; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current='page'] { color: var(--text); background: var(--surface-2); }
.nav-link[aria-current='page']::before {
  content: ''; position: absolute; left: -16px; top: 9px; bottom: 9px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--gold); box-shadow: 0 0 14px var(--gold);
}
.nav-link[aria-current='page'] svg { color: var(--gold-text); opacity: 1; }
.nav-cta { margin-top: 6px; }

.side-section { display: flex; flex-direction: column; gap: 4px; min-height: 0; }
.side-title { padding: 0 12px; font-size: var(--fs-xs); color: var(--text-3); font-weight: 600; }
.side-subjects { overflow: auto; display: flex; flex-direction: column; gap: 1px; max-height: 34vh; }
.side-subject {
  display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 10px;
  color: var(--text-2); text-decoration: none; font-size: var(--fs-sm);
}
.side-subject:hover, .side-subject[aria-current='page'] { background: var(--surface-2); color: var(--text); }
.side-subject .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.side-subject .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-subject .count { font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.side-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 4px; }

.main { min-width: 0; padding: 30px clamp(18px, 4vw, 48px) 80px; }
.view { max-width: 1140px; margin: 0 auto; }
.view.enter { animation: view-in 0.42s var(--ease) both; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.page-head .sub { color: var(--text-2); margin-top: 6px; max-width: 62ch; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; }

.topbar { display: none; }
.bottomnav { display: none; }

#banner-slot:empty { display: none; }
#banner-slot { margin: 0 auto 22px; max-width: 1140px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: sticky; top: 0; z-index: 30;
    padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 78%, transparent);
    backdrop-filter: blur(14px) saturate(1.3);
    border-bottom: 1px solid var(--line);
  }
  .topbar .brand { padding: 0; }
  .topbar .brand-mark { width: 30px; height: 30px; }
  .topbar .brand-name { font-size: 1.25rem; }
  .topbar-actions { display: flex; gap: 6px; }
  .main { padding: 20px 16px calc(96px + env(safe-area-inset-bottom)); }
  .bottomnav {
    display: grid; grid-template-columns: repeat(5, 1fr);
    position: fixed; z-index: 40; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px; border-radius: 20px;
    background: color-mix(in srgb, var(--surface-solid) 86%, transparent);
    backdrop-filter: blur(18px) saturate(1.4);
    border: 1px solid var(--line-strong);
    box-shadow: var(--shadow-2);
  }
  .bn-link {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 7px 2px; border-radius: 14px; text-decoration: none;
    color: var(--text-3); font-size: 0.68rem; font-weight: 600;
  }
  .bn-link svg { width: 21px; height: 21px; }
  .bn-link[aria-current='page'] { color: var(--gold-text); background: var(--gold-soft); }
  .bn-link.bn-primary svg {
    width: 34px; height: 34px; padding: 7px; margin-top: -2px; border-radius: 12px;
    background: linear-gradient(140deg, var(--gold-hi), var(--gold) 55%, var(--ember));
    color: var(--on-gold); box-shadow: 0 6px 18px -6px rgba(242, 181, 68, 0.8);
  }
  .bn-link.bn-primary { color: var(--text-2); }
  .bn-link.bn-primary[aria-current='page'] { background: transparent; color: var(--gold-text); }
  .page-head { margin-bottom: 20px; }
}

/* runner mode hides nav chrome for focus */
body.focus-mode .sidebar, body.focus-mode .bottomnav, body.focus-mode .topbar { display: none; }
body.focus-mode .app { grid-template-columns: 1fr; }
body.focus-mode .main { padding-bottom: 40px; }
