:root {
  color-scheme: light;
  --ink:#251d1a; --ink-soft:#6a5e57; --paper:#f4eee6; --accent:#a43752;
  --accent-dark:#78263c; --line:#d8ccc0; --panel:#fffaf4;
  font-family:Inter,ui-sans-serif,system-ui,-apple-system,"Segoe UI",sans-serif;
}
* { box-sizing:border-box; }
[hidden] { display:none !important; }
html,body { min-height:100%; }
body { margin:0; color:var(--ink); background:#ded4ca; overflow-x:hidden; }
button,input { font:inherit; }
button { color:inherit; }
button:focus-visible,input:focus-visible,.gallery-stage:focus-visible { outline:3px solid #2c6670; outline-offset:2px; }

.editor-toolbar {
  position:fixed; z-index:100; inset:14px 14px auto; min-height:58px;
  display:flex; align-items:center; gap:12px; padding:8px 10px;
  color:#fffaf4; background:rgba(37,29,26,.95); border:1px solid rgba(255,255,255,.12);
  border-radius:15px; box-shadow:0 16px 42px rgba(35,23,18,.26); backdrop-filter:blur(14px);
}
.brand { display:flex; align-items:center; gap:9px; flex:0 0 auto; }
.brand-mark { width:36px; height:36px; display:grid; place-items:center; border:1px solid rgba(255,255,255,.28); border-radius:50%; font:italic 21px Georgia,serif; }
.brand-copy { display:grid; line-height:1.12; }
.brand-copy strong { font:500 15px Georgia,serif; }
.brand-copy span { color:#cbbfb8; font-size:10px; }
.device-switch { display:flex; gap:3px; padding:3px; flex:0 0 auto; border-radius:10px; background:rgba(255,255,255,.08); }
.device-button { min-height:34px; padding:6px 10px; border:0; border-radius:7px; color:#d8cdc6; background:transparent; cursor:pointer; font-size:12px; font-weight:750; }
.device-button.is-active { color:var(--ink); background:#fff6ec; }
.toolbar-actions { min-width:0; display:flex; align-items:center; gap:4px; flex:1 1 auto; overflow-x:auto; scrollbar-width:none; }
.toolbar-actions::-webkit-scrollbar { display:none; }
.tool-button { min-width:36px; height:36px; display:inline-flex; align-items:center; justify-content:center; gap:6px; padding:0 9px; flex:0 0 auto; border:0; border-radius:8px; color:#eee4dd; background:transparent; cursor:pointer; font-size:11px; font-weight:750; }
.tool-button:hover:not(:disabled) { background:rgba(255,255,255,.1); }
.tool-button:disabled { opacity:.34; cursor:not-allowed; }
.height-control{display:inline-flex;align-items:center;gap:5px;color:#f7eee8;font:600 12px/1.2 system-ui;white-space:nowrap}
.height-control input{width:82px;padding:6px 7px;border:1px solid rgba(255,255,255,.35);border-radius:7px;background:#fff;color:#2b211e;font:600 12px system-ui}
.tool-button svg,.return-edit-button svg { width:18px; height:18px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.tool-button-accent { color:white; background:var(--accent); }
.tool-button-accent:hover:not(:disabled) { background:var(--accent-dark); }
.tool-button-light { color:var(--ink); background:#fff7ef; }
.tool-button-danger { color:#ffb6c0; }
.toolbar-divider { width:1px; height:26px; flex:0 0 auto; background:rgba(255,255,255,.16); }
.selection-summary { max-width:130px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:#d1c5be; font-size:11px; }
.save-status { flex:0 0 auto; color:#bfcabf; font-size:10px; white-space:nowrap; }
.save-status.is-dirty { color:#f0c77f; }

.gallery-page,.stage-scroll { min-height:100vh; }
.stage-scroll { width:100%; overflow:visible; padding:0; }
.stage-zoom { position:relative; margin:0 auto; transform-origin:top center; }
.gallery-stage {
  position:relative; overflow:hidden; transform-origin:0 0; touch-action:none;
  background:linear-gradient(rgba(255,255,255,.42),rgba(255,255,255,.42)),radial-gradient(circle at 24% 16%,rgba(181,116,118,.12),transparent 29%),radial-gradient(circle at 82% 58%,rgba(119,144,135,.12),transparent 34%),#f5f0e9;
}
.gallery-item { position:absolute; user-select:none; touch-action:none; cursor:grab; }
.gallery-item:active { cursor:grabbing; }
.gallery-item.image-item { margin:0; overflow:visible; background:transparent; filter:drop-shadow(0 14px 18px rgba(54,37,27,.16)); }
.gallery-item.image-item a { display:block; width:100%; height:100%; background:transparent; }
.gallery-item.image-item img { display:block; width:100%; height:100%; object-fit:contain; background:transparent; pointer-events:none; }
.gallery-item.text-item { display:flex; align-items:flex-start; overflow:hidden; padding:7px 8px; white-space:pre-wrap; overflow-wrap:anywhere; line-height:1.28; }
body[data-mode="edit"] .gallery-item.text-item.is-selected { overflow:visible; }
.gallery-item.title-item { font-family:Georgia,serif; letter-spacing:.01em; }
.gallery-item.title-item::after { content:""; display:block; width:36px; margin-top:9px; border-bottom:2px solid var(--accent); }
.gallery-item.text-item.title-item { display:block; }
.gallery-item.quote-item { font-family:Georgia,serif; font-style:italic; }
.gallery-item.small-text-item { color:var(--ink-soft); letter-spacing:.015em; }
body[data-mode="edit"] .gallery-item.is-selected { outline:3px solid var(--accent); outline-offset:6px; }
body[data-mode="edit"] .gallery-item.is-selected::before { content:attr(data-label); position:absolute; left:-9px; bottom:calc(100% + 10px); z-index:10; padding:5px 8px; border-radius:5px; color:white; background:var(--accent); font:700 12px/1.1 system-ui; white-space:nowrap; }
.resize-handle { position:absolute; width:18px; height:18px; border:3px solid white; border-radius:50%; background:var(--accent); box-shadow:0 2px 6px rgba(55,22,28,.35); }
.resize-handle[data-handle="nw"] { left:-15px; top:-15px; cursor:nwse-resize; }
.resize-handle[data-handle="ne"] { right:-15px; top:-15px; cursor:nesw-resize; }
.resize-handle[data-handle="sw"] { left:-15px; bottom:-15px; cursor:nesw-resize; }
.resize-handle[data-handle="se"] { right:-15px; bottom:-15px; cursor:nwse-resize; }
.resize-handle[data-handle="rotate"] { left:calc(50% - 11px); top:-52px; width:22px; height:22px; cursor:grab; background:#2c6670; }
.resize-handle[data-handle="rotate"]::after { content:""; position:absolute; left:8px; top:18px; width:2px; height:28px; background:#2c6670; }
.effect-item { overflow:visible; background:transparent; transform-origin:center; }
.effect-item .effect-visual { position:absolute; inset:0; display:block; pointer-events:none; }
.background-item { overflow:visible; background:transparent; transform-origin:center; }
.background-item .background-visual { position:absolute; inset:0; display:block; pointer-events:none; }
body[data-mode="preview"] .effect-item,body[data-mode="preview"] .background-item { pointer-events:none; }
body[data-mode="preview"] .editor-toolbar,body[data-mode="preview"] .library-panel,body[data-mode="preview"] .library-scrim,body[data-mode="preview"] .placement-hint { display:none !important; }
body[data-mode="preview"] .gallery-item { cursor:default; }
body[data-mode="preview"] .resize-handle,body[data-mode="preview"] .gallery-item.is-selected::before { display:none; }

.return-edit-button { position:fixed; z-index:120; right:18px; top:18px; min-height:42px; display:inline-flex; align-items:center; gap:8px; padding:9px 13px; border:0; border-radius:10px; color:white; background:rgba(37,29,26,.9); box-shadow:0 10px 28px rgba(31,21,18,.25); cursor:pointer; }
.placement-hint { position:fixed; z-index:105; left:50%; top:88px; transform:translateX(-50%); display:grid; gap:2px; min-width:min(430px,calc(100vw - 28px)); padding:11px 15px; color:white; text-align:center; background:var(--accent); border-radius:10px; box-shadow:0 12px 30px rgba(90,25,43,.28); pointer-events:none; }
.placement-hint strong { font-size:13px; }.placement-hint span { font-size:11px; opacity:.9; }
body.is-placing .gallery-stage { cursor:crosshair; }

.library-scrim { position:fixed; z-index:109; inset:0; border:0; background:rgba(26,19,16,.34); }
.library-panel { position:fixed; z-index:110; top:14px; bottom:14px; right:14px; width:min(380px,calc(100vw - 28px)); padding:22px; overflow:auto; border-radius:16px; background:var(--panel); box-shadow:0 24px 70px rgba(35,23,18,.34); }
.panel-head,.dialog-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; }
.eyebrow { margin:0 0 5px; color:var(--accent); font-size:10px; font-weight:850; letter-spacing:.13em; text-transform:uppercase; }
h2 { margin:0; font:500 24px/1.15 Georgia,serif; }
.close-button { width:36px; height:36px; border:0; border-radius:50%; background:#eee5dc; cursor:pointer; font-size:22px; }
.panel-help,.dialog-note { color:var(--ink-soft); font-size:13px; line-height:1.5; }
.panel-add-grid { display:grid; grid-template-columns:1fr 1fr; gap:7px; margin:4px 0 16px; }
.panel-add-button { width:100%; min-height:42px; border:1px solid var(--line); border-radius:9px; color:white; background:var(--ink); cursor:pointer; font-weight:750; }
.artwork-list { display:grid; gap:10px; }
.artwork-card { padding:13px; border:1px solid var(--line); border-radius:11px; background:#fff; }
.artwork-card-head { display:flex; justify-content:space-between; gap:8px; margin-bottom:10px; }
.artwork-card strong { display:block; font:500 16px Georgia,serif; }.artwork-card small { color:var(--ink-soft); font-size:11px; }
.artwork-card-actions { display:flex; flex-wrap:wrap; gap:6px; }
.artwork-pill { min-height:32px; padding:5px 10px; border:1px solid var(--line); border-radius:999px; background:white; cursor:pointer; font-size:11px; font-weight:750; }
.artwork-pill.is-selected { color:var(--accent-dark); border-color:#c98b99; background:#fff2f5; }.artwork-pill.is-hidden { border-style:dashed; }

.dialog { width:min(520px,calc(100vw - 28px)); padding:0; border:0; border-radius:17px; color:var(--ink); background:var(--panel); box-shadow:0 26px 80px rgba(35,23,18,.35); }
.dialog::backdrop { background:rgba(31,23,20,.52); backdrop-filter:blur(3px); }.dialog form { padding:24px; }.dialog-head { margin-bottom:18px; }
.field { display:grid; gap:6px; margin-bottom:14px; }.field span { color:var(--ink-soft); font-size:12px; font-weight:750; }.field input,.field textarea { padding:9px 11px; border:1px solid var(--line); border-radius:8px; resize:vertical; }.field input { height:42px; }
.file-drop { min-height:145px; display:grid; place-items:center; align-content:center; gap:7px; padding:20px; border:1px dashed #aa9a8c; border-radius:12px; text-align:center; background:#faf6f1; cursor:pointer; }.file-drop input { position:absolute; width:1px; height:1px; opacity:0; }.file-drop svg { width:28px; height:28px; fill:none; stroke:var(--accent); stroke-width:1.7; }.file-drop span { color:var(--ink-soft); font-size:11px; }
.drop-kind-content { padding:24px; }.drop-file-name { margin:0 0 12px; padding:10px 12px; border-radius:9px; background:#f6efe8; overflow-wrap:anywhere; }.drop-kind-actions { display:grid; gap:10px; margin-top:18px; }
.import-preview { display:grid; grid-template-columns:minmax(90px,150px) 1fr; gap:13px; align-items:center; margin:14px 0 0; padding:11px; border:1px solid var(--line); border-radius:11px; background:#fff; }
.import-preview[hidden] { display:none; }
.import-preview img { display:block; width:100%; max-height:150px; object-fit:contain; background:transparent; }
.import-preview figcaption { overflow-wrap:anywhere; color:var(--ink-soft); font-size:12px; line-height:1.45; }
.dialog-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:18px; }.dialog-button { min-height:40px; padding:8px 13px; border:1px solid var(--line); border-radius:8px; background:white; cursor:pointer; font-weight:750; }.dialog-button-primary { color:white; border-color:var(--accent); background:var(--accent); }
.effects-dialog { width:min(640px,calc(100vw - 28px)); }
.effect-presets { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin:12px 0; padding:11px; border:1px solid var(--line); border-radius:11px; }
.effect-presets legend { padding:0 6px; color:var(--ink-soft); font-size:12px; font-weight:800; }
.effect-presets button { min-height:40px; padding:7px; border:1px solid var(--line); border-radius:9px; background:#fff; cursor:pointer; font-size:12px; font-weight:750; }
.effect-presets button.is-active { color:#fff; border-color:var(--accent); background:var(--accent); }
.effect-preview { position:relative; height:120px; margin:14px 0; overflow:hidden; border:1px solid var(--line); border-radius:12px; background:linear-gradient(135deg,#eadfd5,#f7f2ec); }
.effect-preview span { position:absolute; left:22%; top:18%; width:56%; height:64%; transform-origin:center; }
.effect-controls { display:grid; grid-template-columns:1fr 1fr; gap:0 14px; }
.effect-controls output { float:right; color:var(--accent-dark); font-weight:650; }
.effect-controls input[type="range"] { width:100%; padding:0; accent-color:var(--accent); }
.effect-color input { width:100%; padding:4px; }
.backgrounds-dialog { width:min(720px,calc(100vw - 28px)); }
.background-presets { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; margin:12px 0; padding:11px; border:1px solid var(--line); border-radius:11px; }
.background-presets legend { padding:0 6px; color:var(--ink-soft); font-size:12px; font-weight:800; }
.background-presets button { min-height:40px; padding:7px; border:1px solid var(--line); border-radius:9px; background:#fff; cursor:pointer; font-size:12px; font-weight:750; }
.background-presets button.is-active { color:#fff; border-color:var(--accent); background:var(--accent); }
.background-preview { position:relative; height:145px; margin:14px 0; overflow:hidden; border:1px solid var(--line); border-radius:12px; background:#f7f2ec; }
.background-preview span { position:absolute; inset:0; display:block; transform-origin:center; }
.background-colors { display:grid; grid-template-columns:repeat(3,1fr); gap:0 12px; }
.background-colors input { width:100%; padding:4px; }
.background-controls { display:grid; grid-template-columns:1fr 1fr; gap:0 14px; }
.background-controls output { float:right; color:var(--accent-dark); font-weight:650; }
.background-controls input[type="range"] { width:100%; padding:0; accent-color:var(--accent); }
.toast { position:fixed; z-index:140; right:20px; bottom:20px; max-width:340px; padding:12px 15px; border-radius:10px; color:white; background:var(--ink); box-shadow:0 12px 30px rgba(37,29,26,.28); font-size:13px; opacity:0; transform:translateY(12px); pointer-events:none; transition:.2s; }.toast.is-visible { opacity:1; transform:none; }
.text-item a { color:inherit; text-decoration:inherit; }

@media (max-width:1100px) { .brand-copy span,.selection-summary,.tool-button span,.save-status { display:none; }.editor-toolbar { gap:7px; }.toolbar-actions { gap:2px; } }
@media (max-width:700px) { .editor-toolbar { top:8px;right:8px;bottom:auto;left:8px;min-height:52px;flex-wrap:nowrap;gap:4px }.brand { display:none }.device-switch { order:1 }.toolbar-actions { order:2;flex-basis:auto }.save-status { display:none }.placement-hint { top:70px }.return-edit-button { top:10px;right:10px } }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { transition-duration:.01ms!important; } }

/* La page source garde ses styles et ses media queries dans son propre document. */
#gallery-frame {display:block;border:0;transform-origin:0 0;background:white;}
.gallery-page,.stage-scroll {min-height:0;}
body {overflow:hidden;}
#stage-zoom {margin:0 auto;}
.editor-toolbar {flex-wrap:wrap;}
#save-button {flex-shrink:0;}
@media(max-width:650px) {
  .editor-toolbar {inset:4px 4px auto;gap:5px;padding:5px;}
  .toolbar-actions {order:3;flex-basis:100%;}
  .tool-button {min-width:40px;height:40px;}
  .save-status {white-space:normal;max-width:120px;}
}
@media(max-width:560px) { .effect-presets,.effect-controls,.background-presets,.background-colors,.background-controls { grid-template-columns:1fr; } }
.save-status {display:block !important;}
@media(max-width:1100px) {
  .save-status {order:4;flex-basis:100%;padding:2px 4px;font-size:11px;max-width:none;}
  .toolbar-actions {min-width:0;}
}

#publication-result{font-size:11px} .media-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px;max-height:45vh;overflow:auto}.media-grid button{padding:5px;background:#fff;border:1px solid #d8ccc0;cursor:pointer}.media-grid img{width:100%;height:100px;object-fit:contain}.media-grid span{display:block;font-size:11px}.media-toolbar{display:flex;gap:8px;margin:12px 0}.media-toolbar input{min-width:0;flex:1}.media-button{margin:8px 0;padding:10px;cursor:pointer}.field select{max-width:100%;padding:8px}.field small{color:#6a5e57;line-height:1.35}.photo-confirmation{padding:10px;border:1px solid #d8ccc0;border-radius:8px;background:#fffaf5}.photo-confirmation input{width:auto;height:auto;margin-right:7px}
