/*
 * design-v2/responsive.css – viewport-driven adjustments for the V2 shell.
 * Loaded after every other v2 CSS so its later media-query rules win.
 *
 * Breakpoints:
 *   Desktop  ≥ 1280px  – original
 *   Laptop   1024–1279 – charts grid narrows, table secondary cols stay
 *   Tablet   768–1023  – 3-panel grid collapses, modal/right drawers
 *                       still allowed; hamburger nav for ≤ 1024
 *   Mobile   ≤ 767     – single column; drawers promote to bottom sheet;
 *                       table rows collapse to label/value stacks
 *
 * The hamburger nav reuses the .v2-overlay-host / .v2-drawer--right
 * primitives from Phase 2 – see #v2-mobile-menu in topnav.php.
 */

/* Mobile bottom action bar is hidden by default; the ≤767 block shows it. */
.v2-botbar { display: none; }

/* ─── LAPTOP (1024–1279) ───────────────────────────────────── */
@media (max-width: 1279px) {
  .v2-screen { padding: 28px 32px 48px; }
  .v2-charts-grid { gap: 14px; }
  .v2-stat-row { gap: 12px; }
}

/* ─── TABLET (768–1023) ────────────────────────────────────── */
@media (max-width: 1023px) {
  .v2-screen { padding: 22px 22px 40px; }

  /* Top nav: hide the 7-route row; surface the hamburger trigger */
  .v2-nav { display: none; }
  .v2-mobile-trigger { display: grid !important; }

  /* Submenu becomes a horizontal scroll strip with snap */
  .v2-subnav { padding: 0 16px; overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; }
  .v2-subnav__items a { scroll-snap-align: start; flex-shrink: 0; }
  /* F-059: keep the Refresh control on touch widths (the whole right cluster
     used to be display:none, leaving installed-PWA users with no reload UI).
     The last-sync meta stays desktop-only; the link collapses to an icon-only
     40px square (label hidden below; accessible name via aria-label). */
  .v2-subnav__right { flex: 0 0 auto; margin-left: 8px; }
  .v2-subnav__right > span { display: none; }
  .v2-subnav__right .quick {
    padding: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .v2-subnav__right .v2-subnav__refresh-label { display: none; }

  /* Panels stack 2-up, then full-width if narrower than 720 */
  .v2-panels { grid-template-columns: 1fr 1fr; }

  /* Stats fold to 2-column */
  .v2-stat-row { grid-template-columns: repeat(2, 1fr); }

  /* Charts grid drops to 6-col so spans halve */
  .v2-charts-grid { grid-template-columns: repeat(6, 1fr); }
  .v2-chart--span3 { grid-column: span 3; }
  .v2-chart--span4 { grid-column: span 6; }
  .v2-chart--span6 { grid-column: span 6; }
  .v2-chart--span8 { grid-column: span 6; }
  .v2-chart--span12 { grid-column: span 6; }

  /* Loyalty grid: 2 cards across */
  .v2-lo-grid { grid-template-columns: repeat(2, 1fr); }

  /* Programme hero stacks stats below name */
  .v2-prog-hero { grid-template-columns: 56px 1fr; }
  .v2-prog-hero__stats { grid-column: 1 / -1; flex-wrap: wrap; gap: 16px; justify-content: flex-start; }
  .v2-prog-hero__stat { text-align: left; }

  /* Tables: hide low-signal columns */
  .v2-flights-t .v2-table__h,
  .v2-flights-t .v2-table__r {
    grid-template-columns: 32px 84px 80px 1fr 80px 90px 64px;
  }
  .v2-flights-t .v2-table__r .col-airline,
  .v2-flights-t .v2-table__r .col-cls:nth-child(7),
  .v2-flights-t .v2-table__r .col-status { display: none; }
  .v2-flights-t .v2-table__h span:nth-child(5),
  .v2-flights-t .v2-table__h span:nth-child(7),
  .v2-flights-t .v2-table__h span:nth-child(10) { display: none; }
}

/* ─── MOBILE (≤ 767) ───────────────────────────────────────── */
@media (max-width: 767px) {
  /* Shared height of the fixed bottom action bar (56px items + 1px border +
     visual breathing room); consumed by .v2-screen and the F-016 Add sheet. */
  :root { --v2-botbar-h: 58px; }

  .v2-screen { padding: 18px 14px 32px; }
  .v2-topnav { padding: 10px 14px; gap: 12px; grid-template-columns: auto 1fr auto; min-width: 0; }

  /* MM-01: the wide tagline wordmark (~200px @48px tall) overflows phones.
     Hide it and swap in the 1:1 square mark; let the centre column collapse.
     (The dead .v2-brand__word rule that used to sit here matched no element.) */
  .v2-brand { min-width: 0; flex-shrink: 0; height: 40px; }
  .v2-brand__logo { display: none; }
  .v2-brand__mark { display: block; height: 32px; width: 32px; }

  /* MM-01 / Evidence A1: the action cluster pinned document scrollWidth at
     394px. Let it (and its flex children) shrink so it never forces overflow. */
  .v2-nav__actions { min-width: 0; flex-shrink: 1; gap: 6px; }
  .v2-nav__actions > * { flex-shrink: 0; }
  .v2-nav__bell-slot { flex-shrink: 0; }

  /* MM-32: lift the account avatar to a >=40px touch target on phones. */
  .v2-profile { width: 40px; height: 40px; font-size: 0.93333rem; }

  /* MM-06 / Evidence A3: keep the subnav tabs on ONE scrollable line (no wrap
     to a 2nd row under the Atlas pill) with an edge fade for affordance. */
  .v2-subnav {
    height: auto;
    min-height: 46px;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 24px), transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 14px, #000 calc(100% - 24px), transparent 100%);
  }
  .v2-subnav::-webkit-scrollbar { display: none; }
  .v2-subnav__items { flex-wrap: nowrap; overflow: visible; flex: 0 0 auto; }
  .v2-subnav__items a { flex-shrink: 0; white-space: nowrap; }

  /* MM-06: un-center the Atlas launcher so it no longer overlays the scrolling
     subnav tabs. Dock it as a trailing item; the .v2-subnav prefix gives 0-2-0
     specificity so it beats the later-loaded bundle rule (0-1-0). */
  .v2-subnav .atlas-launcher-slot {
    position: static;
    transform: none;
    left: auto;
    top: auto;
    margin-left: auto;
    flex: 0 0 auto;
    z-index: 1;
  }
  .v2-subnav .atlas-launcher-pill { min-width: 0; }

  /* Single-column panels and charts */
  .v2-panels { grid-template-columns: 1fr; gap: 14px; }
  .v2-stat-row { grid-template-columns: 1fr; }
  .v2-charts-grid { grid-template-columns: 1fr; }
  .v2-chart--span3, .v2-chart--span4, .v2-chart--span6, .v2-chart--span8, .v2-chart--span12 { grid-column: span 1; }

  /* Atlas bar simplifies */
  .v2-atlas-bar { padding: 12px 14px; border-radius: 14px; }
  .v2-atlas-bar__greet { font-size: 1.06667rem; }
  .v2-atlas-bar__q { font-size: 0.93333rem; }
  .v2-chips { gap: 6px; }
  .v2-chip { padding: 6px 12px; font-size: 0.83333rem; }

  /* Loyalty grid full-width */
  .v2-lo-grid { grid-template-columns: 1fr; }

  /* Donuts shrink */
  .v2-donut { width: 84px; height: 84px; }
  .v2-donut svg { width: 84px; height: 84px; }
  .v2-donut__total { font-size: 1.13333rem; }
  .v2-donut-wrap { grid-template-columns: 84px 1fr; gap: 14px; }

  /* Tables collapse to label/value stacks */
  .v2-table__h { display: none; }
  .v2-table__r {
    grid-template-columns: 1fr auto;
    grid-template-areas: "title actions" "meta meta" "value value";
    gap: 6px 12px;
    padding: 14px 16px;
  }
  .v2-flights-t .v2-table__r,
  .v2-stays-t .v2-table__r {
    grid-template-columns: 32px 1fr auto;
  }
  .v2-flights-t .v2-table__r > *:not(.col-sel):not(.col-flight):not(.col-route):not(.col-miles):not(.col-act),
  .v2-stays-t .v2-table__r > *:not(.col-sel):not(.col-route):not(.col-miles):not(.col-act) {
    display: none;
  }

  /* Drawer promote: modal / right → bottom sheet on phones */
  .v2-drawer--modal,
  .v2-drawer--right {
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    transform: none !important;
    width: 100% !important;
    max-height: 90vh !important;
    border-radius: 22px 22px 0 0 !important;
    border-bottom: none;
    animation: v2-bottomIn 420ms var(--ease-drawer) both !important;
  }
  .v2-drawer--modal::after,
  .v2-drawer--right::after {
    content: "";
    display: block;
    width: 36px;
    height: 4px;
    background: var(--hairline-strong);
    border-radius: 999px;
    margin: 10px auto 0;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
  }

  /* PI-05: slim the wizard step chrome on phones so it does not eat
     above-the-fold height in the bottom sheet. Drop the labels, keep two small
     dots + connector as a minimal progress line. */
  .v2-wiz-steps { padding: 6px 0 10px; gap: 8px; }
  .v2-wiz-step__labels { display: none; }
  .v2-wiz-step__num { width: 22px; height: 22px; font-size: 0.73333rem; }
  /* PI-05: keep the quick-adjust date chips and the disclosure summary at a
     comfortable 44px tap target. */
  .v2-se-quick-dates .v2-btn--xs { min-height: 44px; }
  .v2-af-more > summary,
  .v2-se-more > summary { padding: 8px 0; min-height: 44px; display: flex; align-items: center; }

  /* Bulk action bar wraps to multi-line */
  .v2-bulk-bar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .v2-bulk-bar__actions { flex-wrap: wrap; }

  /* Toasts: full-width minus margins */
  .v2-toast-stack { right: 10px; bottom: 10px; left: 10px; }
  .v2-toast { width: auto; max-width: none; }

  /* F-016: on phones the Add menu opens as a bottom sheet pinned just above
     the bottom action bar, matching the bar's thumb-reach purpose (the old
     rule left it document-anchored at top:56px, the opposite corner of the
     screen from the Add button). position:fixed also means the focus() call
     on open can no longer scroll-jump the page. Markup + focus handling stay
     in add_popover.php untouched; the menu remains in document order. */
  .v2-add-pop {
    position: fixed;
    top: auto;
    right: 10px;
    left: 10px;
    bottom: calc(var(--v2-botbar-h, 58px) + env(safe-area-inset-bottom, 0px) + 10px);
    width: auto;
    max-height: calc(100dvh - 140px);
    overflow-y: auto;
    border-radius: 18px;
    transform-origin: bottom center;
    animation: v2-addSheetIn 240ms var(--ease-drawer) both;
  }

  /* MM-09: 16px form controls inside drawers stop iOS Safari focus-zoom. */
  .v2-drawer .v2-field input,
  .v2-drawer .v2-field select,
  .v2-drawer .v2-field textarea,
  .v2-drawer input[type="text"],
  .v2-drawer input[type="number"],
  .v2-drawer input[type="date"],
  .v2-drawer input[type="email"],
  .v2-drawer input[type="tel"],
  .v2-drawer textarea,
  .v2-drawer select {
    font-size: 1.06667rem;
  }

  /* MM-39: the drawer form grid collapses to a single column on phones. */
  .v2-f-grid { grid-template-columns: 1fr; }
  .v2-f-grid .c1,
  .v2-f-grid .c2,
  .v2-f-grid .c3,
  .v2-f-grid .c4 { grid-column: 1 / -1; }
  /* Opt-in tight 2-up only for explicitly short numeric pairs. */
  .v2-f-grid--pair { grid-template-columns: 1fr 1fr; }
  .v2-f-grid--pair .c1,
  .v2-f-grid--pair .c2 { grid-column: auto; }

  /* MM-32: drawer close button reaches a comfortable 44px touch target. */
  .v2-drawer__close { width: 44px; height: 44px; border-radius: 11px; }
  .v2-drawer__close svg { width: 18px; height: 18px; }

  /* MM-10: per-row edit/delete reach a 40x40 target; the 16px checkbox gets a
     >=40px invisible hit area (::before) without growing the visible box. */
  .v2-table__r .v2-row-act { width: 40px; height: 40px; border-radius: 9px; }
  .v2-table__r .v2-row-act svg { width: 16px; height: 16px; }
  .v2-table__r .col-act { gap: 8px; }
  .v2-table__r .col-sel .v2-cb,
  .v2-table__h .col-sel .v2-cb { position: relative; }
  .v2-table__r .col-sel .v2-cb::before,
  .v2-table__h .col-sel .v2-cb::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
  }
  .v2-flights-t .v2-table__r,
  .v2-stays-t .v2-table__r { column-gap: 12px; }

  /* MM-11: the map is the primary content on phones — give it a usable height
     (70dvh, with a px floor for browsers without dvh) instead of the 420px the
     shell.css @960 block sets. These rules load after shell.css at equal
     specificity so they win for phones without !important. */
  .v2-map-frame { padding: 12px; gap: 12px; }
  .v2-map-google { height: 70dvh; min-height: 360px; }
  .v2-map-canvas { min-height: 360px; }
  .v2-map-controls { flex-wrap: wrap; row-gap: 10px; }
  .v2-map-control,
  .v2-segmented,
  .v2-switch { flex: 0 1 auto; }
  .v2-map-control__sel { min-height: 40px; }
  .v2-seg { min-height: 40px; display: inline-flex; align-items: center; }
  .v2-switch { min-height: 40px; }
  .v2-map-legend { flex-wrap: wrap; row-gap: 4px; max-width: calc(100% - 28px); bottom: 10px; left: 10px; }

  /* MM-14-b: the deferred-Atlas launcher FAB is REPLACED on mobile by the bottom
     action bar's Atlas button (the loader still lazy-loads the bundle on first
     interaction; window.MM_openAtlas is the open hook). Hidden so there is a
     single Atlas entry point on touch. */
  .atlas-launcher-static { display: none !important; }

  /* ─── Bottom action bar (Home / Add / Atlas) — thumb reach ──── */
  .v2-botbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: stretch;
    z-index: 8400;
    background: var(--paper, #fff);
    border-top: 1px solid var(--hairline, #e5e7eb);
    padding-bottom: env(safe-area-inset-bottom);
    box-shadow: 0 -2px 12px rgba(15, 23, 42, 0.06);
  }
  .v2-botbar__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 8px 4px;
    border: 0;
    background: none;
    color: var(--ink-muted, #64748b);
    font-family: inherit;
    font-size: 0.73333rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .v2-botbar__item svg { width: 23px; height: 23px; }
  .v2-botbar__item.is-active { color: var(--navy, #1a2b4c); }
  .v2-botbar__item--accent svg { color: var(--orange, #ff6b00); }
  .v2-botbar__item:active { background: var(--paper-shade, #f1f5f9); }

  /* Keep the last page content clear of the fixed bar. */
  .v2-screen { padding-bottom: calc(var(--v2-botbar-h, 58px) + env(safe-area-inset-bottom)); }

  /* MM-34: the full Smart Inbox forwarding address must be readable on mobile;
     wrap it and stack the Copy button below. Desktop keeps the single-line
     ellipsis from overlays.css. */
  .v2-inb-addr__row { flex-direction: column; align-items: stretch; gap: 8px; }
  .v2-inb-addr__code {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-all;
    line-height: 1.45;
  }
  .v2-inb-addr__copy { justify-content: center; }

  /* ─── Touch-target hardening (Task 0.4) ─────────────────────── */

  /* MM-42: Atlas launcher pill 32×32 — its width is fixed by a more specific
     base rule, so grow the TAP AREA with a centered 44×44 invisible ::before
     (pattern 2, same as the brand link) rather than fighting specificity. The
     visible pill stays 32×32; the whole 44×44 region is tappable. */
  .atlas-launcher-pill { position: relative; }
  .atlas-launcher-pill::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  /* MM-43: Brand logo link 32×40, width under 44px — keep the logo visual
     size, add a centered invisible hit-area overlay (pattern 2). */
  .v2-brand { position: relative; }
  .v2-brand::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
  }

  /* MM-44: Mode-toggle option buttons 23px tall -> min-height 40px.
     Keep label centred (pattern 1 with inline-flex). */
  .v2-mode-toggle__opt { min-height: 40px; display: inline-flex; align-items: center; }

  /* MM-45: Loyalty-row detail-link 30×30 -> 40×40 (pattern 1).
     Small icon link; growing the box is fine and keeps it a clean target. */
  .v2-lr__detail-link { width: 40px; height: 40px; }

  /* MM-46: Loyalty-row fc-fix button 85×14px -> min-height 40px (pattern 1).
     Inline-flex + center so the label sits vertically centred. */
  .v2-lr__fc-fix { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

  /* MM-47: Section-header see-all / expand links 14-18px tall -> min-height 40px.
     Covers both <a> and <button> elements (pattern 1 with inline-flex). */
  a.v2-dash-section__link,
  button.v2-dash-section__link { min-height: 40px; display: inline-flex; align-items: center; }

  /* MM-48: Mark-pill filter buttons 20px tall -> min-height 36px (pattern 1).
     Pill filters; a 36px floor is proportionate to their compact visual form. */
  .v2-mark-pill { min-height: 36px; display: inline-flex; align-items: center; }

  /* MM-49: Chart-link rows 18-19px tall — PRIMARY tappable list rows on
     /flights/ and /stays/. These are full-width rows so growing to 44px
     is the right call. Use display:grid (not flex): a single-column grid
     stretches the inner .lg-row/.v2-bar-row to full width by default, whereas
     flex would let the single child shrink to content width (Codex review). */
  a.v2-chart-link { display: grid; align-items: center; min-height: 44px; }

  /* MM-50: Dashboard trip-card title links and item-title buttons 23-26px tall
     -> min-height 40px; inline-flex + centred vertically (pattern 1). */
  .v2-trips-b__ttl--link,
  .v2-trips-b__item-t--link { min-height: 40px; display: inline-flex; align-items: center; }

  /* MM-51: Loyalty-card adjust buttons 25px tall -> min-height 40px (pattern 1). */
  .v2-lo-card__adjust { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

  /* MM-52 (P0): Slide-over close button 12×19px -> 44×44 explicit (pattern 1).
     The base desktop rule is 40×40; mobile needs 44×44 and display:flex so
     the × glyph stays centred when the button gets a fixed size. */
  .mm-slide-over__close {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  /* MM-53: mm-btn--primary in the goals UI renders 19px tall because the v2
     layout does not load lib/app.css (where mm-btn padding lives). Scoped
     TIGHTLY (Codex review): the slide-over's own buttons via
     .mm-quick-goal-panel, and the "Add Goal" trigger via the dedicated
     .mm-goals-add class — NOT the broad .mm-page-card .mm-btn, which matched
     unrelated page-card buttons on reward-miles/profile/quick-add. The
     desktop manifestation of this root cause is decision D8 (separate task). */
  .mm-quick-goal-panel .mm-btn,
  .mm-goals-add { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }

  /* MM-54: Goal-type radio labels — label is the clickable target.
     Each <label> wraps a bare 13×13 radio + text (inline-flex, ~19px tall).
     min-height 40px makes the full label area tappable. */
  .mm-quick-goal__radios label { min-height: 40px; display: inline-flex; align-items: center; }

  /* ─── App-surface touch targets (Phases 1/3/4) ──────────────── */

  /* MM-56: Trip-overview "Back to Trips" link 19px tall -> min-height 40px.
     Pattern 1 (explicit min-size + centering). */
  .v2-tb-back { min-height: 40px; display: inline-flex; align-items: center; }

  /* MM-57: Trip-overview inline segment edit button 18px tall -> min-height 40px.
     Targets the bare <button> inside .v2-tov-seg__edit (pattern 1). */
  .v2-tov-seg__edit button { min-height: 40px; display: inline-flex; align-items: center; }

  /* MM-58: Trip-card action buttons 30x30 (x4 per card) -> 40x40 (pattern 1).
     Icon stays 16x16 via the existing .v2-trip-card__act-ic rule.
     !important (Codex/D12): trips.css:176 sets 30x30 and loads AFTER
     responsive.css, so it would otherwise defeat this on narrow fine-pointer
     viewports. (Real touch devices already get 40px via trips.css:226
     pointer:coarse; this covers the narrow fine-pointer case too.) */
  .v2-trip-card__act { width: 40px !important; height: 40px !important; }

  /* MM-59: Trip-card select checkbox wrapper — the opacity:0 input + its visual
     proxy are both 20x20. Grow the wrapper (<label>) to min 40x40 so the full
     area is hittable on touch; center the visual box within the expanded tap
     area. The host is position:absolute so min-size expands the hit zone. */
  .v2-trip-card__selwrap { min-width: 40px; min-height: 40px; align-items: center; justify-content: center; }

  /* MM-60: Programme-detail "← Back to Programmes" link 17px tall -> min-height 40px.
     The link already carries class mm-program-detail-back (pattern 1). */
  .mm-program-detail-back { min-height: 40px; display: inline-flex; align-items: center; }

  /* MM-61: Preferences notification checkbox labels 21px tall -> min-height 40px.
     Each label wraps an 18x18 checkbox + text. The full label becomes the tap
     target (pattern 1). Scoped to .settings-preferences-page .toggle-group to
     avoid widening every checkbox label site-wide. */
  .settings-preferences-page .toggle-group label { min-height: 40px; }

  /* MM-62: Preferences quiet-hours time inputs 24px tall -> min-height 40px.
     Font-size 16px prevents iOS Safari auto-zoom on focus (already global for
     drawer inputs at MM-09; replicated here for the out-of-drawer time fields). */
  .settings-preferences-page #flight-alerts input[type="time"] {
    min-height: 40px;
    font-size: 1.06667rem;
  }

  /* MM-63: Atlas panel header icon buttons (Close/Memory/New-chat) 28x28 -> 44x44.
     !important: the atlas-shell bundles side-panel.css and injects it at runtime
     (after responsive.css), so its base 28px sizing would otherwise win the
     cascade. Editing the bundled source needs an atlas-shell rebuild; forcing the
     mobile override is the lower-risk fix (matches the drawer-promote !important
     pattern above). Does not affect the side-panel (>=768) layout. */
  .atlas-panel-icon-btn { width: 44px !important; height: 44px !important; }

  /* MM-64: Atlas composer Attach + Send buttons 32x32 -> 44x44 (pattern 1).
     Primary input actions on the mobile full-screen panel. !important for the
     same reason as MM-63 (runtime-injected side-panel.css loads later). */
  .atlas-panel-attach,
  .atlas-panel-send { width: 44px !important; height: 44px !important; }

  /* MM-66: Trip-overview Archive button clips at ≤375px because .v2-tov-actions
     is nowrap and scrolls horizontally. Let it wrap so all actions stay on-screen
     (pattern: structural flex-wrap). Gap kept from the base rule (8px).
     !important: trips.css `.v2-tov-actions { flex-wrap: nowrap }` ties on
     specificity and wins on source order, so the override must force it (verified
     on staging: archive button right 408->138, on-screen). Matches the codebase's
     other mobile-override rules (drawer-promote block above also uses !important). */
  .v2-tov-actions { flex-wrap: wrap !important; }

  /* MM-67: Profile/Prefs scrollable subnav affordance — the edge-fade mask is
     already applied to .v2-subnav in the mobile block above (MM-06), and
     overflow-x:auto is set by shell.css at ≤960px. Explicitly confirm
     overflow-x:auto here so the scroll+mask is active at mobile widths. */
  .v2-subnav { overflow-x: auto; }
}

/* F-016: slide-up entrance for the mobile Add bottom sheet. */
@keyframes v2-addSheetIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* F-088: reduced-motion override for the phone bottom sheets. The drawer-
   promote rule above sets `animation: v2-bottomIn 420ms … !important`, which
   defeats both the overlays.css reduced-motion cap and the tokens.css 0.01ms
   wildcard (equal importance resolves by source order, and this sheet loads
   last). This block sits AFTER the mobile block so it wins the tie: sheets
   appear with a short opacity-only fade instead of the 420ms slide. */
@media (max-width: 767px) and (prefers-reduced-motion: reduce) {
  .v2-drawer--modal,
  .v2-drawer--right,
  .v2-add-pop {
    animation: v2-reduceFadeIn 120ms ease both !important;
  }
}
@keyframes v2-reduceFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── VERY NARROW (≤ 360px) — icon-only Add button ─────────── */
@media (max-width: 360px) {
  /* MM-01: at 320/360 the cluster + logo + hamburger exceed the viewport.
     Drop the 'Add' label to an icon-only 40px square; the accessible name
     stays on the button via aria-label/title. */
  .v2-add-btn { padding: 0; width: 40px; height: 40px; justify-content: center; gap: 0; }
  .v2-add-btn__label { display: none; }
  .v2-add-btn svg { width: 18px; height: 18px; }
}

/* ─── VERY NARROW (≤ 379px) — stack the drawer footer actions ── */
@media (max-width: 379px) {
  /* MM-39: full-width stacked Back/Continue on iPhone SE / 360px Androids. */
  .v2-drawer__foot { flex-wrap: wrap; gap: 10px; }
  .v2-drawer__foot .info { flex: 1 1 100%; order: 2; }
  .v2-drawer__foot .actions { flex: 1 1 100%; order: 1; }
  .v2-drawer__foot .actions .v2-btn { flex: 1 1 auto; justify-content: center; }
}

/* ─── TOUCH (coarse pointer) — comfortable row controls >767px too ── */
@media (pointer: coarse) {
  /* MM-10: touch tablets / hybrid laptops also get 40px row controls. */
  .v2-table__r .v2-row-act { width: 40px; height: 40px; }
  .v2-table__r .v2-row-act svg { width: 16px; height: 16px; }
  .v2-table__r .col-sel .v2-cb,
  .v2-table__h .col-sel .v2-cb { position: relative; }
  .v2-table__r .col-sel .v2-cb::before,
  .v2-table__h .col-sel .v2-cb::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    transform: translate(-50%, -50%);
  }

  /* MM-27: touch users get a camera affordance + softened upload copy. */
  .v2-dz__h--fine { display: none; }
  .v2-dz__h--coarse { display: inline; }
  .v2-dz__camera { display: inline-flex; }

  /* MM-55: profile avatar button 36×36 at 768px (tablet) -> 40×40 on any
     touch device. Placed here (pointer: coarse) rather than ≤767 because
     the finding was on the 768px tablet viewport. */
  .v2-profile.v2-profile--img { width: 40px; height: 40px; }

  /* MM-65: Atlas history rail-toggle 28×28 at 768px (tablet, side-panel mode)
     -> 40×40 on any touch device. The rail only shows at ≥768; coarse-pointer
     catches real touch tablets. Desktop with fine pointer is unchanged. */
  .atlas-panel-rail-toggle { width: 40px !important; height: 40px !important; }
}

/* ─── SUBNAV REFRESH (F-059) ───────────────────────────────── */
/* All-viewport layout for the subnav Refresh link now that it carries an
   inline SVG (subnav.php via mm_render_svg_icon). Desktop shows icon+label;
   the ≤1023px block above collapses it to icon-only. */
.v2-subnav__right .quick {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.v2-subnav__refresh-ic { width: 14px; height: 14px; flex-shrink: 0; }

/* ─── MOBILE MENU DRAWER (hamburger payload) ───────────────── */
.v2-mobile-trigger {
  display: none;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  cursor: pointer;
}
.v2-mobile-trigger:hover { color: var(--color-text-inverse); background: rgba(255, 255, 255, 0.08); }
.v2-mobile-trigger svg { width: 18px; height: 18px; stroke-width: 1.8; }

#v2-mobile-menu .v2-drawer__body { padding: 0; }
.v2-mobile-menu__list { display: flex; flex-direction: column; padding: 6px; }
.v2-mobile-menu__list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  text-decoration: none;
  color: var(--ink);
  font-family: 'Geist', sans-serif;
  font-weight: 500;
  font-size: 1rem;
  border-radius: 10px;
}
.v2-mobile-menu__list a:hover { background: var(--paper-shade); color: var(--ink-strong); }
.v2-mobile-menu__list a.active { background: var(--paper-shade); color: var(--ink-strong); font-weight: 600; }
.v2-mobile-menu__list a.active::before {
  content: "";
  width: 3px;
  height: 16px;
  background: var(--orange);
  border-radius: 2px;
  display: inline-block;
}

/* ─── A11Y POLISH ─────────────────────────────────────────── */

/* Skip link */
.v2-skip {
  position: absolute;
  top: -100px;
  left: 8px;
  background: var(--navy);
  color: var(--paper-soft);
  padding: 8px 14px;
  border-radius: 8px;
  text-decoration: none;
  font-family: 'Geist', sans-serif;
  font-weight: 600;
  font-size: 0.86667rem;
  z-index: 9999;
  transition: top 160ms var(--ease-out);
}
.v2-skip:focus,
.v2-skip:focus-visible {
  top: 8px;
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* Focus rings – orange 2px @ 2px offset for every interactive element */
[data-design-v2] :focus-visible {
  outline: 2px solid var(--orange) !important;
  outline-offset: 2px !important;
  border-radius: inherit;
}
[data-design-v2] .v2-drawer__close:focus-visible,
[data-design-v2] .v2-cb:focus-visible,
[data-design-v2] .v2-row-act:focus-visible { outline-offset: 0 !important; }
/* Don't double-up on links/buttons that already have an outline-like state */
[data-design-v2] .v2-nav a:focus-visible,
[data-design-v2] .v2-subnav__items a:focus-visible {
  outline-offset: 4px !important;
}

/* Forced-colors mode (Windows high contrast) */
@media (forced-colors: active) {
  [data-design-v2] {
    --paper: Canvas;
    --paper-soft: Canvas;
    --paper-shade: Canvas;
    --ink: CanvasText;
    --ink-strong: CanvasText;
    --ink-muted: GrayText;
    --hairline: GrayText;
  }
}
