/* ============================================================
   Variables & Reset
   ============================================================ */
:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #d1d5db;
  --text: #111827;
  --text-muted: #6b7280;
  --accent: #e52d27;
  --accent-dark: #b91c1c;
  --accent-hover: #dc2020;
  --focus-ring: #2563eb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.12), 0 1px 2px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.12);
  --transition: 200ms ease;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242736;
  --border: #323548;
  --text: #f1f3f9;
  --text-muted: #9ca3af;
  --accent: #ff4040;
  --accent-dark: #e52d27;
  --accent-hover: #ff5555;
  --focus-ring: #60a5fa;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition:
    background var(--transition),
    color var(--transition);
}

/* ============================================================
   Accessibility
   ============================================================ */
.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--focus-ring);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  z-index: 9999;
  text-decoration: none;
  transition: top var(--transition);
}
.skip-link:focus {
  top: 1rem;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   Header
   ============================================================ */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.header-inner {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
}

/* ============================================================
   Font Awesome 7 — système de couleurs & animations
   ============================================================ */

/* Icône YouTube dans le h1 */
.fa-icon-yt {
  font-size: 1.5rem;
  color: var(--accent);
  /* Couleurs FA7 duotone (Pro) — inactif en free, prêt si kit Pro */
  --fa-primary-color: var(--accent);
  --fa-secondary-color: color-mix(in srgb, var(--accent) 40%, transparent);
  /* Légère pulsation permanente */
  animation: fa-beat 3s ease-in-out infinite;
  --fa-beat-scale: 1.08;
  --fa-animation-duration: 3s;
}

/* Icônes de section (titres h2) */
.section-title i {
  font-size: 1rem;
  color: var(--accent);
  --fa-primary-color: var(--accent);
  --fa-secondary-color: color-mix(in srgb, var(--accent) 35%, transparent);
  --fa-secondary-opacity: 0.5;
  transition: transform var(--transition);
}
.panel-section:hover .section-title i {
  animation: fa-beat 0.6s ease-out 1;
  --fa-beat-scale: 1.18;
}

/* Icône upload — SVG inline (0 dépendance réseau) */
.upload-zone-icon {
  display: block;
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--text-muted);
  transition:
    color var(--transition),
    transform var(--transition);
}
.upload-zone:hover .upload-zone-icon,
.upload-zone.drag-over .upload-zone-icon {
  color: var(--accent);
  animation: upload-beat 0.9s ease infinite;
}
@keyframes upload-beat {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.18) translateY(-2px);
  }
}

/* Icône télécharger — bounce au survol du bouton */
.btn-primary i {
  font-size: 1rem;
  --fa-animation-duration: 0.8s;
  --fa-bounce-height: -0.12em;
  --fa-bounce-rebound: 0;
}
.btn-primary:hover i {
  animation: fa-bounce var(--fa-animation-duration, 0.8s) ease infinite;
}

/* Icône supprimer — shake au survol */
.btn-remove i {
  --fa-animation-duration: 0.7s;
}
.btn-remove:hover i {
  animation: fa-shake var(--fa-animation-duration, 0.7s) ease infinite;
}

/* Canvas-tools label icon */
.canvas-tools-label i {
  color: var(--accent);
  --fa-primary-color: var(--accent);
  font-size: 0.9rem;
}

/* Soleil / Lune — toggle de thème */
.btn-icon {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}
.btn-icon:hover {
  background: var(--border);
}
/* Soleil = amber chaud, Lune = violet doux */
[data-theme="light"] .icon-sun {
  color: #f59e0b;
}
[data-theme="dark"] .icon-moon {
  color: #a78bfa;
}

/* Spin d'un quart de tour au clic du toggle (classe ajoutée/retirée par JS) */
.btn-icon.theme-spinning i {
  animation: fa-spin 0.4s linear 1;
}

[data-theme="light"] .icon-moon,
[data-theme="dark"] .icon-sun {
  display: none;
}
[data-theme="light"] .icon-sun,
[data-theme="dark"] .icon-moon {
  display: block;
}

/* Masque la lune par défaut (avant que le JS détermine le thème) */
.icon-moon {
  display: none;
}

/* ============================================================
   Workspace layout — 3 colonnes
   ============================================================ */
.workspace {
  max-width: 1600px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  grid-template-areas: "panel-left preview panel-right";
  gap: 1.25rem;
  flex: 1;
  align-items: start;
}

.panel-left {
  grid-area: panel-left;
}
.preview-area {
  grid-area: preview;
}
.panel-right {
  grid-area: panel-right;
}

/* ============================================================
   Panel (aside)
   ============================================================ */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  /* colle le panneau en haut et suit le scroll */
  position: sticky;
  top: calc(56px + 1.25rem); /* hauteur header + gap */
  max-height: calc(100vh - 56px - 2.5rem);
  overflow-y: auto;
  /* scrollbar discrète */
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.panel::-webkit-scrollbar {
  width: 4px;
}
.panel::-webkit-scrollbar-track {
  background: transparent;
}
.panel::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.panel-section {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
}
.panel-left .panel-section {
  padding: 0.875rem;
}
.panel-section:last-child {
  border-bottom: none;
}

.section-title {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

/* ============================================================
   Form elements
   ============================================================ */
.form-group {
  margin-bottom: 0.875rem;
}
.form-group:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
}

input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  font-family: inherit;
}
input[type="text"]:hover {
  border-color: var(--text-muted);
}
input[type="text"]:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 25%, transparent);
}

.hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Checkbox */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  user-select: none;
  margin-bottom: 0;
}

input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-custom {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface-2);
  flex-shrink: 0;
  transition:
    background var(--transition),
    border-color var(--transition);
}

input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--accent);
  border-color: var(--accent);
}

input[type="checkbox"]:checked + .checkbox-custom::after {
  content: "";
  display: block;
  width: 5px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

input[type="checkbox"]:focus-visible ~ .checkbox-custom,
.checkbox-label:has(input[type="checkbox"]:focus-visible) .checkbox-custom {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ============================================================
   Design grid
   ============================================================ */
.design-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.625rem;
}

.design-option {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
  background: var(--surface-2);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
.design-option:hover {
  border-color: var(--accent);
  color: var(--text);
}
.design-option.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.design-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.design-option:has(input:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.design-preview {
  width: 100%;
  aspect-ratio: 16/9;
  border-radius: 3px;
  overflow: hidden;
  background: #1a1a2e;
}

/* Tiny design previews */
.dp-cinematic {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ff4500, #ffd700);
  position: relative;
}
.dp-cinematic .dp-text-center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 20%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
}
.dp-cinematic .dp-bar-bottom {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18%;
  background: rgba(0, 0, 0, 0.6);
}

.dp-split {
  width: 100%;
  height: 100%;
  display: flex;
}
.dp-split .dp-left {
  flex: 0.4;
  background: #ff4500;
}
.dp-split .dp-right {
  flex: 0.6;
  background: linear-gradient(135deg, #1a1a1a, #333);
}

.dp-bold {
  width: 100%;
  height: 100%;
  background: #111;
  position: relative;
  display: flex;
  align-items: center;
}
.dp-bold .dp-block {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 45%;
  background: #ff4500;
}
.dp-bold .dp-lines {
  position: absolute;
  right: 8%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 40%;
}
.dp-bold .dp-lines div {
  height: 5px;
  background: #fff;
  border-radius: 1px;
}
.dp-bold .dp-lines div:nth-child(2) {
  width: 70%;
}
.dp-bold .dp-lines div:nth-child(3) {
  width: 45%;
}

.dp-minimal {
  width: 100%;
  height: 100%;
  background: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 6px;
  gap: 3px;
}
[data-theme="dark"] .dp-minimal {
  background: #1a1d27;
}
.dp-accent-top,
.dp-accent-bottom {
  height: 3px;
  background: #ff4500;
  border-radius: 1px;
}
.dp-accent-top {
  width: 40%;
}
.dp-accent-bottom {
  width: 25%;
}
.dp-minimal .dp-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.dp-minimal .dp-lines .long {
  height: 4px;
  background: #333;
  border-radius: 1px;
  width: 80%;
}
.dp-minimal .dp-lines .short {
  height: 3px;
  background: #999;
  border-radius: 1px;
  width: 50%;
}
[data-theme="dark"] .dp-minimal .dp-lines .long {
  background: #e0e0e0;
}

.dp-gaming {
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  position: relative;
  overflow: hidden;
}
.dp-diag {
  position: absolute;
  top: -20%;
  left: -10%;
  width: 60%;
  height: 140%;
  background: #ff4500;
  transform: skewX(-12deg);
  opacity: 0.9;
}
.dp-gaming .dp-lines {
  position: absolute;
  right: 8%;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 35%;
}
.dp-gaming .dp-lines div {
  height: 5px;
  background: #fff;
  border-radius: 1px;
}
.dp-gaming .dp-lines div:last-child {
  width: 65%;
  opacity: 0.7;
}

.dp-tutorial {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
}
.dp-badge-circle {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e94560;
  flex-shrink: 0;
}
.dp-tutorial .dp-lines {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}
.dp-tutorial .dp-lines div {
  height: 4px;
  background: #fff;
  border-radius: 1px;
  opacity: 0.9;
}
.dp-tutorial .dp-lines div:last-child {
  width: 60%;
  opacity: 0.6;
}

/* — Podcast — */
.dp-podcast {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a0a2e, #2d1b4e);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px;
}
.dp-podcast .dp-mic {
  width: 8px;
  height: 20px;
  background: #fff;
  border-radius: 4px 4px 0 0;
  flex-shrink: 0;
  position: relative;
}
.dp-podcast .dp-mic::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 6px;
  background: #fff;
}
.dp-podcast .dp-waves {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 100%;
}
.dp-podcast .dp-waves div {
  width: 3px;
  background: #ff4500;
  border-radius: 2px;
}
.dp-podcast .dp-waves div:nth-child(1) {
  height: 30%;
}
.dp-podcast .dp-waves div:nth-child(2) {
  height: 60%;
}
.dp-podcast .dp-waves div:nth-child(3) {
  height: 90%;
}
.dp-podcast .dp-waves div:nth-child(4) {
  height: 50%;
}
.dp-podcast .dp-waves div:nth-child(5) {
  height: 70%;
}

/* — News — */
.dp-news {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #0d1b3e);
  position: relative;
}
.dp-news .dp-banner {
  position: absolute;
  top: 25%;
  left: 0;
  right: 0;
  height: 30%;
  background: #e52d27;
}
.dp-news .dp-ticker {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18%;
  background: rgba(255, 255, 255, 0.15);
}

/* — Vlog — */
.dp-vlog {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ffe4e1, #ffd1c1);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
}
[data-theme="dark"] .dp-vlog {
  background: linear-gradient(135deg, #2e1a1a, #3e2a1a);
}
.dp-vlog .dp-frame {
  width: 55%;
  height: 75%;
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.5);
  position: relative;
}
[data-theme="dark"] .dp-vlog .dp-frame {
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.08);
}
.dp-vlog .dp-lines {
  position: absolute;
  bottom: 8%;
  right: 8%;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dp-vlog .dp-lines div {
  height: 3px;
  background: #ff4500;
  border-radius: 1px;
}
.dp-vlog .dp-lines div:first-child {
  width: 24px;
}
.dp-vlog .dp-lines div:last-child {
  width: 16px;
  opacity: 0.6;
}

/* — Versus — */
.dp-versus {
  width: 100%;
  height: 100%;
  display: flex;
  position: relative;
  overflow: hidden;
}
.dp-versus .dp-side-left {
  flex: 1;
  background: #ff4500;
}
.dp-versus .dp-side-right {
  flex: 1;
  background: #1a1a2e;
}
.dp-versus .dp-vs {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  z-index: 1;
}

/* — Countdown — */
.dp-countdown {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #0a0a0a, #1a1a2e);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dp-countdown .dp-number {
  font-size: 24px;
  font-weight: 900;
  color: #ff4500;
  line-height: 1;
}
.dp-countdown .dp-arrow {
  position: absolute;
  right: 12%;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid #ffd700;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

/* — Review — */
.dp-review {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
}
.dp-review .dp-stars {
  font-size: 8px;
  color: #ffd700;
  letter-spacing: 1px;
  line-height: 1;
}
.dp-review .dp-lines {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 70%;
}
.dp-review .dp-lines div {
  height: 3px;
  background: #fff;
  border-radius: 1px;
}
.dp-review .dp-lines div:last-child {
  width: 60%;
  opacity: 0.6;
}

/* — Collage — */
.dp-collage {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  background: #111;
  position: relative;
}
.dp-collage .dp-cell {
  background: #333;
}
.dp-collage .dp-cell:nth-child(1) {
  background: #2a3a4a;
}
.dp-collage .dp-cell:nth-child(2) {
  background: #3a2a4a;
}
.dp-collage .dp-cell:nth-child(3) {
  background: #4a3a2a;
}
.dp-collage .dp-cell:nth-child(4) {
  background: #2a4a3a;
}
.dp-collage .dp-overlay-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  height: 25%;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 2px;
}

/* ============================================================
   Palette inline — barre sous les textes
   ============================================================ */
.canvas-tools-row--palette {
  align-items: center;
  gap: 1rem;
  padding: 0.625rem 1.125rem;
}

.palette-grid-inline {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.palette-opt {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  padding: 0.3rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
  background: var(--surface-2);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}
.palette-opt:hover {
  border-color: var(--accent);
  color: var(--text);
}
.palette-opt.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}
.palette-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.palette-opt:has(input:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.palette-swatch-sm {
  display: flex;
  width: 36px;
  height: 16px;
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.palette-swatch-sm span {
  flex: 1;
  display: block;
}

/* ============================================================
   Preview area
   ============================================================ */
.preview-area {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.preview-header h2 {
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.preview-size {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.1rem 0.5rem;
  border-radius: 100px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.625rem 1.25rem;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition),
    box-shadow var(--transition);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent);
  font-family: inherit;
}
.btn-primary:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--accent) 50%, transparent);
}
.btn-primary:active {
  transform: translateY(0);
}

.canvas-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  line-height: 0;
}

#thumbnailCanvas {
  width: 100%;
  height: auto;
  display: block;
  border-radius: calc(var(--radius) - 1px);
}

.preview-info {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

/* ============================================================
   Canvas tools — barre sous le canvas
   ============================================================ */
.canvas-tools {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.canvas-tools-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1.125rem;
  min-height: 60px;
}

.canvas-tools-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  flex-shrink: 0;
  white-space: nowrap;
}

/* Grille 3 champs texte sous le canvas */
.canvas-tools-row--texts {
  align-items: flex-start;
  padding: 0.875rem 1.125rem;
}

.canvas-tools-fields {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 2fr 2fr 1fr;
  gap: 0.5rem 0.875rem;
}
.canvas-tools-fields .form-group {
  margin-bottom: 0;
}

/* ============================================================
   Footer
   ============================================================ */
footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: auto;
}

/* ============================================================
   Grille options en 2 colonnes dans le panneau droit
   ============================================================ */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem 0.75rem;
  margin-bottom: 1rem;
}
.options-grid .checkbox-label {
  margin-bottom: 0;
}

/* ============================================================
   Onglets (panneaux gauche + droit)
   ============================================================ */
.tabs-nav {
  display: flex;
  border-bottom: 2px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
  /* Reste collé en haut du panneau quand on scrolle */
  position: sticky;
  top: 0;
  z-index: 2;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 0.5rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  transition:
    color var(--transition),
    border-color var(--transition),
    background var(--transition);
}

.tab-btn i {
  font-size: 0.8rem;
}

.tab-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  background: var(--surface);
}

.tab-panel {
  display: flex;
  flex-direction: column;
}

.tab-panel.hidden {
  display: none;
}

/* ============================================================
   Responsive
   ============================================================ */

/* ——— 4K / 2160p+ : panneaux et typographie plus larges ——— */
@media (min-width: 2200px) {
  html { font-size: 18px; }
  .workspace {
    max-width: 2200px;
    grid-template-columns: 360px 1fr 380px;
    gap: 1.75rem;
    padding: 1.75rem 2rem;
  }
  .header-inner { max-width: 2200px; }
  .design-grid { gap: 0.75rem; }
  .channel-grid { max-height: 420px; }
}

/* ——— Grand desktop 1600-2200px : un peu plus d'espace ——— */
@media (min-width: 1600px) and (max-width: 2199px) {
  .workspace {
    grid-template-columns: 300px 1fr 330px;
  }
  .channel-grid { max-height: 360px; }
}

/* ——— Tablette paysage (1100-1440px) ——— */
@media (max-width: 1440px) {
  .workspace {
    grid-template-columns: 260px 1fr 260px;
  }
  .design-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ——— Tablette portrait (900-1100px) ——— */
@media (max-width: 1100px) {
  .workspace {
    grid-template-columns: 248px 1fr;
    grid-template-areas:
      "panel-left preview"
      "panel-right panel-right";
  }
  .panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  /* Le panneau droit avec onglets reste en flex colonne */
  .panel-right {
    display: flex;
    flex-direction: column;
  }
  /* Les tab-panels prennent toute la largeur */
  .panel-right .tab-panel {
    width: 100%;
  }
  /* Tabs-nav n'a plus besoin d'être sticky quand le panneau n'est plus scrollable */
  .tabs-nav {
    position: static;
  }
}

/* ——— Mobile (< 900px) ——— */
@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "panel-left"
      "preview"
      "panel-right";
    padding: 1rem;
  }
  .panel {
    position: static;
    max-height: none;
    overflow-y: visible;
  }
  .panel-right {
    display: flex;
    flex-direction: column;
  }
  /* Design grid : 3 colonnes sur mobile large, suffisant pour les 13 designs */
  .design-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .canvas-tools-fields {
    grid-template-columns: 1fr 1fr;
  }
}

/* ——— Canvas-tools : repli vertical sous 600px ——— */
@media (max-width: 600px) {
  .canvas-tools-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.625rem;
    padding: 0.875rem 1rem;
  }
  .canvas-tools-fields {
    grid-template-columns: 1fr;
    width: 100%;
  }
}

/* ——— Petit mobile (< 540px) ——— */
@media (max-width: 540px) {
  .design-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .palette-grid-inline {
    gap: 0.35rem;
  }
  .palette-opt span { display: none; } /* Cache les labels texte sur petit écran */
  .options-grid {
    grid-template-columns: 1fr;
  }
  .header-inner {
    padding: 0.75rem 1rem;
  }
  .workspace {
    padding: 0.75rem;
  }
  /* Onglets plus compacts sur petit écran */
  .tab-btn {
    padding: 0.5rem 0.25rem;
    font-size: 0.72rem;
    gap: 0.25rem;
  }
  .tab-btn i {
    font-size: 0.7rem;
  }
}

/* ============================================================
   Channel grid
   ============================================================ */
.channel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  max-height: 300px;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.channel-grid::-webkit-scrollbar {
  width: 4px;
}
.channel-grid::-webkit-scrollbar-track {
  background: transparent;
}
.channel-grid::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.channel-option {
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  padding: 0.375rem 0.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  transition:
    border-color var(--transition),
    background var(--transition),
    box-shadow var(--transition);
  background: var(--surface-2);
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}
.channel-option:hover {
  border-color: var(--accent);
  color: var(--text);
}
.channel-option.selected {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  color: var(--text);
  box-shadow: 0 0 0 1px var(--accent);
}

.channel-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.channel-option:has(input:focus-visible) {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.channel-logo-wrap {
  background: #ffffff;
  border-radius: 4px;
  width: 100%;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 2px 4px;
}
.channel-logo-wrap img {
  max-width: 100%;
  max-height: 26px;
  object-fit: contain;
}

.channel-none-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 32px;
  font-size: 1.1rem;
  color: var(--text-muted);
  border-radius: 4px;
  border: 1.5px dashed var(--border);
}

/* Date input */
input[type="date"] {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9375rem;
  font-family: inherit;
  transition:
    border-color var(--transition),
    box-shadow var(--transition);
  color-scheme: light dark;
}
input[type="date"]:hover {
  border-color: var(--text-muted);
}
input[type="date"]:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus-ring) 25%, transparent);
}

#dateGroup {
  transition: opacity var(--transition);
}
#dateGroup.hidden {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================================
   Upload zone
   ============================================================ */
.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 1.25rem 0.75rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface-2);
  transition:
    border-color var(--transition),
    background var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.upload-zone p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

/* SVG et textes passent devant l'input absolu (qui reste transparent) */
.upload-zone > svg,
.upload-zone > p {
  position: relative;
  z-index: 1;
  pointer-events: none;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 2; /* au-dessus des éléments → capture les clics */
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
  margin-top: 0.625rem;
}
.upload-preview img {
  width: 80px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.upload-preview-info {
  flex: 1;
  min-width: 0;
}
.upload-filename {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-remove {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  flex-shrink: 0;
  font-family: inherit;
  transition:
    background var(--transition),
    color var(--transition),
    border-color var(--transition);
}
.btn-remove:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ============================================================
   Corner picker (sélecteur de position logo/date)
   ============================================================ */
.corner-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 4px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  aspect-ratio: 2.8 / 1;
  background: var(--surface-2);
  margin-top: 0.375rem;
}

.corner-opt {
  display: flex;
  cursor: pointer;
  border-radius: 4px;
  transition: background var(--transition);
}
.corner-opt:nth-child(1) {
  align-items: flex-start;
  justify-content: flex-start;
  padding: 4px;
}
.corner-opt:nth-child(2) {
  align-items: flex-start;
  justify-content: flex-end;
  padding: 4px;
}
.corner-opt:nth-child(3) {
  align-items: flex-end;
  justify-content: flex-start;
  padding: 4px;
}
.corner-opt:nth-child(4) {
  align-items: flex-end;
  justify-content: flex-end;
  padding: 4px;
}

.corner-opt input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.corner-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  display: block;
  transition:
    background var(--transition),
    border-color var(--transition),
    transform var(--transition);
}
.corner-opt:hover .corner-dot {
  border-color: var(--accent);
  transform: scale(1.2);
}
.corner-opt.selected .corner-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.corner-opt:has(input:focus-visible) .corner-dot {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}
