/* ══════════════════════════════════════════════════
   TUNNEL IA v2 — Expérience conversationnelle
   Charge avec tunnel.css (hérite des variables)
══════════════════════════════════════════════════ */

/* ── Footer masqué sur la page tunnel IA ─────── */
body.page-template-tunnel-ai .site-footer { display: none !important; }

/* ── Full-height body (template tunnel-ai) ───── */
body.page-template-tunnel-ai {
  display: flex;
  flex-direction: column;
  height: 100dvh;      /* hauteur fixe — pas de min-height pour éviter l'expansion */
  max-height: 100dvh;
  overflow: hidden;
}

body.page-template-tunnel-ai > #content {
  flex: 1;
  min-height: 0;       /* clé : empêche l'expansion flex */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.page-template-tunnel-ai #site-content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Page : pleine hauteur, pas de padding ────── */
.tai-page {
  flex: 1;
  min-height: 0;       /* empêche l'expansion */
  padding: 0 !important;
  justify-content: flex-start !important;
  align-items: center !important;
  overflow: hidden;
}

/* ── Card : centrée, max 1600px, pleine hauteur ── */
.tai-card {
  aspect-ratio: unset !important;
  min-height: 0 !important;    /* clé pour le scroll interne */
  max-height: 100% !important;
  max-width: 1600px !important;
  width: 100% !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  flex: 1;
  overflow: hidden;
}

/* Panneau droit : min-height:0 pour permettre le scroll */
.tai-right {
  min-height: 0 !important;
  overflow: hidden !important;
}
.tai-right-inner-lib {
  min-height: 0;
}

/* ── Gauche : Lya parle ───────────────────────── */
.tai-left {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Header ────────────────────────────────────── */
.tai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--tnl-border);
  flex-shrink: 0;
}

.tai-agent-row {
  display: flex; align-items: center; gap: 10px; min-width: 0;
}

.tai-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--tnl-accent-soft);
  border: 1.5px solid rgba(26,188,156,.35);
  display: flex; align-items: center; justify-content: center;
  font-size: .95rem; flex-shrink: 0;
}

.tai-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.tai-name {
  font-family: var(--font-family-heading, 'Sora', sans-serif);
  font-size: var(--text-sm); font-weight: 700; color: var(--tnl-text);
  display: flex; align-items: center; gap: 7px;
}

.tai-online {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: 600; color: var(--tnl-accent);
  font-family: inherit;
}

.tai-dot {
  width: 6px; height: 6px;
  border-radius: 50%; background: var(--tnl-accent); flex-shrink: 0;
  animation: pulse 2s ease infinite;
}

.tai-subtitle { font-size: var(--text-xs); color: var(--tnl-muted); }

/* Badge étape */
.tai-step-badge {
  flex-shrink: 0;
  background: var(--tnl-accent-soft);
  border: 1px solid rgba(26,188,156,.28);
  color: var(--tnl-accent);
  font-size: var(--text-xs); font-weight: 700;
  padding: .28em .8em; border-radius: 999px;
  white-space: nowrap;
}

/* ── Bulle message Lya ────────────────────────── */
.tai-speech {
  flex-shrink: 0;
  padding: 20px 16px 12px;
}

.tai-lya-bubble {
  background: rgba(26,188,156,.09);
  border: 1px solid rgba(26,188,156,.2);
  border-radius: 16px 16px 16px 4px;
  padding: .8rem 1rem;
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--tnl-text);
  animation: taiMsgIn .3s ease both;
}

@keyframes taiMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Dots typing dans la bulle */
.tai-typing-dots {
  display: flex; align-items: center; gap: 5px; padding: 2px 0;
}
.tai-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--tnl-accent); display: block;
  animation: taiDot 1.2s ease infinite; opacity: .5;
}
.tai-typing-dots span:nth-child(2) { animation-delay: .18s; }
.tai-typing-dots span:nth-child(3) { animation-delay: .36s; }

@keyframes taiDot {
  0%,60%,100% { opacity: .25; transform: scale(.8); }
  30%          { opacity: 1;   transform: scale(1.1); }
}

/* ── Step header panneau droit ────────────────── */
.tai-step-header {
  flex-shrink: 0;
  padding: 18px 22px 0;
}

.tai-step-label {
  font-size: var(--text-xs); font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  color: var(--tnl-accent); margin-bottom: 5px;
}

.tai-step-title {
  font-family: var(--font-family-heading, 'Sora', sans-serif);
  font-size: 1.35rem; font-weight: 800; color: var(--tnl-text);
  margin: 0 0 14px; line-height: 1.2;
}

/* Filtres famille */
.tai-step-filters {
  display: flex; gap: 7px; flex-wrap: nowrap;
  overflow-x: auto; padding-bottom: 14px;
  border-bottom: 1px solid var(--tnl-border);
  scrollbar-width: none;
}
.tai-step-filters::-webkit-scrollbar { display: none; }

.tai-filter-chip {
  padding: .33em 1em;
  border-radius: 999px;
  border: 1.5px solid var(--tnl-border);
  background: transparent;
  color: var(--tnl-muted);
  font-size: var(--text-sm); font-weight: 600;
  font-family: inherit; cursor: pointer;
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.tai-filter-chip:hover { border-color: var(--tnl-accent); color: var(--tnl-accent); }
.tai-filter-chip.active {
  background: var(--tnl-accent); border-color: var(--tnl-accent); color: #fff;
}

/* right-inner quand step-header présent */
.tai-right {
  display: flex; flex-direction: column;
}
.tai-right-inner { flex: 1; min-height: 0; }


/* ── Suggestions (juste sous la bulle) ───────── */
.tai-suggestions {
  flex-shrink: 0;
  padding: 10px 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tai-chip {
  padding: .55em 1.1em;
  border-radius: 999px;
  border: 1.5px solid var(--tnl-border);
  background: rgba(255,255,255,.05);
  color: var(--tnl-text);
  font-size: var(--text-sm);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .15s;
}
.tai-chip:hover {
  border-color: var(--tnl-accent);
  color: var(--tnl-accent);
  background: var(--tnl-accent-soft);
}

/* ── Zone de choix inline (gauche) ───────────── */
.tai-choices {
  flex: 1;
  min-height: 0;
  padding: 10px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.tai-choices:empty { display: none; }

.tai-choice-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: 1.5px solid var(--tnl-border);
  border-radius: 12px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  transition: all .18s;
  animation: taiMsgIn .25s ease both;
}
.tai-choice-card:hover {
  border-color: var(--tnl-accent);
  background: var(--tnl-accent-soft);
  transform: translateX(3px);
}
.tai-choice-ico  { font-size: 1.3rem; flex-shrink: 0; }
.tai-choice-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--tnl-text);
}
.tai-choice-card:hover .tai-choice-label { color: var(--tnl-accent); }
.tai-choice-sub  {
  font-size: var(--text-xs);
  color: var(--tnl-muted);
  margin-top: 1px;
}

/* ── Barre d'input fixe en bas ────────────────── */

.tai-input-bar {
  flex-shrink: 0;
  border-top: 1px solid var(--tnl-border);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--tnl-card-l);
}

.tai-input {
  flex: 1;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--tnl-border);
  border-radius: 999px;
  color: var(--tnl-text);
  font-family: inherit;
  font-size: var(--text-sm);
  padding: .5rem 1rem;
  outline: none;
  transition: border-color .15s;
}
.tai-input:focus { border-color: rgba(26,188,156,.4); }
.tai-input::placeholder { color: rgba(255,255,255,.2); }

.tai-send {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #148556, #2bd879);
  border: none; color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: all .2s;
}
.tai-send:hover { box-shadow: 0 4px 14px rgba(31,184,108,.45); transform: scale(1.06); }

/* ── Droite : panneau interactif ──────────────── */
.tai-right {
  position: relative;
  overflow: hidden;
}

.tai-right-inner {
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  transition: opacity .25s ease, transform .25s ease;
}

.tai-right-inner.fading {
  opacity: 0;
  transform: scale(.97);
}

/* ── Panel : Grille produits (style boutique) ─── */
.tai-panel-product {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.06) transparent;
  padding: 20px;
}

.tai-shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 14px;
  align-content: start;
}

.tai-pcard {
  background: rgba(255,255,255,.04);
  border: 1.5px solid var(--tnl-border);
  border-radius: 16px;
  overflow: hidden;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  flex-direction: column;
}
.tai-pcard:hover {
  border-color: rgba(26,188,156,.45);
  transform: translateY(-3px);
  box-shadow: 0 10px 28px rgba(0,0,0,.3);
}
.tai-pcard.sel {
  border-color: var(--tnl-accent);
  background: var(--tnl-accent-soft);
}
.tai-pcard-img-wrap {
  width: 100%;
  aspect-ratio: 1;
  background: rgba(255,255,255,.03);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.tai-pcard-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  transition: transform .3s ease;
}
.tai-pcard:hover .tai-pcard-img { transform: scale(1.06); }
.tai-pcard-info {
  padding: 10px 12px 12px;
}
.tai-pcard-name {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--tnl-text);
  line-height: 1.3;
  margin-bottom: 3px;
}
.tai-pcard.sel .tai-pcard-name { color: var(--tnl-accent); }
.tai-pcard-price {
  font-size: var(--text-xs);
  color: var(--tnl-muted);
  font-weight: 600;
}

/* ── Bottom sheet variantes ───────────────────── */
.tai-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(2px);
  z-index: 9;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease;
}
.tai-sheet-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.tai-variant-sheet {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: var(--tnl-card-l);
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--tnl-border);
  box-shadow: 0 -20px 50px rgba(0,0,0,.5);
  z-index: 10;
  transform: translateY(100%);
  transition: transform .38s cubic-bezier(.32,.72,0,1);
  display: flex;
  flex-direction: column;
  max-height: 68%;
}
.tai-variant-sheet.open {
  transform: translateY(0);
}

.tai-sheet-handle {
  width: 36px; height: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,.15);
  margin: 12px auto 0;
  flex-shrink: 0;
}

.tai-sheet-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--tnl-border);
  flex-shrink: 0;
}
.tai-sheet-pimg {
  width: 52px; height: 52px;
  border-radius: 10px;
  object-fit: contain;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--tnl-border);
  flex-shrink: 0;
}
.tai-sheet-pname {
  font-family: var(--font-family-heading, 'Sora', sans-serif);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--tnl-text);
}
.tai-sheet-pprice {
  font-size: var(--text-xs);
  color: var(--tnl-muted);
  margin-top: 2px;
}
.tai-sheet-close {
  margin-left: auto;
  width: 28px; height: 28px;
  border-radius: 50%;
  border: 1px solid var(--tnl-border);
  background: transparent;
  color: var(--tnl-muted);
  font-size: 1rem; line-height: 1;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all .15s;
}
.tai-sheet-close:hover { border-color: rgba(255,255,255,.25); color: var(--tnl-text); }

.tai-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.06) transparent;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tai-sheet-foot {
  padding: 12px 18px 18px;
  flex-shrink: 0;
  border-top: 1px solid var(--tnl-border);
}

/* ── Panel : Variant ──────────────────────────── */
.tai-panel-variant {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 20px;
}

.tai-variant-img {
  width: 140px; height: 140px;
  object-fit: contain;
  border-radius: 12px;
  filter: drop-shadow(0 12px 28px rgba(0,0,0,.4));
  flex-shrink: 0;
}

.tai-variant-opts {
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tai-variant-lbl {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--tnl-muted);
  margin-bottom: 6px;
}

.tai-confirm-btn {
  width: 100%;
  max-width: 320px;
  background: linear-gradient(135deg, #148556, #2bd879);
  color: #fff; border: none; border-radius: 999px;
  padding: .75rem 1.2rem;
  font-size: var(--text-sm); font-weight: 800;
  cursor: pointer; font-family: inherit;
  transition: box-shadow .2s, transform .15s;
  flex-shrink: 0;
}
.tai-confirm-btn:hover:not(:disabled) {
  box-shadow: 0 8px 22px rgba(31,184,108,.4);
  transform: translateY(-1px);
}
.tai-confirm-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Panel : Source ───────────────────────────── */
.tai-panel-source {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 24px;
}

.tai-src-card {
  width: 100%;
  max-width: 340px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border: 1.5px solid var(--tnl-border);
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  cursor: pointer;
  transition: all .18s;
}
.tai-src-card:hover {
  border-color: var(--tnl-accent);
  background: var(--tnl-accent-soft);
  transform: translateX(4px);
}
.tai-src-ico { font-size: 1.6rem; flex-shrink: 0; }
.tai-src-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--tnl-text);
}
.tai-src-sub {
  font-size: var(--text-xs);
  color: var(--tnl-muted);
  margin-top: 2px;
}

/* ── Panel : Design ───────────────────────────── */
.tai-panel-design {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 16px;
}

.tai-design-inner {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Upload zone */
.tai-upload {
  border: 2px dashed rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.tai-upload:hover { border-color: rgba(26,188,156,.4); background: rgba(26,188,156,.03); }
.tai-upload-ico { font-size: 2rem; margin-bottom: 8px; }
.tai-upload-title { font-size: var(--text-sm); font-weight: 600; color: var(--tnl-text); }
.tai-upload-link  { color: var(--tnl-accent); }
.tai-upload-hint  { font-size: var(--text-xs); color: var(--tnl-muted); margin-top: 3px; }

/* Textarea prompt */
.tai-prompt {
  width: 100%;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--tnl-border);
  border-radius: 12px;
  color: var(--tnl-text);
  font-family: inherit; font-size: var(--text-sm);
  padding: .85rem 1rem;
  resize: none; height: 90px;
  transition: border-color .15s;
  box-sizing: border-box;
}
.tai-prompt:focus { outline: none; border-color: rgba(26,188,156,.4); }
.tai-prompt::placeholder { color: rgba(255,255,255,.18); }

/* Mode toggle (photo direct/transformer) */
.tai-mode-row {
  display: flex;
  gap: 6px;
}
.tai-mode-btn {
  flex: 1;
  padding: .5rem .6rem;
  border-radius: 10px;
  border: 1px solid var(--tnl-border);
  background: transparent;
  color: var(--tnl-muted);
  font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; font-family: inherit;
  display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all .15s;
}
.tai-mode-btn--active {
  border-color: var(--tnl-accent);
  color: var(--tnl-accent);
  background: var(--tnl-accent-soft);
}

/* Section label */
.tai-section-lbl {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--tnl-muted);
  margin-bottom: 6px;
}

/* Library grid */
.tai-lib-tabs { display: flex; gap: 6px; }
.tai-lib-tab {
  flex: 1; padding: .38em .7em;
  border-radius: 8px; border: 1px solid var(--tnl-border);
  background: transparent; color: var(--tnl-muted);
  font-size: var(--text-xs); font-weight: 600;
  cursor: pointer; font-family: inherit; transition: all .14s;
}
.tai-lib-tab.sel { border-color: var(--tnl-accent); color: var(--tnl-accent); background: var(--tnl-accent-soft); }

.tai-lib-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  max-height: 180px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.06) transparent;
}
.tai-lib-item {
  aspect-ratio: 1;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: rgba(255,255,255,.04);
  transition: border-color .15s;
}
.tai-lib-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tai-lib-item:hover { border-color: rgba(26,188,156,.4); }
.tai-lib-item.sel   { border-color: var(--tnl-accent); }

/* ── Panel : Bibliothèque (FileLibrary intégré) ── */
/* Le wrap est fils direct de tai-right-inner (flex-column) */
.tai-lib-wrap {
  flex: 1;
  width: 100%;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

/* Sidebar */
.tai-lib-wrap .file-library-sidebar {
  width: 160px !important;
  flex-shrink: 0 !important;
  border-radius: 0 !important;
  border: none !important;
  border-right: 1px solid var(--tnl-border) !important;
  background: rgba(255,255,255,.025) !important;
  padding: 14px 12px !important;
  height: 100% !important;
  box-sizing: border-box !important;
  overflow-y: auto;
}
.tai-lib-wrap .file-library-sidebar .sidebar-title { font-size: .62rem; }
.tai-lib-wrap .file-library-sidebar .file-library-folders button {
  font-size: var(--text-xs) !important;
  padding: 7px 10px !important;
}
.tai-lib-wrap .file-drop-zone {
  font-size: .68rem !important;
  padding: 10px 8px !important;
  min-height: 70px !important;
}

/* Main */
.tai-lib-wrap .file-library-main {
  flex: 1 !important;
  min-width: 0 !important;
  overflow: hidden !important;
  display: flex !important;
  flex-direction: column !important;
  height: 100% !important;
}

/* Body — scrolle en interne, ne déborde jamais */
.tai-lib-wrap .file-library-body {
  flex: 1 !important;
  min-height: 0 !important;      /* essentiel pour que flex:1 scroll et pas expand */
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 10px 12px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.06) transparent;
}

/* Search */
.tai-lib-wrap #searchInput {
  width: 100% !important;
  background: rgba(255,255,255,.05) !important;
  border: 1px solid var(--tnl-border) !important;
  border-radius: 8px !important;
  color: var(--tnl-text) !important;
  font-family: inherit !important;
  font-size: var(--text-xs) !important;
  padding: .45rem .75rem !important;
  outline: none !important;
  box-sizing: border-box !important;
}
.tai-lib-wrap #searchInput:focus { border-color: rgba(26,188,156,.4) !important; }

/* Grille images */
.tai-lib-wrap .file-list.grid-view {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
  grid-auto-rows: 160px !important;
  gap: 10px !important;
  width: 100% !important;
  align-content: start !important;
  overflow: visible !important; /* le scroll est sur file-library-body */
}
.tai-lib-wrap .file-item {
  position: relative !important;
  width: 100% !important;
  height: 160px !important;     /* contraint la hauteur de la cellule */
  min-height: 0 !important;
  max-height: 160px !important;
  border-radius: 10px !important;
  overflow: hidden !important;  /* empêche le débordement de l'image */
  cursor: pointer !important;
  border: 2px solid transparent !important;
  background: rgba(255,255,255,.05) !important;
  transition: border-color .18s !important;
  box-sizing: border-box !important;
}
.tai-lib-wrap .file-item:hover,
.tai-lib-wrap .file-item.selected { border-color: var(--tnl-accent) !important; }
.tai-lib-wrap .file-item img {
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
}
.tai-lib-wrap .file-item .file-name,
.tai-lib-wrap .file-item .preview-icon,
.tai-lib-wrap .file-item .apply-button { display: none !important; }

/* Pagination */
.tai-lib-wrap .pagination-controls {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  justify-content: center !important;
  padding: 6px 0 !important;
  flex-shrink: 0 !important;
}
.tai-lib-wrap .pagination-controls button { padding: .3em .8em; border-radius: 6px; border: 1px solid var(--tnl-border); background: transparent; color: var(--tnl-muted); font-size: var(--text-xs); cursor: pointer; font-family: inherit; }
.tai-lib-wrap .pagination-controls button:hover:not(:disabled) { border-color: var(--tnl-accent); color: var(--tnl-accent); }
.tai-lib-wrap .pagination-controls button:disabled { opacity: .3; }
.tai-lib-wrap .pagination-controls .page-input { width: 42px; text-align: center; border-radius: 6px; border: 1px solid var(--tnl-border); background: transparent; color: var(--tnl-text); font-size: var(--text-xs); padding: .3em; }
.tai-lib-wrap .pagination-controls .page-total { font-size: var(--text-xs); color: var(--tnl-muted); }

/* Cacher les filtres inutiles dans ce contexte */
.tai-lib-wrap #format-block { display: none !important; }

/* Empty state */
.tai-lib-wrap .file-library-empty { text-align: center; padding: 20px 10px; color: var(--tnl-muted); font-size: var(--text-sm); }
.tai-lib-wrap .file-library-empty-title { font-weight: 600; color: var(--tnl-text); margin-bottom: 6px; }
.tai-lib-wrap .file-library-empty-subtitle { font-size: var(--text-xs); }
.tai-lib-wrap .file-library-empty-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 12px; }
.tai-lib-wrap .file-library-empty-primary,
.tai-lib-wrap .file-library-empty-secondary { font-size: var(--text-xs); padding: .35em .9em; border-radius: 999px; border: 1px solid var(--tnl-border); background: transparent; color: var(--tnl-accent); cursor: pointer; text-decoration: none; }

/* Thumbnails dans la sidebar mockup */
.tai-mockup-sidebar .tnl-thumb {
  width: 54px !important;
  height: 54px !important;
  flex-shrink: 0;
}

/* Confirm bar */
.tai-lib-confirm-bar {
  flex-shrink: 0;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--tnl-border);
  width: 100%;
  box-sizing: border-box;
}

/* ── Panel : Génération ───────────────────────── */
.tai-panel-gen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}

.tai-gen-ico {
  font-size: 3rem;
  animation: pulse 2s ease infinite;
}

.tai-gen-label {
  font-family: var(--font-family-heading, 'Sora', sans-serif);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--tnl-text);
  text-align: center;
}

.tai-gen-bar-wrap {
  width: 200px;
  height: 3px;
  background: rgba(255,255,255,.08);
  border-radius: 999px;
  overflow: hidden;
}
.tai-gen-bar {
  height: 100%;
  background: linear-gradient(90deg, #148556, #2bd879);
  border-radius: 999px;
  width: 0%;
  transition: width .5s ease;
}

/* ── Panel : Résultat ─────────────────────────── */
.tai-panel-result {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  overflow: hidden;
}

.tai-result-wrap {
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.tai-result-mockup {
  flex: 1;
  min-width: 0;
  max-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,.55), 0 0 0 1px rgba(26,188,156,.12);
}
.tai-result-mockup canvas,
.tai-result-mockup img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 14px;
}

/* Sidebar vues mockup — verticale à droite */
.tai-mockup-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 60px;
  flex-shrink: 0;
  overflow-y: auto;
  scrollbar-width: none;
  max-height: 100%;
}
.tai-mockup-sidebar::-webkit-scrollbar { display: none; }
.tai-mockup-sidebar:empty { display: none; }

/* ── Navigation historique versions ──────────── */
.tai-history-nav {
  display: none;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
  max-width: 360px;
}
.tai-history-nav.visible { display: flex; }

.tai-history-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 1px solid var(--tnl-border);
  background: rgba(255,255,255,.05);
  color: var(--tnl-text);
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .9rem; line-height: 1;
  transition: all .15s;
}
.tai-history-btn:hover:not(:disabled) {
  border-color: var(--tnl-accent);
  color: var(--tnl-accent);
}
.tai-history-btn:disabled { opacity: .28; cursor: not-allowed; }

.tai-history-thumbs {
  display: flex;
  gap: 6px;
  flex: 1;
  overflow-x: auto;
  scrollbar-width: none;
}
.tai-history-thumbs::-webkit-scrollbar { display: none; }

.tai-history-thumb {
  width: 44px; height: 44px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--tnl-border);
  flex-shrink: 0;
  background: rgba(255,255,255,.04);
  transition: border-color .15s, transform .15s;
}
.tai-history-thumb:hover  { border-color: rgba(26,188,156,.45); transform: scale(1.06); }
.tai-history-thumb.sel    { border-color: var(--tnl-accent); }
.tai-history-thumb img    { width: 100%; height: 100%; object-fit: contain; display: block; }

.tai-history-count {
  font-size: var(--text-xs);
  color: var(--tnl-muted);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 32px;
  text-align: center;
}

.tai-result-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  width: 100%;
  max-width: 360px;
}
.tai-action-btn {
  flex: 1;
  padding: .65rem .8rem;
  border-radius: 999px; border: none;
  font-family: inherit; font-size: var(--text-sm); font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px;
  transition: all .15s; white-space: nowrap;
}
.tai-action-btn--main {
  background: linear-gradient(135deg, #148556, #2bd879);
  color: #fff;
}
.tai-action-btn--secondary {
  background: var(--tnl-accent-soft);
  color: var(--tnl-accent);
  border: 1px solid rgba(26,188,156,.22) !important;
}
.tai-action-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.tai-action-btn:disabled { opacity: .45; cursor: not-allowed; }

.tai-thumb-strip {
  display: flex; gap: 8px; justify-content: center; flex-shrink: 0;
}
.tai-thumb-strip:empty { display: none; }
.tai-thumb {
  width: 52px; height: 52px;
  border-radius: 8px; overflow: hidden;
  cursor: pointer;
  border: 2px solid var(--tnl-border);
  background: rgba(255,255,255,.03);
  transition: border-color .15s, transform .15s;
  flex-shrink: 0;
}
.tai-thumb:hover  { border-color: rgba(26,188,156,.4); transform: scale(1.05); }
.tai-thumb.sel    { border-color: var(--tnl-accent); }
.tai-thumb img, .tai-thumb canvas { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ══════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════ */

/* ── Portrait : masquer le step header ────────── */
@media (orientation: portrait) {
  .tai-step-header { display: none !important; }
}

/* ── Tablette paysage (768px – 1024px) ────────── */
@media (min-width: 768px) and (max-width: 1024px) {
  .tai-shop-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
  .tnl-left { min-width: 260px; }
  .tai-message { font-size: .95rem; }
  .tai-panel-source { padding: 20px 16px; gap: 8px; }
  .tai-src-card { padding: 11px 13px; }
  .tai-result-actions { max-width: 100%; }
  .tai-history-nav { max-width: 100%; }
}

/* ── Tablette portrait (toutes tailles en orientation portrait jusqu'à 1024px) ── */
@media (max-width: 1024px) and (orientation: portrait) {
  .tai-card {
    flex-direction: column;
    border-radius: 0 !important;
    min-height: 100dvh;
    height: auto;
  }

  /* Lya en haut, pleine largeur */
  .tai-left {
    order: -1;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--tnl-border);
  }
  .tai-right {
    flex: 1;
    width: 100% !important;
    max-width: none !important;
    min-height: 50vh;
    border-right: none;
  }

  .tai-speech { padding: 16px 18px 10px; }
  .tai-message { font-size: .95rem; max-width: 340px; }
  .tai-choices { padding: 0 14px 12px; }

  .tai-panel-product { padding: 14px; }
  .tai-shop-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }

  .tai-variant-sheet { max-height: 75%; }
  .tai-panel-source { padding: 16px 14px; gap: 8px; }

  .tai-panel-result { padding: 14px; gap: 8px; }
  .tai-result-actions { max-width: 100%; }
  .tai-history-nav { max-width: 100%; }
}

/* ── Mobile portrait (moins de 600px) ─────────── */
@media (max-width: 599px) {
  body.page-template-tunnel-ai { overflow-y: auto; }

  .tai-card {
    flex-direction: column;
    border-radius: 0 !important;
    min-height: 100dvh;
    height: auto;
  }

  /* Lya en haut, pleine largeur */
  .tai-left {
    order: -1;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    flex-shrink: 0;
    border-right: none;
    border-bottom: 1px solid var(--tnl-border);
  }
  .tai-right {
    flex: 1;
    width: 100% !important;
    max-width: none !important;
    min-height: 45vh;
    border-right: none;
  }

  /* Header */
  .tai-header { padding: 10px 13px; }
  .tai-name   { font-size: var(--text-xs); }
  .tai-avatar { width: 30px; height: 30px; font-size: .8rem; }

  /* Message Lya */
  .tai-speech  { padding: 12px 14px 8px; }
  .tai-message { font-size: .88rem; max-width: 240px; }

  /* Choices */
  .tai-choices     { padding: 0 11px 10px; gap: 5px; }
  .tai-choice-card { padding: 8px 10px; gap: 8px; }
  .tai-choice-ico  { font-size: 1.1rem; }
  .tai-choice-label{ font-size: var(--text-xs); }
  .tai-choice-sub  { display: none; }

  /* Input */
  .tai-input-bar { padding: 8px 11px; }

  /* Grille produits */
  .tai-panel-product { padding: 12px 10px; }
  .tai-shop-grid     { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .tai-pcard-info    { padding: 7px 9px 9px; }
  .tai-pcard-name    { font-size: .62rem; }
  .tai-pcard-price   { font-size: .58rem; }

  /* Bottom sheet */
  .tai-variant-sheet { max-height: 85%; }
  .tai-sheet-head    { padding: 11px 13px; }
  .tai-sheet-body    { padding: 11px 13px; }
  .tai-sheet-foot    { padding: 9px 13px 14px; }

  /* Source */
  .tai-panel-source { padding: 14px 11px; gap: 7px; }
  .tai-src-card     { padding: 9px 11px; gap: 9px; }
  .tai-src-sub      { display: none; }
  .tai-src-ico      { font-size: 1.3rem; }

  /* Design */
  .tai-panel-design  { padding: 14px 11px; }
  .tai-design-inner  { gap: 10px; }

  /* Résultat */
  .tai-panel-result  { padding: 12px 11px; gap: 7px; }
  .tai-result-actions{ max-width: 100%; }
  .tai-action-btn    { font-size: var(--text-xs); padding: .5rem .55rem; }
  .tai-history-nav   { max-width: 100%; }
  .tai-history-thumb { width: 36px; height: 36px; border-radius: 6px; }
  .tai-history-btn   { width: 28px; height: 28px; font-size: .8rem; }
  .tai-history-count { min-width: 28px; font-size: .68rem; }

  /* Génération */
  .tai-panel-gen { gap: 12px; }
  .tai-gen-ico   { font-size: 2rem; }
  .tai-gen-label { font-size: var(--text-sm); }
  .tai-gen-bar-wrap { width: 160px; }
}
