/* Shell. Under 700 px a bottom tab bar, 700-1099 px a left icon rail, from 1100 px a labelled sidebar.
   One <nav> serves all three; only its CSS changes. */
.shell { min-height: 100dvh; }

.nav {
  position: fixed; inset: auto 0 0 0; z-index: 20;
  display: flex; flex-direction: column;
  background: var(--bar-bg);
  -webkit-backdrop-filter: blur(18px) saturate(1.4); backdrop-filter: blur(18px) saturate(1.4);
  border-top: 1px solid var(--hairline);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.nav__brand, .nav__foot { display: none; }
.nav__list { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.nav__item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: var(--tab-h); padding: var(--s2) var(--s1);
  color: var(--ink-muted); text-decoration: none; font-size: 0.6875rem; font-weight: 500; line-height: 1.1;
  transition: color 0.15s var(--ease);
}
.nav__item svg { width: 24px; height: 24px; flex: none; }
.nav__item[aria-current="page"] { color: var(--accent-text); }
.nav__item[aria-current="page"] svg { stroke-width: 2.2; }
.nav__li--wide { display: none; }

.view { min-width: 0; padding: var(--s5) max(var(--s4), env(safe-area-inset-left)) calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s5)) max(var(--s4), env(safe-area-inset-right)); outline: none; }
.view:focus-visible { outline: none; }

.page { width: 100%; max-width: 44rem; margin-inline: auto; }
.page--narrow { max-width: 30rem; }
.page--wide { max-width: 78rem; }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); }
.row--between { justify-content: space-between; }

/* Chart screens split in two from sidebar width: bodygraph left, summary right (iPad AdaptiveColumns). */
.split { display: grid; gap: var(--s5); }

@media (min-width: 700px) {
  .shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); }
  .nav {
    position: sticky; top: 0; inset: auto; height: 100dvh; z-index: 10;
    border-top: 0; border-right: 1px solid var(--hairline);
    padding: var(--s4) 0 var(--s4) env(safe-area-inset-left);
    justify-content: flex-start; align-items: stretch;
  }
  .nav__brand { display: flex; align-items: center; justify-content: center; gap: var(--s3); min-height: 3rem; margin-bottom: var(--s4); color: var(--ink); text-decoration: none; }
  .nav__mark { width: 28px; height: 28px; color: var(--accent); }
  .nav__word { display: none; font-family: var(--font-serif); font-size: var(--step-1); font-weight: 600; }
  .nav__list { display: flex; flex-direction: column; gap: var(--s1); padding: 0 var(--s2); }
  .nav__item { flex-direction: row; justify-content: center; min-height: 3rem; border-radius: var(--r); }
  .nav__item:hover { background: var(--surface-sunk); }
  .nav__item[aria-current="page"] { background: var(--surface-sunk); }
  .nav__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .nav__li--wide { display: block; }
  .nav__foot { display: flex; flex-direction: column; gap: var(--s1); margin-top: auto; padding: 0 var(--s2); }
  .nav__foot .nav__item { font-size: var(--step--1); }
  .view { padding: var(--s6) var(--s6) var(--s7); }
}

@media (min-width: 1100px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .nav { padding-inline: var(--s3); }
  .nav__brand { justify-content: flex-start; padding-inline: var(--s3); }
  .nav__word { display: inline; }
  .nav__list { padding: 0; }
  .nav__item { justify-content: flex-start; gap: var(--s3); padding-inline: var(--s3); font-size: var(--step-0); }
  .nav__label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .nav__foot { padding: 0; }
  .view { padding: var(--s6) var(--s7) var(--s7); }
  .split { grid-template-columns: minmax(0, 26rem) minmax(0, 1fr); align-items: start; gap: var(--s6); }
  .split > :first-child { position: sticky; top: var(--s6); }
}
