/* Studio d'apparence : l'aperçu à côté des réglages sur grand écran, au-dessus sur téléphone. */
.page-studio { padding-bottom: calc(24px + var(--bas)); }
.studio-barre {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: rgba(var(--fond-rgb), 0.9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--ligne);
}
.studio-barre .retour { min-height: 42px; padding: 6px 12px 6px 6px; text-decoration: none; }
.studio-titre { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.studio-titre b { font-family: var(--titre); font-weight: 400; font-size: 24px; }
.studio-titre span { color: var(--encre-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sauvegarde { margin-left: auto; font-size: 14px; color: var(--encre-3); white-space: nowrap; }
.studio-refus { margin: 24px 16px; }
.studio-refus a { color: var(--or-vif); }

.studio { display: grid; gap: 16px; padding: 16px; }
.studio-apercu { display: grid; gap: 12px; align-content: start; min-width: 0; }
.cadre-apercu { position: relative; width: 100%; border-radius: 16px; overflow: hidden; background: #000; border: 1px solid var(--ligne); }
.scene-apercu { position: absolute; left: 0; top: 0; width: 1920px; height: 1080px; transform-origin: 0 0; }
/* faux plan de caméra derrière l'overlay live */
.scene-apercu.camera { background: url(/panel/fond-camera.jpg) center / cover; }
.scene-apercu iframe { position: absolute; inset: 0; width: 1920px; height: 1080px; border: 0; color-scheme: normal; background: transparent; }
.poignees { position: absolute; inset: 0; touch-action: none; }
.poignee {
  position: absolute; border: 3px dashed rgba(var(--or-vif-rgb), 0.9); border-radius: 14px;
  background: rgba(var(--or-rgb), 0.08); cursor: grab; touch-action: none;
}
.poignee:hover, .poignee.saisie { background: rgba(var(--or-rgb), 0.18); border-style: solid; }
.poignee.saisie { cursor: grabbing; }
.poignee span {
  position: absolute; left: -3px; top: -46px; padding: 6px 14px; border-radius: 10px;
  background: var(--or); color: var(--sur-or); font: 600 24px var(--texte); white-space: nowrap;
}
.poignee .coin {
  position: absolute; right: -18px; bottom: -18px; width: 36px; height: 36px; border-radius: 50%;
  background: var(--or); border: 4px solid var(--sur-or); cursor: nwse-resize;
}

.tests-apercu { display: grid; gap: 8px; }
.puces-tests { display: flex; flex-wrap: wrap; gap: 8px; }
.puces-tests button {
  appearance: none; border: 1px solid var(--ligne); background: var(--carte); border-radius: 999px;
  min-height: 40px; padding: 6px 15px; font-weight: 600; font-size: 15px; cursor: pointer;
}
.puces-tests button:hover { border-color: rgba(var(--or-rgb), 0.6); }
.choix-ecran { max-width: 560px; }

.studio-reglages { display: grid; gap: 14px; align-content: start; min-width: 0; }
.partie { display: grid; gap: 14px; }
.partie[hidden] { display: none; }
.champ output { margin-left: 6px; font-weight: 500; color: var(--or-vif); font-variant-numeric: tabular-nums; }

.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.theme {
  appearance: none; display: grid; gap: 10px; justify-items: start; text-align: left; cursor: pointer;
  padding: 14px; border-radius: 14px; border: 1px solid rgba(var(--encre-rgb), 0.1);
  background: linear-gradient(160deg, var(--f), color-mix(in srgb, var(--f) 70%, #000)); color: var(--t);
}
.theme:hover { border-color: var(--a); }
.theme b { font-size: 19px; font-weight: 500; line-height: 1.1; }
.pastilles { display: flex; gap: 5px; }
.pastilles i { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 2px rgba(0, 0, 0, calc(0.25 * var(--ombre))); }

.couleurs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.couleur { display: flex; align-items: center; gap: 10px; padding: 6px 10px 6px 6px; border-radius: 12px; background: var(--fond); border: 1px solid var(--ligne); cursor: pointer; font-size: 15px; font-weight: 600; }
.couleur input { appearance: none; -webkit-appearance: none; width: 38px; height: 38px; border: 0; padding: 0; border-radius: 9px; background: none; cursor: pointer; flex: none; }
.couleur input::-webkit-color-swatch-wrapper { padding: 0; }
.couleur input::-webkit-color-swatch { border: 1px solid rgba(var(--encre-rgb), 0.2); border-radius: 9px; }
.couleur input::-moz-color-swatch { border: 1px solid rgba(var(--encre-rgb), 0.2); border-radius: 9px; }

.essai-polices { display: grid; gap: 4px; padding: 16px; border-radius: 14px; background: var(--fond); border: 1px solid var(--ligne); }
.essai-polices b { font-family: var(--titres); font-weight: 500; font-size: 30px; color: var(--accent); line-height: 1.1; }
.essai-polices span { font-family: var(--texte); font-size: 17px; }
.essai-polices em { font-family: var(--chiffres); font-style: normal; font-weight: 600; font-size: 26px; }

.styles-alertes { display: grid; gap: 8px; }
.styles-alertes button {
  appearance: none; display: grid; gap: 2px; text-align: left; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--ligne); background: var(--fond); font: inherit;
}
.styles-alertes button b { font-size: 17px; }
.styles-alertes button span { font-size: 14.5px; color: var(--encre-3); }
.styles-alertes button.actif { border-color: rgba(var(--or-rgb), 0.7); background: rgba(var(--or-rgb), 0.12); }
.styles-alertes button.actif b { color: var(--or-vif); }

.types-alertes { display: grid; gap: 12px; }
.type-alerte { display: grid; gap: 8px; padding: 12px; border-radius: 14px; background: var(--fond); border: 1px solid var(--ligne); }
.type-alerte .interrupteur { min-height: 36px; font-weight: 600; }
.ligne-son, .ligne-ambiance { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; }
.ligne-ambiance { grid-template-columns: 96px 1fr auto; padding: 6px 0; }
.ligne-ambiance span { font-weight: 600; }
.ligne-son select, .ligne-ambiance select, .message-alerte {
  min-height: 44px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--ligne); background: var(--carte); color: var(--encre); font: inherit; font-size: 15px; min-width: 0; width: 100%;
}
.ligne-son .bouton, .ligne-ambiance .bouton { min-height: 44px; padding: 6px 12px; font-size: 15px; }
#ambiances { display: grid; }

.liste-fichiers { display: grid; gap: 8px; }
.fichier { display: grid; grid-template-columns: 1fr auto auto auto; gap: 8px; align-items: center; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--fond); border: 1px solid var(--ligne); }
.fichier.logo { grid-template-columns: 48px 1fr auto auto; padding-left: 8px; }
.fichier.logo img { width: 48px; height: 48px; object-fit: contain; }
.fichier b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fichier span { font-size: 13.5px; color: var(--encre-3); }
.fichier .bouton { min-height: 40px; padding: 4px 12px; font-size: 14px; }
.fichier.choisi { border-color: rgba(var(--or-rgb), 0.6); }
.envoyer { cursor: pointer; }

@media (min-width: 1000px) {
  .studio { grid-template-columns: minmax(0, 1fr) 440px; align-items: start; max-width: 1700px; margin: 0 auto; }
  .studio-apercu { position: sticky; top: 84px; }
  .studio-reglages { max-height: calc(100dvh - 100px); overflow-y: auto; padding-right: 4px; scrollbar-width: thin; }
}
@media (max-width: 999px) {
  /* sur téléphone, l'aperçu reste visible en haut pendant qu'on règle */
  .studio-apercu { position: sticky; top: 64px; z-index: 3; background: var(--fond); padding-bottom: 8px; }
  .tests-apercu .aide { display: none; }
}

/* onglets du studio : ils passent à la ligne au lieu de déborder */
.studio .sous-onglets { flex-wrap: wrap; overflow: visible; }
.studio .sous-onglets button { flex: 1 1 auto; padding: 0 10px; }
@media (max-width: 999px) {
  .tests-apercu { display: none; }
  .studio-apercu { gap: 8px; }
  .choix-ecran button { min-height: 36px; font-size: 14px; padding: 0 6px; }
}

/* bouton lecture / pause des sons */
.bouton.lecture { width: 46px; padding: 0; }
.bouton.lecture svg { width: 18px; height: 18px; }
.bouton.lecture.joue { background: rgba(var(--or-rgb), 0.16); border-color: rgba(var(--or-rgb), 0.6); color: var(--or-vif); }

/* barre du studio : état du brouillon, retour, annuler, enregistrer */
.sauvegarde.modifie { color: var(--or-vif); }
.actions-studio { display: flex; gap: 8px; flex: none; }
.actions-studio .bouton { min-height: 42px; padding: 6px 14px; font-size: 15px; }
.actions-studio #revenir { width: 44px; padding: 0; }
@media (max-width: 999px) {
  .studio-barre { flex-wrap: wrap; row-gap: 6px; }
  .sauvegarde { order: 3; flex-basis: 100%; margin-left: 0; font-size: 13px; }
  .actions-studio { margin-left: auto; }
  .actions-studio .bouton { min-height: 38px; padding: 4px 10px; font-size: 14px; }
}

/* message sur téléphone */
.studio-mobile { display: grid; justify-items: center; gap: 14px; max-width: 420px; margin: 0 auto; padding: 48px 24px; text-align: center; }
.studio-mobile[hidden] { display: none; }
.studio-mobile svg { width: 56px; height: 56px; color: var(--or); }
.studio-mobile h1 { margin: 0; font-family: var(--titre); font-weight: 400; font-size: 28px; line-height: 1.15; }
.studio-mobile p { margin: 0; color: var(--encre-2); line-height: 1.45; }
.studio-mobile .aide b { color: var(--encre); overflow-wrap: anywhere; }
.actions-studio[hidden], .sauvegarde[hidden] { display: none; }

/* format de l'aperçu : 16:9 ou 9:16 (double format Twitch) */
.ligne-format { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.choix-format { flex: none; }
.ligne-format .aide { font-size: 13.5px; flex: 1; min-width: 220px; }
