/* ============================================================
   LAYOUTS
   Three navigation patterns, designed separately:
     mobile  (< 720px)  bottom bar with a central capture button
     tablet  (720-1079) icon rail
     desktop (>= 1080)  sidebar
   ============================================================ */

.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.app__main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page {
  flex: 1;
  padding: var(--space-5) var(--space-4);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-6) + env(safe-area-inset-bottom));
}

.page__inner { max-width: var(--reading-width); margin: 0 auto; }

/* --- Top bar --------------------------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  background: var(--canvas);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar__title {
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.topbar__actions { display: flex; gap: var(--space-1); }

/* --- Page header ----------------------------------------------- */
.page-header { margin-bottom: var(--space-6); }
.page-header__date { font-size: var(--text-sm); color: var(--ink-muted); margin-bottom: var(--space-1); }
.page-header__greeting { font-size: var(--text-xl); }

/* --- Brand mark ------------------------------------------------- */
.brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-3);
  font-weight: var(--weight-bold);
}

.brand__mark {
  width: 22px;
  height: 22px;
  flex: none;
  border-radius: var(--radius-sm);
  background: var(--brand);
  position: relative;
}

/* Two stacked strokes: a full line and a short one. A plan, and the
   one small step taken from it. */
.brand__mark::before,
.brand__mark::after {
  content: "";
  position: absolute;
  left: 5px;
  height: 2px;
  background: var(--ink-inverse);
  border-radius: 1px;
}
.brand__mark::before { top: 8px; width: 12px; }
.brand__mark::after { top: 13px; width: 6px; }

.brand__name { font-size: var(--text-base); letter-spacing: -0.01em; }

/* --- Navigation lists (shared) ---------------------------------- */
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  text-decoration: none;
  font-size: var(--text-base);
  transition: background var(--speed) var(--ease), color var(--speed) var(--ease);
}

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

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

.nav-link svg { width: 20px; height: 20px; flex: none; }

/* --- Sidebar (desktop) ------------------------------------------ */
.sidebar {
  display: none;
  width: var(--sidebar-width);
  flex: none;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--canvas);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.sidebar__nav { padding: var(--space-2); display: grid; gap: 2px; }
.sidebar__spacer { flex: 1; }

/* Settings is separate from the 8 main destinations, so it is
   divided off rather than listed with them. */
.sidebar__footer {
  padding: var(--space-2);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 2px;
}

/* --- Rail (tablet) ----------------------------------------------- */
.rail {
  display: none;
  width: var(--rail-width);
  flex: none;
  flex-direction: column;
  align-items: center;
  border-right: 1px solid var(--line);
  background: var(--canvas);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  padding: var(--space-3) 0;
}

.rail__nav { display: grid; gap: var(--space-1); }
.rail__spacer { flex: 1; }

.rail .nav-link {
  width: 48px;
  height: 48px;
  justify-content: center;
  padding: 0;
}

.rail .nav-link span { display: none; }

/* --- Bottom navigation (mobile) ---------------------------------- */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.bottom-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: var(--text-xs);
}

.bottom-nav__item svg { width: 22px; height: 22px; }
.bottom-nav__item[aria-current="page"],
.bottom-nav__item[aria-expanded="true"] { color: var(--brand); }

.bottom-nav__capture {
  display: flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__capture button {
  width: 52px;
  height: 52px;
  border: none;
  border-radius: 50%;
  background: var(--brand);
  color: var(--ink-inverse);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bottom-nav__capture svg { width: 24px; height: 24px; }

/* --- Sheet (mobile "More" menu and capture) ---------------------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(17, 22, 20, 0.45);
  display: flex;
  align-items: flex-end;
}

.sheet {
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  background: var(--surface);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: var(--space-4);
  padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
}

.sheet__handle {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: 0 auto var(--space-4);
}

.sheet__title { font-size: var(--text-md); margin-bottom: var(--space-3); }
.sheet__nav { display: grid; gap: 2px; }
.sheet__divider { height: 1px; background: var(--line); margin: var(--space-3) 0; }

/* ============================================================
   BREAKPOINTS
   ============================================================ */

/* Tablet: icon rail, wider page padding, more room for content. */
@media (min-width: 720px) {
  .rail { display: flex; }
  .bottom-nav { display: none; }

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

  .page__inner { max-width: 44rem; }

  .toast-region { bottom: var(--space-4); }

  /* On a larger screen a bottom sheet feels wrong, so it becomes a
     centred dialog with the same contents. */
  .sheet-backdrop { align-items: center; justify-content: center; padding: var(--space-5); }

  .sheet {
    max-width: 34rem;
    max-height: 82vh;
    border-radius: var(--radius-lg);
  }

  .sheet__handle { display: none; }
}

/* Desktop: sidebar replaces the rail. */
@media (min-width: 1080px) {
  .rail { display: none; }
  .sidebar { display: flex; }

  .page { padding: var(--space-7) var(--space-7); }
  .page__inner { max-width: 46rem; margin: 0 auto; }
}
