/* ═══════════════════════════════════════════════════════════════════════════
   LeadBuddy — mobile phone (≤768px) ONLY. Desktop ≥769px untouched.
   Validated against iPhone 14 Pro (393×852).
   ═══════════════════════════════════════════════════════════════════════════ */

#mobile-bottom-nav,
#mobile-session-backdrop,
#mobile-more-sheet,
#mobile-install-hint,
#mobile-filters-btn,
#mobile-filters-backdrop,
#mobile-back-btn,
.mobile-session-sheet-handle,
.mobile-only {
  display: none;
}

@media (max-width: 768px) {
  :root {
    --topbar-height: 48px;
    --mobile-bottom-nav-height: 56px;
  }

  html,
  body {
    height: 100dvh;
    overflow: hidden;
    overscroll-behavior: none;
  }

  #app {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  /* ─── Topbar: icon rail only ────────────────────────────────────────────── */

  #topbar {
    height: 48px;
    min-height: 48px;
    gap: 4px;
    padding: 0 6px;
    flex-shrink: 0;
    overflow: hidden;
  }

  #topbar-logo span,
  #topbar-search-trigger kbd,
  #topbar-help-btn,
  #topbar-guide-btn,
  #topbar-team-stats-pref,
  #topbar-credits,
  #topbar-filters {
    display: none !important;
  }

  #topbar-logo {
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    margin: 0;
    justify-content: center;
  }

  #topbar-search-trigger {
    flex: 1;
    min-width: 0;
    min-height: 40px;
    justify-content: flex-start;
    gap: 8px;
    padding: 0 12px;
    overflow: hidden;
    font-size: 14px;
    color: var(--text-secondary);
  }

  #topbar-search-trigger > svg {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
  }

  #topbar-search-trigger .mobile-search-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
  }

  #topbar-search-trigger kbd {
    display: none !important;
  }

  #topbar-right {
    gap: 2px;
    flex-shrink: 0;
  }

  #theme-toggle {
    min-width: 40px;
    min-height: 40px;
  }

  /* Compte → sheet Plus (évite "Alexandr…" tronqué) ; picker dédié ci-dessous */
  #user-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0 !important;
    pointer-events: none !important;
    overflow: hidden !important;
  }

  /* Picker compte — bottom sheet (pas le <select> natif flottant) */
  .mobile-account-sheet {
    position: fixed;
    inset: 0;
    z-index: 520;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
  }

  .mobile-account-sheet.is-open {
    pointer-events: auto;
    opacity: 1;
  }

  .mobile-account-backdrop {
    position: absolute;
    inset: 0;
    border: none;
    background: rgba(0, 0, 0, 0.45);
    padding: 0;
    cursor: pointer;
  }

  .mobile-account-panel {
    position: relative;
    z-index: 1;
    max-height: min(72vh, 520px);
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border-radius: 18px 18px 0 0;
    border: 1px solid var(--border);
    border-bottom: none;
    padding: 0 0 calc(12px + env(safe-area-inset-bottom, 0px));
    transform: translateY(12px);
    transition: transform 0.22s ease;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.28);
  }

  .mobile-account-sheet.is-open .mobile-account-panel {
    transform: translateY(0);
  }

  .mobile-account-handle {
    width: 36px;
    height: 4px;
    margin: 10px auto 4px;
    border-radius: 999px;
    background: var(--border);
    flex-shrink: 0;
  }

  .mobile-account-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 14px 8px;
    flex-shrink: 0;
  }

  .mobile-account-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
  }

  .mobile-account-close {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg-surface);
    color: var(--text-secondary);
    padding: 0;
    cursor: pointer;
  }

  .mobile-account-hint {
    margin: 0 14px 10px;
    font-size: 0.82rem;
    color: var(--text-muted);
  }

  .mobile-account-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 0;
  }

  .mobile-account-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    width: 100%;
  }

  .mobile-account-item.is-active {
    border-color: var(--orange);
    background: color-mix(in srgb, var(--orange) 12%, var(--bg-surface));
    color: var(--orange);
  }

  .mobile-account-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-account-check {
    flex-shrink: 0;
    font-size: 16px;
    font-weight: 700;
  }

  html.mobile-account-open #mobile-bottom-nav {
    pointer-events: none;
  }

  #mobile-filters-btn {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-width: 40px;
    min-height: 40px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
  }

  html.mobile-in-session #mobile-filters-btn {
    display: inline-flex;
  }

  /* ─── Main column — réserve la place de la bottom nav (plus de contenu dessous) ─ */

  #main-layout {
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
  }

  #center-panel {
    width: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding-bottom: 0;
  }

  #right-panel {
    display: none !important;
  }

  /* Footer desktop → HIDDEN on phone (was overlapping bottom nav) */
  #app-footer {
    display: none !important;
  }

  /* ─── Session sheet ─────────────────────────────────────────────────────── */

  #session-panel {
    display: none !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    width: 100%;
    height: min(85dvh, 620px);
    max-height: calc(100dvh - env(safe-area-inset-top, 0px) - 56px);
    z-index: 240;
    border-right: none;
    border-top: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
    padding-bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow-lg);
    transform: translateY(110%);
    transition: transform 0.28s ease;
    pointer-events: none;
    background: var(--bg-surface);
    overflow: hidden;
  }

  html.mobile-session-sheet-open #session-panel {
    display: flex !important;
    transform: translateY(0);
    pointer-events: auto;
  }

  .mobile-session-sheet-handle {
    display: flex;
    justify-content: center;
    padding: 10px 0 6px;
    flex-shrink: 0;
  }

  .mobile-session-sheet-handle::before {
    content: "";
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background: var(--border);
  }

  #mobile-session-backdrop,
  #mobile-filters-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 230;
    background: var(--bg-overlay);
    border: none;
    padding: 0;
    margin: 0;
  }

  html.mobile-session-sheet-open #mobile-session-backdrop,
  html.mobile-filters-open #mobile-filters-backdrop {
    display: block;
  }

  html.mobile-filters-open #topbar-filters {
    display: block !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 260;
    width: 100%;
    max-height: min(88dvh, 720px);
    overflow-y: auto;
    background: var(--bg-card);
    border-radius: 16px 16px 0 0;
    padding: 14px 14px calc(20px + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow-lg);
  }

  html.mobile-filters-open #topbar-filters .topbar-session-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  html.mobile-filters-open #topbar-filters-panel {
    position: static !important;
    display: block !important;
    width: 100%;
    max-width: none;
    box-shadow: none;
    border: none;
    padding: 0;
    opacity: 1;
    pointer-events: auto;
    transform: none;
  }

  /* ─── Bottom nav ────────────────────────────────────────────────────────── */

  #mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 220;
    height: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding: 0 2px env(safe-area-inset-bottom, 0px);
    background: var(--bg-surface);
    border-top: 1px solid var(--border);
    align-items: stretch;
  }

  body.login-pending #mobile-bottom-nav {
    display: none !important;
  }

  /* Hide bottom nav under modals / sheets */
  html.mobile-more-open #mobile-bottom-nav,
  html.mobile-session-sheet-open #mobile-bottom-nav,
  html.mobile-filters-open #mobile-bottom-nav,
  html.mobile-dialog-open #mobile-bottom-nav {
    display: none !important;
  }

  .mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--mobile-bottom-nav-height);
    padding: 6px 2px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  .mobile-nav-item svg {
    width: 22px;
    height: 22px;
  }

  .mobile-nav-item.is-active {
    color: var(--orange);
  }

  .mobile-nav-item:active {
    background: var(--bg-card-hover);
  }

  /* ─── Back discret ──────────────────────────────────────────────────────── */

  .mobile-back-btn {
    display: none;
    position: fixed;
    top: calc(env(safe-area-inset-top, 0px) + 54px);
    left: 10px;
    z-index: 230;
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: color-mix(in srgb, var(--bg-surface) 92%, transparent);
    color: var(--text-secondary);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    padding: 0;
  }

  .mobile-back-btn.is-visible {
    display: inline-flex;
  }

  /* Pas de double retour quand la page a déjà le sien */
  #main-layout:has(.fraicheur-back) #mobile-back-btn,
  #main-layout:has(.sb-back) #mobile-back-btn,
  #main-layout:has(.lists-back) #mobile-back-btn,
  #main-layout:has(.sessions-back) #mobile-back-btn,
  #main-layout:has(.sessions-back-btn) #mobile-back-btn,
  #main-layout:has(.resv-back) #mobile-back-btn,
  #main-layout:has(.fu-back) #mobile-back-btn,
  #main-layout:has(#fu-back-btn) #mobile-back-btn,
  #main-layout:has(.import-back) #mobile-back-btn {
    display: none !important;
  }

  .mobile-back-btn:active {
    transform: scale(0.96);
    color: var(--orange);
  }

  /* Une seule vue à la fois — l’accueil ne doit jamais cohabiter */
  html.mobile-view-home #emails-view,
  html.mobile-view-home #sessions-view,
  html.mobile-view-home #lists-view,
  html.mobile-view-home #scoreboard-view,
  html.mobile-view-home #follow-ups-view,
  html.mobile-view-home #fraicheur-view,
  html.mobile-view-home #reservations-view,
  html.mobile-view-home #help-view,
  html.mobile-view-home #guide-view,
  html.mobile-view-home #import-view {
    display: none !important;
  }

  #main-layout:has(#emails-view.visible) #home-screen,
  #main-layout:has(#sessions-view.visible) #home-screen,
  #main-layout:has(#lists-view.visible) #home-screen,
  #main-layout:has(#scoreboard-view.visible) #home-screen,
  #main-layout:has(#follow-ups-view.visible) #home-screen,
  #main-layout:has(#fraicheur-view.visible) #home-screen,
  #main-layout:has(#reservations-view.visible) #home-screen,
  #main-layout:has(#help-view.visible) #home-screen,
  #main-layout:has(#guide-view.visible) #home-screen,
  #main-layout:has(#import-view.visible) #home-screen,
  #main-layout:has(#oneshot-file-view.visible) #home-screen,
  html.mobile-view-emails #home-screen,
  html.mobile-view-more #home-screen,
  html.mobile-view-session #home-screen {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    max-height: 0 !important;
    min-height: 0 !important;
    flex: 0 0 0 !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    pointer-events: none !important;
  }

  #emails-view.visible,
  #sessions-view.visible,
  #lists-view.visible,
  #scoreboard-view.visible,
  #follow-ups-view.visible,
  #fraicheur-view.visible,
  #reservations-view.visible,
  #help-view.visible,
  #guide-view.visible,
  #import-view.visible {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
  }

  .mobile-nav-item.is-dimmed {
    opacity: 0.45;
  }

  #home-start-btn.mobile-cta-pulse {
    animation: mobile-cta-pulse 0.9s ease 2;
  }

  @keyframes mobile-cta-pulse {
    0%,
    100% {
      box-shadow: 0 4px 20px rgba(233, 83, 13, 0.35);
      transform: scale(1);
    }
    50% {
      box-shadow: 0 0 0 6px color-mix(in srgb, var(--orange) 28%, transparent);
      transform: scale(1.02);
    }
  }

  /* ─── More sheet (iOS-like) ─────────────────────────────────────────────── */

  #mobile-more-sheet {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 250;
    align-items: flex-end;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.28s ease, visibility 0.28s ease;
  }

  html.mobile-more-open #mobile-more-sheet {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }

  .mobile-more-panel {
    width: 100%;
    max-height: min(88dvh, 720px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-card);
    border-radius: 18px 18px 0 0;
    padding: 10px 14px calc(20px + env(safe-area-inset-bottom, 0px));
    transform: translateY(110%);
    transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1);
    will-change: transform;
  }

  html.mobile-more-open .mobile-more-panel {
    transform: translateY(0);
  }

  .mobile-more-handle {
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--text-muted) 55%, transparent);
    margin: 2px auto 10px;
  }

  .mobile-more-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 2px 8px;
  }

  .mobile-more-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.01em;
    text-transform: none;
    padding: 0;
  }

  .mobile-more-close {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: none;
    background: var(--bg-elevated, var(--bg-surface));
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .mobile-more-section-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 14px 4px 8px;
  }

  .mobile-more-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .mobile-more-grid--account {
    grid-template-columns: 1fr 1fr;
  }

  .mobile-more-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 600;
    text-align: left;
  }

  .mobile-more-item span:not(.mobile-more-ico):not(.mobile-more-account-label) {
    display: none;
  }

  .mobile-more-ico {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    flex-shrink: 0;
    font-size: 16px;
    line-height: 1;
    background: color-mix(in srgb, var(--ico, var(--orange)) 18%, transparent);
  }

  .mobile-more-item--danger {
    border-color: color-mix(in srgb, #ef4444 35%, var(--border));
    color: #ef4444;
  }

  .mobile-more-account-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
  }

  /* Session sheet slide */
  #session-panel {
    transition: transform 0.36s cubic-bezier(0.32, 0.72, 0, 1) !important;
  }

  /* ─── Home ──────────────────────────────────────────────────────────────── */

  #home-screen {
    flex: 1;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-padding-bottom: 24px;
    padding: 10px 14px 20px !important;
  }

  #home-screen .home-inner,
  .home-inner {
    max-width: 100% !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #home-step-hub.home-step--active {
    gap: 14px !important;
    display: flex !important;
    flex-direction: column;
  }

  /* Ordre mobile : variante → KPI → actions (liens) → bas */
  .home-variant-bar { order: 0; }
  #home-hub-beta,
  #home-hub-day { order: 1; }
  #home-resume-btn { order: 2; }
  .home-actions { order: 3; display: flex; flex-direction: column; gap: 10px; }
  #home-cta-pair { order: 1; }
  #home-util-row { order: 2; }
  .home-user-hint { order: 0; }
  #home-hub-beta-tail { order: 4; }
  #home-last-session { order: 5; }

  .home-greeting {
    font-size: 11px !important;
    margin-bottom: 2px !important;
    letter-spacing: 0.04em;
  }

  .home-title {
    font-size: 1.25rem !important;
    line-height: 1.2 !important;
    margin-bottom: 4px !important;
  }

  .home-hero--compact {
    margin-bottom: 4px !important;
  }

  .home-kpis-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 8px !important;
    margin-bottom: 8px !important;
  }

  .home-kpis-period {
    width: 100% !important;
    justify-content: stretch !important;
    margin-left: 0 !important;
  }

  .home-kpis-period-chips {
    width: 100%;
    justify-content: space-between;
  }

  .home-kpis-period-btn {
    flex: 1;
    text-align: center;
    min-height: 32px;
    font-size: 11px !important;
  }

  .home-hub-grid,
  .home-kpis-grid,
  .home-kpi-grid,
  .home-shortcuts,
  .home-admin-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }

  .home-kpi-card {
    min-height: 0 !important;
    max-height: 68px;
    padding: 8px 8px 6px !important;
    gap: 1px !important;
    align-items: flex-start !important;
    text-align: left !important;
    overflow: hidden;
  }

  .home-kpi-value {
    font-size: 17px !important;
  }

  .home-kpi-label {
    font-size: 11px !important;
  }

  .home-kpi-hint {
    display: none !important;
  }

  #home-hub-beta {
    padding-bottom: 4px;
  }

  .home-cta-pair {
    gap: 8px !important;
    margin-top: 4px;
  }

  .home-btn-cta {
    min-height: 48px !important;
    padding: 12px 16px !important;
    font-size: 15px !important;
  }

  .home-btn-cta--muted {
    color: var(--text-primary) !important;
    background: var(--bg-elevated, var(--bg-card)) !important;
    border: 1px solid color-mix(in srgb, var(--orange) 28%, var(--border)) !important;
    opacity: 1 !important;
  }

  .home-btn-cta--muted:disabled {
    opacity: 0.7 !important;
    color: var(--text-secondary) !important;
  }

  /* Liens utilitaires → sheet Plus (évite doublon sous Prospecter) */
  #home-util-row,
  .home-util-row {
    display: none !important;
  }

  #home-start-btn,
  #home-resume-btn,
  #home-relances-btn,
  .home-primary-cta {
    width: 100%;
    min-height: 48px;
  }

  .home-day,
  .hd-shell {
    padding: 0 !important;
  }

  .hd-board,
  .hd-grid {
    grid-template-columns: 1fr !important;
  }

  /* Ma journée — aérer un peu */
  .home-day-source-bar {
    flex-wrap: wrap;
    gap: 8px;
  }

  .home-hub-panel {
    gap: 10px;
  }

  /* ─── Overlay views (emails, lists, …) ──────────────────────────────────── */

  #emails-view.visible,
  #lists-view.visible,
  #scoreboard-view.visible,
  #follow-ups-view.visible,
  #fraicheur-view.visible,
  #sessions-view.visible,
  #help-view.visible,
  #guide-view.visible,
  #import-view.visible,
  #reservations-view.visible {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    padding-bottom: 0 !important;
    margin-top: 0 !important;
  }

  /* Sécurité : aucune vue overlay inactive ne doit prendre de place */
  #emails-view:not(.visible),
  #lists-view:not(.visible),
  #scoreboard-view:not(.visible),
  #follow-ups-view:not(.visible),
  #fraicheur-view:not(.visible),
  #sessions-view:not(.visible),
  #help-view:not(.visible),
  #guide-view:not(.visible),
  #import-view:not(.visible),
  #reservations-view:not(.visible),
  #oneshot-file-view:not(.visible) {
    display: none !important;
  }

  /* Sur e-mails : une seule barre de recherche (celle de la vue) */
  html.mobile-view-emails #topbar-search-trigger {
    display: none !important;
  }

  /* Ne forcer flex QUE quand la vue e-mails est ouverte — sinon elle
     occupe ~50px et décale Réservations / autres pages Plus. */
  #emails-view:not(.visible) {
    display: none !important;
    flex: 0 0 0 !important;
    height: 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    pointer-events: none !important;
  }

  #emails-view.visible,
  #emails-view.visible #emails-view-content {
    display: flex !important;
    flex-direction: column !important;
    min-height: 0 !important;
    overflow: hidden !important;
    position: relative;
  }

  .emails-app {
    flex-direction: column !important;
    min-height: 0 !important;
    height: 100% !important;
    flex: 1 !important;
    overflow: hidden !important;
  }

  /* Liste = écran principal ; le hub vide desktop ne s’empile plus dessous */
  .emails-sidebar {
    width: 100% !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    height: auto !important;
    overflow: hidden !important;
    display: flex !important;
    flex-direction: column !important;
    border-right: none !important;
    border-bottom: none !important;
  }

  .emails-sidebar-list,
  #emails-sidebar-list {
    flex: 1 1 auto !important;
    min-height: 120px !important;
    height: 100% !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 12px !important;
  }

  .emails-sidebar-controls {
    flex-shrink: 0;
  }

  /* Hub vide : masqué. Compose / détail : plein écran. Expéditeurs : sous les onglets. */
  .emails-workspace:not(:has(.emails-compose:not(.hidden))):not(:has(.emails-detail:not(.hidden))):not(:has(#emails-senders-panel:not(.hidden))) {
    display: none !important;
  }

  .emails-workspace:has(.emails-compose:not(.hidden)),
  .emails-workspace:has(.emails-detail:not(.hidden)) {
    display: flex !important;
    position: absolute;
    inset: 0;
    z-index: 5;
    background: var(--bg-base);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Expéditeurs Gmail — visibles sous Modèles / Expéditeurs */
  .emails-app:has(#emails-senders-panel:not(.hidden)) {
    display: flex !important;
    flex-direction: column !important;
  }

  .emails-app:has(#emails-senders-panel:not(.hidden)) .emails-sidebar {
    flex: 0 0 auto !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .emails-app:has(#emails-senders-panel:not(.hidden)) .emails-sidebar-list,
  .emails-app:has(#emails-senders-panel:not(.hidden)) .emails-sidebar-senders-aside {
    display: none !important;
  }

  .emails-workspace:has(#emails-senders-panel:not(.hidden)) {
    display: flex !important;
    position: relative !important;
    inset: auto !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
    overflow: auto !important;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-base);
    z-index: 1;
  }

  #emails-senders-panel:not(.hidden) {
    display: flex !important;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    padding: 12px 14px calc(16px + var(--mobile-bottom-nav-height, 56px) + env(safe-area-inset-bottom, 0px)) !important;
    box-sizing: border-box;
    align-items: stretch;
  }

  .emails-senders-inner {
    max-width: 100% !important;
  }

  .emails-senders-head {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px;
  }

  .emails-senders-connect {
    width: 100% !important;
    min-height: 44px;
    justify-content: center;
  }

  .emails-sender-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px;
  }

  .emails-sender-actions {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .emails-sender-actions .emails-sender-btn {
    min-height: 40px;
    justify-content: center;
  }

  .emails-sidebar-head,
  .emails-hub,
  .emails-compose {
    padding: 12px 14px !important;
  }

  .emails-hub,
  .emails-hub-inner,
  .emails-hub-hero,
  .emails-hub-section,
  .emails-hub-lead,
  .emails-sidebar-title span,
  .emails-hub-desc,
  .emails-intro,
  .emails-hub-subtitle,
  .emails-hub-hint {
    position: static !important;
    float: none !important;
    max-width: 100% !important;
    white-space: normal !important;
    line-height: 1.45;
  }

  .emails-hub.hidden {
    display: none !important;
  }

  .emails-sidebar-item {
    min-height: 52px;
    padding: 12px 14px !important;
  }

  .emails-list {
    padding-bottom: 12px;
  }


  /* Aircall dock au-dessus de la bottom nav */
  .aircall-dock {
    bottom: calc(var(--mobile-bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 12px) !important;
    width: calc(100vw - 20px) !important;
    left: 50% !important;
  }

  /* ─── Dialogs / search as true sheets above everything ──────────────────── */

  dialog[open] {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    height: auto !important;
    margin: 0 !important;
    border-radius: 16px 16px 0 0 !important;
    z-index: 400 !important;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  dialog::backdrop {
    z-index: 399 !important;
  }

  #dialog-search[open] {
    top: 0 !important;
    bottom: 0 !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    border-radius: 0 !important;
  }

  /* Search polish detail → search-modal.css (filtres repliés + scroll résultats) */

  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  .btn,
  .btn-primary,
  .action-btn {
    min-height: 44px;
  }

  /* Contact */
  #prospecting-view,
  #contact-card {
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px !important;
    max-width: 100%;
  }

  #action-buttons {
    position: sticky;
    bottom: 0;
    z-index: 40;
    background: var(--bg-base);
    padding: 10px 0 calc(8px + env(safe-area-inset-bottom, 0px));
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .action-btn {
    min-height: 48px;
  }

  #contact-name {
    font-size: 1.3rem !important;
    word-break: break-word;
  }

  html.mobile-scroll-lock,
  html.mobile-scroll-lock body {
    overflow: hidden !important;
  }

  @media (prefers-reduced-motion: reduce) {
    #session-panel {
      transition: none !important;
    }
  }
}

@media (min-width: 769px) {
  #mobile-bottom-nav,
  #mobile-session-backdrop,
  #mobile-more-sheet,
  #mobile-account-sheet,
  #mobile-install-hint,
  #mobile-filters-btn,
  #mobile-filters-backdrop,
  #mobile-back-btn,
  .mobile-session-sheet-handle,
  .mobile-only {
    display: none !important;
  }
}
