@font-face{font-family:JameelNooriNastaleeq;src:url('../assets/fonts/JameelNooriNastaleeq.ttf') format('truetype');font-display:swap}@font-face{font-family:Nastaliq;src:url('../assets/fonts/Urdu.ttf') format('truetype');font-display:swap}*{box-sizing:border-box}body{margin:0;background:#f3f2ee;color:#242c29;font:14px system-ui,sans-serif}header{height:84px;border-bottom:1px solid #dedfd7;display:flex;align-items:center;gap:28px;padding:0 4vw;background:#fafaf7}.brand{display:flex;align-items:center;gap:18px;flex-shrink:0;text-decoration:none}.wordmark{font:700 27px/1.1 Georgia,serif;letter-spacing:-1px;white-space:nowrap;color:#244f40}.wordmark>span{color:#bd6419}.brand img{display:block;width:auto;height:52px;max-width:42vw;object-fit:contain}button,input,select,textarea{font:inherit}button{border:1px solid #ccd2c9;background:#fafbf8;color:#244f40;padding:11px 15px;border-radius:7px;cursor:pointer}button:hover{background:#e6ede5}button:disabled{opacity:.5;cursor:wait}main{display:grid;grid-template-columns:340px minmax(0,1fr);gap:48px;max-width:1400px;margin:auto;padding:36px 4vw}.eyebrow{font-size:10px;font-weight:750;letter-spacing:2px;color:#6b8271}h1{font:32px/1.15 Georgia;margin:10px 0}p{color:#778075;line-height:1.6}.intro{margin-bottom:26px}.intro p{font-size:13px}details,.card{border:1px solid #dce0d7;background:#fcfcf9;border-radius:10px;margin-bottom:14px;overflow:hidden}summary{padding:18px;cursor:pointer;font-size:12px;color:#738476}summary b{color:#29372e;margin-left:10px;font-size:14px}summary small{display:block;margin:6px 0 0 29px;font-size:10px}h2{margin:0;font:26px Georgia}.card h2{font:600 14px system-ui;padding:18px}.card h2 span{font-size:12px;color:#738476;margin-right:12px}.section,.card>label{padding:0 18px}.section{padding-bottom:18px}label{display:block;font-size:12px;font-weight:600;margin-bottom:15px}label small{font-weight:400;color:#8b9388}input:not([type=range]):not([type=checkbox]):not([type=color]),textarea,select{width:100%;border:1px solid #d9dfd4;border-radius:6px;background:#fff;padding:10px;color:#344137;margin-top:7px}textarea{resize:vertical;line-height:1.9}input[type=range]{display:block;width:100%;margin-top:12px;accent-color:#356447}input[type=checkbox]{accent-color:#356447}input[type=color]{display:block;margin-top:8px;width:100%;height:33px;border:0;background:none}.pair,.checks{display:flex;gap:15px}.pair>*{flex:1}.checks{flex-wrap:wrap;gap:8px}.hint{font-size:11px}.upload{margin:0 18px 20px;padding:22px!important;border:1px dashed #a9bba4;border-radius:7px;text-align:center;background:#f0f4ec;color:#365a3d}.upload input{font-size:10px}.upload small{display:block;margin-top:9px}.canvas-wrap{background:#dddcd5;padding:18px;border-radius:12px;box-shadow:0 12px 35px #25382c0a}canvas{display:block;width:100%;height:auto;touch-action:none;cursor:grab;box-shadow:0 3px 12px #0002}.preview-note{display:flex;justify-content:space-between;font-size:10px;color:#7c897a;padding:14px 0}.preview-note span:first-child{color:#4c7454}.download{display:flex;gap:12px;align-items:end;padding:20px;background:#fcfcf9;border:1px solid #dce0d7;border-radius:10px}.download label{margin:0;flex:1}.download button{background:#244f40;color:white;border-color:#244f40;min-height:42px}.download button:hover{background:#34684e}#warning{color:#b53c2e;font-size:12px;min-height:10px}#status{font-size:12px}footer{max-width:1600px;margin:auto;padding:20px 4vw;border-top:1px solid #dedfd7;font-size:12px;color:#74806f;display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:18px}.footer-brand img{height:36px}.footer-brand .wordmark{font-size:22px}.footer-credit a{color:#244f40;text-underline-offset:3px}:focus-visible{outline:3px solid #a9bd7c;outline-offset:3px}
/* Let controls shrink inside grid and flex layouts without horizontal overflow. */
main>*,.brand,.pair>*,.download>*{min-width:0}
.brand{max-width:100%}
button,input,select,textarea{max-width:100%}
input:not([type=checkbox]):not([type=color]),select,textarea{min-width:0}
button,summary{min-height:44px}
input[type=range]{min-height:28px;margin-left:0;margin-right:0}
input[type=checkbox]{width:18px;height:18px;vertical-align:middle}
.checks label{display:flex;align-items:center;gap:5px;min-height:44px;margin-bottom:0}
.hint,#status,#warning{overflow-wrap:anywhere}
.preview-note{gap:8px 16px;flex-wrap:wrap}
.download{flex-wrap:wrap}
.download label{flex:1 1 130px}
.download button{width:100%}
footer .brand{flex-wrap:wrap}

/* Desktop: keep the preview between both settings columns. */
@media(min-width:1200px){
  main{grid-template-columns:minmax(240px,280px) minmax(0,1fr) minmax(240px,280px);gap:24px;max-width:1800px;padding:36px clamp(24px,3vw,54px);align-items:start}
  article{position:sticky;top:24px;align-self:start}
}

/* Tablet and compact desktop: preview first, settings side by side. */
@media(min-width:700px) and (max-width:1199px){
  main{grid-template-columns:repeat(2,minmax(0,1fr));gap:24px;max-width:1000px;padding:28px 24px;align-items:start}
  article{grid-column:1/-1;grid-row:1;width:100%;max-width:720px;justify-self:center}
}

/* Phone: a single column with full-width, touch-friendly controls. */
@media(max-width:699px){
  header{height:auto;min-height:84px;flex-wrap:wrap;gap:12px;padding:16px}
  header .brand{gap:10px;flex-shrink:1}
  header .brand img{height:auto;width:96px;max-width:28vw}
  header .wordmark{font-size:clamp(19px,5vw,24px)}

  main{display:flex;flex-direction:column;padding:20px 16px;gap:20px}
  main>*{width:100%}
  article{order:-1}
  .canvas-wrap{padding:8px;border-radius:9px}
  .download{padding:14px;gap:14px}
  .download label{flex-basis:100%}
  input:not([type=range]):not([type=checkbox]):not([type=color]),select,textarea{font-size:16px;min-height:44px}
  .section>button,.card>button{width:100%}
  .preview-note{font-size:10px;line-height:1.5}
  footer{padding:20px 16px;gap:16px}
  .footer-brand{gap:10px}
  .footer-brand img{height:auto;width:96px;max-width:28vw}
  .footer-brand .wordmark{font-size:20px}
}
@media(max-width:359px){
  .pair{flex-direction:column;gap:0}
  summary,.card h2{padding:16px}
  .section,.card>label{padding-left:14px;padding-right:14px}
  .upload{margin-left:14px;margin-right:14px;padding:16px!important}
}

.word-color-controls{margin:0 18px 20px;padding:12px;border:1px solid #dce0d7;border-radius:7px;background:#f0f4ec}.word-color-controls label{margin-bottom:10px}.word-color-controls .pair{flex-wrap:wrap;gap:8px}.word-color-controls button{flex:1 1 100px;padding:9px;font-size:12px}

.extra-picture{margin:0 0 18px;padding:14px 12px;border:1px solid #dce0d7;border-radius:7px;min-width:0}.extra-picture legend{padding:0 5px;font-weight:600}.extra-picture button{width:100%}

/* History stays immediately below the poster, with local save feedback alongside. */
.editor-toolbar{display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px 18px;margin:14px 0 0;padding:12px 14px;background:#fcfcf9;border:1px solid #dce0d7;border-radius:12px;box-shadow:0 3px 12px #25382c06}
.history-actions{display:inline-flex;align-items:center;padding:4px;gap:4px;background:#edf1e9;border:1px solid #dce3d6;border-radius:10px}
.history-actions button{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-width:96px;min-height:44px;padding:8px 14px;border:1px solid transparent;border-radius:7px;background:transparent;color:#244f40;font-size:13px;font-weight:650;line-height:1.2;transition:background-color .15s,border-color .15s,box-shadow .15s}
.history-actions button:not(:disabled){background:#fff;border-color:#d6dfd1;box-shadow:0 1px 3px #25382c0c}
.history-actions button:not(:disabled):hover{background:#e1ebdd;border-color:#b6c8ad}
.history-actions button:not(:disabled):active{background:#d5e3cf;box-shadow:inset 0 1px 3px #25382c12}
.history-actions button:disabled{opacity:1;color:#8a9586;background:transparent;cursor:not-allowed}
.history-icon{font:24px/1 system-ui,sans-serif}
#draftStatus{flex:1 1 140px;min-width:0;font-size:11px;line-height:1.5;color:#52644d;text-align:right;overflow-wrap:anywhere}
@media(max-width:420px){.editor-toolbar{justify-content:center;padding:10px}.history-actions{width:100%}.history-actions button{flex:1;min-width:0}#draftStatus{flex-basis:100%;text-align:center}}
@media(prefers-reduced-motion:reduce){.history-actions button{transition:none}}
.overflow-tools{display:flex;align-items:center;flex-wrap:wrap;gap:10px;margin:10px 0}.overflow-tools #warning{flex:1 1 200px;margin:0}.overflow-tools button{flex-shrink:0}[hidden]{display:none!important}

/* Keep reset close to the poster, distinct from the history controls. */
.editor-toolbar .reset-post{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:46px;margin-left:auto;padding:10px 14px;border:1px solid #dfc7b3;border-radius:9px;background:#fbf3eb;color:#854421;font-size:13px;font-weight:650;line-height:1.3;transition:background-color .15s,border-color .15s,box-shadow .15s}
.editor-toolbar .reset-post:not(:disabled):hover{background:#f4e5d6;border-color:#c99773;box-shadow:0 2px 5px #8544210c}
.editor-toolbar .reset-post:not(:disabled):active{background:#ecd5bf;box-shadow:inset 0 1px 3px #85442114}
.editor-toolbar .reset-post:disabled{opacity:.5;cursor:not-allowed}
.reset-icon{font:23px/1 system-ui,sans-serif}
.editor-toolbar #draftStatus{flex-basis:100%;padding-top:10px;border-top:1px solid #e6e9e0;text-align:left}
@media(max-width:420px){.editor-toolbar .reset-post{width:100%;margin-left:0}.editor-toolbar #draftStatus{text-align:center}}
@media(prefers-reduced-motion:reduce){.editor-toolbar .reset-post{transition:none}}

/* Keep controls usable with narrow viewports, landscape phones and text zoom. */
html{min-width:0;scroll-padding:16px}
header,main,footer,.section,.card,.pair,.download,.editor-toolbar{min-width:0}
label,summary,button,.wordmark{overflow-wrap:anywhere}
input[type=file]{width:100%;max-width:100%;overflow:hidden}
input[type=file]::file-selector-button{max-width:100%;white-space:normal}
.pair>*{min-width:0}
.canvas-wrap{min-width:0;max-width:100%}
.editor-toolbar>*{max-width:100%}
@media(max-width:540px){.pair{flex-wrap:wrap}.pair>label{flex:1 1 160px}.section{padding:16px}.word-color-controls{margin-left:14px;margin-right:14px}}
@media(max-width:320px){header,main,footer{padding-left:10px;padding-right:10px}.canvas-wrap{padding:5px}.mode-switch a{min-width:0}.brand{flex-wrap:wrap;justify-content:center}.history-actions button{padding-left:8px;padding-right:8px}}
@media(min-width:1200px) and (max-height:760px){article{position:static}}

/* Spacious desktop workspaces: each column scrolls only through its content. */
@media(min-width:1200px) and (min-height:700px){
  body{height:100vh;height:100dvh;display:flex;flex-direction:column;overflow:hidden}
  body>header{flex:0 0 auto}
  body>main{flex:1 1 0;min-height:0;width:100%;margin:0 auto;padding-top:24px;padding-bottom:24px;grid-template-rows:minmax(0,1fr);align-items:start}
  main>aside,main>article{position:static;align-self:start;min-height:0;max-height:100%;overflow-y:auto;overflow-x:hidden;overscroll-behavior-y:contain;scroll-padding-block:12px}
  main>article>:last-child,main>aside>:last-child{margin-bottom:0}
  main>aside:focus-visible,main>article:focus-visible{outline-offset:-3px}
}

/* Hide scrollbar tracks while retaining wheel, touch and keyboard scrolling. */
*{scrollbar-width:none;-ms-overflow-style:none}
*::-webkit-scrollbar{display:none;width:0;height:0}

/* Footer follows download/export controls inside the preview scroll area. */
main>article>footer{width:100%;margin:12px 0 0;padding:8px 0;gap:6px 12px;font-size:11px}
main>article>footer .brand{gap:10px;flex-wrap:wrap}
main>article>footer .brand img{height:auto;width:64px;max-width:22vw}
main>article>footer .wordmark{font-size:16px}
