/* ============================================================================
   ds/shell.css — responsive app shell (owner decision 1) + public top bar
   ----------------------------------------------------------------------------
   Markup: src/_includes/nav.njk (from src/_data/navigation.json).
   Phone <768: sticky top app bar + fixed bottom tab bar + More bottom sheet.
   Tablet 768–1023: 80px side rail + app bar; More opens as a side sheet.
   Desktop ≥1024: 256px persistent sidebar + slim top bar.
   The app shell shows only when the middleware marked the body signed-in
   (body[data-authenticated="true"]); otherwise the public bar shows.
   AccessCore button (owner decision 5): 48px, above the tab bar on phones,
   in a reserved zone at the bottom of the rail/sidebar on larger screens.
   Task pages (D17): html[data-shell-kind="task"] hides the tab bar on phones.
   ============================================================================ */

/* No global horizontal-overflow guard (removed after Batch 5): every page must
   fit 320px on its own; wide content scrolls inside its own container. */

/* Skip link appears instantly on focus (no slide-in), so it is fully in view
   the moment it receives focus. */
.skip-link { z-index: 10000; transition: none; }

/* ---------------------------------------------------------------------------
   Visibility: app shell vs public bar, decided at runtime by the middleware.
   --------------------------------------------------------------------------- */
.af-app-only { display: none; }
html[data-shell="app"] body[data-authenticated="true"] .af-app-only { display: contents; }
html[data-shell="app"] body[data-authenticated="true"] .af-public-only { display: none; }
.af-auditor-only { display: none; }
body[data-is-auditor="true"] .af-auditor-only { display: list-item; }

/* ---------------------------------------------------------------------------
   Brand mark
   --------------------------------------------------------------------------- */
.af-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--af-sp-3);
  min-height: var(--af-target-min);
  color: var(--af-ink);
  font-family: var(--af-font-display);
  font-weight: 600;
  font-size: var(--af-fs-lg);
  text-decoration: none;
  white-space: nowrap;
}
.af-brand:hover { color: var(--af-ink); text-decoration: none; }
.af-brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: var(--af-r-sm);
  background: var(--af-primary);
  color: var(--af-on-primary);
}
.af-brand-mark i { display: block; width: 12px; height: 12px; border: 2.5px solid currentColor; border-radius: 3px; }

/* ---------------------------------------------------------------------------
   Public top bar (anonymous pages) and focus bar (auth forms, interstitials)
   --------------------------------------------------------------------------- */
.af-publicbar {
  position: sticky;
  top: 0;
  z-index: var(--af-z-sticky);
  display: flex;
  align-items: center;
  gap: var(--af-sp-3);
  min-height: var(--af-appbar-h);
  padding: var(--af-safe-top) max(var(--af-sp-4), env(safe-area-inset-right, 0px)) 0 max(var(--af-sp-4), env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--af-bg) 92%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-block-end: 1px solid var(--af-border);
}
.af-publicbar-links { display: none; gap: var(--af-sp-1); }
.af-publicbar-link {
  display: inline-flex;
  align-items: center;
  min-height: var(--af-target-min);
  padding-inline: var(--af-sp-3);
  border-radius: var(--af-r-md);
  color: var(--af-ink-soft);
  font-weight: 500;
  text-decoration: none;
}
.af-publicbar-link:hover { background: var(--af-surface-sunken); color: var(--af-ink); text-decoration: none; }
.af-publicbar-cta { display: flex; gap: var(--af-sp-2); margin-inline-start: auto; }
.af-publicbar-cta .af-btn { min-height: var(--af-target-min); }
.af-publicbar--focus { justify-content: center; }
@media (min-width: 768px) {
  .af-publicbar { padding-inline: var(--af-sp-6); }
  .af-publicbar-links { display: flex; }
  .af-publicbar--focus { justify-content: flex-start; }
}
@media (max-width: 379.98px) {
  .af-publicbar .af-brand-name { display: none; }
  /* Logo-only brand link keeps a full tap target (Phase 6 QA Q1-07). */
  .af-publicbar .af-brand { min-width: var(--af-target-min); justify-content: center; }
}

/* ---------------------------------------------------------------------------
   App bar (all widths; slim top bar on desktop)
   --------------------------------------------------------------------------- */
.af-appbar {
  position: sticky;
  top: 0;
  z-index: var(--af-z-sticky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--af-sp-2);
  min-height: calc(var(--af-appbar-h) + var(--af-safe-top));
  padding: var(--af-safe-top) var(--af-sp-2) 0;
  padding-inline: max(var(--af-sp-2), env(safe-area-inset-left, 0px)) max(var(--af-sp-2), env(safe-area-inset-right, 0px));
  background: color-mix(in srgb, var(--af-bg) 94%, transparent);
  backdrop-filter: saturate(1.2) blur(8px);
  -webkit-backdrop-filter: saturate(1.2) blur(8px);
  border-block-end: 1px solid transparent;
}
.af-appbar.is-scrolled { border-block-end-color: var(--af-border); box-shadow: var(--af-shadow-1); }
.af-appbar-start { display: flex; align-items: center; gap: var(--af-sp-1); min-width: 0; flex: 1; }
.af-appbar-end { display: flex; align-items: center; gap: var(--af-sp-1); flex: none; }
.af-appbar-brand { padding-inline: var(--af-sp-2); }
.af-appbar-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--af-font-display);
  font-size: var(--af-fs-lg);
  font-weight: 600;
  padding-inline: var(--af-sp-1);
}
.af-appbar-search-label, .af-appbar-search .af-kbd { display: none; }

/* Notification bell (keeps its IDs; restyled here). */
.af-bell { position: relative; }
.af-bell .notification-bell-badge {
  position: absolute;
  top: 6px;
  /* style.css sets right:0; reset both physical sides first so the logical
     inline-end does not stretch the badge across the bell in RTL. */
  left: auto;
  right: auto;
  inset-inline-end: 4px;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding-inline: 4px;
  border-radius: var(--af-r-pill);
  background: var(--af-danger);
  color: var(--af-on-danger);
  font-size: var(--af-fs-xs);
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 0 0 2px var(--af-bg);
}
.af-bell .notification-bell-badge[hidden] { display: none; }
.af-bell .notification-bell-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  /* style.css sets right:0; reset both physical sides first (as for the badge
     above) or right:0 wins over inset-inline-end in RTL and the panel runs
     off the viewport's inline-end edge (Phase 6 Q1-02). */
  left: auto;
  right: auto;
  inset-inline-end: 0;
  z-index: var(--af-z-dropdown);
  width: min(360px, calc(100vw - 24px));
  padding: var(--af-sp-2);
  border-radius: var(--af-r-lg);
  background: var(--af-surface-elev);
  border: 1px solid var(--af-border);
  box-shadow: var(--af-shadow-2);
}
.af-bell .notification-bell-dropdown[hidden] { display: none; }
.af-bell .notification-bell-list { list-style: none; margin: 0; padding: 0; }
.af-bell .notification-bell-list li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--af-sp-3);
  border-radius: var(--af-r-md);
  color: var(--af-ink);
  font-size: var(--af-fs-sm);
}
.af-bell .notification-bell-list li + li { border-block-start: 1px solid var(--af-border); }
.af-bell .notification-bell-list small { color: var(--af-ink-faint); font-size: var(--af-fs-xs); }
.af-bell .notification-bell-list .bell-empty { color: var(--af-ink-soft); text-align: center; }
.af-bell .notification-bell-link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--af-target-min);
  margin-block-start: var(--af-sp-1);
  border-radius: var(--af-r-md);
  color: var(--af-primary-text);
  font-weight: 600;
  text-decoration: none;
}
.af-bell .notification-bell-link:hover { background: var(--af-primary-soft); text-decoration: none; }
@media (max-width: 767.98px) {
  /* Phone: the bell list opens as a bottom sheet. */
  .af-bell .notification-bell-dropdown {
    position: fixed;
    top: auto;
    inset-inline: 0;
    inset-block-end: 0;
    width: auto;
    max-height: 70dvh;
    overflow-y: auto;
    z-index: var(--af-z-sheet);
    border-radius: var(--af-r-xl) var(--af-r-xl) 0 0;
    padding: var(--af-sp-4) var(--af-sp-3) calc(var(--af-sp-3) + var(--af-safe-bottom));
    box-shadow: 0 0 0 100vmax var(--af-scrim), var(--af-shadow-3);
    /* room under the content for the AccessCore trigger (moved down below) */
    padding-block-end: calc(var(--af-ac-size) + 28px + var(--af-safe-bottom));
  }
  /* While the bell sheet is open the tab bar is behind it: the AccessCore
     trigger sits in the sheet's reserved bottom strip, never on an item. */
  html.af-bell-open[data-shell] body[data-authenticated] .accesscore-fab { bottom: calc(var(--af-safe-bottom) + 16px); inset-block-end: calc(var(--af-safe-bottom) + 16px); }
}
.af-bell-title {
  margin: 0 0 var(--af-sp-2);
  padding-inline: var(--af-sp-3);
  font-size: var(--af-fs-md);
  font-weight: 600;
  color: var(--af-ink);
}

/* Account button (the SSR-filled nav-user-toggle). */
.af-account { position: relative; }
.af-account .nav-user-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--af-sp-2);
  min-width: var(--af-target-min);
  min-height: var(--af-target-min);
  padding: 4px;
  border: 0;
  border-radius: var(--af-r-pill);
  background: transparent;
  color: var(--af-ink);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.af-account .nav-user-toggle:hover { background: var(--af-surface-sunken); }
.af-account .nav-user-photo {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--af-primary-soft);
  color: var(--af-primary-text);
  font-family: var(--af-font-display);
  font-weight: 600;
  font-size: var(--af-fs-sm);
}
.af-account .nav-label,
.af-account .nav-arrow { display: none; }
.af-account .nav-label[data-nav-user-pending] { visibility: hidden; }
.af-account .nav-arrow { font-size: 10px; color: var(--af-ink-faint); }

/* Account menu (disclosure, not role=menu). */
.af-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline-end: 0;
  z-index: var(--af-z-dropdown);
  width: 300px;
  max-height: calc(100dvh - var(--af-appbar-h) - 24px);
  overflow-y: auto;
  padding: var(--af-sp-2);
  border-radius: var(--af-r-lg);
  background: var(--af-surface-elev);
  border: 1px solid var(--af-border);
  box-shadow: var(--af-shadow-2);
}
.af-menu[hidden] { display: none; }
.af-menu-list { list-style: none; margin: 0; padding: 0; }
.af-menu-item {
  display: flex;
  align-items: center;
  gap: var(--af-sp-3);
  width: 100%;
  min-height: var(--af-target-min);
  padding-inline: var(--af-sp-3);
  border: 0;
  border-radius: var(--af-r-md);
  background: transparent;
  color: var(--af-ink);
  font: inherit;
  font-size: var(--af-fs-sm);
  font-weight: 500;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.af-menu-item .af-i { color: var(--af-ink-soft); }
.af-menu-item:hover { background: var(--af-surface-sunken); color: var(--af-ink); text-decoration: none; }
.af-menu-item--logout, .af-menu-item--logout .af-i { color: var(--af-danger); }
.af-menu-sep { height: 1px; margin: var(--af-sp-2) var(--af-sp-3); background: var(--af-border); }
.af-menu-lang {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--af-sp-2);
  min-height: var(--af-target-min);
  padding-inline: var(--af-sp-3) 0;
  font-size: var(--af-fs-sm);
  font-weight: 500;
}
.af-menu-lang-label { display: inline-flex; align-items: center; gap: var(--af-sp-3); }
.af-menu-lang-label .af-i { color: var(--af-ink-soft); }

/* ---------------------------------------------------------------------------
   Bottom tab bar (phones)
   --------------------------------------------------------------------------- */
.af-tabbar {
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: var(--af-z-nav);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-block-end: var(--af-safe-bottom);
  padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px);
  background: var(--af-surface);
  border-block-start: 1px solid var(--af-border);
}
.af-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: var(--af-tabbar-h);
  min-width: 0;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--af-ink-faint);
  font-family: var(--af-font-body);
  font-size: var(--af-fs-xs);
  font-weight: 500;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.af-tab:hover { color: var(--af-ink); text-decoration: none; }
.af-tab-pill {
  display: grid;
  place-items: center;
  width: 56px;
  height: 30px;
  border-radius: var(--af-r-pill);
  transition: background-color var(--af-dur) var(--af-ease);
}
.af-tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* AccessCore large text (Q2-16 follow-up): the tab column is ~64-78px, so the
   label's growth is capped (16px he; 14px en, see below) and, only while a
   scale is set, a word that still doesn't fit wraps to a second line
   (hyphenated in English) instead of ending in an ellipsis. At 100% there is
   no data-ac-font-scale and the caps sit above the 13px/11px base. */
html[data-ac-font-scale] .af-tab:not(.af-tab--add) .af-tab-label {
  font-size: min(var(--af-fs-xs), 16px);
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
  hyphens: auto;
  text-align: center;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.af-tab[aria-current="page"],
.af-tab[data-current="true"] { color: var(--af-primary-text); font-weight: 600; }
.af-tab[aria-current="page"] .af-tab-pill,
.af-tab[data-current="true"] .af-tab-pill { background: var(--af-primary-soft); }
.af-tab:focus-visible { outline-offset: -4px; border-radius: var(--af-r-md); }

/* Center Add tab: a filled 48px circle inside the bar (not a floating FAB). */
.af-tab--add { color: var(--af-ink-soft); }
.af-tab--add .af-tab-pill {
  width: 48px;
  height: 48px;
  margin-block-start: -6px;
  border-radius: 50%;
  background: var(--af-primary);
  color: var(--af-on-primary);
  box-shadow: var(--af-shadow-2);
}
.af-tab--add:hover .af-tab-pill { background: var(--af-primary-hover); }
.af-tab--add .af-i { width: 26px; height: 26px; stroke-width: 2.2; }
.af-tab--add .af-tab-label { display: none; }

/* ---------------------------------------------------------------------------
   Side rail (768–1023) and sidebar (≥1024)
   --------------------------------------------------------------------------- */
.af-sidenav { display: none; }

.af-navitem {
  display: flex;
  align-items: center;
  gap: var(--af-sp-3);
  width: 100%;
  min-height: var(--af-target-min);
  padding-inline: var(--af-sp-3);
  border: 0;
  border-radius: var(--af-r-md);
  background: transparent;
  color: var(--af-ink-soft);
  font: inherit;
  font-size: var(--af-fs-md);
  font-weight: 500;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.af-navitem:hover { background: var(--af-surface-sunken); color: var(--af-ink); text-decoration: none; }
.af-navitem[aria-current="page"],
.af-navitem[data-current="true"] { background: var(--af-primary-soft); color: var(--af-primary-text); font-weight: 600; }
.af-sidenav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.af-navgroup { margin-block-start: var(--af-sp-4); }
.af-navgroup-title {
  margin: 0 0 var(--af-sp-1);
  padding-inline: var(--af-sp-3);
  color: var(--af-ink-faint);
  font-family: var(--af-font-body);
  font-size: var(--af-fs-xs);
  font-weight: 500;
  letter-spacing: 0;
}
.af-sidenav-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--af-sp-2);
  min-height: var(--af-control-h);
  margin-block: var(--af-sp-2) var(--af-sp-4);
  padding-inline: var(--af-sp-4);
  border: 0;
  border-radius: var(--af-r-md);
  background: var(--af-primary);
  color: var(--af-on-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.af-sidenav-add:hover { background: var(--af-primary-hover); }
.af-ac-zone { flex: none; height: var(--af-ac-zone-h); }

/* ---------------------------------------------------------------------------
   More sheet rows
   --------------------------------------------------------------------------- */
.af-more-group { margin-block-start: var(--af-sp-4); }
.af-more-group:first-child { margin-block-start: 0; }
.af-more-group--tabs { display: none; }
.af-more-group-title { margin: 0 0 var(--af-sp-1); padding-inline: var(--af-sp-1); color: var(--af-ink-faint); font-family: var(--af-font-body); font-size: var(--af-fs-sm); font-weight: 500; }
.af-more-list { list-style: none; margin: 0; padding: 0; border-radius: var(--af-r-lg); background: var(--af-surface); border: 1px solid var(--af-border); overflow: hidden; }
.af-more-list > li + li { border-block-start: 1px solid var(--af-border); }
.af-more-row {
  display: flex;
  align-items: center;
  gap: var(--af-sp-3);
  width: 100%;
  min-height: 56px;
  padding-inline: var(--af-sp-4);
  border: 0;
  background: transparent;
  color: var(--af-ink);
  font: inherit;
  font-weight: 500;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}
.af-more-row:hover, .af-more-row:active { background: var(--af-surface-sunken); color: var(--af-ink); text-decoration: none; }
.af-more-row > .af-i:first-child { color: var(--af-ink-soft); }
.af-more-row[aria-current="page"] { color: var(--af-primary-text); font-weight: 600; }
.af-more-row[aria-current="page"] > .af-i:first-child { color: var(--af-primary-text); }
.af-more-row-label { flex: 1; min-width: 0; }
.af-more-row-chev { color: var(--af-ink-faint); }
.af-more-row--static { cursor: default; flex-wrap: wrap; }
.af-more-row--static:hover { background: transparent; }
.af-more-logout { margin-block: var(--af-sp-5) var(--af-sp-2); }
.af-more-logout .af-btn { color: var(--af-danger); }

/* ---------------------------------------------------------------------------
   AccessCore button (owner decision 5) — override from the shell only.
   --------------------------------------------------------------------------- */
/* All shells (app, focus, public): the same 48px trigger everywhere. */
html[data-shell] body .accesscore-fab {
  width: var(--af-ac-size);
  height: var(--af-ac-size);
}

/* ===========================================================================
   PHONE (<768): app bar + tab bar
   =========================================================================== */
@media (max-width: 767.98px) {
  html[data-shell="app"] body[data-authenticated="true"] {
    /* content (and the footer) clears tab bar + AccessCore button */
    padding-block-end: var(--af-bottom-clearance);
  }
  /* WCAG 2.4.11: viewport scroll-padding is read from the root element, so it
     lives on html (body scroll-padding has no effect). nav.js adds a focusin
     fallback for browsers that ignore scroll-padding on focus. */
  html[data-shell="app"]:has(> body[data-authenticated="true"]) {
    scroll-padding-block-end: var(--af-bottom-clearance);
  }
  html[data-shell="app"] body[data-authenticated="true"] .accesscore-fab {
    inset-block-end: calc(var(--af-tabbar-h) + var(--af-safe-bottom) + 12px);
    bottom: calc(var(--af-tabbar-h) + var(--af-safe-bottom) + 12px);
  }
  html[data-shell="app"] body[data-authenticated="true"] .accesscore-drawer {
    bottom: calc(var(--af-tabbar-h) + var(--af-safe-bottom) + var(--af-ac-size) + 20px);
    max-height: calc(100dvh - var(--af-tabbar-h) - var(--af-ac-size) - 48px - var(--af-safe-bottom));
  }
  /* Task pages (D17) and focus/public pages: no tab bar. */
  html[data-shell-kind="task"] .af-tabbar { display: none; }
  html[data-shell-kind="task"] body[data-authenticated="true"] { padding-block-end: calc(var(--af-ac-size) + var(--af-safe-bottom) + 32px); }
  html[data-shell-kind="task"] body .accesscore-fab,
  html[data-shell="app"] body:not([data-authenticated="true"]) .accesscore-fab,
  html[data-shell="focus"] body .accesscore-fab {
    bottom: calc(var(--af-safe-bottom) + 16px);
  }
  /* Task pages have no tab bar, and an open sheet covers it: the authenticated
     app rule above (higher specificity) would otherwise keep the trigger a
     tab-bar height up, over the sheet's or page's sticky action bar. Sheets and
     sticky bars leave the bottom inline-start corner free for it. */
  html[data-shell="app"][data-shell-kind="task"] body[data-authenticated="true"] .accesscore-fab,
  html.af-scroll-lock[data-shell="app"] body[data-authenticated="true"] .accesscore-fab {
    bottom: calc(var(--af-safe-bottom) + 16px);
    inset-block-end: calc(var(--af-safe-bottom) + 16px);
  }
  /* On-screen keyboard (iOS has no interactive-widget): hide the tab bar
     while a text field has focus on touch devices. */
  @media (pointer: coarse) {
    body:has(:is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]), textarea, select):focus) .af-tabbar { display: none; }
  }

  .af-more { max-height: calc(100dvh - var(--af-safe-top) - 24px); }
  .af-appbar-brand .af-brand-name { font-size: var(--af-fs-md); }
}

/* ===========================================================================
   TABLET (768–1023): side rail
   =========================================================================== */
@media (min-width: 768px) {
  .af-tabbar { display: none; }
  .af-sheet-grabber { display: none; }

  html[data-shell="app"] body[data-authenticated="true"] { padding-inline-start: var(--af-sidenav-rail-w); }

  .af-sidenav {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    z-index: var(--af-z-nav);
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: var(--af-sidenav-rail-w);
    padding: calc(var(--af-sp-3) + var(--af-safe-top)) var(--af-sp-2) var(--af-sp-2);
    padding-inline-start: max(var(--af-sp-2), env(safe-area-inset-left, 0px));
    background: var(--af-surface);
    border-inline-end: 1px solid var(--af-border);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
  .af-sidenav-brand { justify-content: center; margin-block-end: var(--af-sp-2); }
  .af-sidenav-brand .af-brand-name { display: none; }
  .af-sidenav-add { width: 56px; height: 56px; min-height: 56px; margin-inline: auto; padding: 0; border-radius: var(--af-r-lg); }
  .af-sidenav-add-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .af-sidenav-groups { display: none; }
  .af-navitem--primary, .af-sidenav-more {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 60px;
    padding: 6px 2px;
    font-size: var(--af-fs-xs);
    text-align: center;
  }
  .af-navitem--primary .af-navitem-label, .af-sidenav-more .af-navitem-label {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .af-sidenav-more { margin-block-start: var(--af-sp-1); }
  .af-ac-zone { margin-block-start: auto; }

  /* AccessCore in the reserved zone at the bottom of the rail. */
  html[data-shell="app"] body[data-authenticated="true"] .accesscore-fab {
    bottom: calc(var(--af-sp-4) + var(--af-safe-bottom));
    inset-inline-start: calc((var(--af-sidenav-rail-w) - var(--af-ac-size)) / 2);
  }
  html[data-shell="app"] body[data-authenticated="true"] .accesscore-drawer {
    inset-inline-start: calc(var(--af-sidenav-rail-w) + 12px);
    bottom: var(--af-sp-4);
  }

  .af-appbar { padding-inline: var(--af-sp-4); }
  .af-appbar-brand { display: none; }

  /* More as a side sheet anchored to the rail. */
  .af-more {
    inset-block: 0;
    inset-inline-start: var(--af-sidenav-rail-w);
    inset-inline-end: auto;
    width: min(380px, calc(100vw - var(--af-sidenav-rail-w)));
    max-height: none;
    border-radius: 0;
    animation-name: afFade;
  }
  .af-more .af-more-group--tabs { display: block; }

  /* Wider page gutters */
  html[data-shell="app"] body[data-authenticated="true"] .main-content > .container { padding-inline: var(--af-sp-6); }
}
@keyframes afFade { from { opacity: 0; } to { opacity: 1; } }

/* ===========================================================================
   DESKTOP (≥1024): persistent sidebar, slim top bar
   =========================================================================== */
@media (min-width: 1024px) {
  html[data-shell="app"] body[data-authenticated="true"] { padding-inline-start: var(--af-sidenav-w); }

  .af-sidenav {
    width: var(--af-sidenav-w);
    padding: calc(var(--af-sp-5) + var(--af-safe-top)) var(--af-sp-3) var(--af-sp-2);
  }
  .af-sidenav-brand { justify-content: flex-start; padding-inline: var(--af-sp-3); margin-block-end: var(--af-sp-3); }
  .af-sidenav-brand .af-brand-name { display: inline; }
  .af-sidenav-add { width: auto; height: auto; min-height: var(--af-control-h); margin-inline: 0; padding-inline: var(--af-sp-4); border-radius: var(--af-r-md); }
  .af-sidenav-add-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .af-sidenav-groups { display: block; }
  .af-sidenav-more { display: none; }
  .af-navitem--primary {
    flex-direction: row;
    justify-content: flex-start;
    gap: var(--af-sp-3);
    min-height: var(--af-target-min);
    padding: 0 var(--af-sp-3);
    font-size: var(--af-fs-md);
    text-align: start;
  }
  .af-sidenav .af-i { width: 20px; height: 20px; }

  html[data-shell="app"] body[data-authenticated="true"] .accesscore-fab {
    inset-inline-start: var(--af-sp-4);
  }
  html[data-shell="app"] body[data-authenticated="true"] .accesscore-drawer {
    inset-inline-start: calc(var(--af-sidenav-w) + 12px);
  }

  .af-appbar { padding-inline: var(--af-sp-7); min-height: 64px; }
  .af-appbar-title { display: none; }
  .af-appbar-back { display: none; }
  /* Search as a field-shaped button */
  .af-appbar-search {
    width: auto;
    min-width: 280px;
    justify-content: flex-start;
    gap: var(--af-sp-2);
    padding-inline: var(--af-sp-4) var(--af-sp-2);
    border: 1px solid var(--af-border-strong);
    border-radius: var(--af-r-pill);
    background: var(--af-surface);
    color: var(--af-ink-faint);
    display: inline-flex;
    align-items: center;
  }
  .af-appbar-search-label { display: inline; flex: 1; text-align: start; font-size: var(--af-fs-sm); }
  .af-appbar-search .af-kbd { display: inline-flex; }
  .af-appbar-search .af-i { width: 20px; height: 20px; }
  .af-account .nav-label { display: inline; max-width: 16ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .af-account .nav-arrow { display: inline; }
  .af-account .nav-user-toggle { padding-inline-end: var(--af-sp-3); }

  html[data-shell="app"] body[data-authenticated="true"] .main-content > .container { padding-inline: var(--af-sp-7); }
}

/* Footer: legal links reachable, quiet. */
.footer { background: var(--af-surface); border-block-start: 1px solid var(--af-border); }
.footer-links a, .footer-link-btn { display: inline-flex; align-items: center; justify-content: center; min-height: var(--af-target-min); min-width: var(--af-target-min); }
/* Phones: one wrapped row of links. Separators are decorative and dropped. */
@media (max-width: 767.98px) {
  .footer .footer-links { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 0 var(--af-sp-1); }
  .footer .footer-separator { display: none; }
  .footer .footer-links a, .footer .footer-link-btn { padding-inline: var(--af-sp-2); }
}

/* Focus pages (sign-in flows): brand + a link to the other language. */
.af-publicbar--focus .af-langlink {
  margin-inline-start: auto;
  display: inline-flex; align-items: center; min-height: var(--af-target-min);
  padding-inline: var(--af-sp-3);
  border-radius: var(--af-r-pill);
  color: var(--af-ink-soft); font-weight: 500; text-decoration: none;
}
.af-publicbar--focus .af-langlink:hover { background: var(--af-surface-sunken); color: var(--af-ink); }
.af-publicbar--focus:has(.af-langlink) { justify-content: flex-start; }

/* Cookie banner: all of its rules (z-index, tab-bar offset) live in
   cookie-consent.css, which loads after this sheet (Phase 5B). */

/* Legacy /m pages keep their own chrome (no shell rendered there). */

/* The AccessCore button floats above every surface (legal obligation, never
   hidden). Give the More sheet's scroll area room so its last rows can be
   scrolled clear of it. */
.af-more .af-sheet-body { padding-block-end: calc(var(--af-ac-zone-h) + var(--af-safe-bottom)); }

/* ===========================================================================
   CP3 fixes
   =========================================================================== */

/* M3 — the page-level transaction FAB duplicates the shell's Add (centre tab
   on phones, rail/sidebar button from 768) at every width; CP2: no floating
   add. It stays in the DOM because the shell's Add clicks it to reuse the
   page's handler (nav.js triggerAdd). */
html[data-shell="app"] body[data-authenticated="true"] #addTransactionBtn.fab-button { display: none !important; }

/* B1 — legacy page FABs vs the tab bar (<768). The tab bar always wins: page
   FABs keep their IDs/handlers but sit ABOVE the bar at the inline-end corner
   (AccessCore owns the inline-start corner), below the bar's z-index so they
   can never take its taps. #addTransactionBtn stays hidden on phones because
   the centre Add tab runs the same handler. */
@media (max-width: 767.98px) {
  html[data-shell="app"] body[data-authenticated="true"] :is(.fab-button, .loan-fab, .mm-fab):not(#addTransactionBtn) {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    inset-inline-start: auto;
    inset-inline-end: 16px;
    bottom: calc(var(--af-tabbar-h) + var(--af-safe-bottom) + 12px);
    inset-block-end: calc(var(--af-tabbar-h) + var(--af-safe-bottom) + 12px);
    width: 56px;
    height: 56px;
    min-width: 56px;
    z-index: calc(var(--af-z-nav) - 1);
    margin: 0;
  }
  .af-tabbar { z-index: var(--af-z-nav); isolation: isolate; }
}

/* B2 — Home's summary grid now lives in pages/home.css (content-width
   based). Tiles keep min-width:0 so money values can shrink, never clip. */
html[data-shell="app"] .finance-dashboard .summary-card,
html[data-shell="app"] .finance-dashboard .summary-card .amount { min-width: 0; }

/* H3 — the AccessCore reserved zone is pinned to the bottom of the rail /
   sidebar (sticky inside the scrolling nav), so nav items scroll under the
   zone and the fixed AccessCore button never sits on a link. */
@media (min-width: 768px) {
  .af-sidenav .af-ac-zone {
    position: sticky;
    bottom: calc(-1 * var(--af-sp-2));
    z-index: 2;
    margin-block-end: calc(-1 * var(--af-sp-2));
    background: var(--af-surface);
    box-shadow: 0 -1px 0 var(--af-border);
  }
  /* Keyboard focus scrolls nav items clear of that zone (Phase 6 Q2-15). */
  .af-sidenav { scroll-padding-block-end: calc(var(--af-ac-zone-h) + var(--af-sp-2)); }
}

/* Q2-16 — phones: content that is wider than the screen (e.g. AccessCore
   200% text) must not widen the layout viewport, or the fixed tab bar grows
   with it and its end tab ("More") is pushed off-screen. */
@media (max-width: 767.98px) {
  html[data-shell="app"] body[data-authenticated="true"] :is(#main-content, .demo-banner) { overflow-x: clip; }
}

/* Q1-06 — short landscape phones (e.g. 667x375): the page toolbars stop
   sticking under the app bar, so app bar + toolbar + tab bar no longer take
   half the height. `html body` lifts the selector over the page CSS, which
   loads after this file. */
@media (max-height: 430px) and (orientation: landscape) and (max-width: 1023.98px) {
  html body :is(#txnPage .txn-toolbar, .lr-toolbar, .rec-toolbar, #categoriesPage .cat-toolbar, .pf-tabs-wrap) { position: relative; inset-block-start: auto; top: auto; }
}

/* B2 (recurring tape) — the page's own 4→2 column switch is at a 900px
   VIEWPORT; re-expressed as ~900px of CONTENT next to the rail (80px) and
   the sidebar (256px). */
@media (min-width: 768px) and (max-width: 979.98px), (min-width: 1024px) and (max-width: 1155.98px) {
  html[data-shell="app"] body[data-authenticated="true"] .mm-tape { grid-template-columns: repeat(2, 1fr); }
  html[data-shell="app"] body[data-authenticated="true"] .mm-tape-cell:nth-child(3) { border-inline-start: 0; }
  /* Same content-width switch for the ledger rows (their 5 fixed tracks
     overflowed ~700px of content at 1024). Mirrors the page's 900px block. */
  html[data-shell="app"] body[data-authenticated="true"] .mm-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "desc amt" "meta meta" "next next";
    gap: 0.35rem 0.75rem;
  }
  html[data-shell="app"] body[data-authenticated="true"] .mm-row-desc { grid-area: desc; }
  html[data-shell="app"] body[data-authenticated="true"] .mm-row-amount { grid-area: amt; }
  html[data-shell="app"] body[data-authenticated="true"] .mm-row-freq { grid-area: meta; text-align: start; }
  html[data-shell="app"] body[data-authenticated="true"] .mm-row-next { grid-area: next; text-align: start; }
  html[data-shell="app"] body[data-authenticated="true"] .mm-row-actions { grid-column: 1 / -1; opacity: 1; transform: none; padding-top: 0.35rem; }
}
@media (max-width: 479.98px) {
  /* Phone: two tape cells per row are ~110px wide; size the signed amount to
     fit instead of clipping it. */
  html[data-shell="app"] body[data-authenticated="true"] .mm-tape-cell { padding: 0.875rem 0.75rem; }
  html[data-shell="app"] body[data-authenticated="true"] .mm-tape-value { font-size: 1.125rem; }
}

/* L2 — English tab labels are longer ("Transactions"); a slightly smaller
   label fits the 72–78px tab at 360–390 instead of truncating. */
html[lang="en"] .af-tab-label { font-size: 0.6875rem; letter-spacing: -0.01em; }
html[lang="en"][data-ac-font-scale] .af-tab:not(.af-tab--add) .af-tab-label { font-size: min(0.6875rem, 14px); }

/* L7 — #main-content is a programmatic focus target for the skip link
   (tabindex="-1"); it never shows a ring of its own. */
#main-content:focus { outline: none; }

/* M7 — recurring view execution rows used fixed 8rem + 5.5rem tracks plus
   three 1rem gaps (~264px before any amount), so at 360–390 the "kind"
   label was pushed off-screen. Phones: two rows of two (date | amount,
   difference | kind). */
@media (max-width: 479.98px) {
  html[data-shell="app"] .mm-view-exec {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.25rem 0.75rem;
  }
  html[data-shell="app"] .mm-view-exec-diff { text-align: start; }
  html[data-shell="app"] .mm-view-exec-kind { text-align: end; }
}

/* Overflow guards (pre-existing page grids with fixed tracks wider than a
   360–390 phone; the capture flagged them as clipped overflow). Minimal,
   layout-only; the full page redesigns are Phase 4. */
@media (max-width: 479.98px) {
  html[data-shell="app"] .progress-section .progress-stats { grid-template-columns: minmax(0, 1fr); }
  html[data-shell="app"] .reports-shell { grid-template-columns: minmax(0, 1fr); }
  html[data-shell="app"] .reports-shell > * { min-width: 0; }
  html[data-shell="app"] .reports-main { grid-template-columns: minmax(0, 1fr); }
  html[data-shell="app"] .reports-filter-group { min-width: 0; max-width: 100%; }
  html[data-shell="app"] .reports-filter-group :is(input, select) { max-width: 100%; }
  /* finance.css forces nowrap with !important at ≤480 */
  html[data-shell="app"] .finance-dashboard .dashboard-header { flex-wrap: wrap !important; row-gap: var(--af-sp-3); }
}

/* ---------------------------------------------------------------------------
   Nav count badge (Recurring: due manual rules awaiting the user).
   Primary, not red: red is reserved for overspend/errors (CP2 decision 3).
   --------------------------------------------------------------------------- */
.af-navbadge { background: var(--af-primary); color: var(--af-on-primary); }
.af-navbadge[hidden] { display: none; }
.af-tab-pill { position: relative; }
.af-tab-pill .af-navbadge { position: absolute; inset-block-start: -6px; inset-inline-end: 4px; }
.af-navitem .af-navbadge, .af-more-row .af-navbadge { margin-inline-start: auto; }
.af-more-row .af-navbadge + .af-more-row-chev { margin-inline-start: var(--af-sp-2); }
/* Rail (icon-only, 768–1023): badge on the icon corner. */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .af-navitem { position: relative; }
  .af-navitem .af-navbadge { position: absolute; inset-block-start: 4px; inset-inline-end: 12px; margin: 0; }
}

/* ===========================================================================
   Notification bell items (js/notification-bell.js). Moved from aurora-global.css 25d.
   The panel/sheet chrome lives in ds/shell.css; these are the item links.
   =========================================================================== */
.af-bell .notification-bell-list li.bell-item { padding: 0; }
.af-bell .bell-item-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: var(--af-target-min, 44px);
  padding: var(--af-sp-3);
  border-radius: var(--af-r-md);
  color: var(--af-ink);
  text-decoration: none;
}
.af-bell .bell-item-link:hover { background: var(--af-surface-sunken); text-decoration: none; }
.af-bell .bell-item-link:focus-visible { outline: 3px solid var(--af-focus); outline-offset: -3px; }
.af-bell .bell-item-link strong { font-size: var(--af-fs-sm); font-weight: 600; overflow-wrap: anywhere; }
.af-bell .bell-item.is-unread .bell-item-link strong::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-inline-end: 6px;
  border-radius: 50%;
  background: var(--af-primary);
  vertical-align: middle;
}
.af-bell .notification-bell-link:focus-visible { outline: 3px solid var(--af-focus); outline-offset: -3px; }
/* Phones: ds/shell.css turns the panel into a fixed bottom sheet, but the app
   bar's backdrop-filter makes the bar its containing block (the "sheet" landed
   inside the 56px bar) and its stacking context kept it under the tab bar.
   While the bell is open (notification-bell.js sets html.af-bell-open) drop the
   blur and lift the bar above the tab bar. */
@media (max-width: 767.98px) {
  html.af-bell-open .af-appbar {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    z-index: var(--af-z-sheet, 510);
  }
}


/* Demo banner: in document flow since Batch 5B (static), so it no longer needs a z-index here. */
/* Programmatic focus on a sheet title (tabindex=-1) shows no ring. */
:is([data-af-dialog], [role="dialog"]) :is(h1, h2)[tabindex="-1"]:is(:focus, :focus-visible) { outline: none; box-shadow: none; }
