:root {
    --bg: #111a20;
    --surface: #18222e;
    --surface-2: #1f2b3a;
    --surface-3: #283749;
    --border: #2a3a4d;
    --border-strong: #3a4e66;
    --text: #e8eef4;
    --text-2: #a9b8c8;
    --text-3: #7a8ca0;
    --accent: #e94560;
    --accent-hover: #ff5a75;
    --accent-soft: rgba(233, 69, 96, .14);
    --danger: #ff8a9c;
    --focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
    --radius: 8px;
    --radius-lg: 12px;
    --ease: .15s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'proxima-nova', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; font-size: 14px; background: var(--bg); color: var(--text); height: 100vh; height: 100dvh; overflow: hidden; user-select: none; -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%; }
button, input, select, textarea, [contenteditable="true"] { font: inherit; color: inherit; }
button { border: none; background: none; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: none; box-shadow: var(--focus); }
[hidden] { display: none !important; }

.icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ── Structure ── */
.app-shell { --left-w: 320px; --right-w: 340px; display: grid; grid-template-columns: var(--left-w) minmax(0, 1fr) var(--right-w); width: 100vw; height: 100vh; height: 100dvh; }
.sidebar { position: relative; background: var(--surface); display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.left-sidebar { border-right: 1px solid var(--border); }
.right-sidebar { border-left: 1px solid var(--border); }
/* Poignée de redimensionnement posée sur la bordure intérieure des panneaux */
.sidebar-resizer { position: absolute; top: 0; bottom: 0; width: 8px; z-index: 20; cursor: col-resize; touch-action: none; }
.left-sidebar .sidebar-resizer { right: -5px; }
.right-sidebar .sidebar-resizer { left: -5px; }
.sidebar-resizer::after { content: ''; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; background: transparent; transition: background var(--ease); }
.sidebar-resizer:hover::after, .sidebar-resizer.dragging::after { background: var(--accent); }
body.resizing-sidebar { cursor: col-resize; }
body.resizing-sidebar * { cursor: col-resize !important; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 20px 20px; }
.sidebar-footer { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 16px 20px 20px; border-top: 1px solid var(--border); }
.footer-actions { display: flex; gap: 8px; }
/* Bouton d'ouverture de la file : visible seulement quand la file devient un tiroir */
.queue-open-btn { display: none; position: relative; width: 42px; height: 42px; }
.queue-badge { position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; line-height: 20px; text-align: center; box-shadow: 0 0 0 2px var(--surface); }
.queue-badge.bump { animation: badge-bump .45s ease-out; }
@keyframes badge-bump { 0% { transform: scale(1); } 35% { transform: scale(1.35); } 100% { transform: scale(1); } }
.queue-close-btn { display: none; }
.queue-backdrop { display: none; position: fixed; inset: 0; z-index: 40; background: rgba(8, 12, 18, .6); opacity: 0; transition: opacity .25s ease; }

.brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid var(--border); }
.brand-logo { width: 28px; height: 28px; object-fit: contain; border-radius: 6px; }
.brand-name { font-size: 1rem; font-weight: 700; letter-spacing: .2px; }
/* ── Sections & champs ── */
.panel-section { display: flex; flex-direction: column; gap: 16px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.panel-section:last-child { border-bottom: none; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: -6px; }
.section-head .btn-link { align-self: auto; display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px; font-size: .75rem; }
.section-head .btn-link .icon { width: 13px; height: 13px; }
.btn-link-danger:hover:not(:disabled) { color: var(--danger); }
.btn-link:disabled { visibility: hidden; }
#resetBtn:disabled { visibility: visible; opacity: .4; }
.section-title { font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .9px; color: var(--text-3); }
.field { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.field-label { font-size: .82rem; font-weight: 600; color: var(--text-2); }
.field-inline { display: flex; gap: 8px; }
.field-inline-toggle { flex-direction: row; align-items: center; justify-content: space-between; cursor: pointer; }

.text-input, .rich-editor, .value-input { width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--text); outline: none; transition: border-color var(--ease), background var(--ease); }
.text-input { height: 38px; padding: 0 12px; font-size: .85rem; min-width: 0; }
.text-input:hover, .rich-editor:hover, .value-input:hover { border-color: #4b6380; }
.text-input:focus, .rich-editor:focus, .value-input:focus { border-color: var(--accent); background: #223246; box-shadow: none; }
.text-input::placeholder { color: var(--text-3); }
/* Champ avec préfixe fixe (ex. « © » du copyright) */
.prefixed-input { position: relative; }
.prefixed-input .input-prefix { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-2); font-weight: 700; pointer-events: none; }
.prefixed-input .text-input { padding-left: 30px; }

.rich-editor { min-height: 92px; max-height: 220px; overflow-y: auto; padding: 10px 12px; line-height: 1.5; cursor: text; user-select: text; }
.rich-editor:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
/* Jauge de longueur du texte : remplissage (--pos) et repère de limite idéale (--limit) posés en JS */
.length-guide { --level: #7fd8a4; display: flex; flex-direction: column; gap: 6px; margin-top: -2px; }
.length-guide[data-level="near"] { --level: #c8d98a; }
.length-guide[data-level="long"] { --level: #ffc46b; }
.length-guide[data-level="too-long"] { --level: var(--danger); }
.length-track { position: relative; height: 3px; border-radius: 2px; background: var(--surface-3); }
.length-fill { position: absolute; inset: 0 auto 0 0; width: var(--pos, 0); border-radius: inherit; background: var(--level); transition: width .2s ease, background var(--ease); }
.length-limit { position: absolute; top: -3px; left: var(--limit); width: 2px; height: 9px; border-radius: 1px; background: var(--text-3); transform: translateX(-50%); }
.length-info { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .72rem; line-height: 1.3; }
.length-status { display: inline-flex; align-items: center; gap: 6px; min-width: 0; color: var(--text-2); }
.length-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--level); transition: background var(--ease); }
.length-guide[data-level="long"] .length-status, .length-guide[data-level="too-long"] .length-status { color: var(--level); font-weight: 600; }
.length-count { color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.length-guide[data-level="long"] .length-count, .length-guide[data-level="too-long"] .length-count { color: var(--level); font-weight: 700; }
.rich-editor .highlight-token { background: rgba(228, 0, 43, .9); color: #fff; padding: 0 .08em; box-decoration-break: clone; -webkit-box-decoration-break: clone; }

/* ── Boutons ── */
.btn { height: 42px; padding: 0 16px; border-radius: var(--radius); font-size: .88rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; transition: background var(--ease), box-shadow var(--ease), color var(--ease); }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 2px 10px rgba(233, 69, 96, .25); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: 0 4px 16px rgba(233, 69, 96, .35); }
.btn-primary:disabled { background: var(--surface-3); color: var(--text-3); box-shadow: none; }

.btn-ghost, .toolbar-btn { height: 34px; padding: 0 12px; border-radius: var(--radius); display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; font-weight: 600; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); transition: background var(--ease), color var(--ease), border-color var(--ease); }
.btn-ghost:hover, .toolbar-btn:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.toolbar-btn:disabled { opacity: .4; }
.btn-ghost[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.btn-sm { height: 30px; font-size: .78rem; }

.btn-icon { width: 38px; height: 38px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: var(--radius); color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); transition: background var(--ease), color var(--ease); }
.btn-icon:hover:not(:disabled) { background: var(--surface-3); color: var(--text); }
.btn-icon:disabled { opacity: .4; }

.btn-link { align-self: center; padding: 4px 8px; border-radius: 6px; font-size: .8rem; color: var(--text-3); transition: color var(--ease); }
.btn-link:hover:not(:disabled) { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

.editor-toolbar { display: flex; gap: 8px; }

/* ── Contrôles segmentés ── */
.segmented-control { display: flex; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 3px; }
.segment-btn { flex: 1; height: 32px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; color: var(--text-2); font-size: .82rem; font-weight: 600; transition: background var(--ease), color var(--ease); }
.segment-btn:hover:not(.active) { background: var(--surface-3); color: var(--text); }
.segment-btn.active { background: var(--accent); color: #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.swatch { width: 12px; height: 12px; border-radius: 50%; background: var(--swatch); box-shadow: 0 0 0 2px rgba(255, 255, 255, .85); }

.format-previews { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.format-box { height: 84px; padding: 10px 4px 8px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 2px; transition: border-color var(--ease), background var(--ease); }
.format-box:hover { border-color: #4b6380; }
.format-box.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.format-shape { background: var(--text-3); border-radius: 2px; margin-bottom: 6px; transition: background var(--ease); }
.format-box.active .format-shape { background: var(--accent); }
.format-shape.square { width: 22px; height: 22px; }
.format-shape.portrait { width: 20px; height: 25px; }
.format-shape.landscape { width: 30px; height: 16px; }
.format-ratio { font-size: .8rem; font-weight: 700; color: var(--text); }
.format-size { font-size: .65rem; color: var(--text-3); }

.toggle-switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.toggle-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle-slider { position: absolute; inset: 0; background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: 999px; transition: background var(--ease), border-color var(--ease); pointer-events: none; }
.toggle-slider::before { content: ''; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform var(--ease); }
.toggle-switch input:checked + .toggle-slider { background: var(--accent); border-color: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow: var(--focus); }

/* ── Zone de travail (DA d'origine conservée) ── */
.main-area { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 18px 22px; min-width: 0; overflow: hidden; position: relative; background: #131E23; }
.canvas-wrapper { position: relative; flex-shrink: 0; background: #0e1520; border-radius: 12px; overflow: hidden; box-shadow: 0 8px 40px rgba(0, 0, 0, .6); border: 2px solid #1e2d40; transition: border-color .4s, box-shadow .4s; cursor: default; }
.canvas-wrapper.drag-over { border-color: #e94560; box-shadow: 0 0 40px rgba(233, 69, 96, .25), 0 8px 40px rgba(0, 0, 0, .6); }
/* Avec une image, le doigt déplace / pince l'image au lieu de faire défiler la page */
.canvas-wrapper.has-image { cursor: grab; touch-action: none; }
.canvas-wrapper.has-image:active { cursor: grabbing; }

.drop-zone { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.drop-zone.hidden { display: none; }
.drop-zone:focus-visible { box-shadow: inset 0 0 0 3px #e94560; }
.cta-bubble { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 36px 48px 28px; border-radius: 20px; background: rgba(12, 18, 28, .85); backdrop-filter: blur(8px); border: 1px solid rgba(255, 255, 255, .06); }
.drop-cta { width: 110px; height: 110px; border-radius: 50%; background: linear-gradient(145deg, #1e3050, #192840); border: 2px solid #2a4a6e; display: flex; align-items: center; justify-content: center; cursor: pointer; animation: pulse 3s ease-in-out infinite; }
.drop-icon svg { width: 40px; height: 40px; stroke: #4a6a8e; }
.drop-label { font-size: .82rem; color: #c0d0e0; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(233, 69, 96, .4); } 70% { box-shadow: 0 0 0 15px rgba(233, 69, 96, 0); } 100% { box-shadow: 0 0 0 0 rgba(233, 69, 96, 0); } }

#bgCanvas, #overlayImg, #gradientOverlay, #titleOverlay { position: absolute; inset: 0; width: 100%; height: 100%; }
#bgCanvas { z-index: 1; }
#gradientOverlay { top: auto; bottom: 0; height: 60%; background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .85)); z-index: 2; pointer-events: none; display: none; }
#gradientOverlay.visible { display: block; }
#overlayImg { z-index: 3; pointer-events: none; }
#overlayImg:not([src]) { visibility: hidden; }
#titleOverlay { z-index: 4; pointer-events: none; }
#titleCanvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#exportCanvas { display: none; }
/* Alerte flou : affichée sur l'aperçu uniquement (jamais exportée), sans décaler la mise en page */
.quality-warning { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 11; width: max-content; max-width: calc(100% - 24px); padding: 7px 12px; border-radius: 8px; background: rgba(40, 24, 8, .92); border: 1px solid #c77a1a; color: #ffc46b; font-size: .75rem; font-weight: 600; line-height: 1.35; text-align: center; white-space: pre-line; pointer-events: none; }

.bottom-bar { display: none; flex-direction: column; align-items: stretch; gap: 12px; background: #1a2332; padding: 12px 16px; border-radius: 10px; border: 1px solid #263548; width: min(100%, 940px); }
.bottom-bar.visible { display: flex; }
.canvas-toolbar { display: flex; justify-content: center; gap: 10px; }

.btn-advanced { height: 40px; padding: 0 20px; border-radius: 8px; background: #2a3545; color: #d0dae6; border: 1px solid #36465a; font-weight: 700; font-size: .85rem; transition: all .2s; }
.btn-advanced:hover { background: #364860; color: #fff; }
.btn-advanced[aria-expanded="true"] { background: #e94560; border-color: #e94560; color: #fff; }
.btn-small { height: 34px; padding: 0 12px; border-radius: 8px; background: #2a3545; color: #d0dae6; border: 1px solid #36465a; transition: all .2s; }
.btn-small:hover:not(:disabled) { background: #364860; }
.btn-small:disabled { opacity: .4; }

.advanced-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 22px; padding-top: 6px; border-top: 1px solid #2e3e50; margin-top: 2px; }
.advanced-row { display: flex; flex-direction: column; gap: 6px; }
.advanced-row label { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: #8aa0b3; }
.advanced-row label small { text-transform: none; letter-spacing: 0; color: #6b7d93; font-weight: 600; }
.advanced-slider { display: grid; grid-template-columns: 1fr 72px 22px; align-items: center; gap: 8px; }
.advanced-slider input[type="range"] { width: 100%; accent-color: #e94560; cursor: pointer; }
.main-area .value-input { height: 34px; padding: 0 10px; text-align: right; border: 1px solid #2e4562; background: #1e3a5f; color: #d0dae6; }
.main-area .value-input:hover { border-color: #3d6a9e; }
.main-area .value-input:focus { border-color: #e94560; background: #22436e; }
.unit { color: #8899aa; font-size: .75rem; }
.advanced-footer { grid-column: 1 / -1; display: flex; justify-content: flex-end; }

.info-bar { min-height: 1.5em; font-size: .82rem; color: #8aa0b3; max-width: 90ch; text-align: center; line-height: 1.5; }
.info-bar.error { color: #ff8a9c; }

/* ── File d'attente ── */
.queue-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.queue-header h2 { font-size: 1rem; font-weight: 700; }
.queue-header p { font-size: .78rem; color: var(--text-3); margin-top: 2px; }
.queue-toolbar { display: flex; justify-content: flex-end; padding: 8px 14px 0; }
.queue-toolbar .btn-link { align-self: auto; }

.queue-grid { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 8px; padding: 8px 20px 16px; }
.queue-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px 32px; text-align: center; color: var(--text-3); }
.queue-empty .icon { width: 32px; height: 32px; stroke-width: 1.5; margin-bottom: 4px; }
.queue-empty p { font-size: .88rem; font-weight: 600; color: var(--text-2); }
.queue-empty span { font-size: .78rem; line-height: 1.45; }

.queue-card { flex-shrink: 0; display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 10px; align-items: center; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; transition: border-color var(--ease), background var(--ease); }
.queue-card.selected { border-color: rgba(233, 69, 96, .55); background: #22293a; }
.queue-card.editing { border-color: #ffc46b; box-shadow: 0 0 0 1px #ffc46b; }
.queue-card.editing .queue-sub { color: #ffc46b; }
.queue-edit:hover { color: #ffc46b; }
.queue-check-wrap { position: relative; display: inline-flex; cursor: pointer; }
.queue-check-wrap input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.queue-check-ui { width: 18px; height: 18px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--bg); display: inline-flex; align-items: center; justify-content: center; color: transparent; transition: background var(--ease), border-color var(--ease); }
.queue-check-ui .icon { width: 12px; height: 12px; stroke-width: 3; }
.queue-check-wrap input:checked + .queue-check-ui { background: var(--accent); border-color: var(--accent); color: #fff; }
.queue-check-wrap input:focus-visible + .queue-check-ui { box-shadow: var(--focus); }
.queue-thumb { height: 52px; width: 52px; object-fit: cover; border-radius: 6px; background: var(--bg); border: 1px solid var(--border); }
.queue-meta { min-width: 0; }
.queue-name { font-size: .78rem; font-weight: 700; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-sub { font-size: .7rem; color: var(--text-3); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-summary { font-size: .7rem; color: var(--text-2); line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-actions { display: flex; gap: 4px; }
.queue-icon-btn { width: 28px; height: 28px; border-radius: 6px; color: var(--text-3); display: inline-flex; align-items: center; justify-content: center; transition: background var(--ease), color var(--ease); }
.queue-icon-btn:hover { background: var(--surface-3); color: var(--text); }
.queue-remove:hover { color: var(--danger); }

/* ── Boîte de confirmation ── */
.confirm-dialog { margin: auto; width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border-strong); border-radius: var(--radius-lg); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .55); }
.confirm-dialog::backdrop { background: rgba(8, 12, 18, .65); backdrop-filter: blur(3px); }
.confirm-dialog[open] { animation: confirm-in .18s ease-out; }
@keyframes confirm-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.confirm-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px 16px; padding: 22px 22px 18px; }
.confirm-icon { width: 40px; height: 40px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: rgba(255, 196, 107, .12); border: 1px solid rgba(255, 196, 107, .35); color: #ffc46b; }
.confirm-icon .icon { width: 20px; height: 20px; }
.confirm-text { display: flex; flex-direction: column; gap: 6px; padding-top: 2px; }
.confirm-title { font-size: .95rem; font-weight: 700; line-height: 1.3; }
.confirm-message { font-size: .82rem; line-height: 1.5; color: var(--text-2); }
.confirm-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; padding-top: 14px; margin-top: 4px; border-top: 1px solid var(--border); }
.confirm-actions .btn-ghost { height: 38px; padding: 0 16px; }
.confirm-actions .btn { width: auto; height: 38px; }

/* ── Écrans moyens (tablette, petit portable) : la file d'attente devient un tiroir ── */
@media (max-width: 1100px) {
    .app-shell { grid-template-columns: var(--left-w) minmax(0, 1fr); }
    .right-sidebar { position: fixed; top: 0; right: 0; bottom: 0; z-index: 50; width: min(400px, 100%); box-shadow: -12px 0 40px rgba(0, 0, 0, .45); transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility 0s linear .25s; }
    .app-shell.queue-open .right-sidebar { transform: none; visibility: visible; transition: transform .25s ease; }
    .queue-backdrop { display: block; pointer-events: none; }
    .app-shell.queue-open .queue-backdrop { opacity: 1; pointer-events: auto; }
    .right-sidebar .sidebar-resizer { display: none; }
    .queue-open-btn, .queue-close-btn { display: inline-flex; }
    .queue-heading { flex: 1; min-width: 0; }
    .queue-header { gap: 8px; }
    .right-sidebar .sidebar-footer { padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}

/* ── Mobile (portrait, ou paysage peu haut) : une seule colonne qui défile, action principale collée en bas ── */
@media (max-width: 760px), (max-width: 1100px) and (max-height: 500px) {
    body { height: auto; min-height: 100vh; min-height: 100dvh; overflow-x: hidden; overflow-y: auto; }
    /* Place réservée en bas pour la barre d'action fixe (hauteur mesurée en JS) */
    .app-shell { display: flex; flex-direction: column; width: 100%; height: auto; min-height: 100vh; min-height: 100dvh; padding-bottom: var(--mobile-footer-h, 120px); }
    /* Le panneau de gauche s'efface : ses blocs s'intercalent autour de l'aperçu */
    .left-sidebar { display: contents; }
    .sidebar-resizer { display: none; }
    .brand { order: 0; padding: calc(12px + env(safe-area-inset-top)) 16px 12px; background: var(--surface); }
    .main-area { order: 1; justify-content: flex-start; gap: 12px; padding: 16px; overflow: visible; }
    .sidebar-scroll { order: 2; flex: none; overflow: visible; padding: 0 16px 8px; background: var(--surface); }
    .left-sidebar > .sidebar-footer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 4px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); box-shadow: 0 -8px 24px rgba(0, 0, 0, .35); }
    .left-sidebar > .sidebar-footer .btn-link { padding: 0 20px; }

    body.queue-locked { overflow: hidden; } /* la page ne défile pas derrière le tiroir ouvert */
    .queue-header { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; }
    .queue-toolbar { padding: 4px 16px 0; }
    .queue-grid { padding: 8px 16px 16px; }
    .right-sidebar .sidebar-footer { padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); }

    .rich-editor { min-height: 110px; max-height: 260px; }
    .panel-section { padding: 16px 0; }
    .cta-bubble { gap: 10px; padding: 24px 28px 20px; }
    .drop-cta { width: 84px; height: 84px; }
    .bottom-bar { width: 100%; padding: 10px; gap: 10px; }
    .canvas-toolbar { flex-wrap: wrap; gap: 8px; }
    .btn-advanced { flex: 1 1 auto; padding: 0 12px; font-size: .82rem; }
    .advanced-panel { grid-template-columns: 1fr; gap: 16px; }
    .btn-small { width: 100%; }
    .info-bar { font-size: .8rem; }
    .confirm-actions .btn, .confirm-actions .btn-ghost { flex: 1; justify-content: center; }
}

/* ── Tactile (téléphone, tablette) : toutes les cibles font au moins 44 × 44 px (Apple HIG / WCAG 2.5.5),
   8 px d'écart entre cibles voisines, 16 px minimum dans les champs (sinon iOS zoome au focus) ── */
@media (pointer: coarse), (max-width: 760px), (max-width: 1100px) and (max-height: 500px) {
    .btn { height: 48px; }
    .btn-icon, .queue-open-btn { width: 44px; height: 44px; }
    /* Bordure redimensionnable (tablette) : zone de prise de 24 px, trait visible sans survol */
    .sidebar-resizer { width: 24px; }
    .left-sidebar .sidebar-resizer { right: -12px; }
    .right-sidebar .sidebar-resizer { left: -12px; }
    .sidebar-resizer::after { left: 11px; background: var(--border-strong); }
    .btn-link { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
    .section-head { margin-bottom: -12px; } /* compense la hauteur du lien « Effacer le texte » */
    .section-head .btn-link { min-height: 44px; padding: 0 8px; font-size: .8rem; }
    .segmented-control { gap: 4px; }
    .segment-btn { height: 44px; }
    .field-inline-toggle { min-height: 44px; }
    .toggle-switch { width: 52px; height: 30px; }
    .toggle-slider::before { width: 22px; height: 22px; }
    .toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }
    /* Boutons plus grands : ils passent à la ligne plutôt que de couper leur libellé */
    .editor-toolbar, .canvas-toolbar { flex-wrap: wrap; }
    .toolbar-btn { flex: 1 1 auto; justify-content: center; height: 44px; white-space: nowrap; }
    .btn-advanced { flex: 1 1 auto; white-space: nowrap; }
    .text-input, .rich-editor, .value-input { font-size: 16px; }
    .text-input { height: 44px; }
    .btn-advanced, .btn-small { height: 44px; }
    .main-area .value-input { height: 44px; }
    .advanced-panel { grid-template-columns: 1fr; } /* curseurs sur toute la largeur : plus faciles à régler au doigt */
    .advanced-slider { grid-template-columns: 1fr 76px 22px; gap: 10px; }
    .confirm-actions .btn, .confirm-actions .btn-ghost { height: 44px; }

    /* Curseurs : piste haute de 44 px et gros bouton à attraper au doigt */
    .advanced-slider input[type="range"] { -webkit-appearance: none; appearance: none; height: 44px; background: transparent; }
    .advanced-slider input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: #2e4562; }
    .advanced-slider input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 28px; height: 28px; margin-top: -11px; border-radius: 50%; background: #e94560; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
    .advanced-slider input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: #2e4562; }
    .advanced-slider input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: #e94560; }
    .advanced-slider input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; border-radius: 50%; background: #e94560; border: 3px solid #fff; }

    /* Cartes de la file : actions sur une 2e ligne pour garder des boutons de 44 px même sur petit écran */
    .queue-card { grid-template-columns: 44px auto minmax(0, 1fr); grid-template-rows: auto auto; gap: 4px 8px; padding: 8px; }
    .queue-check-wrap { grid-row: 1 / 3; width: 44px; height: 44px; align-items: center; justify-content: center; }
    .queue-check-ui { width: 24px; height: 24px; }
    .queue-thumb { grid-row: 1 / 3; align-self: center; }
    .queue-actions { justify-self: end; gap: 8px; }
    .queue-icon-btn { width: 44px; height: 44px; }
}

@media (max-width: 480px) {
    .right-sidebar { width: 100%; border-left: none; }
}

/* Section repliable « Déjà téléchargés » en bas de la file */
.queue-done { flex-shrink: 0; padding: 14px 4px 6px; text-align: center; font-size: .85rem; font-weight: 600; color: #7fd8a4; }
.queue-exported { flex-shrink: 0; display: flex; flex-direction: column; gap: 8px; margin-top: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
.queue-exported-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.queue-exported-head .btn-link { align-self: auto; }
.queue-exported-toggle { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 2px; border-radius: 6px; font-size: .8rem; font-weight: 600; color: var(--text-2); transition: color var(--ease); }
.queue-exported-toggle:hover { color: var(--text); }
.queue-exported-toggle:focus-visible { outline: none; box-shadow: var(--focus); }
.queue-exported-chevron { width: 15px; height: 15px; transition: transform var(--ease); }
.queue-exported.open .queue-exported-chevron { transform: rotate(90deg); }
.queue-exported-count { min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--surface-3); font-size: .72rem; text-align: center; color: var(--text-2); }
.queue-card.exported { opacity: .65; transition: opacity var(--ease), border-color var(--ease), background var(--ease); }
.queue-card.exported:hover, .queue-card.exported:focus-within, .queue-card.exported.selected, .queue-card.exported.editing { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
    .right-sidebar, .queue-backdrop { transition: none !important; }
    .queue-badge.bump { animation: none; }}
