/* ============================== Thème éditeur ============================== */
:root {
  --canvas: #1e1e1e; --panel: #2c2c2c; --field: #383838; --hover: #404040; --line: #3e3e3e;
  --text: #e6e6e6; --mute: #9a9a9a; --dim: #6f6f6f; --accent: #0d99ff; --accent-2: #0b85de;
  --warn: #f5a623; --err: #f24822; --ok: #14ae5c;
  --r: 6px; --panel-w: 300px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; overflow: hidden; background: var(--canvas); color: var(--text);
  font: 12.5px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
button, input, select { font: inherit; color: inherit; }
svg.i { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code { font-family: ui-monospace, Menlo, monospace; }

/* ---------- Panneau gauche ---------- */
.panel {
  width: var(--panel-w); flex: none; display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line); min-height: 0;
}
.panel__head { padding: 14px 16px 12px; border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; justify-content: space-between; }
.brand b { font-size: 13px; letter-spacing: .01em; }
.brand .home {
  display: inline-flex; align-items: center; gap: 4px; margin-left: -6px; padding: 4px 8px 4px 4px; border-radius: var(--r);
  color: var(--text); font-size: 13px; font-weight: 600; text-decoration: none;
}
.brand .home:hover { background: var(--hover); }
.mode { font-size: 11px; color: var(--mute); margin-top: 2px; }
.mode.edit { color: var(--accent); }
.head-actions { display: flex; gap: 6px; margin-top: 12px; }
.panel__body { flex: 1; overflow-y: auto; }
.sec { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.sec h3 { margin: 0 0 10px; font-size: 11px; font-weight: 600; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.sec h3 small { font-weight: 400; color: var(--mute); }
.sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.f { display: block; margin-bottom: 10px; }
.f:last-child { margin-bottom: 0; }
.f > span { display: block; font-size: 11px; color: var(--mute); margin-bottom: 4px; }
.in {
  width: 100%; height: 30px; padding: 0 9px; border-radius: var(--r);
  background: var(--field); border: 1px solid transparent; outline: none;
}
.in:hover { border-color: var(--line); }
.in:focus { border-color: var(--accent); }
.in.bad { border-color: var(--err); }
.help { font-size: 11px; color: var(--mute); margin-top: 4px; overflow-wrap: anywhere; }
.help code { color: var(--text); font-size: 10.5px; }
.row { display: flex; gap: 8px; align-items: flex-start; }
.row > * { flex: 1; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 30px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--line);
  background: transparent; cursor: pointer; white-space: nowrap;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: .35; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; height: 38px; }
.btn.primary:hover:not(:disabled) { background: var(--accent-2); }
.btn.ghost { border-color: transparent; }
.btn.danger { color: #ff8a73; }
.btn.sm { height: 26px; padding: 0 8px; font-size: 11.5px; }
.btn[hidden] { display: none; }
.btn.wide { width: 100%; }
.stepper { display: flex; align-items: center; background: var(--field); border-radius: var(--r); height: 30px; }
.stepper button { width: 30px; height: 30px; border: 0; background: none; cursor: pointer; color: var(--mute); font-size: 15px; border-radius: var(--r); }
.stepper button:hover { color: var(--text); background: var(--hover); }
.stepper output { flex: 1; text-align: center; font-variant-numeric: tabular-nums; }
.seg { display: flex; background: var(--field); border-radius: var(--r); padding: 2px; }
.seg button { flex: 1; height: 26px; border: 0; background: none; border-radius: 4px; cursor: pointer; color: var(--mute); font-size: 11.5px; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.seg button.on { background: var(--hover); color: var(--text); box-shadow: 0 0 0 1px var(--line) inset; }
.color { display: flex; gap: 8px; align-items: center; }
.color input[type=color] { width: 30px; height: 30px; flex: none; padding: 0; border: 1px solid var(--line); border-radius: var(--r); background: none; cursor: pointer; }
.color input[type=color]::-webkit-color-swatch-wrapper { padding: 3px; }
.color input[type=color]::-webkit-color-swatch { border: 0; border-radius: 3px; }
.swatches { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.swatches button { width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--line); cursor: pointer; padding: 0; }
.swatches button:hover { outline: 1px solid var(--accent); outline-offset: 1px; }
.swatches .add { background: none; color: var(--mute); font-size: 13px; line-height: 1; }
.empty-sel { color: var(--mute); font-size: 11.5px; line-height: 1.5; }
.kv { display: flex; justify-content: space-between; gap: 8px; color: var(--mute); font-size: 11.5px; padding: 3px 0; }
.kv b { color: var(--text); font-weight: 500; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv b.gain { color: #5fd18b; }
.note { display: flex; gap: 6px; font-size: 11px; line-height: 1.4; padding: 7px 9px; border-radius: var(--r); margin-top: 8px; }
.note.warn { background: rgba(245,166,35,.12); color: #f7c26b; }
.note.info { background: rgba(13,153,255,.12); color: #7cc4ff; }
.note.err { background: rgba(242,72,34,.14); color: #ff9a83; }
.note.ok { background: rgba(20,174,92,.14); color: #6fdc9f; }
.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
/* Panneau de sélection : en-tête fixe avec retour aux réglages de la page */
.sel-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 8px;
  background: var(--panel); border-bottom: 1px solid var(--line); }
.sel-head .btn { flex: none; color: var(--mute); }
.sel-head .btn:hover { color: var(--text); }
.sel-title { font-size: 12.5px; font-weight: 600; display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.sel-title small { color: var(--mute); font-weight: 400; }
.tips ul { margin: 0; padding-left: 16px; color: var(--mute); font-size: 11.5px; line-height: 1.5; }
.tips li + li { margin-top: 4px; }
.tips b { color: var(--text); font-weight: 500; }
.panel__foot { padding: 12px 16px 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.kbd { font-size: 10.5px; color: var(--dim); text-align: center; }

/* Recadrage : image entière, cadre de la partie visible, le reste assombri */
.focus { position: relative; width: 100%; margin: 0 auto; background: #111; border-radius: var(--r);
  overflow: hidden; cursor: grab; touch-action: none; user-select: none; }
.focus.dragging { cursor: grabbing; }
.focus.no-crop { cursor: default; }
.focus img, .focus video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; pointer-events: none; -webkit-user-drag: none; }
.crop { position: absolute; pointer-events: none; outline: 1.5px solid #fff; outline-offset: -1px; }
.crop--desk { box-shadow: 0 0 0 9999px rgba(0,0,0,.62); }
.crop--mob { outline: 1.5px dashed #7cc4ff; }
.crop span { position: absolute; left: 4px; top: 3px; font-size: 9.5px; line-height: 1; padding: 2px 4px; border-radius: 3px;
  background: rgba(0,0,0,.6); color: #fff; }
.crop--mob span { left: auto; right: 4px; top: auto; bottom: 3px; color: #7cc4ff; }
.focus.no-crop .crop span { display: none; }

/* Fenêtre d'import : zone de dépôt, URL */
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 22px 16px; margin-top: 4px;
  border: 1.5px dashed #4a4a4a; border-radius: 10px; cursor: pointer; color: var(--mute); outline: none; transition: border-color .12s, background .12s; }
.drop svg.i { width: 26px; height: 26px; stroke-width: 1.3; color: var(--dim); }
.drop u { color: var(--accent); text-decoration: none; }
.drop small { font-size: 11px; color: var(--dim); }
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--accent); background: rgba(13,153,255,.07); }
.drop.over svg.i { color: var(--accent); }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0 10px; color: var(--dim); font-size: 11px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.url-row { display: flex; gap: 6px; }
.url-row .btn.primary { height: 30px; font-weight: 500; }
.help.err { color: #ff9a83; }

/* ---------- Zone d'aperçu ---------- */
.stage { flex: 1; position: relative; min-width: 0; display: flex; flex-direction: column; }
.stage__bar {
  height: 40px; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; border-bottom: 1px solid var(--line); color: var(--mute); font-size: 11.5px; white-space: nowrap;
}
.stage__bar .url { font-family: ui-monospace, Menlo, monospace; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.save-state { color: var(--dim); }
.bar-left { display: flex; align-items: center; gap: 10px; }
.seg--bar { padding: 2px; }
/* Poids de la page */
.stage__bar { position: relative; }
.weight { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--field); color: var(--text); font-size: 11.5px; font-variant-numeric: tabular-nums; cursor: pointer; }
.weight svg.i { width: 14px; height: 14px; }
.weight small { font-size: 10.5px; opacity: .7; }
.wp-title small { font-weight: 400; color: var(--mute); }
.weight:hover { border-color: #555; }
.weight.w-warn { background: rgba(245,166,35,.14); border-color: rgba(245,166,35,.5); color: #f7c26b; }
.weight.w-err { background: rgba(242,72,34,.16); border-color: rgba(242,72,34,.6); color: #ff9a83; }
b.w-ok { color: #6fdc9f !important; } b.w-warn { color: #f7c26b !important; } b.w-err { color: #ff9a83 !important; }
.weight-pop { position: absolute; z-index: 40; left: 14px; top: 44px; width: 300px; padding: 12px 14px; white-space: normal;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.55); color: var(--text); }
.wp-title { font-weight: 600; font-size: 12.5px; margin-bottom: 6px; }
.wp-sub { margin: 10px 0 4px; font-size: 11px; color: var(--mute); font-weight: 600; }
.wp-list { display: flex; flex-direction: column; gap: 2px; }
.wp-list button { display: flex; justify-content: space-between; gap: 10px; padding: 5px 6px; margin: 0 -6px; border: 0; border-radius: 6px;
  background: none; cursor: pointer; font-size: 11.5px; color: var(--mute); text-align: left; }
.wp-list button:hover { background: var(--hover); color: var(--text); }
.wp-list button span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wp-list button b { color: var(--text); font-weight: 500; flex: none; }
.wp-help { margin-top: 10px; line-height: 1.45; }
.seg--bar button { flex: none; padding: 0 10px; height: 24px; }
.canvas {
  flex: 1; overflow: auto; padding: 40px 40px 120px;
  background-color: var(--canvas);
  background-image: radial-gradient(#2f2f2f 1px, transparent 1px); background-size: 18px 18px;
}
.frame {
  position: relative; margin: 0 auto; overflow: hidden; background: #000;
  box-shadow: 0 0 0 1px var(--line), 0 18px 50px rgba(0,0,0,.45);
}
.frame iframe { position: absolute; left: 0; top: 0; border: 0; display: block; transform-origin: 0 0; background: transparent; }

/* ---------- Barre d'outils flottante ---------- */
/* Visible seulement quand une case est sélectionnée. Boutons : icône + petit libellé dessous. */
.ctx {
  position: absolute; z-index: 20; left: 50%; bottom: 22px; display: flex; align-items: center; gap: 2px; padding: 4px;
  background: #2c2c2c; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5), 0 1px 0 rgba(255,255,255,.04) inset;
  transform: translateX(-50%); white-space: nowrap;
  transition: opacity .14s ease, transform .14s ease;
}
.ctx.hide { opacity: 0; transform: translate(-50%, 10px); pointer-events: none; visibility: hidden; transition: opacity .14s ease, transform .14s ease, visibility 0s .14s; }
.ctx .count { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 8px 0 8px; color: var(--mute); font-size: 10.5px; line-height: 1.2; }
.ctx .count b { color: var(--text); font-weight: 600; font-size: 11.5px; }
.ctx .t {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-width: 54px; height: 46px; padding: 0 6px; border: 0; border-radius: 8px;
  background: none; cursor: pointer; color: var(--text); font-size: 10px; line-height: 1;
}
.ctx .t svg.i { width: 18px; height: 18px; }
.ctx .t span { color: var(--mute); }
.ctx .t:hover:not(:disabled) { background: var(--hover); }
.ctx .t:hover:not(:disabled) span { color: var(--text); }
.ctx .t:disabled { opacity: .3; cursor: not-allowed; }
.ctx .t.danger:hover:not(:disabled), .ctx .t.danger:hover:not(:disabled) span { color: #ff8a73; }
.ctx .sep { width: 1px; height: 28px; background: var(--line); margin: 0 3px; }
.ctx .link-edit { display: flex; gap: 4px; align-items: center; padding: 0 4px; }
.ctx .link-edit > svg.i { color: var(--mute); }
.ctx .link-edit .in { width: 280px; height: 32px; }
.ctx .link-edit .t { flex-direction: row; height: 32px; min-width: 0; padding: 0 10px; font-size: 11.5px; }
.ctx .link-edit .t span, .ctx .link-edit .t { color: var(--text); }

/* ---------- Vignette du déplacement d'une case ---------- */
.drag-ghost {
  position: fixed; z-index: 60; left: 0; top: 0; pointer-events: none; overflow: hidden;
  border-radius: 8px; border: 2px solid var(--accent); background: linear-gradient(135deg, #4a4a4a, #2b2b2b);
  box-shadow: 0 14px 34px rgba(0,0,0,.55), 0 2px 6px rgba(0,0,0,.4);
  transform: translate(-50%, -50%) rotate(-3deg) scale(.6); opacity: 0; transition: transform .12s ease, opacity .12s ease, border-color .12s;
}
.drag-ghost.on { transform: translate(-50%, -50%) rotate(-3deg) scale(1); opacity: .95; }
.drag-ghost img, .drag-ghost video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.drag-ghost .g-price { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-weight: 900; font-size: 22px;
  text-shadow: 0 2px 8px rgba(0,0,0,.6); }
.drag-ghost .g-label { position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); white-space: nowrap;
  padding: 3px 8px; border-radius: 10px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.drag-ghost.bad { border-color: var(--err); }
.drag-ghost.bad .g-label { background: var(--err); }

/* ---------- Dialogues & toast ---------- */
dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text);
  padding: 0; width: min(480px, 92vw); box-shadow: 0 24px 70px rgba(0,0,0,.6);
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.dlg__h { padding: 16px 18px 6px; font-weight: 600; font-size: 14px; }
.dlg__b { padding: 6px 18px 14px; color: var(--mute); line-height: 1.55; max-height: 65vh; overflow: auto; }
.dlg__b .big { font-family: ui-monospace, Menlo, monospace; color: var(--text); font-size: 13px; background: var(--field); padding: 8px 10px; border-radius: var(--r); margin: 6px 0 10px; word-break: break-all; }
.dlg__b b, .dlg__b strong { color: var(--text); }
.dlg__b a { color: var(--accent); }
.dlg__b ul { margin: 6px 0; padding-left: 18px; }
.dlg__f { padding: 12px 18px 16px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); }
.dlg__f .btn.primary { height: 32px; }
.toast {
  position: fixed; left: calc(50% + var(--panel-w) / 2); bottom: 100px; transform: translate(-50%, 16px);
  background: #383838; border: 1px solid #4a4a4a; color: var(--text); padding: 9px 14px; border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: .18s; z-index: 50; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-color: rgba(242,72,34,.6); }

/* Démo : logo du header */
.logo-field { display: flex; align-items: center; gap: 8px; }
.logo-thumb { width: 96px; height: 40px; flex: none; display: grid; place-items: center; padding: 4px 6px; border-radius: 6px; background: #000; }
.logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
