/* App shell (docs/design): content, bottom nav with the raised "+" (mobile) → side rail (≥ 900px). Utilities. */
.b-shell { min-height: 100dvh; display: flex; flex-direction: column; }

.b-main {
  flex: 1;
  width: 100%; max-width: var(--content-max);
  margin: 0 auto;
  /* bottom: clear the nav and the feedback bubble, so the last row can scroll out from under it */
  padding: calc(var(--gutter) + env(safe-area-inset-top)) var(--gutter) calc(var(--nav-h) + var(--space-6) + var(--add-size) + env(safe-area-inset-bottom));
}

/* Screen title row: title + subtitle left, an action (toggle / back) beside it. */
.b-screen-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-4); }
.b-screen-head__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.b-screen-head h1 { margin: 0; }
.b-screen-head__sub { font-size: var(--fs-s); color: var(--c-muted); }
.b-brand { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl); color: var(--c-primary); }
.b-back {
  flex: none; display: grid; place-items: center;
  width: var(--tap); height: var(--tap); border-radius: var(--radius-round);
  background: var(--c-surface); color: var(--c-text);
}
.b-back svg { width: 20px; height: 20px; }
.b-screen-head--back { justify-content: flex-start; }

.b-bottomnav {
  position: fixed; inset: auto 0 0 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: center;
  min-height: var(--nav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--c-surface);
  border-top: var(--border-w) solid var(--c-nav-border);
  text-align: center;
}
.b-bottomnav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 48px; min-width: var(--tap);
  color: var(--c-muted); text-decoration: none; font-size: var(--fs-xs);
}
.b-bottomnav__item svg { width: 22px; height: 22px; }
.b-bottomnav__item.active { color: var(--c-primary); font-weight: 700; }
.b-bottomnav__item[aria-disabled=true] { opacity: .45; cursor: default; }
.b-bottomnav__add {
  justify-self: center;
  display: grid; place-items: center;
  width: var(--add-size); height: var(--add-size); margin-top: -22px;
  border-radius: var(--radius-round);
  background: var(--c-primary); color: var(--c-primary-ink);
  text-decoration: none;
  box-shadow: var(--shadow-2);
}
.b-bottomnav__add svg { width: 26px; height: 26px; }

@media (min-width: 900px) {
  .b-bottomnav {
    inset: 0 auto 0 0;
    width: var(--rail-w);
    grid-template-columns: 1fr; grid-auto-rows: min-content; align-content: start; gap: var(--space-2);
    padding: var(--space-5) 0;
    border-top: 0; border-right: var(--border-w) solid var(--c-nav-border);
  }
  .b-bottomnav__add { margin: var(--space-2) auto; order: -1; }
  .b-main { padding: var(--space-5) var(--space-5) var(--space-6) calc(var(--rail-w) + var(--space-5)); max-width: calc(var(--content-max) + var(--rail-w)); }
}

/* Bare layout (sign-in) */
.b-bare { min-height: 100dvh; display: grid; place-items: center; padding: var(--space-5) var(--space-4); }

/* Utilities */
.b-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.b-stack--tight { gap: var(--space-3); }
.b-row { display: flex; align-items: center; gap: var(--space-3); }
.b-grid-2 { display: grid; gap: var(--space-3); grid-template-columns: 1fr; }
@media (min-width: 560px) { .b-grid-2 { grid-template-columns: 1fr 1fr; } }
.b-pair { display: grid; gap: var(--space-3); grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* ---------- D53 the desktop workbench (>= 1024 px). Below 1024 px nothing changes. ---------- */
.b-desk { display: none; }
@media (min-width: 1024px) {
  html { font-size: 106.25%; } /* base text one step larger: 15 to 16 px */
  .b-desk { display: block; }
  .b-shell:has(.b-rail) .b-bottomnav { display: none; }
  .b-shell:has(.b-rail) .b-main {
    max-width: calc(var(--content-max-desk) + var(--rail-w-desk));
    /* the bottom keeps clear of the feedback bubble (52 px at --space-5 from the corner) */
    padding: var(--space-5) var(--space-6) calc(52px + var(--space-5) * 2) calc(var(--rail-w-desk) + var(--space-6));
  }
  .b-rail {
    position: fixed; inset: 0 auto 0 0; z-index: 10; width: var(--rail-w-desk);
    display: flex; flex-direction: column; gap: var(--space-1); padding: var(--space-5) var(--space-3);
    background: var(--c-surface); border-right: var(--border-w) solid var(--c-nav-border);
  }
  .b-rail__brand { font-family: var(--font-display); font-weight: 800; font-size: var(--fs-xl); color: var(--c-primary); padding: 0 var(--space-3) var(--space-4); }
  .b-rail__item {
    display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
    min-height: 40px; padding: 0 var(--space-3); border-radius: var(--radius-m);
    color: var(--c-text); text-decoration: none; font-weight: 600;
  }
  .b-rail__item:hover { background: var(--c-primary-soft); }
  .b-rail__item.active { background: var(--c-primary-soft); color: var(--c-primary); }
  .b-rail__badge { min-width: 22px; padding: 0 6px; border-radius: var(--radius-round); background: var(--c-warn-soft); color: var(--c-warn-ink); font-size: var(--fs-xs); text-align: center; line-height: 22px; }
}
