/* Studio — feuille unique, sans préprocesseur.
   Les couleurs sont des variables : le thème sombre se contente de les redéfinir. */

:root {
  --fond: #f6f5f2;
  --fond-carte: #ffffff;
  --fond-creux: #eceae5;
  --texte: #1b1f23;
  --texte-doux: #5b6670;
  --trait: #d9d5cd;
  --accent: #1f6f5c;
  --accent-clair: #e6f0ec;
  --vert: #2f7d55;
  --orange: #b4621c;
  --rouge: #b4332a;
  --onde: #1f6f5c;
  --tete: #b4332a;
  --rayon: 10px;
  --ombre: 0 1px 2px rgba(20, 24, 28, .06), 0 6px 18px rgba(20, 24, 28, .05);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fond: #14181c;
    --fond-carte: #1b2026;
    --fond-creux: #232a31;
    --texte: #e9ecef;
    --texte-doux: #9aa6b1;
    --trait: #313a43;
    --accent: #5ec2a4;
    --accent-clair: #1d2b28;
    --vert: #5ec285;
    --orange: #e0a158;
    --rouge: #e4796d;
    --onde: #5ec2a4;
    --tete: #e4796d;
    --ombre: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--fond);
  color: var(--texte);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%; /* iPhone en paysage : ne pas grossir le texte */
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 .4em; font-weight: 650; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .7em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9em; background: var(--fond-creux); padding: .1em .3em; border-radius: 4px; }

.chargement { padding: 2rem; color: var(--texte-doux); }

/* ───────── Bandeau ───────── */

.bandeau {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  padding: .6rem max(1rem, env(safe-area-inset-left)) .6rem max(1rem, env(safe-area-inset-left));
  background: var(--fond-carte);
  border-bottom: 1px solid var(--trait);
  position: sticky;
  top: 0;
  z-index: 10;
}

.titre-projet { display: flex; flex-direction: column; min-width: 0; }
.titre-projet strong { font-size: 1.05rem; }
.titre-projet .sous, .sous { color: var(--texte-doux); font-size: .85rem; }

.onglets { display: flex; gap: .25rem; margin-left: auto; flex-wrap: wrap; }
.onglets button { position: relative; }
.onglets button.actif { background: var(--accent-clair); color: var(--accent); border-color: transparent; font-weight: 600; }
.pastille {
  display: inline-block; min-width: 1.3em; margin-left: .35em; padding: 0 .3em;
  background: var(--orange); color: #fff; border-radius: 1em; font-size: .72rem; line-height: 1.5;
}
.lien-retour { border: 0 !important; background: none !important; color: var(--texte-doux) !important; padding-left: 0 !important; }
.actions-bandeau { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }

/* ───────── Structure ───────── */

.vue {
  padding: 1rem max(1rem, env(safe-area-inset-left)) 3rem;
  max-width: 1500px;
  margin: 0 auto;
}

.colonne { display: flex; flex-direction: column; gap: 1rem; max-width: 900px; }

.deux-colonnes {
  display: grid;
  grid-template-columns: minmax(220px, 300px) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}
.deux-colonnes.inverse { grid-template-columns: minmax(0, 1fr) minmax(280px, 400px); }

/* ⚠️ Un élément de grille vaut `min-width: auto` : il refuse de descendre sous la
   largeur minimale de son contenu, et c'est la COLONNE ENTIÈRE qui s'élargit. Sur
   un écran de 390 px, un <canvas> (largeur intrinsèque 300 px) poussait la colonne
   à 416 px : la moitié droite des boutons sortait de l'écran, sans barre de
   défilement visible ni le moindre signe. */
.deux-colonnes > * { min-width: 0; }

@media (max-width: 860px) {
  .deux-colonnes, .deux-colonnes.inverse { grid-template-columns: 1fr; }
  .colonne-laterale { order: 2; }
}

.carte {
  background: var(--fond-carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 1rem;
}
.carte.vide { text-align: center; padding: 2.5rem 1rem; }
.entete-carte { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.entete-carte h2 { margin: 0; }
.entete-carte .actions, .entete-carte .portee { margin-left: auto; }

.aide { color: var(--texte-doux); font-size: .88rem; }
.aide-longue summary { cursor: pointer; font-weight: 600; }
.aide-longue ol, .aide-longue ul { padding-left: 1.2rem; }
.aide-longue li { margin-bottom: .35em; }
.diagnostic { font-size: .9rem; color: var(--accent); font-weight: 500; }

/* ───────── Boutons et champs ───────── */

button {
  font: inherit;
  padding: .45rem .8rem;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: var(--fond-carte);
  color: var(--texte);
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.primaire { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.gros { padding: .7rem 1.2rem; font-size: 1.05rem; }
button.enregistre { background: var(--rouge); border-color: var(--rouge); color: #fff; font-weight: 700; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .78; } }
button.vert { border-color: var(--vert); color: var(--vert); font-weight: 600; }
button.vert.actif { background: var(--vert); color: #fff; }
button.orange { border-color: var(--orange); color: var(--orange); font-weight: 600; }
button.orange.actif { background: var(--orange); color: #fff; }
button.actif { background: var(--accent-clair); color: var(--accent); border-color: transparent; font-weight: 600; }
button.danger-discret { border-color: transparent; color: var(--rouge); }
button.lien { border: 0; background: none; padding: .1rem .3rem; text-decoration: underline; text-underline-offset: 2px; }
button.discret { color: var(--texte); }

.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.espace { flex: 1 1 auto; }

label.champ { display: flex; flex-direction: column; gap: .25rem; margin-bottom: .75rem; font-size: .9rem; font-weight: 600; }
label.champ.ligne { flex-direction: row; align-items: flex-start; gap: .5rem; font-weight: 400; }
label.champ.ligne input[type="checkbox"], label.champ.ligne input[type="radio"] { margin-top: .3rem; flex: none; }
label.champ .aide { font-weight: 400; }

input[type="text"], input[type="file"], textarea, select {
  font: inherit;
  padding: .45rem .6rem;
  border: 1px solid var(--trait);
  border-radius: 8px;
  background: var(--fond);
  color: var(--texte);
  width: 100%;
  font-weight: 400;
}
textarea { resize: vertical; min-height: 4rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

fieldset { border: 1px solid var(--trait); border-radius: var(--rayon); padding: .8rem; margin: 0 0 1rem; }
legend { font-weight: 650; padding: 0 .4rem; font-size: .9rem; }

/* ───────── Listes et tableaux ───────── */

.tableau { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tableau th, .tableau td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--trait); vertical-align: top; }
.tableau thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texte-doux); }
.tableau td.rang { color: var(--texte-doux); font-variant-numeric: tabular-nums; }
.tableau.petit th, .tableau.petit td { padding: .2rem .4rem; border: 0; }
.tableau .fleche { color: var(--texte-doux); }
.actions-cellule { white-space: nowrap; }
.actions-cellule button { padding: .2rem .45rem; }
.texte-item { overflow-wrap: anywhere; }
.note-cellule { color: var(--texte-doux); }
.groupe {
  display: inline-block; margin-left: .4em; padding: 0 .4em;
  background: var(--fond-creux); color: var(--texte-doux);
  border-radius: 4px; font-size: .75rem;
}

.etiquette { display: inline-block; padding: 0 .45em; border-radius: 4px; font-size: .75rem; font-weight: 600; margin-right: .3em; }
.etiquette.ok { background: var(--accent-clair); color: var(--vert); }
.etiquette.refaire { background: #f6e3d2; color: var(--orange); }
.etiquette.juger { background: var(--fond-creux); color: var(--texte-doux); }
.etiquette.vide { background: var(--fond-creux); color: var(--texte-doux); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .etiquette.refaire { background: #3a2a1b; } }

.grille-projets { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.fiche-projet h3 { cursor: pointer; }
.fiche-projet h3:hover { color: var(--accent); }
.liste-projets { display: flex; flex-direction: column; gap: 1rem; }
.place { margin-top: .5rem; }

/* ───────── Barre latérale du studio ───────── */

.colonne-laterale {
  background: var(--fond-carte);
  border: 1px solid var(--trait);
  border-radius: var(--rayon);
  padding: .6rem;
  position: sticky;
  top: 4.2rem;
  max-height: calc(100vh - 5.5rem);
  display: flex;
  flex-direction: column;
  gap: .5rem;
}
.filtres { display: flex; flex-wrap: wrap; gap: .25rem; }
.filtres button { padding: .2rem .5rem; font-size: .8rem; }
.barre-avancement { height: 5px; background: var(--fond-creux); border-radius: 3px; overflow: hidden; }
.barre-avancement > div { height: 100%; background: var(--vert); transition: width .3s; }
.titre-pile { margin: 0; }

.liste-items { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1 1 auto; min-height: 120px; }
.liste-items li {
  display: flex; gap: .45rem; align-items: baseline;
  padding: .3rem .4rem; border-radius: 6px; cursor: pointer; font-size: .9rem;
}
.liste-items li:hover { background: var(--fond-creux); }
.liste-items li.courant { background: var(--accent-clair); color: var(--accent); font-weight: 600; }
.pastille-etat { flex: none; width: 1em; text-align: center; color: var(--texte-doux); }
.liste-items li.ok .pastille-etat { color: var(--vert); }
.liste-items li.a-refaire .pastille-etat { color: var(--orange); }
.panneau-micro { flex: none; }

/* ───────── Scène ───────── */

.scene { display: flex; flex-direction: column; gap: .7rem; }
.fil-ariane { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .85rem; color: var(--texte-doux); }
.fil-ariane .rang { font-variant-numeric: tabular-nums; }
.pistes { display: flex; gap: .25rem; }
.pistes button { padding: .2rem .55rem; font-size: .85rem; }

.texte-scene {
  font-size: clamp(1.5rem, 4.5vw, 2.4rem);
  line-height: 1.25;
  font-weight: 600;
  margin: .3em 0 0;
  overflow-wrap: anywhere;
}
.note-scene { color: var(--texte-doux); font-size: 1.05rem; margin-top: .2em; }

.zone-onde { background: var(--fond-creux); border-radius: 8px; padding: .5rem; }
canvas.onde { display: block; width: 100%; min-width: 0; height: 90px; }
.infos-onde { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .82rem; color: var(--texte-doux); padding-top: .3rem; }
.sature { color: var(--rouge); }
.autre-auteur { color: var(--accent); font-weight: 600; }

.vu { display: flex; align-items: center; gap: .6rem; }
/* `min-width: 0` pour la même raison : en contexte flex, un canvas ne rétrécit
   pas sous ses 300 px intrinsèques si on ne l'y autorise pas. */
canvas.vumetre { flex: 1 1 auto; min-width: 0; height: 16px; display: block; }
.chrono { font-variant-numeric: tabular-nums; color: var(--texte-doux); min-width: 4.5em; text-align: right; }

.commandes { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.clavier { border-top: 1px dashed var(--trait); padding-top: .5rem; margin: 0; }

.prises ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .2rem; }
.prises li { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; font-size: .88rem; padding: .2rem .3rem; border-radius: 6px; }
.prises li.courante { background: var(--accent-clair); }

/* ───────── Retouches ───────── */

.reglages { display: flex; flex-direction: column; gap: .5rem; }
.bloc-effet { border: 1px solid var(--trait); border-radius: 8px; padding: .55rem .7rem; }
.bloc-effet.actif { border-color: var(--accent); background: var(--accent-clair); }
.bloc-effet .aide { margin: 0; }
.titre-effet { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; }
.curseurs { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .5rem 1rem; margin-top: .5rem; }
label.champ.curseur { gap: .1rem; margin: 0; }
.libelle-curseur { display: flex; justify-content: space-between; font-size: .85rem; }
.libelle-curseur output { font-variant-numeric: tabular-nums; color: var(--accent); }
.portee { display: flex; gap: .25rem; flex-wrap: wrap; }
.modeles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .5rem; }
.modele { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: .15rem; }
.surcharges { margin-top: .8rem; }
.surcharges ul { margin: 0; padding-left: 1rem; }

.carte-ecoute { position: sticky; top: 4.2rem; }
.paire-ondes { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .6rem; }
.paire-ondes canvas { background: var(--fond-creux); border-radius: 6px; }
.etapes { font-size: .85rem; color: var(--texte-doux); padding-left: 1.1rem; margin: .4rem 0; }
.rapport { display: flex; flex-direction: column; gap: .3rem; }

.apercu { list-style: none; margin: .3rem 0; padding: 0; font-size: .88rem; max-height: 9rem; overflow-y: auto; }
.apercu li { padding: .1rem 0; border-bottom: 1px solid var(--trait); }

.diag { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; font-size: .85rem; margin: .5rem 0; }
.diag dt { color: var(--texte-doux); }
.diag dd { margin: 0; }
.journal { font-size: .72rem; max-height: 10rem; overflow: auto; background: var(--fond-creux); padding: .4rem; border-radius: 6px; white-space: pre-wrap; word-break: break-all; }

/* ───────── Dialogues et messages ───────── */

.voile {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(10, 14, 18, .5);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  overscroll-behavior: contain;
}
.dialogue, .chantier { width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; }
.corps-dialogue { overflow-y: auto; }
.pied-dialogue { display: flex; justify-content: flex-end; gap: .5rem; padding-top: .8rem; }

.barre-progres { height: 8px; background: var(--fond-creux); border-radius: 4px; overflow: hidden; margin: .5rem 0; }
.barre-progres-interne { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.chantier-libelle { font-size: .88rem; color: var(--texte-doux); margin: 0; overflow-wrap: anywhere; }

.messages {
  position: fixed; z-index: 60; left: 50%; transform: translateX(-50%);
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: .4rem; align-items: center;
  width: min(560px, calc(100% - 2rem));
  pointer-events: none;
}
.message {
  background: var(--texte); color: var(--fond);
  padding: .5rem .9rem; border-radius: 8px; font-size: .9rem;
  box-shadow: var(--ombre); transition: opacity .4s, transform .4s;
  pointer-events: auto;
}
.message.ok { background: var(--vert); color: #fff; }
.message.alerte { background: var(--rouge); color: #fff; }
.message.parti { opacity: 0; transform: translateY(6px); }

@media (max-width: 520px) {
  .onglets { width: 100%; margin-left: 0; }
  .onglets button { flex: 1 1 auto; padding: .4rem .3rem; font-size: .85rem; }
  .commandes button { flex: 1 1 auto; }
  .vue { padding-left: max(.75rem, env(safe-area-inset-left)); padding-right: max(.75rem, env(safe-area-inset-right)); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ───────── Voix du projet ───────── */

.liste-voix { list-style: none; margin: 0 0 .5rem; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.liste-voix li { display: flex; align-items: center; gap: .5rem; }
.liste-voix .rang { color: var(--texte-doux); width: 1.2em; font-variant-numeric: tabular-nums; }
.liste-voix input[type="text"] { max-width: 16rem; font-weight: 600; }
.liste-voix .aide { white-space: nowrap; }
.porte-par { color: var(--accent); font-weight: 600; }

/* ───────── Commentaires ───────── */

.commentaires { border-top: 1px dashed var(--trait); padding-top: .5rem; }
.commentaires > details > summary { cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--texte-doux); }
.commentaires .fil { list-style: none; margin: .5rem 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.commentaires .fil li { background: var(--fond-creux); border-radius: 8px; padding: .45rem .6rem; }
.commentaires .fil li.resolu { opacity: .6; }
.tete-commentaire { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; font-size: .85rem; }
.corps-commentaire { margin: .25rem 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.actions-commentaire { display: flex; gap: .3rem; font-size: .82rem; }
.ajout-commentaire { display: flex; gap: .4rem; align-items: flex-start; flex-wrap: wrap; }
.ajout-commentaire textarea { flex: 1 1 14rem; min-height: 2.6rem; }

/* ───────── Bilans de fusion et de partage ───────── */

.bilan { margin: .3rem 0 .6rem; padding-left: 1.1rem; }
.bilan li { margin-bottom: .2em; }
.avertissement { color: var(--orange); font-weight: 500; }
