/* =========================================================================
   MAGNET — RESPONSIVE SHELL FOUNDATIONS
   Structure only. No redesign. Everything below references existing tokens
   (tokens.css) — spacing scale, radii, shadows, colours, typography.

   Breakpoints (single source of truth):
     desktop  ≥ 1025px   — current grid shell, unchanged
     tablet   641–1024px — sidebar auto-collapses, expands as an OVERLAY
     mobile   ≤ 640px    — sidebar hidden, bottom nav + quick-action FAB

   Reusable components added here:
     .app                 DesktopShell        (existing grid — documented, not restyled)
     .sb-scrim            TabletSidebarOverlay (dim layer behind floating sidebar)
     .mobile-bottom       MobileShell         (fixed bottom region: nav + FAB)
     .bottom-nav          MobileBottomNav
     .quick-fab           QuickActionButton
     .quick-sheet         QuickActionsSheet
     .mobile-page         MobilePageContainer (opt-in per-page wrapper, used later)
   ========================================================================= */

/* (the --safe-* + responsive shell metric tokens now live in tokens.css) */

/* =========================================================================
   TABLET — 641 … 1024px
   The grid main column is flexible (1fr). When the sidebar is expanded it
   floats OVER the content instead of widening the column and pushing it.
   ========================================================================= */
/* Standard sheet header is mobile-only — hidden by default; the mobile media
   query (FilterSheet block) sets display:flex. Visual styles live here in base
   so the Design System can preview it on desktop. Baked into static menus so
   it only appears when they render as bottom sheets. */
.sheet-head {
  position: relative; display: none; align-items: center; gap: 8px;
  /* the sheet container contributes 12px above (its top inset), so 0 here +
     12px below keeps the buttons/title perfectly centred — 12px all around,
     matching the 12px side padding */
  min-height: 56px; padding: 0 6px 12px;
  border-bottom: 1px solid var(--border);
}
.sheet-head-title {
  /* absolute centring resolves against the PADDING box, whose 12px bottom
     pad (top inset lives on the sheet container) would sit the title 6px
     below the X/✓ buttons — pull it back up to the content-box centre */
  position: absolute; left: 50%; top: calc(50% - 6px); transform: translate(-50%, -50%);
  font-size: var(--text-base); font-weight: var(--fw-semibold);
  color: var(--text-strong); pointer-events: none;
  max-width: 58%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sheet-head-x, .sheet-head-ok {
  width: 44px; height: 44px; border-radius: var(--radius-full); flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
}
.sheet-head-x { background: var(--surface-field); color: var(--text-strong); }
@media (hover: hover) and (pointer: fine) {
  .sheet-head-x:hover { background: var(--border); }
}
.sheet-head-x svg { width: 18px; height: 18px; }
.sheet-head-ok { margin-left: auto; background: var(--primary-600); color: var(--on-primary); }
.sheet-head-ok svg { width: 19px; height: 19px; }

@media (min-width: 641px) and (max-width: 1024px) {
  /* Reserve a fixed 84px rail and pin the page content to column 2 so it
     NEVER shifts. The sidebar is always absolute (floating); expanding only
     animates its own width (84 → full) on top of the content — same open
     motion as desktop, minus the content push. */
  .app {
    grid-template-columns: var(--sidebar-rail) 1fr;
  }
  .app > .main { grid-column: 2; }

  .app > .sidebar {
    position: absolute;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-rail);
    z-index: var(--z-popover);
    transition: width var(--dur-slow) var(--ease), box-shadow var(--dur-slow) var(--ease);
  }
  .app:not(.collapsed) > .sidebar {
    width: var(--sidebar-w);
    box-shadow: var(--shadow-lg);
  }
  /* dim layer behind the floating sidebar — tap to collapse */
  .app:not(.collapsed) > .sb-scrim { opacity: 1; pointer-events: auto; }

  /* settings sidebar: same tablet model as the main one — an icon rail while
     .app.collapsed (labels/search/version hidden, icons centred with title
     tooltips, back + » stacked up top), expanding to the full text nav as an
     overlay via the » toggle; the shared .sb-scrim dims and tap-collapses. */
  .settings-head .collapse { display: inline-flex; }
  /* one button per state, matching the main rail: the rail shows only »
     (expand); ‹ back-to-app lives in the expanded overlay beside the title */
  .app.collapsed > .settings-sidebar .settings-back { display: none; }
  /* rail head keeps the standard shell-header height so » sits on the same
     line as the topbar crumb — exactly like the main sidebar's rail */
  .app.collapsed > .settings-sidebar .settings-head { justify-content: center; padding: var(--safe-top) 0 0; }
  .app.collapsed > .settings-sidebar .settings-head .collapse { margin-left: 0; }
  .app.collapsed > .settings-sidebar .settings-search,
  .app.collapsed > .settings-sidebar .settings-group-label,
  .app.collapsed > .settings-sidebar .settings-item span,
  .app.collapsed > .settings-sidebar .settings-version { display: none; }
  .app.collapsed > .settings-sidebar .settings-body { padding: var(--space-2); }
  .app.collapsed > .settings-sidebar .settings-item { justify-content: center; padding: 0; height: 42px; }
  .app.collapsed > .settings-sidebar .settings-group { display: flex; flex-direction: column; gap: 2px; }
  .app.collapsed > .settings-sidebar .settings-group + .settings-group { margin-top: var(--space-2); padding-top: var(--space-2); border-top: 1px solid var(--border-faint); }
}

/* TabletSidebarOverlay scrim — only ever active on tablet (see media query) */
.settings-nav-scrim { display: none; }   /* shown only on mobile (settings drawer) */
.sb-scrim {
  display: none;
  position: absolute; inset: 0;
  z-index: calc(var(--z-popover) - 1);
  background: rgba(20, 20, 28, 0.42);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
@media (min-width: 641px) and (max-width: 1024px) {
  .sb-scrim { display: block; }
}

/* =========================================================================
   MOBILE — ≤ 640px
   Desktop sidebar fully hidden. Compact top header. Fixed bottom nav + FAB.
   ========================================================================= */
.mobile-account-trigger { display: none; }
.dashboard-greeting { display: contents; }
@media (max-width: 640px) {
  /* viewport-accurate height so the bottom bar never floats over fold */
  .app-frame { height: 100dvh; }
  body.is-client-view .app-frame { height: calc(100dvh - var(--cv-bar-h)); }
  .cv-bar-msg span { display: none; }   /* phones: just the name */

  /* compact button labels — the desktop wording swaps for its short
     stand-in (see components.css .btn-label-sm) */
  .btn-label-ext { display: none; }
  .btn-label-sm { display: inline; }

  /* single column — desktop sidebar removed from layout entirely */
  .app { grid-template-columns: 1fr; }
  .app > .sidebar { display: none; }
  .sb-scrim { display: none; }

  /* ---- compact top header (MobileShell header) -------------------- */
  .topbar.shell-header {
    height: calc(68px + var(--safe-top));
    padding-top: var(--safe-top);
    padding-left: max(var(--space-5), var(--safe-left));
    padding-right: max(var(--space-4), var(--safe-right));
    gap: var(--space-2);
    border-bottom: 0;
  }
  /* drop the wide AI search (mobile uses the FAB search sheet) */
  .topbar .search,
  .topbar.search-open .search { display: none; }
  .topbar-right { gap: 8px; }
  /* Attio-inspired mobile hierarchy: the route name is the page heading, not
     a desktop breadcrumb. The active bottom tab already supplies the icon. */
  .topbar .crumb {
    min-width: 0;
    gap: var(--space-2);
    font-size: var(--text-2xl);
    font-weight: var(--fw-bold);
    letter-spacing: -0.035em;
    line-height: 1.05;
  }
  .topbar .crumb > .ico,
  .topbar .crumb > .cal-crumb-date .ico { display: none; }
  .topbar .crumb .seg.cur,
  .topbar .crumb .crumb-greet-name { font-weight: var(--fw-bold); }
  .dashboard-greeting { display: none; }
  .mobile-account-trigger {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    max-width: min(72vw, 250px);
    min-height: 44px;
    gap: var(--space-2);
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-strong);
    font: inherit;
    cursor: pointer;
  }
  .mobile-account-trigger .mobile-account-avatar {
    width: 30px;
    height: 30px;
    flex: 0 0 30px;
    border-radius: 9px;
    font-size: var(--text-sm);
  }
  .mobile-account-trigger.account,
  .mobile-account-trigger.account:hover {
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  .mobile-account-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: var(--text-base);
    font-weight: var(--fw-semibold);
    letter-spacing: -0.025em;
  }
  .mobile-account-chevron {
    display: inline-flex;
    flex: 0 0 auto;
    color: var(--text-muted);
  }
  .mobile-account-chevron svg { width: 14px; height: 14px; }
  .topbar-right .btn,
  .topbar-right .btn-icon {
    min-width: 44px;
    height: 44px;
    border-radius: var(--radius-full);
    /* Attio mobile: the discs float on a soft, wide shadow — no hairline */
    border-color: transparent;
    box-shadow: var(--shadow-disc);
  }
  .topbar-right .btn-icon {
    width: 44px;
    padding: 0;
  }
  .topbar-right .btn svg {
    width: 19px;
    height: 19px;
  }
  .topbar-right .cal-viewseg,
  .topbar-right .cal-viewseg button { border-radius: 100px; }
  .topbar-right .segmented {
    min-height: 44px;
    padding: 4px;
  }
  .topbar-right .segmented button {
    height: 36px;
    min-width: 58px;
    padding: 0 14px;
    font-size: var(--text-sm);
  }

  /* page toolbar row — let it scroll horizontally rather than wrap/clip */
  .main-toolbar.shell-header {
    padding-left: max(var(--space-4), var(--safe-left));
    padding-right: max(var(--space-4), var(--safe-right));
  }

  /* ---- page content: clear the bottom bar, respect side safe areas -- */
  .view-scroll {
    padding-bottom: calc(var(--bottomnav-h) + var(--space-6) + var(--safe-bottom));
    scrollbar-gutter: auto;
  }

  /* iOS shell: the bottom nav is the native Liquid Glass tab bar (NativeTabs.swift).
     The web bar is gone and the bar's height already reaches the page as
     env(safe-area-inset-bottom), so the scroll pane only needs its own gap. */
  /* --native-tabbar-inset: the bar's reach up from the screen edge (posted by
     native); minus the home indicator it plays the web bar's height in every
     existing padding formula (scroll pane, keyboard variants) */
  body.native-tabs { --native-tabbar-inset: 83px; --bottomnav-h: calc(var(--native-tabbar-inset) - var(--safe-bottom)); }
  body.native-tabs .mobile-bottom,
  body.native-tabs .mobile-bottom-fade { display: none !important; }
  .keyboard-up:not(.keyboard-avoidance-paused) .view-scroll {
    padding-bottom: calc(var(--bottomnav-h) + var(--space-6) + var(--safe-bottom) + var(--app-keyboard-height, 0px));
  }

  .keyboard-up:not(.keyboard-avoidance-paused) .view-scroll,
  .keyboard-up:not(.keyboard-avoidance-paused) .drawer-body,
  .keyboard-up:not(.keyboard-avoidance-paused) .td-scroll,
  .keyboard-up:not(.keyboard-avoidance-paused) .ne-scroll,
  .keyboard-up:not(.keyboard-avoidance-paused) .modal-body,
  .keyboard-up:not(.keyboard-avoidance-paused) .sched-body,
  .keyboard-up:not(.keyboard-avoidance-paused) .settings-body,
  .keyboard-up:not(.keyboard-avoidance-paused) .cal-time-body {
    scroll-padding-bottom: calc(var(--app-keyboard-height, 0px) + 24px);
  }

  /* Anchored bottom sheets stay put when the keyboard opens (native reveal scroll
     is suppressed); instead their OWN scroll container gets keyboard-height of
     extra bottom room so the in-app avoidance can lift any focused input clear of
     the keyboard by scrolling inside the sheet — never by moving the sheet. The
     padding sits below the fold, so adding/removing it doesn't shift visible
     content. (.view-scroll has its own keyboard padding above.) */
  /* A real trailing spacer, not padding: these panes are flex columns, and
     WebKit leaves a flex scroller's end padding out of its scrollable
     overflow — so the pane never gained the room to scroll a low field up. */
  .keyboard-up:not(.keyboard-avoidance-paused) .drawer-body::after,
  .keyboard-up:not(.keyboard-avoidance-paused) .td-scroll::after,
  .keyboard-up:not(.keyboard-avoidance-paused) .ne-scroll::after,
  .keyboard-up:not(.keyboard-avoidance-paused) .modal-sheet .modal-body::after,
  .keyboard-up:not(.keyboard-avoidance-paused) .sched-body::after,
  .keyboard-up:not(.keyboard-avoidance-paused) .cal-time-body::after {
    content: ""; display: block; flex: 0 0 auto; width: 100%;
    height: calc(var(--app-keyboard-height, 0px) + 24px);
  }
}

/* =========================================================================
   MobileShell — fixed bottom region holding the nav bar + quick FAB.
   Hidden by default; shown only at ≤640px (rule above).
   ========================================================================= */
.mobile-bottom {
  display: none;
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--space-3) + var(--safe-bottom));   /* float above the edge */
  z-index: var(--z-toolbar);
  align-items: stretch;
  gap: var(--space-3);
  padding-left: max(var(--space-4), var(--safe-left));
  padding-right: max(var(--space-4), var(--safe-right));
  pointer-events: none;   /* let taps fall through the gaps between pieces */
}
.mobile-bottom > * { pointer-events: auto; }
/* The mobile search sheet is kept mounted at every width (preloaded so the first
   tap is instant), but it's a phone-only UI. Hide it by default — otherwise above
   640px it has no layout rules and renders as a stray block with a full-width
   icon. The max-width:640px block below lays it out (display:flex wins on source
   order). */
.mobile-search-sheet { display: none; }
/* show the bottom region only on mobile. Declared AFTER the base rule above so
   it wins on source order (equal specificity); also hide the dashboard's
   secondary toolbar on mobile. */
@media (max-width: 640px) {
  .mobile-bottom { display: flex; }
  /* Dashboard uses its header for the workspace/account trigger; its secondary
     desktop toolbar remains redundant on a phone. */
  #main:has(#viewScroll > .dash) #mainToolbar { display: none; }
  .dash > .kpi-grid { order: 1; }

  /* New Event is reachable via the calendar FAB on mobile — hide the
     redundant toolbar button so it isn't shown twice. */
  [data-new-event] { display: none; }

  /* Clients grid is toolbar-less on mobile (owner call 28 Aug): grid is the
     only phone view (no Grid/List/Performance switch) and the bottom-nav FAB
     carries Create-client — the whole row goes. The All/Pinned/Overdue/
     Inactive segment still collapses into the ⋮ kebab that
     applyMobileLeadTools moves up beside the "Clients" crumb (its
     .filter-menu renders as the shared FilterSheet, same as Tasks/Leads). */
  #mainToolbar[data-route="projects"] { display: none; }
  .topbar-right .proj-filterdd.tb-moved { display: block; }

  /* Client detail: ONE topbar control — the section selector (Edit/Delete
     live at the bottom of its sheet); other tabs retain only their
     context-specific toolbar actions. */
  .topbar-right .client-sectiondd.tb-moved { display: block; }
  /* Icon-only trigger: current section's icon + chevron — the label would
     truncate at this width, so it's dropped (title/aria-label carry it). */
  .topbar-right .client-section-trigger {
    padding: 0 8px 0 10px;
    gap: 4px;
  }
  .topbar-right .client-section-trigger .client-section-label { display: none; }
  .topbar-right .client-section-trigger > svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
  }
  .topbar-right .client-section-trigger > svg:last-child {
    width: 13px;
    height: 13px;
    opacity: 0.6;
  }
  #mainToolbar[data-route="client"] .cd-tabseg,
  #mainToolbar[data-route="client"] .cd-overview-actions { display: none; }
  /* ---- 16px mobile page gutter ------------------------------------
     Home/Leads/Tasks and the shell chrome inset pages at
     max(var(--space-4), safe-area); the Clients grid, the client-profile
     tabs and Settings shipped with their 24px desktop gutter — align them.
     (Tab-specific :has() overrides like the Content/Deliverables full-bleed
     wrappers are higher-specificity and keep their padding: 0.) */
  .projects-page,
  .client-detail,
  .drive,
  .cdeliv-page,
  .cdeliv-rail,
  .cs-list-wrap,
  .cs-create-head, .cs-create-body, .cs-create-foot,
  .csched,
  .set-page {
    padding-left: max(var(--space-4), var(--safe-left));
    padding-right: max(var(--space-4), var(--safe-right));
  }
  .cdeliv-layout > .cdeliv-cycbar {
    padding-left: max(var(--space-4), var(--safe-left));
    padding-right: max(var(--space-4), var(--safe-right));
  }
  /* .cd-header full-bleeds through the parent inset with negative margins —
     keep the two in lock-step so its hairline still reaches the edges */
  .cd-header {
    margin-left: calc(-1 * max(var(--space-4), var(--safe-left)));
    margin-right: calc(-1 * max(var(--space-4), var(--safe-right)));
    padding-left: max(var(--space-4), var(--safe-left));
    padding-right: max(var(--space-4), var(--safe-right));
  }

  /* Client detail: the toolbar row exists only for tab-specific actions.
     Hide it by default on mobile — Overview and Integrations have none, and
     Deliverables is view-first (Manage services stays desktop-only) — and
     bring it back only when the tab renders real controls (Content subtabs,
     Files, Notes). */
  #mainToolbar[data-route="client"] { display: none; }
  #mainToolbar[data-route="client"]:has(> .btn:not([data-manage-services]), > .btn-split, > .segmented:not(.cd-tabseg)) { display: flex; }
  /* the schedule tab is view-only on mobile — no Create-post split button */
  #mainToolbar[data-route="client"] > .btn-split { display: none; }
  /* Files: the Drive Sync wiring is a desktop task, and grid is the one
     mobile view — no grid/list toggle */
  #mainToolbar[data-route="client"] .files-sync,
  #mainToolbar[data-route="client"] .files-viewseg,
  #mainToolbar[data-route="drive"] .files-viewseg { display: none; }
  #mainToolbar[data-route="client"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  #mainToolbar[data-route="client"]::-webkit-scrollbar { display: none; }
  #mainToolbar[data-route="client"] > * { flex-shrink: 0; }

  /* Keep the breadcrumb readable beside the two client-detail controls. */
  .topbar .crumb:has(.crumb-client) {
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  /* the Drive's path (DriveView topCrumb): the parent and where you are */
  .topbar .crumb .drive-crumb-far { display: none; }
  .topbar .crumb:has(.crumb-client) .crumb-link,
  .topbar .crumb:has(.crumb-client) .crumb-sep { flex-shrink: 0; }
  .topbar .crumb .crumb-client {
    min-width: 0;
    overflow: hidden;
  }
  .crumb-client-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Assignment belongs with client identity on mobile; edit/delete live in the
     topbar actions sheet, so the duplicate title pencil is removed. */
  .cd-title-wrap { min-width: 0; flex: 1; }
  .cd-title { width: 100%; min-width: 0; }
  .cd-title-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .cd-title .cd-edit { display: none; }
  .cd-sub { flex-wrap: nowrap; }
  .cd-mobile-assign {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 28px;
    padding: 0 9px;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    background: var(--surface-field);
    color: var(--text);
    font-size: var(--text-xs);
    font-weight: var(--fw-semibold);
    margin-left: auto;
    flex-shrink: 0;
  }
  .cd-mobile-assign svg { width: 14px; height: 14px; color: var(--primary-600); }

  /* Create note + Manage templates live in the FAB / elsewhere on mobile, so
     the notes toolbar row is empty — hide it (keep the empty-state CTA). */
  #mainToolbar[data-route="notes"] { display: none; }

  /* Calendars filter → icon-only on mobile (drop the label). It is relocated
     into the topbar next to the Month/Day toggle by applyMobileLeadTools(). */
  .cal-filter-btn { width: 44px; height: 44px; padding: 0; justify-content: center; border-radius: var(--radius-full); }
  .cal-filter-btn > span { display: none; }

  /* mobile calendar: the period label now lives in the topbar crumb (tappable →
     today) and paging is by swipe, so the second toolbar row is empty — hide it. */
  #mainToolbar[data-route="calendar"] { display: none; }
  .cal-crumb-date {
    background: none; border: none; padding: 0 2px; margin: 0;
    font: inherit; cursor: pointer; min-height: 44px;
    display: inline-flex; align-items: center; gap: 5px;
  }
  .cal-crumb-date:active { opacity: 0.55; }

  /* Mobile settings navigation: compact section picker above the bottom edge. */
  .app > .settings-sidebar {
    display: flex;
    position: fixed; top: auto; bottom: 0; left: 0; right: 0;
    width: auto;
    max-height: 80dvh;
    padding: 12px 16px calc(16px + var(--safe-bottom));
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 28px 28px 0 0;
    z-index: calc(var(--z-popover) + 4);
    transform: translateY(100%);
    visibility: hidden;
    transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow-lg);
  }
  body.settings-nav-open .app > .settings-sidebar { transform: translateY(0); visibility: visible; }
  .app > .settings-sidebar::before {
    content: ""; width: 36px; height: 4px; flex-shrink: 0;
    margin: 0 auto 20px; border-radius: 100px; background: var(--border-strong);
  }
  .app > .settings-sidebar .settings-head,
  .app > .settings-sidebar .sidebar-toolbar,
  .app > .settings-sidebar .settings-search,
  .app > .settings-sidebar .settings-version { display: none; }
  .app > .settings-sidebar .settings-body { flex: 0 1 auto; padding: 0; overscroll-behavior: contain; }
  .app > .settings-sidebar .settings-group { margin-bottom: 20px; }
  .app > .settings-sidebar .settings-group:last-child { margin-bottom: 0; }
  .app > .settings-sidebar .settings-group-label { font-size: 12px; margin-bottom: 8px; }
  .app > .settings-sidebar .settings-item { height: 48px; border-radius: 12px; font-size: 15px; }
  .app.collapsed > .settings-sidebar .settings-item span { display: inline; }
  /* Settings header (Attio "Edit Profile"): a 44px disc either side of a
     centred title — exit chevron on the left, primary "done" check on the
     right — both in the same raised disc as the topbar's sort / filter / add. */
  /* Settings is a pushed screen: it slides in from the right and pops back
     out from Back / Done or a left→right drag (settingsSlide.js drives the
     transform). The tab bar + FAB hide under it — it has its own exits. */
  body:has(#app > .settings-sidebar) .mobile-bottom { display: none; }   /* #app only — the popping layer must not hide the tab bar it reveals */
  .app:has(> .settings-sidebar) .view-scroll { padding-bottom: calc(var(--space-6) + var(--safe-bottom)); }
  .settings-slide {
    touch-action: pan-y; will-change: transform;
    box-shadow: var(--shadow-lg);
    animation: settingsPush var(--motion-sheet-open) var(--ease-enter);
  }
  /* while pushing in / popping out, settings is its own fixed layer so the
     screen behind (a ghost on push, the real rebuilt shell on pop) can sit
     underneath and parallax with it */
  /* Page switch (tab bar): a fast whole-page crossfade — a static ghost of
     the outgoing <main> (shared/lib/viewTransition) pinned over the page,
     under the bottom bar, fading out while the new route renders beneath.
     The per-view slide-in intro is off on phones: the crossfade IS the intro. */
  .view-ghost {
    position: fixed; z-index: calc(var(--z-toolbar) - 1);
    pointer-events: none; overflow: hidden;
    opacity: 1; transition: opacity 160ms var(--ease);
  }
  .view-ghost.is-fading { opacity: 0; }
  .view-enter { animation: none; }
  .settings-slide.is-pushing { position: fixed; inset: 0; z-index: var(--z-overlay); }
  /* the pop: #app's whole settings content moves into this fixed layer (still
     a .app, so every settings-scoped rule keeps matching) and slides off */
  .settings-layer {
    position: fixed; inset: 0; z-index: var(--z-overlay);
    box-shadow: var(--shadow-lg); will-change: transform;
    transition: transform var(--motion-sheet-close) var(--ease-ios);
  }
  .settings-layer.is-dragging { transition: none; }
  .settings-layer.is-leaving { transform: translateX(100%); }
  .settings-ghost { position: fixed; inset: 0; overflow: hidden; pointer-events: none; background: var(--surface); }
  .settings-ghost > .mobile-bottom { display: flex; }
  .settings-behind { will-change: transform; transition: transform var(--motion-sheet-close) var(--ease-ios); }
  .settings-behind.is-pushing { transition-duration: var(--motion-sheet-open); transition-timing-function: var(--ease-enter); }
  .settings-behind.is-dragging { transition: none; }
  .settings-dim {
    position: fixed; inset: 0; z-index: calc(var(--z-overlay) - 1); pointer-events: none;
    background: var(--overlay-dark); opacity: 0;
    transition: opacity var(--motion-sheet-close) var(--ease-ios);
  }
  .settings-behind.is-dragging ~ .settings-dim, .settings-dim.is-dragging { transition: none; }
  .app:has(> .settings-sidebar) #main > .topbar > .topbar-right { display: none; }
  .app:has(> .settings-sidebar) #main > .topbar > .crumb {
    flex: 1; display: grid; grid-template-columns: 44px minmax(0, 1fr) 44px;
    align-items: center; gap: var(--space-2);
    font-size: var(--text-lg); font-weight: var(--fw-semibold); letter-spacing: -0.02em;
  }
  .settings-mobile-back,
  .settings-mobile-done {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex-shrink: 0; padding: 0;
    border-radius: var(--radius-full);
    background: var(--surface); color: var(--text-strong);
    border: 1px solid transparent; box-shadow: var(--shadow-disc);
  }
  .settings-mobile-done {
    background: var(--btn-primary-bg); color: var(--btn-primary-fg);
  }
  @media (hover: hover) and (pointer: fine) {
    .settings-mobile-done:hover { background: var(--btn-primary-hover); }
  }
  .settings-mobile-back:active,
  .settings-mobile-done:active { transform: scale(0.97); }
  .settings-mobile-back svg,
  .settings-mobile-done svg { width: 19px; height: 19px; }
  /* Settings pages share a quiet canvas, compact group headings and flat
     surfaces. Profile details read as rows rather than nested input cards. */
  .app:has(> .settings-sidebar) #main,
  .app:has(> .settings-sidebar) #main > .topbar { background: var(--surface-field); }
  .app:has(> .settings-sidebar) .set-page {
    padding: 12px 16px 28px;
    gap: 16px;
  }
  .app:has(> .settings-sidebar) .set-section-head h2 {
    font-size: 14px; font-weight: var(--fw-medium); color: var(--text-muted);
  }
  .app:has(> .settings-sidebar) .set-section-head p { font-size: 12px; line-height: 1.5; }
  .app:has(> .settings-sidebar) .set-subhead { margin: 12px 4px -8px; }
  .app:has(> .settings-sidebar) .set-card {
    border-radius: 18px;
    border-color: var(--border-faint);
    box-shadow: none;
    padding: 16px;
  }
  .app:has(> .settings-sidebar) .set-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .app:has(> .settings-sidebar) .set-label { font-size: 12px; font-weight: var(--fw-medium); }
  .app:has(> .settings-sidebar) .set-card .input {
    min-height: 44px; font-size: 16px; border-radius: 10px; box-shadow: none;
  }
  .app:has(> .settings-sidebar) .set-card .btn { min-height: 44px; border-radius: 100px; }
  .app:has(> .settings-sidebar) .set-row { min-height: 64px; gap: 12px; }
  /* Notifications → Push: the native "This device" block is a card nested in
     the channel panel — on phones it reads as plain rows in the list, not an
     inset box with its own padding */
  .app:has(> .settings-sidebar) .notification-channel-options [data-native-notification-card] {
    padding: 0; border: 0; border-radius: 0; box-shadow: none; gap: 0;
  }
  .app:has(> .settings-sidebar) .notification-channel-options .set-rows-label {
    padding: 12px 0 0; font-size: 12px; font-weight: var(--fw-medium); color: var(--text-muted);
  }
  .app:has(> .settings-sidebar) .notification-channel-options [data-native-notification-card] + .set-row { border-top: 1px solid var(--border-faint); }
  .app:has(> .settings-sidebar) .set-row-title { font-size: 15px; font-weight: var(--fw-medium); }
  .app:has(> .settings-sidebar) .set-row-desc { line-height: 1.5; }
  .set-profile-page > .set-section-head:first-child { display: none; }
  .set-profile-page .set-pic {
    gap: 16px; padding-bottom: 20px; border-bottom: 1px solid var(--border-faint);
  }
  .set-profile-page .set-pic-avatar .avatar,
  .set-profile-page .set-pic-img { width: 60px; height: 60px; font-size: 22px; }
  .set-profile-page .set-pic-badge { width: 24px; height: 24px; right: -2px; bottom: -2px; }
  .set-profile-page .set-pic-badge svg { width: 13px; height: 13px; }
  .set-profile-page .set-pic-title { font-size: 15px; }
  .set-profile-page .set-pic-desc { font-size: 12px; line-height: 1.5; }
  .set-profile-page .set-pic-btn { margin-top: 8px; font-size: 13px; }
  /* Client profile: the photo card stands alone; the account details are an
     iOS-style grouped list — label left, value right, hairline dividers. */
  .set-profile-client .set-pic { padding-bottom: 0; border-bottom: 0; }
  .app:has(> .settings-sidebar) .set-kv-card { padding: 0 16px; }
  .set-kv-row { min-height: 48px; padding: 10px 0; gap: 12px; }
  .set-kv dt { flex-basis: 116px; font-size: 14px; }
  .set-kv dd { font-size: 16px; }
  .set-kv-foot { margin: -4px 4px 0; font-size: 12px; line-height: 1.5; }
  /* Integrations → Share a login: the 2-up input wrap truncates its
     placeholders at phone width — stack the fields full-width */
  .axr-addcred .input { flex-basis: 100%; min-width: 0; min-height: 44px; font-size: 16px; }
  .axr-addcred .btn { min-height: 44px; }
  .app:has(> .settings-sidebar) #viewScroll > .set-section > .set-section-head:first-child:has(h2):not(:has(p)) { display: none; }
  .settings-nav-scrim {
    display: block; position: fixed; inset: 0;
    z-index: calc(var(--z-popover) + 3);
    background: rgba(11, 11, 15, 0.4);
    opacity: 0; pointer-events: none;
    transition: opacity 240ms cubic-bezier(0.22, 1, 0.36, 1);
  }
  body.settings-nav-open .settings-nav-scrim { opacity: 1; pointer-events: auto; }
  .settings-nav-toggle {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1-5);
    background: none; border: none; padding: 0; margin: 0; font: inherit;
    cursor: pointer; color: inherit; min-height: 44px; min-width: 0; justify-self: center; max-width: 100%;
  }
  .settings-nav-toggle .seg.cur { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .settings-nav-toggle .ico { color: var(--text-strong); display: inline-flex; }
  .settings-nav-toggle .ico svg { width: 19px; height: 19px; }
  .settings-nav-toggle > svg:last-child { width: 16px; height: 16px; color: var(--text-soft); }
  @media (prefers-reduced-motion: reduce) {
    .app > .settings-sidebar, .settings-nav-scrim { transition: none; }
  }

  /* leads filter controls moved into the topbar — Status & Filter become
     icon-only; the view switch keeps its label. */
  .topbar-right .tb-moved { flex-shrink: 0; }
  .topbar-right #filterDd .btn,
  .topbar-right #orderDd .btn {
    width: 44px; height: 44px; padding: 0; justify-content: center;
  }
  .topbar-right #filterDd .btn > span,
  .topbar-right #filterDd .btn > svg:last-child,
  .topbar-right #orderDd .btn > span,
  .topbar-right #orderDd .btn > svg:last-child { display: none; }
  /* Add lead — icon-only (+) in the topbar, like the other moved controls */
  .topbar-right [data-new-lead].tb-moved { width: 44px; height: 44px; padding: 0; justify-content: center; }
  .topbar-right [data-new-lead].tb-moved > span { display: none; }
  /* the ⋮ kebab replaces the Status/Filter/View triggers — the filter dd's move
     up only so their menus can render as bottom sheets; triggers hide */
  .topbar-right .leads-tools-dd.tb-moved { display: block; }
  .topbar-right #filterDd > .btn,
  .topbar-right #orderDd > .btn { display: none; }
  /* disabled status (board view) → icon-only too */
  .topbar-right > button.btn.tb-moved[disabled] {
    width: 44px; height: 44px; padding: 0; justify-content: center;
  }
  .topbar-right > button.btn.tb-moved[disabled] > span,
  .topbar-right > button.btn.tb-moved[disabled] > svg:last-child { display: none; }
  /* keyboard-attached mobile search sheet (opened from the Leads FAB). */
  .mobile-search-sheet {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--z-popover) + 3);
    padding: var(--space-3) max(var(--space-4), var(--safe-right))
             calc(var(--space-3) + var(--safe-bottom)) max(var(--space-4), var(--safe-left));
    background: var(--surface);
    border-top: 1px solid var(--border);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    box-shadow: var(--shadow-lg);
    will-change: padding-bottom, transform, opacity;
    overflow: visible;
    opacity: 0;
  }
  /* Kept mounted + warm between opens (preloadMobileSearchSheet) so the first
     tap pays no init cost. Invisible (opacity:0 from the base rule) and inert so
     it never intercepts taps on the bottom nav / FAB while idle. */
  .mobile-search-sheet.is-preload {
    pointer-events: none;
    transform: translateY(100%);
  }
  .mobile-search-sheet.is-ready { opacity: 1; }
  .mobile-search-sheet.is-kb {
    padding-bottom: var(--space-3);
  }
  .mobile-search-sheet::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: calc(-1 * var(--keyboard-offset, 0px));
    height: var(--keyboard-offset, 0px);
    background: var(--surface);
    pointer-events: none;
  }
  .mobile-search-sheet.is-closing {
    opacity: 0;
    transform: translateY(calc(100% - var(--keyboard-offset, 0px)));
  }
  .mobile-search-field {
    flex: 1;
    min-width: 0;
    height: 48px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: 0 var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-field);
    color: var(--text-soft);
  }
  .mobile-search-field svg {
    width: 19px;
    height: 19px;
    color: var(--primary-500);
    flex-shrink: 0;
  }
  .mobile-search-field input {
    width: 100%;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: var(--text-base);
  }
  .mobile-search-field input:focus,
  .mobile-search-field input:focus-visible {
    outline: none;
    border: 0;
    box-shadow: none;
  }
  /* the FIELD carries the focus ring (the inner input's is suppressed above),
     matching the shared .search:focus-within treatment */
  .mobile-search-field:focus-within {
    border-color: var(--primary-400);
    box-shadow: var(--ring-primary);
  }
  .mobile-search-field input::placeholder { color: var(--text-soft); }
  .mobile-search-field input::-webkit-search-cancel-button { display: none; }
  /* ONE close button on mobile — the sheet head's 44px grey disc with an ink
     X (.sheet-head-x): modal heads, drawer heads (X and back-chevron alike),
     the dashboard customiser, note bars and the search sheet all share it. */
  .modal-close,
  .drawer-close,
  .dashcust-close,
  .modal-note .ne-bar-close,
  .mobile-search-close {
    width: 44px; height: 44px; flex-shrink: 0; padding: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--radius-full); border: 0;
    background: var(--surface-field); color: var(--text-strong);
  }
  @media (hover: hover) and (pointer: fine) {
    .modal-close:hover,
    .drawer-close:hover,
    .dashcust-close:hover,
    .modal-note .ne-bar-close:hover,
    .mobile-search-close:hover { background: var(--border); color: var(--text-strong); }
  }
  .modal-close svg,
  .drawer-close svg,
  .dashcust-close svg,
  .modal-note .ne-bar-close svg,
  .mobile-search-close svg { width: 18px; height: 18px; }
  /* =======================================================================
     FilterSheet — ONE shared bottom-sheet shell, reused by every filter /
     picker popover on mobile: the leads Status & Sort menus, the lead stage /
     follow-up picker, and the calendar "Calendars" filter. Each control keeps
     its own inner markup; this shell standardises the surface, top radius,
     grab handle, slide-up animation and scrim. Built on shared tokens.
     ======================================================================= */
  .filter-sheet,
  .topbar-right .filter-dd .filter-menu,
  .stage-picker.sp-sheet,
  .cal-filt-pop {
    position: fixed; left: 0; right: 0; top: auto; bottom: 0;
    width: 100%; min-width: 0; max-height: 80dvh; overflow-y: auto;
    border: none; border-top: 1px solid var(--border);
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    padding: var(--space-2) max(var(--space-3), var(--safe-left))
             calc(var(--space-4) + var(--safe-bottom)) max(var(--space-3), var(--safe-right));
    box-shadow: var(--shadow-lg);
    z-index: calc(var(--z-popover) + 2);
    animation: leadSheetUp var(--motion-sheet-open) var(--ease-enter);   /* shared open curve, matching every other sheet */
  }
  /* (grab-handle pill removed — sheets are dismissed by swipe-down / scrim /
     the header X; a small top inset keeps the chrome from hugging the edge) */
  .filter-sheet,
  .topbar-right .filter-dd .filter-menu,
  .stage-picker.sp-sheet,
  .cal-filt-pop { padding-top: var(--space-3); }
  /* comfortable (≥48px) tap targets inside any filter sheet */
  .filter-sheet .filter-opt,
  .topbar-right .filter-dd .filter-menu .filter-opt,
  .stage-picker.sp-sheet .filter-opt,
  .stage-picker.sp-sheet .sp-fu { min-height: 48px; font-size: var(--text-base); }
  .cal-filt-pop .cal-filt-row { min-height: 48px; padding: 10px 8px; }
  /* the sheet header now provides the title — hide the inline one, keep Select all */
  .cal-filt-pop.filter-sheet .cal-filt-head { justify-content: flex-end; }
  .cal-filt-pop.filter-sheet .cal-filt-head > span:first-child { display: none; }
  /* ===== Standard sheet header — shown on mobile (visual styles in base) ====
     Circular X (left) · centered title · primary tick (right). Matches the
     note editor + drawer sheets so every bottom sheet reads the same. */
  .sheet-head {
    display: flex;
    margin: 0 calc(-1 * max(var(--space-3), var(--safe-right))) 4px
            calc(-1 * max(var(--space-3), var(--safe-left)));
    padding-left: max(var(--space-3), var(--safe-left));
    padding-right: max(var(--space-3), var(--safe-right));
  }
  /* the standard sheet header sits just below the shared grab handle */

  /* shared scrim — dim layer that blocks page hover/clicks and dismisses on tap */
  .filter-sheet-scrim,
  .sheet-scrim,
  .sp-scrim {
    position: fixed; inset: 0;
    z-index: calc(var(--z-popover) + 1);
    background: var(--sheet-scrim);
  }
  /* leads filter sheets: fade the dim in alongside the sheet's slide-up */
  .lead-menu-scrim { animation: scrimFade var(--motion-overlay) var(--ease-enter); }

  /* remove the leads settings (gear) + Exports button on mobile */
  #mainToolbar[data-route="reports"] [data-leadsettings],
  #mainToolbar[data-route="reports"] .btn-split:has(.btn-primary) { display: none; }
  /* remove the date-scope ("All time") control on mobile */
  #mainToolbar[data-route="reports"] #sortDd { display: none; }
  /* with Status/Filter/view moved to the topbar and the rest removed, the
     leads toolbar row is empty on mobile — hide it entirely */
  #mainToolbar[data-route="reports"] { display: none; }
  /* the Sorted-by / Filter pills compact to icon + count beside the crumb */
  .topbar-right #leadsToolsTrigger .lf-trigger-label,
  .topbar-right #leadsToolsTrigger > svg:last-child,
  .topbar-right #leadsSortTrigger .lf-trigger-label,
  .topbar-right #leadsSortTrigger > svg:last-child { display: none; }
  .topbar-right #leadsToolsTrigger,
  .topbar-right #leadsSortTrigger {
    position: relative;
    width: 44px;
    min-width: 44px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-full);
  }
  /* the applied-filter count rides the disc's top-right corner (app-badge
     style, like the tab badges) instead of squeezing in beside the icon */
  .topbar-right #leadsToolsTrigger .lf-count {
    position: absolute; top: -3px; right: -3px;
    min-width: 18px; height: 18px; padding: 0 5px;
    box-shadow: 0 0 0 2px var(--surface);
  }

  /* Content tab — the Sharing|Scheduling toggle matches the 44px topbar
     buttons and keeps a short label (Share / Schedule via the
     .btn-label-ext/.btn-label-sm swap); the primary action goes icon-only
     and the row's padding/gaps tighten so it all fits on 375px */
  #mainToolbar [data-cc-new-share] span,
  #mainToolbar [data-cc-compose] span { display: none; }
  #mainToolbar { padding: 0 var(--space-4); gap: var(--space-2); }
  #mainToolbar .ch-tabs { padding: 3px; }
  #mainToolbar .ch-tabs button { height: 44px; padding: 0 var(--space-3); }
  #mainToolbar [data-cc-new-share],
  #mainToolbar .btn-split .btn { height: 44px; min-width: 44px; }

  /* Tasks — the All/Today/Upcoming segmented collapses into a kebab (3-dot)
     menu relocated to the topbar top-right; its menu renders as the shared
     FilterSheet. The toolbar row is then empty — hide it. */
  #mainToolbar[data-route="tasks"] { display: none; }
  .topbar-right .tasks-viewdd.tb-moved { display: block; }
  .topbar-right .tasks-view-trigger {
    width: 44px;
    min-width: 44px;
    height: 44px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-full);
  }
  .topbar-right .tasks-view-trigger .tasks-view-current {
    display: none;
  }
  .topbar-right .tasks-view-trigger svg { flex-shrink: 0; }
  /* the inline capture bar gives way to the FAB-opened quick-add composer */
  .ctasks .task-qa { display: none; }
  /* the due-date + priority pickers join the FilterSheet shell but must stay
     ABOVE the quick-add composer (+3) — the generic shell z (+2) would sink them */
  .td-due-menu.filter-sheet, .td-pri-menu.filter-sheet { z-index: calc(var(--z-popover) + 4); }
  .td-due-scrim { z-index: calc(var(--z-popover) + 4); }
  /* finger-sized priority options, like the due presets */
  .td-pri-menu.filter-sheet [data-pri] { min-height: 48px; font-size: var(--text-base); border-radius: var(--radius-md); }
  .td-pri-menu.filter-sheet { gap: 2px; }
  /* finger-sized quick-action icons in the sheet (≥48px) */
  .td-due-menu.filter-sheet .td-due-quick { gap: var(--space-2); margin: var(--space-3) 0 var(--space-2); }
  .td-due-menu.filter-sheet .td-due-quick button { height: 48px; border-radius: var(--radius-md); }
  .td-due-menu.filter-sheet .td-due-quick button svg { width: 20px; height: 20px; }
  /* swipe-down dismiss (wireSheetDrag) — drag wins on the handle/header
     chrome, content keeps vertical scroll (same split as .drawer.sheet) */
  .td-due-menu.filter-sheet { touch-action: none; }
  .td-due-menu.filter-sheet .td-due-quick,
  .td-due-menu.filter-sheet .sp-dtp,
  .td-due-menu.filter-sheet .td-time-list { touch-action: pan-y; }
  /* finger-sized Time button + time slots in the sheet */
  .td-due-menu.filter-sheet .td-due-time-btn { height: 48px; font-size: var(--text-base); border-radius: var(--radius-md); }
  .td-due-menu.filter-sheet .td-time-list { max-height: 46vh; overscroll-behavior: contain; }
  .td-due-menu.filter-sheet .td-time-slot { height: 40px; font-size: var(--text-base); }
  .td-due-menu.filter-sheet .td-time-clear { height: 44px; font-size: var(--text-base); border-radius: var(--radius-md); }
  /* finger-sized footer (Clear + OK, equal width) */
  .td-due-menu.filter-sheet .td-due-foot .td-due-clear,
  .td-due-menu.filter-sheet .td-due-foot .td-due-done { height: 48px; font-size: var(--text-base); }

  /* Account/workspace actions use a native-feeling bottom sheet on phones.
     Desktop keeps the anchored sidebar dropdown unchanged. */
  .account-menu-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: calc(var(--z-popover) + 4);
    background: var(--sheet-scrim);
    animation: scrimFade var(--motion-overlay) var(--ease-enter);
  }
  /* anchored to the screen's bottom edge like a native sheet — the home
     indicator's inset is padding INSIDE the sheet, not a gap under it */
  .account-menu.filter-menu {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none;
    z-index: calc(var(--z-popover) + 5);
    padding: var(--space-2) max(var(--space-3), var(--safe-left)) calc(var(--space-3) + var(--safe-bottom)) max(var(--space-3), var(--safe-right));
    border-radius: 28px 28px 0 0;
    border-bottom: 0;
    box-shadow: var(--shadow-lg);
    animation: leadSheetUp var(--motion-sheet-open) var(--ease-enter);
  }
  .account-menu.filter-menu.is-closing {
    animation: none;
    transform: translate3d(0, 100%, 0);
    transition: transform var(--motion-sheet-close) var(--ease-exit);
  }
  .account-menu-scrim.is-closing { opacity: 0; transition: opacity var(--motion-sheet-close) var(--ease); animation: none; }
  .account-sheet-handle {
    display: block;
    width: 38px;
    height: 5px;
    margin: 0 auto var(--space-3);
    border-radius: var(--radius-full);
    background: var(--gray-300);
  }
  .account-menu .account-menu-head {
    min-height: 72px;
    padding: var(--space-3);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
  }
  .account-menu .account-menu-head .avatar { width: 42px; height: 42px; }
  .account-menu .account-menu-name { font-size: var(--text-base); }
  .account-menu .account-menu-email { font-size: var(--text-sm); }
  .account-menu .cfile-menu-sep { margin: var(--space-3) 0; }
  .account-menu .account-mobile-only { display: flex; }
  .account-menu .cfile-menu-opt {
    min-height: 52px;
    border-radius: var(--radius-lg);
    font-size: var(--text-base);
  }
}

/* Preserve the client name on very narrow phones by reducing the breadcrumb
   back affordance to its familiar Clients icon. */
@media (max-width: 360px) {
  .topbar .crumb:has(.crumb-client) { gap: 6px; }
  .topbar .crumb:has(.crumb-client) .crumb-link-label,
  .topbar .crumb:has(.crumb-client) .crumb-sep { display: none; }
}

/* bottom fade layer — above page content, behind the floating nav.
   Hidden by default; shown only on mobile (rule below, after the base so it
   wins on source order). Never blocks taps. */
.mobile-bottom-fade {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(104px + var(--safe-bottom));
  z-index: calc(var(--z-toolbar) - 1);
  pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(20, 20, 28, 0.06));
}
@media (max-width: 640px) {
  .mobile-bottom-fade { display: block; }
}

/* ---- MobileBottomNav — floating glass tab bar (Apple HIG style) ----- */
.bottom-nav {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: var(--space-1);
  min-width: 0;
  padding: 6px;
  border-radius: var(--radius-full);
  /* frosted liquid glass: translucent fill + heavy blur/saturation, a bright
     top edge highlight and soft outer shadow for the "lifted glass" feel */
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid color-mix(in srgb, #ffffff 28%, var(--border));
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 1px rgba(255, 255, 255, 0.55),
    inset 0 -1px 1px rgba(20, 20, 28, 0.04);
}
/* dark: soften the white glass rim — the light-tuned 28% / .55 highlights
   read as a hard outline on a dark surface */
html[data-theme="dark"] .bottom-nav {
  border-color: color-mix(in srgb, #ffffff 14%, var(--border));
  box-shadow:
    var(--shadow-lg),
    inset 0 1px 1px rgba(255, 255, 255, 0.22),
    inset 0 -1px 1px rgba(20, 20, 28, 0.04);
}
.bottom-nav-item {
  flex: 1;
  min-width: 0;
  min-height: 48px;                 /* ≥44px tap target */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: var(--radius-full);
  color: var(--text-soft);
  font-size: var(--text-2xs);
  font-weight: var(--fw-semibold);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.bottom-nav-item::before {
  content: "";
  position: absolute;
  /* Fill the equal-width tab slot, including the first/last tab's end space. */
  inset: 0;
  border-radius: var(--radius-full);
  background: var(--nav-active-bg);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease);
}
.bottom-nav-item svg { position: relative; z-index: 1; width: 22px; height: 22px; }
.bottom-nav-item .bn-label {
  /* The dock is persistent and every button has an accessible name. Keeping
     only the icons makes it calmer and frees space at narrow phone widths. */
  display: none;
}
.bottom-nav-item.active { color: var(--nav-active-fg); background: transparent; }
.bottom-nav-item.active::before { opacity: 1; }
.bottom-nav-item.active svg { color: var(--primary-600); }

/* Tab badge (Tasks due-count) — a small count pill pinned to the icon's
   top-right, app-badge style. Injected by ResponsiveShell.setTabBadge;
   removed entirely at zero, so an empty pill never renders. */
.bottom-nav-item { position: relative; }
.bottom-nav-item .bn-badge {
  position: absolute;
  z-index: 2;
  top: 3px; left: calc(50% + 6px);
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: var(--radius-full);
  background: var(--primary-600); color: var(--on-primary);
  font-size: 10px; font-weight: var(--fw-semibold); line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface);   /* ring so it reads over the icon */
}

/* ---- QuickActionButton — circular, separate floating action -------- */
.quick-fab {
  flex: 0 0 auto;
  align-self: center;
  width: 56px; height: 56px;        /* fixed square → perfect circle */
  border-radius: var(--radius-full);
  display: inline-flex; align-items: center; justify-content: center;
  /* the per-route create control IS the page's primary CTA → ink pill (4 Sep) */
  background: var(--btn-primary-bg); color: var(--btn-primary-fg); border: 1px solid var(--btn-primary-border);
  box-shadow: var(--shadow-lg), var(--btn-primary-shadow);
  transition: background var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}
.quick-fab svg { width: 24px; height: 24px; }
  @media (hover: hover) and (pointer: fine) {
    .quick-fab:hover { background: var(--btn-primary-hover); }
  }
.quick-fab:active { transform: scale(0.94); }
.quick-fab.is-open { background: var(--btn-primary-hover); }

/* =========================================================================
   QuickActionsSheet — bottom sheet of quick actions (mobile).
   Built on the same scrim/surface/radius/shadow tokens as Modal.
   ========================================================================= */
.quick-sheet-scrim {
  position: fixed; inset: 0;
  z-index: var(--z-popover);
  background: var(--sheet-scrim);
  opacity: 0; pointer-events: none;
  transition: opacity var(--motion-overlay) var(--ease-enter);
}
.quick-sheet-scrim.show { opacity: 1; pointer-events: auto; }

.quick-sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: calc(var(--z-popover) + 1);
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-top-left-radius: var(--radius-2xl);
  border-top-right-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3)
           max(var(--space-4), var(--safe-right))
           calc(var(--space-4) + var(--safe-bottom))
           max(var(--space-4), var(--safe-left));
  transform: translateY(100%);
  transition: transform var(--motion-sheet-open) var(--ease-enter);
}
.quick-sheet.show { transform: translateY(0); }
.quick-sheet-handle { display: none; }
.quick-sheet-title {
  font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-strong);
  padding: var(--space-1) var(--space-2) var(--space-4);
}
.quick-sheet-actions {
  display: flex; flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--surface);
}
.quick-sheet-action {
  position: relative;
  display: flex; align-items: center; gap: var(--space-3);
  width: 100%; min-height: 60px;
  padding: var(--space-3) var(--space-4);
  border-radius: 0;
  color: var(--text); font-size: var(--text-base); font-weight: var(--fw-medium);
  text-align: left;
  transition: background var(--dur) var(--ease);
}
.quick-sheet-action[hidden] { display: none; }
.quick-sheet-action:not([hidden]):has(~ .quick-sheet-action:not([hidden]))::after {
  content: "";
  position: absolute;
  left: calc(var(--space-4) + 26px + var(--space-3));
  right: 0; bottom: 0;
  height: 1px;
  background: var(--border);
}
  @media (hover: hover) and (pointer: fine) {
    .quick-sheet-action:hover { background: var(--nav-hover-bg); }
  }
.quick-sheet-action:active { background: var(--surface-field); }
/* the label never wraps — a two-line label would re-centre the icon between
   the lines and read as "off centre" next to its single-line neighbours */
.quick-sheet-action > span:not(.qa-ico):not(.qa-chevron) { min-width: 0; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quick-sheet-action .qa-ico {
  width: 26px; height: 26px; flex-shrink: 0;
  border-radius: 7px;
  display: inline-flex; align-items: center; justify-content: center;
  background: #2869f5; color: #fff;
}
.quick-sheet-action[data-quick="my-plan"] .qa-ico { background: #f57c16; }
.quick-sheet-action[data-quick="settings"] .qa-ico { background: #788292; }
.quick-sheet-action .qa-ico svg { width: 18px; height: 18px; }
.quick-sheet-action .qa-chevron {
  display: inline-flex; flex: 0 0 auto;
  margin-left: auto; color: var(--text-soft);
}
.quick-sheet-action .qa-chevron svg { width: 18px; height: 18px; }
.dashboard-shortcuts { display: none; }
@media (max-width: 640px) {
  .dashboard-shortcuts {
    display: flex; flex-shrink: 0;
    border-color: color-mix(in srgb, var(--border) 55%, var(--surface));
    border-radius: 22px;
    box-shadow: none;
  }
  .dashboard-shortcuts .quick-sheet-action {
    min-height: 48px;
    gap: 12px;
    padding: 8px 18px;
    font-size: 17px;
    font-weight: var(--fw-medium);
  }
  .dashboard-shortcuts .qa-ico {
    width: 22px; height: 22px;
    border-radius: 6px;
  }
  .dashboard-shortcuts .qa-ico svg { width: 15px; height: 15px; }
  .dashboard-shortcuts .quick-sheet-action::after {
    left: 52px;
    background: color-mix(in srgb, var(--border) 55%, var(--surface));
  }
  .dashboard-shortcuts .qa-chevron { opacity: 0.65; }
  .dashboard-shortcuts .qa-chevron svg { width: 16px; height: 16px; }
  .dashboard-shortcuts [data-dashboard-route="plan"] .qa-ico { background: #f57c16; }
}

/* =========================================================================
   MobilePageContainer — opt-in wrapper for per-page mobile work (later).
   Provides responsive padding + the bottom-bar clearance in one class so
   individual pages don't re-invent it when they're optimised one by one.
   ========================================================================= */
.mobile-page {
  padding: var(--space-5) var(--space-6);
}
@media (max-width: 640px) {
  .mobile-page {
    padding: var(--space-4) max(var(--space-4), var(--safe-left)) 0
             max(var(--space-4), var(--safe-right));
  }
}

/* leads toolbar reveal — slide-up bottom-sheet keyframe + reduced-motion */
@keyframes leadSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes settingsPush { from { transform: translateX(100%); } to { transform: translateX(0); } }
@keyframes scrimFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes searchDrop { from { transform: translateY(-14px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@media (max-width: 640px) and (prefers-reduced-motion: reduce) {
  .settings-slide, .settings-layer, .settings-behind, .settings-dim { animation: none; transition: none; }
  .filter-sheet,
  .topbar-right .filter-dd .filter-menu,
  .stage-picker.sp-sheet,
  .cal-filt-pop { animation: none; }
}
