/*
 * Version téléphone du bureau (20 novembre 2026).
 * Tout ce fichier vit dans « @media (max-width: 760px) » : au-delà, il ne change rien (l'écran d'ordinateur reste identique).
 * On adapte, on ne redessine pas : mêmes couleurs, mêmes polices, mêmes écrans ; seulement la place, la taille des cibles au doigt
 * et les marges des écrans à encoche. Chargé après app.css et glory.css.
 */
@media (max-width: 760px) {
  /* ----- Zones sûres (encoche, coins arrondis, barre du bas) : rien d'utile ne passe dessous ----- */
  :root { --sur-haut: env(safe-area-inset-top, 0px); --sur-bas: env(safe-area-inset-bottom, 0px); --sur-gauche: env(safe-area-inset-left, 0px); --sur-droite: env(safe-area-inset-right, 0px); }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  :is(html, html.glory) main { padding-left: max(16px, var(--sur-gauche)); padding-right: max(16px, var(--sur-droite)); }
  :is(html, html.glory) .foot { padding: .6rem max(16px, var(--sur-droite)) calc(.8rem + var(--sur-bas)) max(16px, var(--sur-gauche)); }
  .login { margin: calc(2rem + var(--sur-haut)) auto calc(2rem + var(--sur-bas)); padding: 0 max(1.25rem, var(--sur-droite)) 0 max(1.25rem, var(--sur-gauche)); }
  .login h1 { font-size: 2.2rem; margin-bottom: .8rem; }
  .login input { min-height: 48px; font-size: 16px; width: 100%; }
  .login .btn { min-height: 48px; width: 100%; }

  /* ----- Barre du haut : une seule ligne, toujours sous le doigt (elle reste en haut quand la page défile) ----- */
  :is(html, html.glory) .topbar { position: sticky; top: 0; z-index: 30; flex-wrap: nowrap; align-items: center; gap: .5rem; min-height: 0;
    padding: calc(.45rem + var(--sur-haut)) max(.75rem, var(--sur-droite)) .45rem max(.75rem, var(--sur-gauche)); }
  html:not(.glory) .topbar { background: var(--fond); }
  /* Le décor de satin ne dépasse plus que d'un liseré sous la barre : jamais derrière le titre de la page. */
  html.glory { --band-h: calc(92px + var(--sur-haut)); }
  :is(html, html.glory) .menu-toggle { flex: none; min-height: 44px; min-width: 44px; padding: .4rem .8rem; font-size: 1rem; }
  .topbar .brandpick { flex: 1 1 auto; min-width: 0; margin-right: 0; gap: 0; }
  /* Le libellé « Marque active » reste lu par les lecteurs d'écran ; à l'œil, la liste parle d'elle-même. */
  .topbar .brandpick__label, .topbar .conseil-declencheur > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  :is(html, html.glory) .topbar .brandpick select { width: 100%; min-width: 0; min-height: 44px; font-size: 16px; text-overflow: ellipsis; }
  :is(html, html.glory) .topbar .conseil-declencheur { flex: none; width: 44px; height: 44px; min-height: 44px; padding: 0; justify-content: center; border-radius: 50%; }
  .topbar .link { flex: none; min-height: 44px; display: inline-flex; align-items: center; font-size: .95rem; }

  /* ----- Menu en tiroir : il glisse depuis la gauche, laisse voir la page derrière, se referme d'un toucher à côté ----- */
  :is(html, html.glory) .sidebar.open { inset: 0 auto 0 0; width: min(86vw, 21.5rem); height: auto; max-height: none; backdrop-filter: none; overflow-y: auto; overscroll-behavior: contain;
    padding: calc(.9rem + var(--sur-haut)) .9rem calc(1.2rem + var(--sur-bas)) max(.9rem, var(--sur-gauche)); box-shadow: 8px 0 30px rgb(0 0 0 / 28%); }
  html:not(.glory) .sidebar.open { background: var(--fond); }
  /* Voile sur le reste de l'écran : il appartient au menu, un toucher dessus le referme. */
  .sidebar.open::after { content: ""; position: fixed; inset: 0 0 0 min(86vw, 21.5rem); background: rgb(20 8 18 / 48%); }
  html:has(.sidebar.open) { overflow: hidden; }
  :is(html, html.glory) .sidebar .brandmark { margin-bottom: .4rem; padding: 0 0 .5rem; }
  :is(html, html.glory) .sidebar .brandmark__name { font-size: 1.5rem; }
  .sidebar .brandmark__logo { width: 36px; height: 36px; margin-bottom: .35rem; }
  :is(html, html.glory) #nav a { min-height: 44px; padding: .45rem .9rem; }
  /* « Quitter le bureau » : rangé au pied du tiroir sur téléphone (voir app.js), en bouton franc. */
  .sidebar #quitter { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 44px; margin-top: .9rem; padding: .5rem 1rem; font-size: 1rem; text-decoration: none; border-radius: 12px; border: 1px solid currentColor; flex: none; }
  html.glory .sidebar #quitter { color: #fff; border-color: rgb(255 255 255 / 38%); background: rgb(255 255 255 / 8%); }

  /* ----- Cibles au doigt : 44 px au moins ----- */
  :is(html, html.glory) .btn, :is(html, html.glory) .btn--large, :is(html, html.glory) .pub-ligne .btn, :is(html, html.glory) .carte-cal .btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
  html:not(.glory) .btn { font-size: 1rem; padding: .5rem 1rem; }
  :is(html, html.glory) .btn--filtre { min-height: 44px; }
  :is(html, html.glory) summary, :is(html, html.glory) .pub-details summary, :is(html, html.glory) .lots-deja summary { min-height: 44px; }
  :is(html, html.glory) .scene > summary { min-height: 52px; }
  .lien-discret, main .link { min-height: 44px; display: inline-flex; align-items: center; font-size: .95rem; }
  label.case, .champ--case, .offres-page .toggle { min-height: 44px; align-items: center; }
  .double-page .chip, .variantes-page .chip { min-height: 44px; }
  /* Champs hors habillage : mêmes garanties (hauteur, 16 px pour éviter le zoom automatique à la saisie). */
  input[type="text"], input[type="date"], input[type="time"], input[type="number"], input[type="url"], input[type="email"], input[type="password"], input[type="search"], input:not([type]), select, textarea { min-height: 44px; font-size: 16px; max-width: 100%; box-sizing: border-box; }
  input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; flex: none; }
  input[type="file"] { max-width: 100%; min-height: 44px; font-size: 16px; }
  .editeur-json { font-size: 16px; }

  /* ----- Rangées d'onglets et de filtres : des pastilles côte à côte ; plus cinq boutons pleine largeur empilés avant le contenu ----- */
  .offres-onglets, .double-etapes, .tabs { flex-wrap: wrap; gap: .4rem; }
  :is(html, html.glory) :is(.offres-onglets, .double-etapes, .tabs) > .btn { width: auto; flex: 0 1 auto; padding: .35rem .85rem; font-size: .98rem; text-align: left; }
  /* Les pages en grille ne s'élargissent jamais au-delà de l'écran, quel que soit leur contenu. */
  .offres-page, .double-page, .charte-site-page, .variantes-page { grid-template-columns: minmax(0, 1fr); }
  .offres-page > *, .double-page > *, .charte-site-page > *, .variantes-page > * { min-width: 0; }
  .filters { gap: .4rem; }
  :is(html, html.glory) .filters > .btn { width: auto; flex: 0 1 auto; border-radius: 999px; padding: .35rem .95rem; }
  /* Deux ou trois boutons de même rang : sur une ligne tant qu'ils tiennent, puis pleine largeur. */
  :is(html, html.glory) .actions > .btn { flex: 1 1 9.5rem; }
  /* Boutons empilés (colonne) : hauteur naturelle, jamais étirée. */
  :is(html, html.glory) .actions--centre > .btn { flex: 0 0 auto; }
  .pagination { flex-wrap: wrap; gap: .5rem; }
  :is(html, html.glory) .pagination .btn { width: auto; flex: 1 1 8rem; }

  /* ----- Titres et cartes : la place d'un téléphone ----- */
  :is(html, html.glory) h1 { font-size: clamp(1.85rem, 8vw, 2.3rem); overflow-wrap: anywhere; }
  :is(html, html.glory) h2 { font-size: 1.5rem; overflow-wrap: anywhere; }
  h3 { overflow-wrap: anywhere; }
  :is(html, html.glory) :is(.card, .carte-verre, .panneau-carte, .conseil-carte) { padding: 1rem; border-radius: 16px; }
  .double-page .carte-verre { padding: 1rem; }
  main img, main video, main iframe, main audio { max-width: 100%; }
  main pre, .journal, .double-consigne, .texte-propose { overflow-x: auto; max-width: 100%; }
  code { overflow-wrap: anywhere; }
  .list li { flex-wrap: wrap; gap: .25rem .75rem; }
  .list li > * { min-width: 0; overflow-wrap: anywhere; }
  .hero__marque { width: auto; }

  /* ----- Studio ----- */
  .carte-lot { grid-template-columns: minmax(0, 1fr); gap: .9rem; padding: 1rem; }
  .carte-lot .vignette--grande { max-height: 14rem; width: auto; max-width: 100%; }
  .carte-lot__corps h2 { font-size: 1.6rem; }
  .reseaux-lignes li { flex-wrap: wrap; row-gap: .2rem; }
  .repere li { flex-wrap: wrap; }
  .creations { grid-template-columns: minmax(0, 1fr); }
  .creation { min-width: 0; }
  .puces-etats { gap: .4rem; }
  .studio-entete { margin-bottom: .75rem; }

  /* ----- Dépôt et contrôle, relecture d'un lot ----- */
  :is(html, html.glory) .etape { grid-template-columns: 2.2rem minmax(0, 1fr); gap: .65rem; padding: .85rem .8rem; }
  :is(html, html.glory) .etape__numero { width: 2.2rem; height: 2.2rem; font-size: 1.25rem; }
  .lots-liste li { gap: .5rem; }
  .lots-liste__nom { flex-basis: 100%; }
  .zone-depot code, .copie-ligne code { overflow-wrap: anywhere; }
  .miniatures { gap: .5rem; }
  .miniature { width: calc(50% - .25rem); }
  .bloc-validation .champ input[type="text"] { max-width: 100%; }
  .carte-lien-creation { align-items: stretch; }

  /* ----- Publications ----- */
  .pub-details dl { grid-template-columns: minmax(0, 1fr); gap: 0 .5rem; }
  .pub-details dt { margin-top: .4rem; }
  .pub-details dd { overflow-wrap: anywhere; }
  .reprog-une__quand { gap: .5rem; }
  .reprog-une__quand input { flex: 1 1 8rem; }
  .reprog-une > summary { display: flex; align-items: center; }

  /* ----- Calendrier : la semaine en liste, le titre entier (pas d'infobulle au doigt) ----- */
  .carte-cal__titre { display: block; -webkit-line-clamp: unset; font-size: .95rem; }
  .carte-cal small { font-size: .8rem; }
  .jour-cal { padding: .6rem .75rem .75rem; }

  /* ----- Atelier des offres ----- */
  .offres-page input[type="text"], .offres-page input[type="number"], .offres-page select, .offres-page textarea { max-width: 100%; }
  .offres-page .line { gap: .6rem; align-items: stretch; }
  .offres-page .line > * { flex: 1 1 100%; min-width: 0; }
  .offres-ligne { grid-template-columns: minmax(0, 1fr); }
  .offres-metriques { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .offres-metriques .metric { padding: .6rem; min-width: 0; overflow-wrap: anywhere; }
  .offres-proposition { padding: .75rem; }
  .moteur-grille { grid-template-columns: minmax(0, 1fr); }

  /* ----- Statuts WhatsApp ----- */
  .apercu-statut img, .apercu-statut video { max-height: 240px; }
  .texte-statut { font-size: 1rem; }

  /* ----- Tableaux -----
     Les tableaux dont les cases portent leur libellé passent en fiches (règle d'app.css). Les autres restent de vrais tableaux,
     que l'on fait glisser de côté dans leur cadre : jamais de débordement de la page. */
  table:not(:has(td[data-label])) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; }
  table:not(:has(td[data-label])) thead { display: table-header-group; position: static; }
  table:not(:has(td[data-label])) tbody { display: table-row-group; }
  table:not(:has(td[data-label])) tr { display: table-row; }
  table:not(:has(td[data-label])) :is(th, td) { display: table-cell; white-space: nowrap; }
  table:not(:has(td[data-label])) td::before { content: none; }
  td[data-label] { overflow-wrap: anywhere; }

  /* ----- Fenêtres : confirmation par code, Conseiller ----- */
  dialog { width: min(100vw - 2rem, 26rem); max-width: calc(100vw - 2rem); max-height: calc(100dvh - 2rem - var(--sur-haut) - var(--sur-bas)); overflow-y: auto; box-sizing: border-box; padding: 1.1rem; border-radius: 16px; border: 1px solid var(--ligne); }
  dialog input { width: 100%; }
  dialog .actions .btn { flex: 1 1 8rem; }
  .conseil-panneau { padding-top: var(--sur-haut); padding-bottom: var(--sur-bas); }
  .conseil-panneau__entete { padding: .9rem 1rem .6rem; }
  .conseil-panneau__entete h2 { font-size: 1.7rem; }
  .conseil-panneau__corps { padding: .5rem 1rem 1rem; overscroll-behavior: contain; }

  /* ----- Bas de page : sur téléphone, les textes de fin de page sont centrés (pied du bureau, pied du Conseiller, notes de fin, pagination) ----- */
  :is(html, html.glory) .foot, .conseil-panneau__pied, :is(html, html.glory) .note-rassurante, :is(html, html.glory) .videos-page .fenetre-prompt .note-rassurante, .note-italique, .conseil-note { text-align: center; }
  .pagination { justify-content: center; text-align: center; }

  /* ----- Divers : rien ne dépasse de l'écran ----- */
  .frise { max-width: 100%; }
  .palettes { grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
  .charte-site-page .elt { grid-template-columns: auto minmax(0, 1fr); }
  .charte-site-page .elt > :last-child:not(.corps) { grid-column: 1 / -1; }
  .double-page .note { grid-template-columns: minmax(0, 1fr) 3rem; }
  .scene__corps { padding: .2rem .8rem .8rem; }
  .trois-etapes li, .pas-depart li { min-width: 0; overflow-wrap: anywhere; }
}

/* Bureau installé sur l'écran d'accueil (ouvert sans la barre du navigateur) : on ne sélectionne pas le texte des commandes par mégarde. */
@media (max-width: 760px) and (display-mode: standalone) {
  .topbar, .sidebar, .btn { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}
