:root{color-scheme:dark;font-family:'Malgun Gothic',system-ui,sans-serif;background:#141414;color:#eee}*{box-sizing:border-box}body{margin:0}header{position:sticky;top:0;z-index:10;background:#191919;border-bottom:1px solid #333;padding:12px max(14px,env(safe-area-inset-left));display:flex;align-items:center;justify-content:space-between;gap:12px}header strong{display:block;font-size:18px}header small{font-size:11px;color:#999}.upload,button{border:1px solid #555;border-radius:9px;background:#303030;color:white;padding:10px 14px;font-size:13px;cursor:pointer}.upload{background:#eee;color:#111;font-weight:700}button:disabled{opacity:.4;cursor:default}main{max-width:1150px;margin:auto;padding:12px;display:grid;gap:12px}.preview-section{display:grid;gap:12px}.panel{background:#202020;border:1px solid #333;border-radius:14px;padding:12px;min-width:0}.sectionhead{display:flex;justify-content:space-between;align-items:center;gap:6px;margin-bottom:10px;font-size:13px}.sectionhead span{color:#aaa}.sectionhead button{padding:6px 8px}.canvasbox{background:#0b0b0b;border-radius:9px;min-height:220px;height:min(47vh,470px);display:flex;align-items:center;justify-content:center;overflow:hidden}.canvasbox canvas{width:100%;height:100%;object-fit:contain;touch-action:none}.hint{font-size:12px;color:#a9a9a9;line-height:1.6;margin:10px 0 0}.settings h2{font-size:14px;margin:8px 0 12px}.settings h2:not(:first-child){margin-top:20px}.field{display:block;font-size:13px;margin:14px 0}.field output{float:right;color:#ccc}.field input[type=range]{display:block;width:100%;margin:12px 0;accent-color:#86efa2}.field select{margin-top:8px;width:100%;border:1px solid #555;border-radius:9px;background:#303030;padding:10px;color:white}.actions{display:flex;gap:10px;margin-top:20px}.actions button{flex:1}.actions #save{background:#e5e5e5;color:#151515;font-weight:700}#status{padding:9px 14px 16px;color:#a5a5a5;font-size:12px;text-align:center}@media(min-width:850px){main{grid-template-columns:minmax(0,2fr) minmax(300px,1fr)}.preview-section{grid-template-columns:repeat(2,minmax(0,1fr));align-content:start}.canvasbox{height:610px}}

[hidden]{display:none!important}.field input[type=color]{display:block;margin-top:8px;width:100%;height:40px;background:#303030;border:1px solid #555;border-radius:8px;padding:3px}#newPattern{width:100%;margin-top:4px}

/* Compact language toggle for desktop and mobile */
.header-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
.lang-switch{display:flex;border:1px solid #555;border-radius:8px;padding:2px;gap:2px;background:#262626}
.lang-switch button{padding:6px 9px;font-size:12px;min-width:35px;background:transparent;border:0;border-radius:5px;color:#aaa}
.lang-switch button[aria-pressed="true"]{background:#e8e8e8;color:#141414;font-weight:700}
@media(max-width:430px){header{gap:7px}header strong{font-size:16px}.upload{padding:9px 10px}.header-actions{gap:6px}.lang-switch button{padding:6px 8px}}

/* Clear button is distinct from the primary photo upload button. */
#clearPhoto{background:#303030;color:#eee}
#clearPhoto:disabled{opacity:.4}

/* Mobile: keep a compact result preview in view while scrolling controls.
   display:contents lets the preview stick within main, not just its short section. */
@media(max-width:849px){
  :root{--Instant-header-height:72px}
  main{display:flex;flex-direction:column;gap:10px;align-items:stretch}
  .preview-section{display:contents}
  .result-panel{order:0;position:sticky;top:calc(var(--Instant-header-height) + 4px);z-index:8;box-shadow:0 5px 18px rgba(0,0,0,.35);padding:9px 12px}
  .result-panel .sectionhead{margin-bottom:6px}
  .result-panel .canvasbox{height:clamp(155px,28dvh,270px);min-height:0}
  .source-panel{order:1}
  .source-panel .canvasbox{height:min(52dvh,460px)}
  .settings{order:2}
}
