/* Application shell layout: desktop navigation rail, mobile top bar + bottom navigation.
   Breakpoint: the rail takes over at 820px; below it the shell is one pane with a bottom bar. */

.app {
  min-height: 100dvh;
  padding-inline: env(safe-area-inset-left) env(safe-area-inset-right);
}

/* --- Mobile (default) --------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: max(var(--space-2), env(safe-area-inset-top)) var(--space-4) var(--space-2);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

/* In the mobile top bar the install control is icon-only; the rail has room for the label. */
@media (max-width: 819.98px) {
  .controls .btn--install {
    padding: var(--space-2);
  }

  .controls .btn--install span {
    display: none;
  }
}

.sidebar {
  display: none;
}

.bottomnav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 5;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  padding-bottom: max(var(--space-1), env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}

.main {
  /* Keep content clear of the fixed bottom navigation and the home indicator. */
  padding: var(--space-5) var(--space-4)
    calc(var(--space-7) + var(--space-6) + env(safe-area-inset-bottom));
}

/* --- Desktop rail ------------------------------------------------------- */

@media (min-width: 820px) {
  .app {
    display: grid;
    grid-template-columns: 230px 1fr;
    grid-template-areas: "sidebar main";
  }

  .topbar,
  .bottomnav {
    display: none;
  }

  .sidebar {
    grid-area: sidebar;
  }

  .main {
    grid-area: main;
  }

  .sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    height: 100dvh;
    padding: var(--space-5) var(--space-3);
    background: var(--surface);
    border-right: 1px solid var(--line);
  }

  .main {
    padding: var(--space-6) var(--space-6) var(--space-7);
  }
}

/* --- Shared pieces ------------------------------------------------------ */

/* Offline indicator sits above the shell in normal flow on mobile; in the desktop grid it spans
   the full width above both panes. */
.offline-bar {
  grid-column: 1 / -1;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-l);
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  border-radius: var(--radius-m);
}

.brand img {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-s);
}

.nav-list {
  display: flex;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar .nav-list {
  flex-direction: column;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-m);
  color: var(--ink);
  text-decoration: none;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  flex: none;
  color: var(--ink-muted);
}

.nav-link:hover {
  background: var(--hover);
}

.nav-link[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-ink-soft);
  font-weight: 600;
}

.nav-link[aria-current="page"] svg {
  color: var(--accent-ink-soft);
}

/* Bottom navigation: icon above a small label, tappable height. */
.bottomnav .nav-link {
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-1);
  font-size: var(--text-xs);
  text-align: center;
}

.rail-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--line);
}

.view {
  max-width: 640px;
  margin-inline: auto;
  animation: view-in 0.18s ease;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}
