/* ── Mobile navigation ────────────────────────────────────
   Phones swap the dashboard sidebar for a sticky trigger bar naming the open
   section, and a bottom sheet listing all of them — the sidebar stacked above
   the panel used to spend ten rows of chrome before any content appeared.
   Desktop is untouched: everything here is display:none above 860px, the same
   breakpoint where .dash collapses to one column. Shared by the dashboard and
   the admin console. */

.mnav { display: none; }

@media (max-width: 860px) {
  .dash-side { display: none; }

  /* Sticks within .dash-main, so the section switcher stays under the thumb
     however deep the panel scrolls. Kept under the topbar dropdown (z 40) and
     the cookie notice (z 60); the sheet layers inside this context. */
  .mnav { display: block; position: sticky; top: 10px; z-index: 30; }

  .mnav-trigger {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: var(--r-md);
    border: 1px solid var(--line-hi);
    background: var(--bg-raised);
    box-shadow: var(--shadow-md);
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
  }

  .mnav-trigger-icon {
    width: 28px; height: 28px;
    border-radius: 9px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    flex: none;
  }
  .mnav-trigger-icon svg { width: 15px; height: 15px; }
  .mnav-trigger-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mnav-trigger-menu { display: grid; place-items: center; color: var(--muted); flex: none; }
  .mnav-trigger-menu svg { width: 17px; height: 17px; }

  /* touch-action:none on the backdrop plus overscroll containment on the list
     is the scroll lock — no body class to go stale across route changes. */
  .mnav-backdrop {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 80;
    touch-action: none;
  }

  .mnav-sheet {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 81;
    display: flex;
    flex-direction: column;
    max-height: min(78dvh, 620px);
    padding: 6px 14px calc(14px + env(safe-area-inset-bottom, 0px));
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--line-hi);
    border-bottom: none;
    background: var(--bg-raised);
    box-shadow: var(--shadow-lg);
  }

  .mnav-grip {
    width: 36px; height: 4px;
    border-radius: var(--r-pill);
    background: var(--line-hi);
    margin: 6px auto 2px;
    flex: none;
  }

  .mnav-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 2px 8px; }
  .mnav-title { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

  .mnav-close {
    width: 34px; height: 34px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    display: grid; place-items: center;
    flex: none;
  }
  .mnav-close svg { width: 15px; height: 15px; }

  .mnav-sheet .agent-picker { padding: 2px 2px 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

  .mnav-list {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 2px;
  }

  .mnav-group {
    padding: 12px 4px 4px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--subtle);
  }

  .mnav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 46px;
    padding: 11px 12px;
    border: none;
    border-radius: var(--r-sm);
    background: transparent;
    color: var(--muted);
    font-size: 15px;
    cursor: pointer;
    text-align: left;
  }
  .mnav-item:active { background: var(--surface-hi); }
  .mnav-item[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 500; }
  .mnav-item svg { width: 17px; height: 17px; flex: none; }
  .mnav-item-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .mnav-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--line);
    flex: none;
  }
  .mnav-links { display: flex; justify-content: center; gap: 4px; }

  /* Entrance plays once per open (index.js gates the class), so the poll
     re-renders that remount the tree do not replay it. */
  .mnav-layer.is-entering .mnav-backdrop { animation: mnav-fade 0.22s var(--ease); }
  .mnav-layer.is-entering .mnav-sheet { animation: mnav-up 0.3s var(--ease); }
}

@keyframes mnav-fade { from { opacity: 0; } }
@keyframes mnav-up { from { transform: translateY(28px); opacity: 0.5; } }

/* Sub-tabs (Sharing, Analytics, Conversations): the segmented strip stretches
   into an even, thumb-sized control; three labels scroll rather than squeeze.
   The first two rules cover every segmented control (admin Verification's
   filter lives inside a panel row, not under .dash-main): labels must never
   wrap inside their pills, and an overlong track scrolls. */
@media (max-width: 700px) {
  .segmented { max-width: 100%; overflow-x: auto; }
  .segmented-btn { white-space: nowrap; }
  .dash-main > .segmented { align-self: stretch; display: flex; }
  .dash-main > .segmented .segmented-btn { flex: 1 0 auto; padding: 9px 12px; }
}
