/* Affichage smartphone : chargé après style.css, ne s'applique qu'aux écrans étroits. */

/* Zones « sûres » (encoche, barre de navigation Android). */
body { padding-bottom: env(safe-area-inset-bottom); }
button, select, input { touch-action: manipulation; }

@media (max-width: 760px) {
  body { font-size: 15px; }
  h1 { font-size: 22px; }
  main { padding: 14px 12px 80px; }

  /* En-tête : logo + utilisateur sur une ligne, onglets défilants dessous. */
  .top {
    position: relative; /* pas collé en haut : il prendrait trop de place */
    flex-wrap: wrap; gap: 8px; padding: 8px 12px calc(6px) 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
  }
  .brand { font-size: 15px; }
  .space-pill { margin-left: auto; gap: 6px; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; flex: 1; }
  .space-pill > span:not(.avatar) { display: none; }
  .view-pick { order: 10; flex: 1 1 100%; font-size: 12px; }
  .view-pick select { flex: 1; }
  #nav { order: 20; flex: 1 1 100%; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  #nav::-webkit-scrollbar { display: none; }
  #nav button { padding: 7px 12px; }
  body.at-home .top { flex-wrap: nowrap; }
  body.at-home #nav, body.at-home .space-pill { display: none; }

  /* Accueil : une carte de profil par ligne. */
  .home { padding: 16px 0; }
  .home h1 { font-size: 26px; margin-bottom: 20px; }
  .spaces { gap: 16px; }
  .space-card { width: 100%; padding: 16px; gap: 12px; }
  .space-star { height: 150px; }
  .add-space { min-height: 120px; }
  .add-space .plus { font-size: 40px; }

  /* Chiffres et barres d'outils. */
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tile { padding: 12px; }
  .tile .num { font-size: 20px; }
  .tile .num.small { font-size: 14px; }
  .split { flex-direction: column; }
  .toolbar { gap: 6px; }
  .toolbar input[type=search], input.wide, input.narrow { min-width: 0; width: 100%; }
  .toolbar select { flex: 1; }
  .toolbar .spacer { display: none; }
  .toolbar .muted.small { width: 100%; order: 5; }

  /* Collection : chaque ligne du tableau devient une fiche. */
  .col-table, .col-table tbody { display: block; border: 0; background: none; }
  .col-table thead { display: block; }
  .col-table thead tr { display: flex; align-items: center; gap: 8px; padding: 0 4px 8px; }
  .col-table thead th { display: none; border: 0; background: none; padding: 0; }
  .col-table thead th:first-child { display: block; }
  .col-table thead th:first-child::after { content: "Tout sélectionner"; margin-left: 8px; font-size: 12px; text-transform: none; letter-spacing: 0; vertical-align: middle; }
  .col-table tbody tr {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; position: relative;
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px; margin-bottom: 10px;
  }
  .col-table td { border: 0 !important; padding: 0; }
  .col-table td:nth-child(1) { order: 1; }                                   /* case à cocher */
  .col-table td:nth-child(2) { order: 2; }                                   /* image */
  .col-table td:nth-child(2) .thumb { width: 54px; }
  .col-table td:nth-child(3) { order: 3; flex: 1 1 calc(100% - 110px); min-width: 0; } /* nom : toute la 1re ligne */
  .col-table td:nth-child(4), .col-table td:nth-child(5),
  .col-table td:nth-child(6), .col-table td:nth-child(7) { order: 4; flex: 1 1 calc(50% - 8px); }
  .col-table td select { width: 100%; max-width: none; padding: 6px; }
  .col-table td:nth-child(8) { order: 5; }                                   /* quantité */
  .col-table td:nth-child(9), .col-table td:nth-child(10) { order: 6; font-size: 12px; text-align: left; }
  .col-table td:nth-child(9)::before { content: "Cote "; color: var(--muted); }
  .col-table td:nth-child(10)::before { content: "30 j "; color: var(--muted); }
  .col-table td:nth-child(11) { order: 7; flex: 1 1 100%; }                  /* prix FR */
  .col-table td:nth-child(11)::before { content: "Prix FR (vendeur FR, carte FR, Excellent ou mieux)"; display: block; font-size: 11px; color: var(--muted); margin-bottom: 3px; }
  .fr-input { flex: 1; width: auto; font-size: 16px; padding: 7px; }
  .fr-line .icon { padding: 7px 12px; }
  .col-table td:nth-child(12) { order: 8; font-size: 17px; }                 /* valeur */
  .col-table td:nth-child(12)::before { content: "Valeur "; font-size: 12px; font-weight: 400; color: var(--muted); }
  .col-table td:nth-child(13) { order: 9; margin-left: auto; }               /* actions */
  .col-table td.empty { flex: 1; }
  .qty button { padding: 5px 12px; }
  .sel-bar { flex-direction: column; align-items: stretch; position: sticky; top: 0; z-index: 5; }
  .sel-bar label { justify-content: space-between; }
  .note { font-size: 11px; }

  /* Grilles de cartes et extensions. */
  .grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tile-card { padding: 4px; }
  .tile-card .cap { font-size: 11px; }
  .tile-card:has(img[data-approx])::after { top: 30px; font-size: 9px; }
  .sets { grid-template-columns: 1fr 1fr; gap: 10px; }
  .set-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .set-head img { max-width: 160px; }

  /* Fenêtres : plein écran. */
  .modal { padding: 0; align-items: stretch; }
  .modal-box { max-height: none; height: 100%; border-radius: 0; padding: 16px 14px 40px; padding-top: calc(16px + env(safe-area-inset-top)); }
  .modal-close { position: sticky; top: 0; float: right; z-index: 2; font-size: 26px; }
  .card-detail { grid-template-columns: 1fr; gap: 14px; }
  .card-detail .big { max-width: 300px; margin: 0 auto; display: block; }
  .prices { grid-template-columns: 1fr 1fr; }
  .add-form { grid-template-columns: 1fr; }
  .add-form label select, .add-form label input { font-size: 16px; padding: 9px; }
  .fr-step { grid-template-columns: 1fr; }
  .fr-step img { max-width: 200px; margin: 0 auto; display: block; }
  #fr-step-input { width: 100%; font-size: 18px; }
  .trade-card img { width: 80px; }
  .notif-cards { flex-direction: column; align-items: stretch; }
  .codes-table { font-size: 12px; }
  .panel { padding: 4px 14px 14px; }
  .profile-row { gap: 8px; }
  .del-owner { margin-left: 0; }

  .toast { bottom: calc(16px + env(safe-area-inset-bottom)); max-width: calc(100% - 24px); text-align: center; border-radius: 16px; }
}
