/* ---------------------------------------------------------------
   Scanner Glitch Art — thème "labo d'analyse", cyan/magenta duotone
   --------------------------------------------------------------- */

:root {
  --bg: #07080d;
  --bg-grid: rgba(255, 255, 255, .025);
  --panel: rgba(20, 22, 32, .65);
  --panel-solid: #12141c;
  --border: rgba(255, 255, 255, .08);
  --border-strong: rgba(255, 255, 255, .16);
  --text: #e7e9f0;
  --muted: #8489a0;
  --cyan: #37f2d0;
  --magenta: #ff3fb0;
  --danger: #ff5c72;
  --radius: 14px;
  --radius-sm: 8px;
  --mono: 'SFMono-Regular', ui-monospace, Menlo, Consolas, 'Courier New', monospace;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(var(--bg-grid) 1px, transparent 1px) 0 0 / 100% 28px,
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px) 0 0 / 28px 100%,
    radial-gradient(ellipse 90% 60% at 50% -10%, rgba(55, 242, 208, .07), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  display: flex;
  flex-direction: column;
}

.mono { font-family: var(--mono); }

/* ---------- Icônes ---------- */

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 15px; height: 15px; flex-shrink: 0; }
.icon-sm { width: 12px; height: 12px; }
.icon-lg { width: 32px; height: 32px; }

/* ---------- En-tête ---------- */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 8, 13, .85);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
}

.brand { display: flex; align-items: center; gap: .8rem; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 1.1rem;
  color: var(--cyan);
  background: rgba(55, 242, 208, .08);
  border: 1px solid rgba(55, 242, 208, .3);
}

.brand-title {
  margin: 0;
  font-size: .95rem;
  font-weight: 800;
  letter-spacing: .08em;
  position: relative;
}
.brand-title em { font-style: normal; color: var(--magenta); }

.brand-title span, .brand-title em {
  position: relative;
  display: inline-block;
}
.brand-title span::before, .brand-title em::before {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: var(--cyan);
  clip-path: inset(0 0 0 0);
  animation: glitchShift 7s infinite steps(1);
  opacity: 0;
}
@keyframes glitchShift {
  0%, 92%, 100% { opacity: 0; transform: translate(0); }
  93% { opacity: .8; transform: translate(-2px, 1px); clip-path: inset(20% 0 40% 0); }
  95% { opacity: .8; transform: translate(2px, -1px); clip-path: inset(60% 0 10% 0); }
  97% { opacity: 0; transform: translate(0); }
}
@media (prefers-reduced-motion: reduce) {
  .brand-title span::before, .brand-title em::before { animation: none; }
}

.brand-sub { margin: 1px 0 0; font-size: .68rem; color: var(--muted); }

.ghost-btn {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .45rem .8rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted);
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: .15s ease;
}
.ghost-btn:hover { color: var(--cyan); border-color: rgba(55, 242, 208, .35); background: rgba(55, 242, 208, .06); }
.ghost-btn .icon { color: var(--magenta); }

/* ---------- Structure principale ----------
   Le point de départ : deux canevas carrés côte à côte. Tout part de là,
   et rien d'autre ne doit pouvoir casser ce carré. On dimensionne donc
   .canvas-frame par sa LARGEUR (aspect-ratio:1/1), jamais en flex:1 vertical
   — sinon sa hauteur dépend de la quantité de boutons du panneau voisin et
   le carré se déforme. La page défile normalement plutôt que de tout
   écraser dans un seul écran. */

.workspace {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 1.25rem;
}

.canvases {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: start;
  gap: 1.25rem;
}

@media (max-width: 860px) {
  .canvases { grid-template-columns: 1fr; }
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .9rem;
  backdrop-filter: blur(8px);
}

@media (max-width: 700px) {
  .workspace { padding-bottom: 88px; }
  .app-footer { margin-bottom: 76px; }
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .55rem;
  flex-wrap: wrap;
  gap: .3rem;
}

.panel-tag {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .08em;
  display: flex;
  align-items: center;
  gap: .4rem;
  color: var(--text);
}
.tag-a .dot { background: var(--cyan); }
.tag-b { color: var(--magenta); }
.tag-b .dot { background: var(--magenta); }

.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.pulse { animation: pulseDot 1.6s ease-in-out infinite; }
@keyframes pulseDot { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.panel-hint { font-size: .62rem; color: var(--muted); }

.canvas-frame {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: 1 / 1;
  /* plafonne le carré à une fraction de la hauteur de fenêtre pour limiter le
     défilement sur les grands écrans, sans jamais casser le ratio 1:1 */
  max-width: min(100%, 62vh);
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  background: #050608;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, .5);
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
}
/* Curseur « saisir » + désactivation des gestes tactiles natifs réservés au
   seul canevas manipulable : #canvasOutput et #canvasPreview n'ont aucun
   listener pointer/wheel, un curseur grab dessus serait trompeur, et
   touch-action:none y bloquerait inutilement le scroll tactile de la page. */
#canvasInteractive {
  cursor: grab;
  touch-action: none;
}
#canvasInteractive:active { cursor: grabbing; }

/* Calque dédié à l'indicateur de position du scanner : purement visuel, posé
   au-dessus de #canvasInteractive. Le garder séparé évite qu'il ne soit
   capturé par l'échantillonnage (getImageData lit #canvasInteractive). */
.scan-indicator-layer {
  position: absolute;
  inset: 0;
  cursor: inherit;
  touch-action: auto;
  pointer-events: none;
}

.empty-state {
  position: absolute;
  /* inset:0 (plutôt qu'une marge) pour recouvrir entièrement le canevas :
     celui-ci est pré-rempli en blanc (couleur de fond par défaut) même
     sans image, un inset laisserait un halo blanc visible tout autour. */
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .35rem;
  text-align: center;
  padding: 1rem;
  color: var(--muted);
  pointer-events: none;
  background: #050608;
  border: 1.5px dashed var(--border-strong);
  border-radius: 9px;
  transition: border-color .15s ease, background .15s ease;
}
.empty-state .icon-lg { color: var(--cyan); opacity: .6; transition: opacity .15s ease; }
.empty-title { margin: 0; font-size: .82rem; font-weight: 700; color: var(--text); }
.empty-sub { margin: 0; font-size: .68rem; max-width: 220px; }

/* Recouvre le cadre pendant la lecture du fichier / le décodage de l'image */
.loading-state {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: rgba(5, 6, 8, .85);
  backdrop-filter: blur(2px);
  color: var(--muted);
  font-size: .68rem;
  pointer-events: none;
}
.loading-state[hidden] { display: none; }
.loading-text { margin: 0; }
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(55, 242, 208, .25);
  border-top-color: var(--cyan);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2s; }
}

/* Le cadre A entier fait office de zone de dépôt/clic tant qu'aucune image
   n'est chargée : #canvasInteractive.empty porte le curseur, on ne peut pas
   viser .empty-state (pointer-events:none) qui ne fait que passer les
   événements au canevas en dessous. */
#canvasInteractive.empty { cursor: pointer; }
#interactiveContainer:hover .empty-state {
  border-color: var(--cyan);
  background: rgba(55, 242, 208, .04);
}
#interactiveContainer:hover .empty-state .icon-lg { opacity: 1; }
#interactiveContainer.drag-over .empty-state {
  border-color: var(--magenta);
  background: rgba(255, 63, 176, .08);
}

.frame-tip {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .62rem;
  color: var(--muted);
  background: rgba(5, 6, 8, .85);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem .55rem;
  pointer-events: none;
}
kbd {
  font-family: var(--mono);
  background: rgba(255, 255, 255, .08);
  border-radius: 4px;
  padding: 0 4px;
  font-size: .62rem;
}
@media (max-width: 700px) {
  /* astuces clavier/souris hors-sujet au doigt : la mini-barre + le lecteur de zoom suffisent */
  .frame-tip { display: none; }
}

/* Mini-barre d'outils flottante sur l'atelier A (zoom / rotation / reset) */
.canvas-toolbar {
  position: absolute;
  top: 10px;
  right: 10px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
#interactiveContainer.has-image .canvas-toolbar { display: flex; }
.cv-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: rgba(5, 6, 8, .8);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  color: var(--text);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.cv-btn:hover, .cv-btn:active { border-color: var(--cyan); color: var(--cyan); background: rgba(55, 242, 208, .1); }

/* Sépare visuellement « changer d'image » (remplace le contenu) des outils
   de transformation (zoom/rotation/reset, qui n'agissent que sur l'affichage) */
#btnChangeImage {
  margin-bottom: 4px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-strong);
  border-radius: 9px 9px 0 0;
  color: var(--cyan);
}

/* Lecteur d'échelle / rotation, apparaît pendant l'interaction */
.transform-readout {
  position: absolute;
  top: 10px;
  left: 10px;
  font-family: var(--mono);
  font-size: .66rem;
  font-weight: 600;
  color: var(--cyan);
  background: rgba(5, 6, 8, .8);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .25rem .5rem;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  z-index: 5;
}
.transform-readout.show { opacity: 1; transform: translateY(0); }

/* Mini-aperçu du résultat, superposé sur l'atelier pour ne pas quitter l'image des yeux */
.pip-preview {
  position: absolute;
  bottom: 54px;
  left: 10px;
  width: 66px;
  height: 66px;
  padding: 0;
  border-radius: 9px;
  overflow: hidden;
  border: 1.5px solid var(--magenta);
  box-shadow: 0 0 14px rgba(255, 63, 176, .45), inset 0 0 0 1px rgba(0, 0, 0, .4);
  cursor: pointer;
  background: #050608;
  display: none;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}
.pip-preview.show { display: block; }
.pip-preview canvas {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  display: block;
  cursor: pointer;
  touch-action: auto;
}
.pip-preview .pip-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  font-size: .5rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, .65);
  padding: 1px 0;
}
@media (max-width: 700px) {
  .pip-preview { bottom: 10px; }
}

.live-badge {
  position: absolute;
  top: 10px;
  /* à droite, pas à gauche : l'encart de réglages (drawInfoOverlay, dessiné
     dans le canevas lui-même) occupe déjà le coin haut-gauche, les deux se
     chevauchaient sinon. */
  right: 10px;
  display: flex;
  align-items: center;
  gap: .35rem;
  font-size: .6rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--magenta);
  background: rgba(255, 63, 176, .12);
  border: 1px solid rgba(255, 63, 176, .3);
  border-radius: 5px;
  padding: .2rem .45rem;
  pointer-events: none;
}
.dot.ping { background: var(--magenta); animation: pulseDot 1s ease-in-out infinite; }

/* Overlay purement visuel façon écran cathodique (scanlines + vignette),
   posé au-dessus de #canvasOutput mais JAMAIS dessiné dans son contexte 2D —
   même logique de séparation que #canvasScanIndicator au-dessus de
   #canvasInteractive (voir script.js/CLAUDE.md) : l'export ne lit jamais que
   `pristine`, donc cet overlay ne peut pas polluer le PNG exporté. */
.crt-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  opacity: .55;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(0, 0, 0, .18) 0px,
      rgba(0, 0, 0, .18) 1px,
      transparent 1px,
      transparent 3px
    ),
    radial-gradient(ellipse at center, transparent 55%, rgba(20, 0, 15, .45) 100%);
}
@media (max-width: 700px) {
  .crt-overlay { opacity: .4; }
}

/* ---------- Boutons génériques ---------- */

.dock-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .6rem;
  font-size: .72rem;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, .04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: .15s ease;
  margin-top: .5rem;
}
.dock-btn:first-child { margin-top: 0; }
.dock-btn:hover { background: rgba(255, 255, 255, .08); border-color: var(--border-strong); }
.dock-btn.lg { padding: .7rem; font-size: .8rem; }

.dock-btn.accent-fill {
  background: linear-gradient(135deg, var(--cyan), #1fb8a0);
  color: #041912;
  border-color: transparent;
}
.dock-btn.accent-fill:hover { filter: brightness(1.08); }
.dock-btn.accent-fill.playing {
  background: linear-gradient(135deg, var(--magenta), #b8228a);
  color: #200013;
}
.dock-btn.accent-fill.lg {
  position: relative;
  overflow: hidden;
}
.dock-btn.accent-fill.lg::after {
  content: '';
  position: absolute;
  inset: 0;
  width: var(--progress, 0%);
  background: rgba(255, 255, 255, .22);
  transition: width .1s linear;
  pointer-events: none;
}
.dock-btn.accent-fill.lg span, .dock-btn.accent-fill.lg .icon { position: relative; z-index: 1; }

.dock-btn.danger-hover:hover {
  background: rgba(255, 92, 114, .1);
  border-color: rgba(255, 92, 114, .4);
  color: var(--danger);
}

button:disabled { opacity: .5; cursor: wait; pointer-events: none; }

.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .6rem; }
.btn-row .dock-btn { margin-top: 0; flex: 1 1 0; min-width: 108px; }
.btn-row .dock-btn.accent-fill { flex-grow: 1.4; }

/* ---------- Console de contrôle ---------- */

.dock {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  backdrop-filter: blur(8px);
  flex-shrink: 0;
}

/* Le wrapper des modules se fond dans la grille du dock sur desktop... */
.settings-panel { display: contents; }

@media (max-width: 980px) {
  .dock { grid-template-columns: 1fr 1fr; }
  /* module Contrôles occupe seul la 2e ligne : autant lui laisser toute la largeur */
  #modControls { grid-column: 1 / -1; }
}
@media (max-width: 700px) {
  .dock { grid-template-columns: 1fr; }
}

.dock-module {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  padding-right: 1rem;
  border-right: 1px solid var(--border);
}
/* #modControls est toujours la dernière colonne visuelle sur desktop :
   on cible l'id plutôt que :last-child, qui ne voit pas au-delà du wrapper
   .settings-panel (display:contents) et se tromperait de module. */
#modControls { border-right: none; padding-right: 0; }

@media (max-width: 980px) {
  /* 3 modules dans une grille à 2 colonnes = repli disgracieux en bordures
     verticales ; on repasse en séparateurs horizontaux, plus simples et sûrs. */
  .dock-module { border-right: none; padding-right: 0; border-bottom: 1px solid var(--border); padding-bottom: .8rem; }
  #modControls { border-bottom: none; padding-bottom: 0; }
}
@media (max-width: 700px) {
  .dock-module:last-child { border-bottom: none; padding-bottom: 0; }
}

/* ---------- Petits écrans : le dock devient un tiroir escamotable ---------- */

@media (max-width: 700px) {
  .dock {
    display: block;
    background: none;
    border: none;
    padding: 0;
    backdrop-filter: none;
  }

  /* module 4 (lecture desktop) laisse place à la barre fixe du bas */
  #modControls { display: none; }

  .settings-panel {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 68vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    padding: 0 1.1rem calc(78px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 40px rgba(0, 0, 0, .5);
    transform: translateY(100%);
    transition: transform .3s cubic-bezier(.32, .72, 0, 1);
    z-index: 55;
  }
  .settings-panel.open { transform: translateY(0); }

  .settings-panel .dock-module {
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem 0;
  }
  .settings-panel .dock-module:last-of-type { border-bottom: none; }
}

.drawer-handle { display: none; }
@media (max-width: 700px) {
  .drawer-handle {
    display: flex;
    justify-content: center;
    padding: .7rem 0 .3rem;
    cursor: pointer;
    position: sticky;
    top: 0;
    background: var(--panel-solid);
    z-index: 1;
  }
  .drawer-handle span {
    width: 38px;
    height: 4px;
    border-radius: 2px;
    background: var(--border-strong);
  }
}

.dock-title {
  margin: 0;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--cyan);
  display: flex;
  align-items: center;
  gap: .4rem;
}
.dock-title .icon { color: var(--cyan); }

/* Élément masqué mais toujours cliquable/focusable (déclenché via .click() en JS) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Champs / sliders */
.field { display: flex; flex-direction: column; gap: .25rem; }
.field-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .68rem;
  color: var(--muted);
}
.value { color: var(--cyan); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
  cursor: pointer;
  /* zone de survol/toucher bien plus grande que la piste visible */
  padding: 12px 0;
  background-clip: content-box;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(55, 242, 208, .6), 0 0 0 4px rgba(55, 242, 208, .12);
  cursor: pointer;
  margin-top: -8px;
}
input[type=range]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 6px rgba(55, 242, 208, .6), 0 0 0 4px rgba(55, 242, 208, .12);
  cursor: pointer;
}
input[type=range]::-moz-range-track {
  height: 4px;
  border-radius: 3px;
  background: rgba(255, 255, 255, .12);
}

/* Boutons bascule (direction / mode couleur) */
.toggle-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .4rem;
}
.toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3rem;
  padding: .4rem;
  font-size: .66rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, .03);
  color: var(--muted);
  cursor: pointer;
  transition: .15s ease;
}
.toggle-btn:hover { color: var(--text); }
.toggle-btn.active {
  background: rgba(55, 242, 208, .1);
  border-color: rgba(55, 242, 208, .45);
  color: var(--cyan);
}

.bg-color-row { align-items: center; }
.swatch {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: rgba(0, 0, 0, .2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .15rem .5rem;
  cursor: pointer;
}
.swatch input[type=color] {
  width: 16px;
  height: 16px;
  border: none;
  padding: 0;
  background: none;
  cursor: pointer;
}

.check-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .68rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
  padding-top: .5rem;
  cursor: pointer;
}
.check-row span { display: flex; align-items: center; gap: .35rem; }
.export-hires-toggle { margin-top: .7rem; }
.check-row input[type=checkbox] {
  width: 15px;
  height: 15px;
  accent-color: var(--cyan);
  cursor: pointer;
}

.scan-progress {
  text-align: center;
  font-size: .68rem;
  color: var(--muted);
  margin: .2rem 0 0;
}
.scan-progress .mono { color: var(--magenta); font-weight: 700; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .74rem;
  font-weight: 600;
  backdrop-filter: blur(8px);
  z-index: 60;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease, background-color .15s ease, border-color .15s ease, color .15s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Erreur (défaut) : triangle d'avertissement + rouge. Succès/info : icône
   « i » + cyan — un « Image exportée. » affiché en rouge alarmait pour rien. */
.toast.error {
  background: rgba(255, 92, 114, .15);
  color: var(--danger);
  border: 1px solid rgba(255, 92, 114, .35);
}
.toast.success {
  background: rgba(55, 242, 208, .15);
  color: var(--cyan);
  border: 1px solid rgba(55, 242, 208, .35);
}

.toast-action {
  margin-left: .3rem;
  flex-shrink: 0;
  background: none;
  border: 1px solid currentColor;
  border-radius: 6px;
  padding: .2rem .55rem;
  color: inherit;
  font-size: .68rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}
.toast-action:hover { background: rgba(255, 255, 255, .12); }
.toast-action[hidden] { display: none; }

@media (max-width: 700px) {
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: calc(80px + env(safe-area-inset-bottom));
  }
}

/* ---------- Barre d'action fixe (mobile) ---------- */

.mobile-bar { display: none; }
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 50;
  opacity: 0;
  transition: opacity .25s ease;
}
.backdrop.show { display: block; opacity: 1; }

@media (max-width: 700px) {
  .mobile-bar {
    display: flex;
    align-items: center;
    gap: .6rem;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    padding: .55rem .8rem calc(.55rem + env(safe-area-inset-bottom));
    background: rgba(9, 10, 16, .92);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
    z-index: 56;
  }

  .mbar-btn {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, .06);
    border: 1px solid var(--border-strong);
    border-radius: 12px;
    color: var(--text);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mbar-btn.accent {
    background: linear-gradient(135deg, var(--cyan), #1fb8a0);
    color: #041912;
    border-color: transparent;
  }
  .mbar-btn[aria-expanded="true"] {
    background: rgba(55, 242, 208, .18);
    border-color: var(--cyan);
    color: var(--cyan);
  }

  .mbar-play {
    position: relative;
    overflow: hidden;
    flex: 1;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    font-size: .78rem;
    font-weight: 800;
    color: #041912;
    background: linear-gradient(135deg, var(--cyan), #1fb8a0);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .mbar-play.playing {
    color: #200013;
    background: linear-gradient(135deg, var(--magenta), #b8228a);
  }
  .mbar-play::after {
    content: '';
    position: absolute;
    inset: 0;
    width: var(--progress, 0%);
    background: rgba(255, 255, 255, .22);
    transition: width .1s linear;
    pointer-events: none;
  }
  .mbar-play span, .mbar-play .icon { position: relative; z-index: 1; }
}

/* ---------- Focus clavier (accessibilité) ----------
   :focus-visible ne s'affiche qu'à la navigation clavier (pas au clic
   souris/tactile), donc aucun risque d'alourdir visuellement les
   interactions courantes à la souris. */
button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Les <input type=color|checkbox> sont enveloppés dans un <label> : on
   surligne le conteneur entier (le rond de couleur / la case seuls sont trop
   petits et parfois mal pris en charge par le focus ring natif). */
.swatch:focus-within,
.check-row:focus-within {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- Pied de page ---------- */

.app-footer {
  text-align: center;
  font-size: .62rem;
  color: var(--muted);
  padding: .6rem;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
