.shell { min-height: 100vh; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: calc(var(--safe-top) + 1rem) .75rem 1rem;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; padding: 0 .5rem 1rem; }
#side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: .65rem; padding: .6rem .75rem; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: .95rem; min-height: 44px;
}
.nav-link:hover { background: var(--surface-2); }
.nav-link[aria-current="page"] { background: #f0f0f1; color: var(--text); font-weight: 600; }
.nav-link svg { width: 20px; height: 20px; flex: none; }
.nav-section { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: .9rem .75rem .3rem; }
.sidebar-footer { margin-top: auto; padding: 1rem .5rem 0; font-size: .85rem; color: var(--muted); }

main#view {
  margin-left: 248px; padding: calc(var(--safe-top) + 1.5rem) 2rem 3rem; max-width: 1200px; outline: none;
}

.bottom-nav { display: none; }

.page-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-header h1 { margin: 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: .75rem; }

body.unauth .sidebar, body.unauth .bottom-nav, body.booting .sidebar, body.booting .bottom-nav { display: none; }
body.unauth main#view, body.booting main#view { margin: 0 auto; max-width: 440px; padding: calc(var(--safe-top) + 3rem) 1rem 2rem; }

@media (max-width: 960px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .sidebar { display: none; }
  main#view { margin-left: 0; padding: calc(var(--safe-top) + 1rem) 1rem calc(var(--safe-bottom) + 96px); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .grid-4.keep-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: var(--safe-bottom);
  }
  .bottom-nav a, .bottom-nav button {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 58px;
    font-size: .7rem; color: var(--muted); text-decoration: none; background: none; border: 0; font-family: inherit;
  }
  .bottom-nav [aria-current="page"] { color: var(--primary); font-weight: 600; }
  .bottom-nav svg { width: 22px; height: 22px; }
  .bottom-nav .fab {
    width: 52px; height: 52px; min-height: 0; border-radius: 50%; background: var(--primary); color: #fff; margin: -18px auto 0;
    box-shadow: 0 4px 12px rgba(241, 39, 80, .35); align-self: start;
  }
  .bottom-nav .fab svg { width: 26px; height: 26px; }
}
