/* ===== STUDIO — s'appuie sur les tokens définis dans style.css ===== */

.studio-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; align-items: start; }

/* Stepper */
.stepper { display: flex; align-items: center; gap: 0; margin-bottom: 20px; padding: 0 2px 4px; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.stepper::-webkit-scrollbar { display: none; }
.step { display: flex; align-items: center; gap: 8px; opacity: .45; transition: var(--transition); flex: 0 0 auto; }
.step.active, .step.done { opacity: 1; }
.step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--bg-tertiary); color: var(--text-secondary); display: grid; place-items: center; font-size: 12px; font-weight: 700; flex-shrink: 0; transition: var(--transition); }
.step.active .step-num { background: var(--bg-inverse); color: var(--text-inverse); }
.step.done .step-num { background: #2a9d3f; color: #fff; }
.step-label { font-size: 13px; font-weight: 600; white-space: nowrap; }
.step-line { flex: 0 0 28px; height: 1px; background: var(--border); margin: 0 10px; }
@media (max-width: 480px) {
  .stepper { gap: 0; }
  .step-num { width: 22px; height: 22px; font-size: 11px; }
  .step-label { font-size: 11.5px; }
  .step-line { flex-basis: 14px; margin: 0 6px; }
}

/* Panels */
.panel { display: none; padding: 22px; }
.panel.active { display: block; }
.panel-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; letter-spacing: -.2px; }
.panel-desc { font-size: 13px; color: var(--text-secondary); margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 8px; margin-top: 16px; }
.field-label:first-child { margin-top: 0; }
.field-optional { color: var(--text-tertiary); font-weight: 500; }
.field-input, .field-textarea { width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 14px; background: var(--bg-secondary); font-family: inherit; transition: var(--transition); }
.field-input:focus, .field-textarea:focus { outline: none; border-color: var(--border-strong); background: var(--bg-primary); }
.field-textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.hint-tag { display: flex; align-items: flex-start; gap: 8px; background: var(--bg-secondary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; color: var(--text-secondary); margin-top: 16px; line-height: 1.5; }
.hint-tag svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; stroke: var(--text-tertiary); fill: none; stroke-width: 1.8; }

/* Mode switch (grandes cartes) */
.mode-switch { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
.mode-btn { text-align: left; border: 1.5px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; background: var(--bg-primary); transition: var(--transition); display: flex; flex-direction: column; gap: 3px; }
.mode-btn:hover { border-color: #ccc; }
.mode-btn.active { border-color: var(--border-strong); background: var(--bg-inverse); color: var(--text-inverse); }
.mode-btn-title { font-size: 14px; font-weight: 700; }
.mode-btn-sub { font-size: 12px; opacity: .65; }

/* Grille personnages */
.perso-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin-top: 4px; }
.perso-card { border: 1.5px solid var(--border); border-radius: var(--radius-md); overflow: hidden; cursor: pointer; transition: var(--transition); position: relative; background: var(--bg-secondary); }
.perso-card:hover { border-color: #ccc; }
.perso-card.selected { border-color: var(--border-strong); box-shadow: 0 0 0 2px var(--bg-inverse) inset; }
.perso-card-photo { aspect-ratio: 1/1; background: var(--bg-tertiary); display: grid; place-items: center; overflow: hidden; }
.perso-card-photo img { width: 100%; height: 100%; object-fit: cover; }
.perso-card-name { font-size: 11.5px; font-weight: 700; padding: 7px 8px; text-align: center; line-height: 1.25; }
.perso-card-order { position: absolute; top: 6px; left: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--bg-inverse); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.perso-card-add { border: 1.5px dashed var(--border); border-radius: var(--radius-md); aspect-ratio: 1/1; display: grid; place-items: center; gap: 4px; color: var(--text-tertiary); font-size: 24px; font-weight: 300; cursor: pointer; transition: var(--transition); background: var(--bg-secondary); }
.perso-card-add:hover { border-color: var(--border-strong); color: var(--text-primary); }
.perso-count-hint { font-size: 12px; color: var(--text-tertiary); margin-top: 10px; }

/* Modal nouveau personnage */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 300; display: none; align-items: flex-end; justify-content: center; }
.modal-overlay.open { display: flex; }
@media (min-width: 640px) { .modal-overlay { align-items: center; } }
.modal-sheet { background: var(--bg-primary); width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 22px; }
@media (min-width: 640px) { .modal-sheet { border-radius: var(--radius-lg); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-secondary); }
.modal-close svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.source-switch { display: flex; gap: 8px; margin-bottom: 16px; }
.source-btn { flex: 1; padding: 9px; border-radius: var(--radius-sm); border: 1px solid var(--border); font-size: 13px; font-weight: 600; background: var(--bg-secondary); }
.source-btn.active { background: var(--bg-inverse); color: #fff; border-color: var(--bg-inverse); }
.style-grid, .genre-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-drop { border: 1.5px dashed var(--border); border-radius: var(--radius-md); aspect-ratio: 1/1; max-width: 200px; margin: 0 auto; display: grid; place-items: center; cursor: pointer; overflow: hidden; background: var(--bg-secondary); color: var(--text-tertiary); gap: 6px; font-size: 12px; }
.photo-drop img { width: 100%; height: 100%; object-fit: cover; }
.perso-apercu { margin-top: 14px; aspect-ratio: 1/1; max-width: 220px; margin-inline: auto; border-radius: var(--radius-md); background: var(--bg-tertiary); display: grid; place-items: center; overflow: hidden; }
.perso-apercu img { width: 100%; height: 100%; object-fit: cover; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }
.modal-actions .btn { flex: 1; }

/* Scénario / scènes */
.scene-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.scene-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: 12px 14px; background: var(--bg-secondary); }
.scene-card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.scene-card-num { font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: .5px; }
.scene-card textarea { width: 100%; border: none; background: transparent; font-size: 13.5px; line-height: 1.5; resize: vertical; min-height: 44px; font-family: inherit; }
.scene-card textarea:focus { outline: none; }
.scene-del { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--text-tertiary); }
.scene-del:hover { background: var(--bg-tertiary); color: #c0392b; }
.scene-add-btn { display: flex; align-items: center; justify-content: center; gap: 6px; width: 100%; padding: 10px; border: 1.5px dashed var(--border); border-radius: var(--radius-md); font-size: 13px; font-weight: 600; color: var(--text-secondary); margin-top: 10px; }
.scene-add-btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; }

/* Storyboard */
.storyboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.storyboard-item { position: relative; border-radius: var(--radius-md); overflow: hidden; aspect-ratio: 9/16; background: var(--bg-tertiary); border: 1px solid var(--border); }
.storyboard-item img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .3s; }
.storyboard-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 11px; color: var(--text-tertiary); text-align: center; padding: 8px; }
.storyboard-caption { position: absolute; bottom: 0; left: 0; right: 0; padding: 8px; font-size: 10.5px; color: #fff; background: linear-gradient(to top, rgba(0,0,0,.75), transparent); line-height: 1.3; }
.storyboard-retry-btn { display: flex; align-items: center; gap: 5px; background: var(--bg-inverse); color: #fff; border-radius: var(--radius-sm); padding: 6px 10px; font-size: 11px; font-weight: 600; }
.storyboard-retry-btn svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 2; }
.storyboard-retry-btn.spinning svg { animation: spin .8s linear infinite; }

/* Spinner générique */
.spinner { width: 18px; height: 18px; border: 2.5px solid var(--border); border-top-color: var(--text-primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-secondary); padding: 14px 0; }
.btn.is-loading { pointer-events: none; transform: none; }
.btn.is-loading:hover { transform: none; }
.btn-spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.38); border-top-color: currentColor; border-radius: 50%; animation: spin .7s linear infinite; flex: 0 0 auto; }
.btn-ghost .btn-spinner { border-color: var(--border); border-top-color: currentColor; }
.btn:disabled { cursor: default; opacity: .82; }

/* Export / vidéo */
.export-status { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-secondary); font-size: 13px; color: var(--text-secondary); margin-bottom: 14px; }
.export-progress { margin-bottom: 14px; }
.export-progress-label { font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--text-secondary); }
.export-progress-bar { height: 6px; border-radius: 4px; background: var(--bg-tertiary); overflow: hidden; }
.export-progress-fill { height: 100%; background: var(--bg-inverse); width: 0%; transition: width .25s ease; }
.export-video { width: 100%; max-width: 320px; margin: 0 auto 16px; display: block; border-radius: var(--radius-md); background: #000; aspect-ratio: 9/16; }
.export-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Aside : résumé de l'affaire */
.summary-card { position: sticky; top: 20px; }
.summary-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.summary-row:last-child { border-bottom: none; }
.summary-row-label { color: var(--text-tertiary); }
.summary-row-value { font-weight: 600; text-align: right; }
.summary-tags { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.summary-tag { background: var(--bg-tertiary); border-radius: var(--radius-xl); padding: 3px 9px; font-size: 11px; font-weight: 600; }

/* Nav du wizard */
.wizard-nav { display: flex; justify-content: space-between; padding: 16px 22px; border-top: 1px solid var(--border); }

/* Toast */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--bg-inverse); color: #fff; padding: 12px 20px; border-radius: var(--radius-md); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: var(--transition); z-index: 400; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #c0392b; }
.toast.success { background: #1f7a3d; }

/* ===== Responsive mobile — Nouvelle affaire ===== */
.studio-layout,
.studio-layout > *,
.section,
.panel,
.mode-switch,
.mode-btn,
.summary-card,
.wizard-nav {
  min-width: 0;
}

@media (max-width: 600px) {
  .page-header {
    align-items: stretch;
    gap: 14px;
    margin-bottom: 20px;
  }

  .page-title-block { min-width: 0; }
  .page-subtitle { max-width: 100%; }
  .page-header > .btn { width: 100%; }

  .stepper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 0 0 4px;
    margin-bottom: 16px;
  }

  .step {
    min-width: 0;
    gap: 6px;
  }

  .step-label { display: none; }
  .step.active .step-label {
    display: inline;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }

  .step-line {
    flex: 1 1 12px;
    min-width: 6px;
    max-width: 24px;
    margin: 0 4px;
  }

  .panel { padding: 16px; }
  .mode-switch { gap: 8px; margin-bottom: 18px; }
  .mode-btn { width: 100%; padding: 10px 10px; }
  .mode-btn-title { font-size: 12.5px; }
  .mode-btn-sub { font-size: 10.5px; }
  .mode-btn-title,
  .mode-btn-sub,
  .panel-title,
  .panel-desc,
  .summary-row-value { overflow-wrap: anywhere; }

  .perso-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .storyboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .summary-row {
    align-items: flex-start;
  }
  .summary-row-label { flex: 0 0 auto; }
  .summary-row-value {
    min-width: 0;
    max-width: 62%;
  }

  .wizard-nav {
    padding: 14px 0 0;
    gap: 10px;
    border-top: 0;
  }
  .wizard-nav .btn { flex: 1 1 0; min-width: 0; }

  .modal-sheet { padding: 18px 16px; }
}

@media (max-width: 380px) {
  .perso-grid,
  .storyboard { grid-template-columns: 1fr; }
  .step.active .step-label { max-width: 82px; }
}

/* Gestion des personnages */
.perso-card-actions { position:absolute; top:6px; right:6px; display:flex; gap:5px; z-index:3; }
.perso-card-action { width:28px; height:28px; border-radius:50%; background:rgba(10,10,10,.82); color:#fff; display:grid; place-items:center; font-size:13px; font-weight:800; box-shadow:0 2px 10px rgba(0,0,0,.18); }
.perso-card-action:active { transform:scale(.94); }
.perso-card.selected .perso-card-actions { right:6px; }
.confirm-sheet { max-width:420px; }
.confirm-message { margin:0; color:var(--text-secondary); line-height:1.55; font-size:14px; }

/* Validation du storyboard */
.storyboard-item-actions { position:absolute; top:8px; right:8px; z-index:4; }
.storyboard-refresh-btn { border:0; border-radius:999px; padding:7px 10px; background:rgba(10,10,10,.82); color:#fff; font-size:11px; font-weight:750; backdrop-filter:blur(8px); }
.storyboard-ready-note { margin-top:12px; padding:11px 13px; border-radius:var(--radius-md); background:var(--bg-secondary); color:var(--text-secondary); font-size:12.5px; line-height:1.45; }

/* Descriptions réseaux sociaux */
.social-wrap { margin-top:24px; padding-top:20px; border-top:1px solid var(--border); }
.social-title { font-size:16px !important; margin-bottom:6px; }
.social-grid { display:grid; gap:12px; margin-top:14px; }
.social-card { border:1px solid var(--border); border-radius:var(--radius-md); padding:14px; background:var(--bg-secondary); }
.social-card-head { display:flex; justify-content:space-between; align-items:center; gap:10px; margin-bottom:9px; }
.social-network { font-size:13px; font-weight:800; }
.social-text { margin:0; white-space:pre-wrap; color:var(--text-secondary); font-size:12.5px; line-height:1.55; }
.social-actions { display:flex; flex-wrap:wrap; gap:8px; margin-top:12px; }
.social-actions button { padding:8px 11px; border-radius:999px; border:1px solid var(--border); background:var(--bg-primary); font-size:11.5px; font-weight:750; }
.social-loading { display:flex; align-items:center; gap:9px; color:var(--text-secondary); font-size:13px; padding:10px 0; }

@media (max-width: 639px) {
  .perso-card-action { width:26px; height:26px; }
  .export-actions .btn { flex:1 1 calc(50% - 5px); }
  #export-share-btn { flex-basis:100%; }
}
