*{box-sizing:border-box}
:root{
  color-scheme:dark;
  --bg:#000;
  --panel:#101114;
  --panel2:#17191e;
  --line:#2a2d34;
  --text:#f5f7fb;
  --muted:#9da4b2;
  --accent:#f5f7fb;
  --danger:#ff5d68;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
}
html,body{margin:0;width:100%;height:100%;overflow:hidden;background:#000;font-family:-apple-system,BlinkMacSystemFont,"SF Pro Display","SF Pro Text",system-ui,sans-serif;color:var(--text);-webkit-user-select:none;user-select:none}
button,input,select{font:inherit}
button{cursor:pointer}
.screen{position:fixed;inset:0;display:none;background:var(--bg)}
.screen.active{display:block}
.stage{position:absolute;inset:0;overflow:hidden;touch-action:none;background:#000}
.perf-frame{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background:#000;will-change:transform,opacity}
.perf-frame img{display:block;max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;pointer-events:none;-webkit-user-drag:none}
.empty-state{position:absolute;inset:0;display:flex;flex-direction:column;gap:8px;align-items:center;justify-content:center;color:#d9dde5;z-index:2;touch-action:none}
.empty-state[hidden]{display:none}
.empty-state small{color:#858c99}
.empty-icon{font-size:54px;font-weight:200;line-height:1}
.perf-hint{position:absolute;left:50%;bottom:calc(18px + var(--safe-bottom));transform:translateX(-50%);padding:8px 12px;border-radius:99px;background:rgba(30,32,38,.72);backdrop-filter:blur(18px);font-size:12px;color:#d7dbe3;z-index:10}
.config-screen,.editor-screen{background:#0a0b0e;overflow:auto;-webkit-overflow-scrolling:touch}
.topbar{position:sticky;top:0;z-index:10;min-height:calc(78px + var(--safe-top));padding:calc(16px + var(--safe-top)) 18px 14px;display:flex;align-items:flex-end;justify-content:space-between;gap:14px;background:rgba(10,11,14,.92);backdrop-filter:blur(22px);border-bottom:1px solid var(--line)}
.topbar h1{font-size:28px;line-height:1;margin:3px 0 0}
.eyebrow{font-size:10px;letter-spacing:.18em;color:#7f8794;font-weight:700}
.btn{border:1px solid var(--line);border-radius:12px;padding:10px 14px;background:#17191e;color:#f7f8fb;font-weight:650}
.btn.primary{background:#f5f7fb;color:#0b0c0f;border-color:#f5f7fb}
.btn.ghost{background:#17191e}
.btn.danger-btn{background:#a5222c;border-color:#c43b46;color:white}
.config-content{padding:20px 16px calc(30px + var(--safe-bottom));max-width:760px;margin:0 auto}
.config-intro p{margin:0 0 16px;color:var(--muted);line-height:1.45}
.add-button{width:100%;min-height:58px;border:1px dashed #424750;border-radius:16px;background:#121419;color:white;display:flex;align-items:center;justify-content:center;gap:8px;font-weight:700}
.add-button span{font-size:24px;font-weight:400}
h2{font-size:15px;margin:26px 4px 10px;color:#b8bec9}
.image-list{display:flex;flex-direction:column;gap:10px}
.image-card{display:grid;grid-template-columns:76px 1fr auto;gap:12px;align-items:center;padding:10px;background:var(--panel);border:1px solid #202329;border-radius:16px}
.thumb{width:76px;height:76px;border-radius:11px;overflow:hidden;background:#050506;display:flex;align-items:center;justify-content:center;border:1px solid #262932}
.thumb img{width:100%;height:100%;object-fit:cover}
.image-meta{min-width:0}
.image-name{font-weight:750;font-size:16px}
.image-sub{font-size:12px;color:var(--muted);margin-top:4px}
.image-actions{display:flex;flex-direction:column;gap:7px}
.small-btn{border:1px solid #30343c;border-radius:10px;padding:8px 10px;background:#1a1d23;color:#eceff4;font-size:12px;font-weight:650}
.small-btn.danger{color:#ff858d}
.dialog{width:min(92vw,460px);border:1px solid #31343b;border-radius:20px;background:#121419;color:white;padding:18px;box-shadow:0 28px 90px rgba(0,0,0,.55)}
.dialog::backdrop{background:rgba(0,0,0,.72);backdrop-filter:blur(8px)}
.dialog-head{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:16px}
.dialog h3{font-size:19px;margin:0}
.icon-btn{border:0;background:#252932;color:white;border-radius:50%;width:32px;height:32px;font-size:21px;line-height:1}
.field{display:flex;flex-direction:column;gap:8px;margin:14px 0}
.field>span{font-size:13px;color:#b7bdc8;font-weight:650}
input[type=file],select{width:100%;border:1px solid #333741;border-radius:12px;background:#1b1e24;color:white;padding:12px}
.switch-row{display:flex;align-items:center;gap:10px;padding:8px 0;color:#eef0f5}
.switch-row input{position:absolute;opacity:0;pointer-events:none}
.switch-ui{width:46px;height:28px;border-radius:99px;background:#363a43;position:relative;transition:.18s}
.switch-ui:after{content:"";position:absolute;width:22px;height:22px;left:3px;top:3px;border-radius:50%;background:white;transition:.18s}
.switch-row input:checked+.switch-ui{background:#34c759}
.switch-row input:checked+.switch-ui:after{transform:translateX(18px)}
.dialog-actions{display:flex;justify-content:flex-end;gap:8px;margin-top:18px}
.add-preview-wrap{height:180px;background:#050506;border-radius:14px;overflow:hidden;display:flex;align-items:center;justify-content:center;border:1px solid #2a2d34}
.add-preview-wrap img{max-width:100%;max-height:100%;object-fit:contain}
.dialog-copy{color:var(--muted);line-height:1.4}
.editor-screen{overflow:hidden}
.editor-topbar{align-items:center;min-height:calc(68px + var(--safe-top))}
.editor-title{text-align:center;min-width:0;flex:1}
.editor-title strong{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;margin-top:3px}
.editor-stage-wrap{position:absolute;left:0;right:0;top:calc(68px + var(--safe-top));bottom:calc(52px + var(--safe-bottom));display:flex;align-items:center;justify-content:center;overflow:hidden;background:#030304;padding:8px}
.editor-stage{position:relative;max-width:100%;max-height:100%;display:flex;align-items:center;justify-content:center}
.editor-stage img{display:block;max-width:100%;max-height:100%;object-fit:contain;-webkit-user-drag:none;pointer-events:none}
.zone-layer{position:absolute;inset:0;pointer-events:none}
.zone{position:absolute;border:2px solid rgba(255,255,255,.95);background:rgba(255,255,255,.12);border-radius:8px;pointer-events:auto;touch-action:none;display:flex;align-items:flex-start;justify-content:flex-start}
.zone .zone-label{font-size:11px;font-weight:800;background:rgba(0,0,0,.72);padding:4px 6px;border-radius:5px;margin:4px;pointer-events:none}
.zone.resizing{border-style:dashed;box-shadow:0 0 0 2px rgba(255,255,255,.16)}
.resize-handle{position:absolute;width:28px;height:28px;right:-14px;bottom:-14px;border-radius:50%;background:#fff;border:7px solid #15171b;box-shadow:0 2px 12px rgba(0,0,0,.45);touch-action:none}
.editor-help{position:absolute;bottom:0;left:0;right:0;min-height:calc(52px + var(--safe-bottom));padding:10px 14px calc(10px + var(--safe-bottom));font-size:12px;color:#9ca3af;text-align:center;background:#0a0b0e;border-top:1px solid #202329}
.sheet{width:min(92vw,460px);margin:auto auto calc(14px + var(--safe-bottom));border-radius:22px}
.sheet-action{width:100%;border:0;border-top:1px solid #2b2f36;background:transparent;color:white;padding:15px 10px;text-align:left;font-weight:700}
.sheet-action.danger{color:#ff747e}
@media (orientation:landscape) and (max-height:500px){
  .topbar{min-height:calc(56px + var(--safe-top));padding-top:calc(8px + var(--safe-top));padding-bottom:8px}
  .topbar h1{font-size:22px}
  .editor-stage-wrap{top:calc(56px + var(--safe-top))}
}


.backup-actions{display:grid;grid-template-columns:1fr;gap:10px;margin-top:12px}
.backup-button{width:100%;display:flex;align-items:center;gap:13px;text-align:left;border:1px solid #2c3038;border-radius:16px;background:#121419;color:#f5f7fb;padding:13px 14px}
.backup-button:active{transform:scale(.995);background:#181b21}
.backup-button>span:last-child{display:flex;flex-direction:column;gap:3px;min-width:0}
.backup-button strong{font-size:14px}
.backup-button small{font-size:11px;color:#8f97a5;line-height:1.3}
.backup-icon{width:34px;height:34px;flex:0 0 34px;border-radius:10px;background:#20232a;display:flex;align-items:center;justify-content:center;font-size:20px}
.restore-summary{margin:14px 0 0;padding:12px 13px;border:1px solid #2d3139;border-radius:12px;background:#181b20;color:#cbd1db;font-size:13px;line-height:1.45}


.fullscreen-btn{
  position:absolute;
  bottom:calc(12px + var(--safe-bottom));
  right:12px;
  z-index:20;
  width:36px;
  height:36px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border:1px solid rgba(255,255,255,.18);
  border-radius:11px;
  background:rgba(12,13,16,.46);
  color:rgba(255,255,255,.86);
  backdrop-filter:blur(14px);
  -webkit-backdrop-filter:blur(14px);
  touch-action:manipulation;
  -webkit-tap-highlight-color:transparent;
}
.fullscreen-btn:active{transform:scale(.94);background:rgba(25,27,32,.68)}
.fullscreen-btn svg{
  width:18px;
  height:18px;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.fullscreen-btn[hidden]{display:none}


/* En plein écran, le mode performance ne montre strictement que l'image. */
:fullscreen .fullscreen-btn,
:fullscreen .perf-hint {
  display:none !important;
}

:-webkit-full-screen .fullscreen-btn,
:-webkit-full-screen .perf-hint {
  display:none !important;
}

@media (display-mode: fullscreen) {
  .fullscreen-btn,
  .perf-hint {
    display:none !important;
  }
}

.save-location-info{
  margin:10px 0 0;
  font-size:12px;
  color:#929aa7;
}
#saveFileName{
  width:100%;
  border:1px solid #333741;
  border-radius:12px;
  background:#1b1e24;
  color:white;
  padding:12px;
  outline:none;
  -webkit-user-select:text;
  user-select:text;
}
#saveFileName:focus{border-color:#6f7785}
