/* =====================================================================
   Velora sur téléphone (09/11/2026) — chargé en dernier, seulement sous 760 px de large.
   Un seul système pour toutes les pages (hors Messages : public/msg-mobile.css) :
   - cibles tactiles de 44 px (boutons, onglets, listes déroulantes, champs, « En savoir plus », cases à cocher dans
     une ligne de 44 px) ; champs à 16 px (pas de zoom sur iPhone) ;
   - fenêtres en feuilles qui montent du bas (pleine largeur, poignée, défilent à l'intérieur, zone sûre du bas) ;
   - en-têtes de page compacts, actions principales pleine largeur, onglets qui défilent de côté ;
   - tableaux larges en cartes ; rien ne dépasse à droite ; rien sous la barre du bas.
   Mesuré par tests/_mobile-audit.mjs et vérifié par tests/mobile-v2.mjs.
   ===================================================================== */
@media (max-width: 760px) {
  /* ---------- cibles tactiles ---------- */
  html body .app :is(.btn-main, .btn-ghost, .btn-danger, .btn-soft) { min-height: 44px; }
  html body .app :is(.btn-main, .btn-ghost, .btn-danger, .btn-soft):is(.sm, .btn-sm) { height: auto !important; min-height: 44px !important; padding-top: 0; padding-bottom: 0; }
  html body .app .view :is(select, input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=color]):not([type=file]):not([type=hidden])) { min-height: 44px !important; }
  /* tout bouton d'une page : 44 px de haut au moins (les petits boutons d'icône aussi en largeur) */
  html body .app .view :is(button, [role=button], a.btn-main, a.btn-ghost):not(.vv-ck):not(.ui-inline) { min-height: 44px; }
  html body .app .view button:is(.sm-plus, [data-star], [data-rv-ask], .ico-btn, .x, .close) { min-width: 44px; }
  html body .app :is(.ct-tabs, .seg-mini, .fx3-seg, .tm-seg, .sm-folder, .seg, .cp-seg:not(fieldset), .auth-seg, .db-seg, .dbx-seg, .sm-subtabs, .v-tabs, .vtabs, .vv-kinds, .tgp-tabs) > button,
  html body .app .view [role="tab"] { min-height: 44px !important; height: auto !important; }
  html body .app .view summary { min-height: 44px; padding-top: 10px; padding-bottom: 10px; box-sizing: border-box; cursor: pointer; }
  html body .app .view :is(.linkish, .guide-open):not(p .linkish):not(li .linkish) { min-height: 44px; display: inline-flex; align-items: center; }
  html body .app :is(.v-ibtn, .ibtn, .icon-btn, .co-x, .vv-ico, .pl-x, .tm2-x) { min-width: 44px !important; min-height: 44px !important; }
  /* cases à cocher et boutons radio : 22 px, dans une ligne de 44 px qui se touche en entier */
  html body .app input:is([type=checkbox], [type=radio]):not(.rl2-sw):not([role=switch]) { width: 22px; height: 22px; flex: none; }
  html body .app label:has(> input:is([type=checkbox], [type=radio])) { min-height: 44px; display: inline-flex; align-items: center; gap: 10px; }
  /* interrupteurs : plus grands au doigt */
  html body .app input.rl2-sw { width: 48px !important; height: 28px !important; }
  /* paramètres : les rubriques de la colonne de gauche */
  html body .app [data-set-tab] { min-height: 48px !important; }
  /* champs : 16 px (iPhone ne zoome plus) */
  html body .app :is(input, select, textarea) { font-size: max(16px, 1em); }

  /* ---------- en-tête de page compact ---------- */
  html body .app .view > .viewbar { padding-top: 6px !important; padding-bottom: 8px !important; gap: 10px !important; row-gap: 10px !important; }
  html body .app .view > .viewbar h1 { font-size: 26px !important; line-height: 1.15; margin: 0 !important; }
  html body .app .view > .viewbar p.muted { margin: 2px 0 0 !important; font-size: 14px; }
  html body .app .view > .viewbar > .viewbar-tools { width: 100%; display: flex; flex-wrap: wrap; gap: 8px; }
  html body .app .view > .viewbar > .viewbar-tools > .btn-main { flex: 1 1 100%; justify-content: center; }
  html body .app .view main.scroll > .wrap, html body .app .view main.scroll > div > .wrap { padding-top: 4px; }

  /* onglets / segments : une ligne qui défile de côté (jamais coupés, jamais sur 3 lignes) */
  html body .app :is(.ct-tabs, .fx3-seg, .sm-subtabs, .tgp-tabs, .v-tabs, .vtabs, .db-seg, .dbx-seg):not(.wrap-ok) { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important; max-width: 100% !important; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  html body .app :is(.ct-tabs, .fx3-seg, .sm-subtabs, .tgp-tabs, .v-tabs, .vtabs, .db-seg, .dbx-seg) > * { flex: none; white-space: nowrap; }

  /* ---------- fenêtres → feuilles qui montent du bas ---------- */
  html body .co-modal { place-items: end stretch !important; padding: 0 !important; align-items: end !important; }
  html body .co-modal > .co-card, html body .co-modal > form.co-card, html body .co-modal > div > .co-card {
    width: 100% !important; max-width: none !important; margin: 0 !important; border-radius: 22px 22px 0 0 !important;
    max-height: calc(var(--vvh, 100dvh) - 28px); overflow-y: auto; overscroll-behavior: contain;
    padding: 26px 18px calc(18px + env(safe-area-inset-bottom, 0px)) !important; border-bottom: 0 !important;
  }
  html body .co-modal > .co-card::before { content: ""; position: sticky; top: -18px; display: block; width: 40px; height: 5px; margin: -14px auto 12px; border-radius: 3px; background: var(--line-2, rgba(255, 255, 255, .18)); }
  html body .co-modal .co-card .co-x { position: absolute; top: 8px; right: 8px; }
  /* les actions du bas d'une feuille : pleine largeur, faciles au pouce */
  html body .co-modal .co-card :is(.co-actions, .ask-actions, .form-actions, footer):not(:empty) { display: flex; flex-wrap: wrap; gap: 8px; }
  html body .co-modal .co-card :is(.co-actions, .ask-actions, .form-actions, footer) > :is(.btn-main, .btn-ghost, .btn-danger) { flex: 1 1 140px; justify-content: center; }
  html body dialog:is(.ask-dialog, .fwd-dialog)[open] { width: 100% !important; max-width: none !important; margin: auto 0 0 !important; border-radius: 22px 22px 0 0 !important; padding-bottom: env(safe-area-inset-bottom, 0px) !important; }
  html body .ask-actions { display: flex; gap: 8px; }
  html body .ask-actions > button { flex: 1; min-height: 48px; }

  /* ---------- listes et tableaux ---------- */
  /* Créatrices : le tableau large se lit en cartes (le bouton « Tableau » reste là pour qui veut défiler) */
  html body .app #view-createurs .crx-table { display: block; overflow-x: auto; }

  /* ---------- rien sous la barre du bas, rien coupé à droite ---------- */
  html body .app .view main.scroll { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important; }
  html body .app .view :is(img, video, canvas, svg.chart, table) { max-width: 100%; }
  html body .app .view pre, html body .app .view code { white-space: pre-wrap; word-break: break-word; }
}
/* très petits écrans (iPhone SE, Android compacts) */
@media (max-width: 380px) {
  html body .app .view > .viewbar h1 { font-size: 23px !important; }
  html body .bottomnav button { font-size: 10.5px !important; }
}

/* ---------- menu (panneau) en accordéon, Paramètres en feuille (public/mobile.js) ---------- */
@media (max-width: 760px) {
  body.side-open .side { width: min(88vw, 340px) !important; max-width: 340px !important; padding-bottom: env(safe-area-inset-bottom, 0px); }
  body.side-open .side .nav .nav-sec[data-sec-btn] { position: relative; }
  body.side-open .side .nav .nav-sec[data-sec-btn]::after { content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -5px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform .15s; }
  body.side-open .side .nav .nav-sec.m-open::after { transform: rotate(-135deg); margin-top: -1px; }
  body.side-open .side .nav .nav-sec[data-sec-btn] { padding-right: 44px !important; }
  body.side-open .side .nav .nav-sec .nav-dot { margin-right: 4px; }
  html body .app .side .nav .nav-sub.m-show:not([hidden]) { display: flex !important; height: auto !important; min-height: 44px !important; margin: 0 0 0 19px !important; padding: 0 10px 0 16px !important; gap: 10px !important; align-items: center; border-left: 1.5px solid var(--line-2, var(--line)); border-radius: 0 10px 10px 0; font-size: 15px; color: var(--fg-2, var(--muted)); }
  html body .app .side .nav .nav-sub.m-show svg { display: block; width: 16px !important; height: 16px !important; }
  html body .app .side .nav .nav-sub.m-show[aria-current="page"] { color: var(--fg) !important; font-weight: 600; background: var(--surface-3) !important; border-left-color: var(--accent); }
  /* (sur téléphone, seules les pages de la section dépliée se montrent) */
  html body.side-open .app .side .nav .nav-sub.sec-open:not(.m-show) { display: none !important; }

  .set-pick { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 56px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--fg); font: inherit; text-align: left; cursor: pointer; }
  .set-pick span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
  .set-pick small { font-size: 12px; color: var(--muted); }
  .set-pick b { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .set-pick svg { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--muted); stroke-width: 2; }
  html body .app #set-tabs { display: none !important; }
  html body #set-tabs.m-sheet { display: flex !important; flex-direction: column !important; flex-wrap: nowrap !important; position: fixed !important; top: auto !important; left: 0; right: 0; bottom: 0; z-index: 1200; max-height: 80dvh; overflow-y: auto !important; overflow-x: hidden !important; gap: 2px; margin: 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom, 0px)) !important; border-radius: 22px 22px 0 0 !important; border: 1px solid var(--line) !important; border-bottom: 0 !important; background: var(--surface) !important; box-shadow: var(--shadow-lg); animation: vmSheetIn .18s var(--ease, ease-out); }
  html body #set-tabs.m-sheet::before { content: ""; flex: none; align-self: center; width: 40px; height: 5px; margin: 0 0 8px; border-radius: 3px; background: var(--line-2, rgba(255, 255, 255, .18)); }
  html body #set-tabs.m-sheet > [data-set-tab] { width: 100% !important; flex: none !important; justify-content: flex-start !important; min-height: 56px !important; padding: 8px 12px !important; }
  html body #set-tabs.m-sheet > [data-set-tab] small { display: block !important; }
  html body #set-tabs.m-sheet > .set-tabs-sep { display: block !important; }
  .set-pick-back { position: fixed; inset: 0; z-index: 1199; background: rgba(5, 5, 8, .55); }
  @keyframes vmSheetIn { from { transform: translateY(24px); opacity: 0; } }

  /* en-têtes : les actions à gauche, sur toute la largeur ; boutons secondaires côte à côte */
  html body .app .view > .viewbar > .viewbar-tools { justify-content: flex-start !important; }
  html body .app .view > .viewbar > .viewbar-tools > :is(.btn-ghost, .btn-soft) { flex: 1 1 0; justify-content: center; }
  html body .app .view > .viewbar > .viewbar-tools > :is(select, .v-search, input[type=search]) { flex: 1 1 100%; width: 100% !important; max-width: none !important; }
  html body .app .view main.scroll { padding-top: 10px !important; }
  /* titres de carte : le titre, puis sa précision dessous (plus de colonnes étroites) */
  html body .app .view :is(.card-head, .dbx-card > header, .gr-sec-h) { flex-wrap: wrap; row-gap: 4px; }
  html body .app .view :is(.card-head, .dbx-card > header) > :is(small, .muted, p) { order: 3; flex-basis: 100%; }
  /* formulaires de filtres : champs pleine largeur, deux par ligne */
  html body .app .view .an-filters { display: grid !important; grid-template-columns: 1fr 1fr; gap: 10px 10px !important; }
  html body .app .view .an-filters > * { min-width: 0; }
  html body .app .view .an-filters :is(select, input) { width: 100% !important; }
}

/* ---------- tableaux larges en cartes (public/mobile.js : classe m-cards, intitulés data-l) ---------- */
@media (max-width: 760px) {
  html body .app .view .m-cards { display: flex !important; flex-direction: column !important; gap: 8px; overflow: visible !important; border: 0 !important; background: transparent !important; grid-template-columns: none !important; min-width: 0 !important; width: 100% !important; }
  html body .app .view .m-cards > thead, html body .app .view .m-cards > .head, html body .app .view .m-cards > .th, html body .app .view .m-cards > .vai-tr.th, html body .app .view .m-cards > .ct-row.head { display: none !important; }
  html body .app .view table.m-cards > tbody { display: flex; flex-direction: column; gap: 8px; }
  html body .app .view .m-cards > [role=row]:not(.head):not(.th), html body .app .view .m-cards > .ct-row:not(.head), html body .app .view .m-cards > .vai-tr:not(.th), html body .app .view .m-cards > tbody > tr {
    display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px 14px !important; align-items: start;
    width: auto !important; min-width: 0 !important; height: auto !important; padding: 14px !important; border: 1px solid var(--line) !important; border-radius: 14px !important; background: var(--surface) !important;
  }
  html body .app .view .m-cards > [role=row]:not(.head):not(.th) > :first-child, html body .app .view .m-cards > .ct-row:not(.head) > :first-child, html body .app .view .m-cards > .vai-tr:not(.th) > :first-child, html body .app .view .m-cards > tbody > tr > :first-child { grid-column: 1 / -1; }
  html body .app .view .m-cards > [role=row]:not(.head):not(.th) > *, html body .app .view .m-cards > .ct-row:not(.head) > *, html body .app .view .m-cards > .vai-tr:not(.th) > *, html body .app .view .m-cards > tbody > tr > * { display: block !important; min-width: 0; padding: 0 !important; border: 0 !important; text-align: left !important; justify-self: stretch; white-space: normal !important; overflow-wrap: anywhere; }
  html body .app .view .m-cards > [role=row]:not(.head):not(.th) > :first-child, html body .app .view .m-cards > .ct-row:not(.head) > :first-child, html body .app .view .m-cards > .vai-tr:not(.th) > :first-child, html body .app .view .m-cards > tbody > tr > :first-child { display: flex !important; align-items: center; gap: 10px; }
  html body .app .view .m-cards [data-l]::before { content: attr(data-l); display: block; margin-bottom: 2px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
  html body .app .view .m-cards > [role=row]:not(.head):not(.th) > :last-child:has(> button:only-child), html body .app .view .m-cards > .ct-row:not(.head) > :last-child:has(> button:only-child), html body .app .view .m-cards > .vai-tr:not(.th) > :last-child:has(> button:only-child), html body .app .view .m-cards > tbody > tr > :last-child:has(> button:only-child) { grid-column: 1 / -1; justify-self: end; }
  html body .app .view .m-cards > [role=row]:not(.head):not(.th) > :last-child:has(> button:only-child)::before, html body .app .view .m-cards > .ct-row:not(.head) > :last-child:has(> button:only-child)::before, html body .app .view .m-cards > .vai-tr:not(.th) > :last-child:has(> button:only-child)::before, html body .app .view .m-cards > tbody > tr > :last-child:has(> button:only-child)::before { display: none; }
  html body .app .view .m-cards small { display: block; }
  /* écrans vides : pas de carré décoratif (place gagnée) ; assistant : sa barre de saisie garde sa hauteur */
  html body .app .view :is(p.empty, div.empty)::before { display: none !important; }
  html body .app .view :is(p.empty, div.empty) { padding: 22px 16px !important; }
  html body .app .cbox .seg { height: auto !important; }
  /* listes de filtres dans les en-têtes de carte : pleine largeur */
  html body .app .view :is(.card-head, .sup-bar, .tgp-bar) > select { flex: 1 1 100%; width: 100% !important; }
}

/* ---------- cases de sélection dans les listes (sans libellé) : 44 px au doigt, 22 px à l'œil ---------- */
@media (max-width: 760px) {
  html body .app .view input[type=checkbox]:is([data-tm2-sel], [data-sel], [data-paid], [data-drp-sel], [data-tgp-sel], [data-crx-sel], [data-fx-sel]) {
    -webkit-appearance: none; appearance: none; width: 44px !important; height: 44px !important; margin: 0 !important; padding: 0; border: 0; border-radius: 12px; background: transparent; position: relative; cursor: pointer; flex: none;
  }
  html body .app .view input[type=checkbox]:is([data-tm2-sel], [data-sel], [data-paid], [data-drp-sel], [data-tgp-sel], [data-crx-sel], [data-fx-sel])::before {
    content: ""; position: absolute; inset: 11px; border: 2px solid var(--line-2, #555); border-radius: 6px; background: var(--surface-2, transparent);
  }
  html body .app .view input[type=checkbox]:is([data-tm2-sel], [data-sel], [data-paid], [data-drp-sel], [data-tgp-sel], [data-crx-sel], [data-fx-sel]):checked::before { background: var(--accent); border-color: var(--accent); }
  html body .app .view input[type=checkbox]:is([data-tm2-sel], [data-sel], [data-paid], [data-drp-sel], [data-tgp-sel], [data-crx-sel], [data-fx-sel]):checked::after {
    content: ""; position: absolute; left: 18px; top: 14px; width: 6px; height: 12px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg);
  }
  html body .app .view input[type=checkbox]:is([data-tm2-sel], [data-sel], [data-paid], [data-drp-sel], [data-tgp-sel], [data-crx-sel], [data-fx-sel]):focus-visible { outline: 2px solid var(--accent); outline-offset: -6px; }
  /* l'Assistant : le bouton Envoyer ; la recherche de la Bibliothèque */
  html body .app #send.as-send { min-height: 44px !important; min-width: 48px; }
  html body .app .view input.ui-bare[type=search], html body .app .view input[data-bl-q] { min-height: 44px !important; }
}

/* ordinateur : rien de tout cela (le bouton des catégories de Paramètres existe mais reste caché) */
@media (min-width: 761px) { .set-pick, .set-pick-back { display: none !important; } }

/* ---------- les autres fenêtres en feuilles : Telegram (tg-win), fiche du pipeline (tiroir) ---------- */
@media (max-width: 760px) {
  html body .tg-modal { padding: 0 !important; place-items: end stretch !important; }
  html body .tg-modal > .tg-win { width: 100% !important; max-width: none !important; max-height: calc(var(--vvh, 100dvh) - 28px) !important; border-radius: 22px 22px 0 0 !important; border-bottom: 0 !important; padding-bottom: env(safe-area-inset-bottom, 0px); }
  html body .tg-modal .tg-win :is(.tg-x, [data-close], .co-x) { min-width: 44px; min-height: 44px; }
  html body .app .gr-dw { top: auto !important; left: 0 !important; width: 100vw !important; height: calc(var(--vvh, 100dvh) - 28px) !important; border-left: 0 !important; border-radius: 22px 22px 0 0; transform: translateY(24px); padding-bottom: env(safe-area-inset-bottom, 0px); }
  html body .app .gr-dw-wrap.in .gr-dw { transform: none; }
  html body .app .gr-dw :is(.gr-dw-x, [data-close], .co-x) { min-width: 44px !important; min-height: 44px !important; }
}

/* notifications (toasts) : en haut comme avant (en bas, elles cacheraient la zone d'écriture des Messages) ; × de 44 px */
@media (max-width: 760px) {
  html body .toasts .tx { min-width: 44px !important; min-height: 44px !important; }
}

/* le × des fenêtres (posées à côté de l'appli, pas dedans) : 44 px */
@media (max-width: 760px) {
  html body :is(.co-modal, .tg-modal, .gr-dw-wrap, dialog) :is(.co-x, [data-close], .tg-x, .icon-btn, .icon-b, [aria-label="Fermer"]) { min-width: 44px !important; min-height: 44px !important; }
}

/* rien ne déborde de sa carte (colonnes de grille et éléments trop larges ramenés à la largeur disponible) ;
   Prospection : ses onglets sur une ligne qui défile */
@media (max-width: 760px) {
  html body .app .view :is(.card, .stack, section, .rl2, .rl2-side, .rl2-main) > * { max-width: 100%; min-width: 0; }
  html body .app .view .rl2 { grid-template-columns: minmax(0, 1fr) !important; }
  html body .app #tgp-tabs, html body .app .tgp-tabs { display: flex !important; flex-wrap: nowrap !important; overflow-x: auto !important; scrollbar-width: none; }
  html body .app :is(#tgp-tabs, .tgp-tabs) > button { flex: none !important; white-space: nowrap !important; }
}

/* connexion, inscription, double authentification (hors de l'appli) : grands champs et boutons au pouce */
@media (max-width: 760px) {
  html body .lock :is(input:not([type=checkbox]):not([type=radio]), select) { min-height: 48px !important; font-size: 16px !important; }
  html body .lock .btn-main { min-height: 52px !important; font-size: 16px !important; }
  html body .lock :is(.btn-ghost, .auth-seg > button, .seg > button, [role=tab]) { min-height: 44px !important; }
  html body .lock :is(.linkish, button.link, a.link) { min-height: 44px; display: inline-flex; align-items: center; }
}

/* dans une carte de tableau : rien de plus large que sa case (listes déroulantes au texte long, champs) */
@media (max-width: 760px) {
  html body .app .view .m-cards :is(td, th, [role=cell], .ct-row > *, .vai-tr > *) > * { max-width: 100%; }
  html body .app .view .m-cards :is(select, input:not([type=checkbox]):not([type=radio])) { width: 100% !important; min-width: 0 !important; }
}

/* Velora IA › Bibliothèque : la recherche à 44 px (sa règle a un identifiant de page, d'où la précision ici) */
@media (max-width: 760px) {
  html body .app #view-scripts .bl-search { height: auto !important; min-height: 48px; }
  html body .app #view-scripts .bl-search input { height: 44px !important; min-height: 44px !important; }
}
