:root{color-scheme:light;--ink:#231c23;--muted:#675c68;--line:#e5dce3;--accent:#722c4c;--soft:#f6eef3;--surface:#fff;font-family:"Tahoma","Arial",sans-serif}
*{box-sizing:border-box}
body{margin:0;background:#f5f2f5;color:var(--ink);font-size:16px}
[hidden]{display:none!important}
header{min-height:84px;background:#241924;color:#fff;display:flex;justify-content:space-between;align-items:center;padding:14px clamp(14px,4vw,54px);gap:16px}
.brand,.actions,.element-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}
.brand{gap:12px}.mark,.hero-icon{display:grid;place-items:center;border-radius:13px;background:#6e3151;color:#fff;width:44px;height:44px;font-size:32px}
h1,h2,p{margin:0}h1{font-size:22px}header p{color:#e1cedc;margin-top:5px;font-size:14px}h2{font-size:17px}p{line-height:1.6}
button,input,select{font:inherit;color:inherit}
button,select{border:1px solid var(--line);border-radius:8px;background:#fff;padding:8px 12px;font-size:14px;cursor:pointer;min-height:38px}
button:hover:enabled{background:var(--soft)}button:disabled{opacity:.48;cursor:default}
button.primary{background:var(--accent);border-color:var(--accent);color:white}button.primary:hover:enabled{background:#552039}
main{max-width:1680px;margin:auto;padding:20px clamp(12px,3vw,36px) 32px}
.filebar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:14px}.filebar strong{overflow-wrap:anywhere}.filebar span,.panel p,#report{color:var(--muted);font-size:14px}
.workspace{display:grid;grid-template-columns:minmax(190px,232px) minmax(0,1fr) minmax(210px,254px);gap:12px;align-items:start}
.panel,.preview{border:1px solid var(--line);border-radius:14px;background:white;overflow:hidden}
.panel{padding:16px}.panel h2{margin-bottom:12px}.panel h2 span{font-size:14px;color:var(--muted);margin-inline-start:4px}
input:not([type=file]){width:100%;min-width:0;border:1px solid var(--line);border-radius:7px;padding:8px 9px;font-size:16px;background:#fff}
#tree{margin-top:12px;max-height:485px;overflow:auto}.row{display:flex;align-items:center;gap:4px;margin-bottom:3px}.row>button{flex:1;text-align:start;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;border-color:transparent;padding:5px 7px;min-height:34px}.row button[aria-pressed=true]{background:var(--soft);color:var(--accent);border-color:#d6b2c7}.row .twisty{flex:0 0 28px;text-align:center}.row .hidden-layer{opacity:.55}
.toolbar{padding:9px;display:flex;justify-content:space-between;gap:8px;flex-wrap:wrap;border-bottom:1px solid var(--line)}.toolbar label{font-size:14px}
.stage{height:clamp(360px,58vh,710px);display:grid;place-items:center;position:relative;overflow:auto;direction:ltr;background:#fff}
.stage.grid{background-color:#fff;background-image:conic-gradient(#e9e4e9 25%,white 0 50%,#e9e4e9 0 75%,white 0);background-size:24px 24px}.stage.dark{background:#201a24}.stage.dragging{outline:3px solid var(--accent);outline-offset:-3px}
#art{width:100%;height:100%;display:flex;align-items:center;justify-content:center;padding:24px;min-width:0}#artwork{display:block;width:100%;height:100%;object-fit:contain;min-width:0}
#empty{position:absolute;inset:auto;direction:rtl;text-align:center;background:#fff;padding:24px;border:1px solid var(--line);border-radius:14px;max-width:90%;box-shadow:0 8px 24px #25132412}.hero-icon{margin:0 auto 12px;width:54px;height:54px}#empty p{margin:8px 0 16px;color:var(--muted)}
#edit{display:grid;gap:10px;margin-top:12px}form label{display:grid;gap:4px;font-size:14px}.pair{display:grid;grid-template-columns:1fr 1fr;gap:7px}.element-actions{margin-top:9px}.danger{color:#9b2b45}
.audit{margin-top:12px}.audit h2{margin-bottom:5px}#report{margin-top:12px}.metrics{display:flex;gap:7px;flex-wrap:wrap}.metric{background:var(--soft);padding:7px 10px;border-radius:6px;color:var(--ink)}#report ul{padding-inline-start:20px;line-height:1.65;margin-bottom:0}
@media(max-width:1050px){.workspace{grid-template-columns:minmax(155px,200px) minmax(0,1fr)}.inspector{grid-column:1/-1}#edit{grid-template-columns:repeat(auto-fit,minmax(170px,1fr));align-items:end}}
@media(max-width:640px){header{align-items:flex-start}.workspace{grid-template-columns:1fr}.preview{grid-row:1}.inspector{grid-column:auto}#tree{max-height:210px}.stage{height:340px}.filebar{align-items:start;flex-direction:column}.toolbar{justify-content:start}}

.stage{display:block}
#empty{top:50%;left:50%;transform:translate(-50%,-50%);width:max-content}
#live{display:block;width:100%;height:100%;border:0;touch-action:none}
#gestureHint{border-top:1px solid var(--line);color:var(--muted);font-size:14px;padding:8px 12px}

#art{position:relative}
#surface{position:absolute;inset:24px;z-index:1;touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none;cursor:grab}
#surface:active{cursor:grabbing}
.sliders{grid-column:1/-1;display:grid;gap:9px}
.sliders label{grid-template-columns:1fr auto;align-items:center}
.sliders output{direction:ltr;font-variant-numeric:tabular-nums}
.sliders input[type=range]{grid-column:1/-1;accent-color:var(--accent);padding:0;margin:0;min-height:28px;direction:ltr}
@media(max-width:640px){
.workspace{grid-template-columns:minmax(96px,28%) minmax(0,1fr);gap:6px}
.preview{grid-row:auto;min-width:0}
.inspector{grid-column:1/-1}
.layers{padding:8px}
.layers h2{font-size:14px}
.layers input{padding:5px;font-size:16px}
#tree{max-height:340px}
.row{padding-inline-start:0!important;gap:0}
.row>button{min-width:0;padding:3px;font-size:13px}
.row .twisty{flex-basis:20px}
#art{padding:6px}
#surface{inset:6px}
.stage{height:clamp(250px,48vh,390px)}
#empty{padding:10px;width:90%}
}
@media(max-width:640px){.row>button{white-space:normal;overflow-wrap:anywhere;line-height:1.25}}
#filename{display:block;color:var(--muted);font-size:14px;overflow-wrap:anywhere;margin-bottom:8px}
@media(max-width:640px){#filename{font-size:13px}.sliders{grid-template-columns:1fr 1fr}.stage{height:clamp(245px,39vh,320px)}}

.workspace{grid-template-columns:minmax(0,1fr) minmax(220px,270px)}
.preview{grid-column:1;grid-row:1}
.inspector{grid-column:2;grid-row:1}
.layers{grid-column:1/-1;grid-row:2}
#edit{grid-template-columns:minmax(0,1fr)}
.color-tools,.color-control{display:grid;gap:6px}
.color-control>div{display:grid;grid-template-columns:36px minmax(0,1fr);gap:5px}
.color-control input[type=color]{height:38px;padding:2px;cursor:pointer}
.color-control button{grid-column:1/-1;justify-self:start}
.color-control label{font-size:14px}
@media(max-width:640px){
.workspace{grid-template-columns:minmax(0,1fr) minmax(115px,36%)}
.inspector{padding:8px}
.inspector .pair,.sliders{grid-template-columns:minmax(0,1fr)}
.inspector h2{font-size:14px}
#selection{overflow-wrap:anywhere}
.color-control>div{grid-template-columns:30px minmax(0,1fr)}
.color-control input:not([type=color]){padding-inline:3px}
.layers{padding:12px}
}

:root{color-scheme:dark;--ink:#f8f3fa;--muted:#c8bacf;--line:#ffffff29;--accent:#e495c7;--soft:#e495c72b;--surface:#272334;--glass:#292337b8;--control:#100f1d9c}
body{background:radial-gradient(ellipse at 12% 0%,#512c52 0%,transparent 48%),radial-gradient(ellipse at 100% 28%,#233354 0%,transparent 52%),#141321;background-attachment:fixed}
header,.panel,.preview,#colorLab{background:var(--glass);backdrop-filter:blur(18px);-webkit-backdrop-filter:blur(18px);box-shadow:0 15px 44px #0806115c}
header{border-bottom:1px solid var(--line);background:#1b1728ba;min-height:76px}
header p{color:var(--muted)}
.panel,.preview,#colorLab{border-radius:18px}
.mark,.hero-icon,button.primary{background:linear-gradient(140deg,#f2add8,#bf70c5);color:#211026}
button.primary:hover:enabled{background:#ffc2e8;color:#211026}
button,select,#empty,input:not([type=file],[type=range]){background:var(--control);border-color:var(--line);color:var(--ink)}
button:hover:enabled{background:var(--soft)}
button,select,input{outline-offset:3px}
:focus-visible{outline:2px solid var(--accent)}
#empty{background:#221c30ed}
.stage.grid{background-color:#b8aec5;background-image:conic-gradient(#a69ab4 25%,#c8bfd1 0 50%,#a69ab4 0 75%,#c8bfd1 0)}
.danger{color:#ff9cb0}
.row button[aria-pressed=true]{border-color:#e495c775}
.inspector{max-height:calc(clamp(360px,58vh,710px) + 110px);overflow:auto;scrollbar-width:thin}
.color-control>div{grid-template-columns:38px minmax(0,1fr)}
.color-control>div button{grid-column:auto;justify-self:stretch;padding-inline:4px}
.color-control>div button:nth-of-type(1){grid-column:1/-1}
.color-control>div button:nth-of-type(2){grid-column:1/-1}
#colorLab{position:fixed;inset:auto auto 18px 18px;margin:0;width:min(350px,calc(100vw - 36px));max-height:90dvh;padding:17px;border:1px solid var(--line);background:#292337f2;color:var(--ink)}
#colorLab::backdrop{background:#100d2b36}
.color-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px}
#colorSample{height:52px;border:1px solid var(--line);border-radius:10px;overflow:hidden;background:repeating-conic-gradient(#d9ccdf 0 25%,#9b90a7 0 50%) 0/16px 16px}
#colorPaint{height:100%}
.color-channels{display:grid;gap:5px;margin-top:12px}
.color-channels label{display:grid;grid-template-columns:1fr auto;gap:3px;font-size:14px}
.color-channels output{direction:ltr}
.color-channels input[type=range]{grid-column:1/-1;appearance:none;-webkit-appearance:none;direction:ltr;height:16px;margin:0 0 7px;padding:0;border:1px solid var(--line);border-radius:12px;background:var(--track,#61506c);accent-color:var(--accent)}
#hueEdit{--track:linear-gradient(90deg,red,#ff0,#0f0,#0ff,#00f,#f0f,red)}
.color-channels input::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:18px;height:18px;border:2px solid #fff;border-radius:50%;background:#33243a}
.color-channels input::-moz-range-thumb{width:15px;height:15px;border:2px solid #fff;border-radius:50%;background:#33243a}
.hex-label{display:grid;gap:4px;font-size:14px}
.swatches{display:grid;grid-template-columns:repeat(8,1fr);gap:5px;margin-top:11px}
.swatches button,.swatches button:hover:enabled{padding:0;min-height:27px;border-radius:7px;background:var(--swatch)}
@media(max-width:640px){
.inspector{max-height:calc(clamp(245px,39vh,320px) + 124px)}
.color-control>div{grid-template-columns:28px minmax(0,1fr)}
#colorLab{inset:auto 8px 8px;width:auto;max-height:61dvh}
}

#moreEdits{min-width:0;border-top:1px solid var(--line)}
#moreEdits summary{padding:10px 0;cursor:pointer;font-size:14px;line-height:1.5}
.advanced-fields{display:grid;gap:10px}
@media(max-width:640px){
  header{min-height:0;align-items:center;padding:10px;gap:6px}
  header .mark{display:none}
  header h1{font-size:18px}
  header p{display:none}
  header .actions{gap:4px}
  header button{padding-inline:8px}
  main{padding:10px 10px 24px}
  .filebar{margin-bottom:8px}
  .workspace{grid-template-columns:minmax(0,1fr);gap:10px}
  .preview,.inspector,.layers{grid-column:1;grid-row:auto}
  .toolbar{padding:6px;gap:4px}
  .toolbar .actions{gap:4px}
  .toolbar label span{display:none}
  .toolbar button,.toolbar select{padding-inline:6px;font-size:13px}
  .toolbar select{max-width:88px}
  .stage{height:clamp(230px,36svh,340px)}
  #gestureHint{font-size:13px;padding:6px 10px}
  .inspector{max-height:none;overflow:visible;padding:12px}
  .inspector h2{margin-bottom:4px}
  .sliders,.inspector .pair,.color-tools{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .sliders label{grid-template-columns:minmax(0,1fr) auto}
  .color-control>div{grid-template-columns:32px minmax(0,1fr)}
  #tree{max-height:240px}
  .panel,.preview{border-radius:14px}
  #colorLab{max-height:70dvh}
}



/* Neutral black glass theme */
:root {
  color-scheme: dark;
  --ink: #fafafa;
  --muted: #c6c7cd;
  --line: #ffffff2b;
  --accent: #d9e2f2;
  --soft: #ffffff22;
  --glass: #18191dc7;
  --control: #090a0dd9;
}
body {
  background: radial-gradient(ellipse at 12% 0%, #383a41, transparent 50%),
    radial-gradient(ellipse at 95% 45%, #25262c, transparent 54%), #070809;
  background-attachment: fixed;
}
header { background: #101115bf; }
.panel, .preview, #colorLab {
  box-shadow: inset 0 1px #ffffff15, 0 15px 44px #0008;
}
.mark, .hero-icon, button.primary {
  background: linear-gradient(145deg, #4a4d55, #202126);
  color: var(--ink);
}
button.primary:hover:enabled { background: #51535b; color: var(--ink); }
#empty, #colorLab { background: #17181cf5; }
.stage.grid {
  background-color: #34353a;
  background-image: conic-gradient(#27282d 25%, #34353a 0 50%, #27282d 0 75%, #34353a 0);
}
.row button[aria-pressed=true] { border-color: #a9b2c47f; }
#open, #save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  direction: ltr;
  width: 104px;
  min-height: 44px;
  padding: 3px 7px;
  border: 1px solid #ffffff30;
  border-radius: 999px;
  background: linear-gradient(145deg, #343840, #24272e);
  color: #fff;
  font: 700 12px/1 Arial, sans-serif;
}
#open {
  background: linear-gradient(145deg, #2a584a, #203b34);
  border-color: #8ac5af45;
}
#open:hover:enabled, #save:hover:enabled { filter: brightness(1.15); }
#save:disabled { opacity: .56; border-color: #ffffff24; }
#save:disabled .button-icon { background: #ffffff16; }
#open .button-icon, #save .button-icon {
  display: grid;
  place-items: center;
  order: 1;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #ffffff21;
  flex: 0 0 20px;
  position: relative;
}
.button-icon::before {
  content: "";
  width: 2px;
  height: 10px;
  background: currentColor;
  border-radius: 2px;
}
.button-icon::after {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: translateY(2px) rotate(45deg);
}
#open .button-icon { transform: rotate(180deg); }
@media (max-width: 520px) {
  header .mark, header .brand p { display: none; }
  header h1 { font-size: 16px; }
  header .actions { gap: 4px; flex-wrap: nowrap; }
  #open, #save { width: 88px; }
}

#objectMode[aria-pressed=true] { background: #284d40; border-color: #a8d8c1; color: #fff; }
#exportDialog {
  width: min(420px, calc(100% - 28px));
  background: #17181c;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  padding: 16px;
}
#exportDialog::backdrop { background: #0008; }
#exportDialog .actions { margin-top: 12px; }
#exportLink { color: white; background: #284d40; padding: 9px 12px; border-radius: 8px; }

body {
  background: radial-gradient(ellipse at 75% 0%, #313744 0%, transparent 43%),
    radial-gradient(ellipse at 0% 28%, #201f29 0%, transparent 48%), #08090c;
  background-attachment: fixed;
}
header { background: #101115e0; padding-block: 12px; }
header .actions { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
#open, #save {
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  width: clamp(86px, 25vw, 122px);
  gap: 7px;
  padding: 4px 10px;
  direction: rtl;
  border-radius: 11px;
  font: 700 14px/1.2 Tahoma, Arial, sans-serif;
}
#open .button-icon, #save .button-icon { order: 0; }
#open { background: linear-gradient(150deg,#386755,#1b3a30); }
#save { background: linear-gradient(150deg,#3b4454,#202530); }
.toolbar { background: #11131b85; }
#exportDialog { max-height: 85dvh; overflow: auto; }
.export-options { display: grid; gap: 10px; margin-top: 12px; }
.export-options section { padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.export-options h3 { margin: 0 0 4px; font-size: 16px; }
.export-options p, #exportStatus { color: var(--muted); font-size: 14px; }
#pngLink { color: white; background: #284d40; padding: 9px 12px; border-radius: 8px; }
#pngPreview { display: block; max-width: 100%; max-height: 160px; margin: 12px auto 0; object-fit: contain; }
@media(max-width: 520px) {
  header { padding-inline: 10px; }
  header .actions { gap: 5px; }
  #open,#save { padding-inline: 6px; gap: 4px; }
}

html[lang=en] #open, html[lang=en] #save, html[lang=en] #empty { direction:ltr; }
#language { min-height:38px; margin-inline-start:auto; }
header .brand { order:-2; }
#language { order:-1; }
.help-button {
  display:inline-grid; place-items:center; vertical-align:middle;
  width:28px; height:28px; min-height:28px; padding:0;
  border-radius:50%; font:700 13px/1 system-ui; color:var(--muted);
}
#toolHelp { width:min(390px,calc(100% - 28px)); border:1px solid var(--line); border-radius:16px; padding:18px; background:#17181c; color:var(--ink); }
#toolHelp p { margin-block:10px 16px; }
#toolHelp::backdrop { background:#0008; }
@media(max-width:520px){
  header{display:grid;grid-template-columns:minmax(0,1fr) auto;}
  header .actions{grid-column:1/-1;}
  #open,#save{width:100%;}
}


.preferences { display:flex; gap:6px; order:-1; margin-inline-start:auto; }
.preferences select { min-height:38px; }
html[data-theme=light] {
  color-scheme: light;
  --ink:#17202b;
  --muted:#485465;
  --line:#68748342;
  --accent:#27546b;
  --soft:#dfeaf0;
  --glass:#ffffffc9;
  --control:#ffffffeb;
}
html[data-theme=light] body {
  background:radial-gradient(ellipse at 85% 0%,#dce8f3,transparent 55%),#f5f7fa;
}
html[data-theme=light] header { background:#ffffffdb;color:var(--ink); }
html[data-theme=light] header { box-shadow:0 8px 24px #34445b17; }
html[data-theme=light] .panel,html[data-theme=light] .preview { box-shadow:0 12px 28px #34445b17; }
html[data-theme=light] .toolbar,html[data-theme=light] #empty,
html[data-theme=light] #toolHelp,html[data-theme=light] #colorLab,
html[data-theme=light] #exportDialog { background:#fff;color:var(--ink); }
html[data-theme=light] .stage.grid {
  background-color:#fff;
  background-image:conic-gradient(#e3e8ef 25%,#fff 0 50%,#e3e8ef 0 75%,#fff 0);
}
html[data-theme=light] #save { background:linear-gradient(145deg,#43546b,#303e50); }
html[data-theme=light] .danger {color:#a52242}
@media(max-width:520px){
  .preferences{gap:4px}
  .preferences select{font-size:13px;padding-inline:5px}
}

/* Match the embedded document's scheme so browsers keep its canvas transparent. */
#live { color-scheme: only light; background: transparent; }

.showcase { margin-top: 16px; }
.showcase-grid { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:12px; }
.demo-card,.product-card {
  display:grid; gap:8px; padding:10px; border:1px solid var(--line);
  background:var(--control); color:var(--ink); border-radius:12px;
  text-align:start; text-decoration:none; min-width:0;
}
.demo-card:hover:enabled,.product-card:hover { background:var(--soft); border-color:var(--accent); }
.demo-card img { display:block; width:100%; aspect-ratio:3/2; object-fit:cover; border-radius:7px; }
.demo-card span { padding:4px 2px; font-weight:700; }
.product-card { border-block-start:2px solid var(--accent); padding:15px; }
.product-card h3 { margin:0; font-size:16px; line-height:1.4; }
@media(max-width:640px) {
  .showcase-grid { grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr)); gap:8px; }
}

.showcase-grid { grid-template-columns:repeat(4,minmax(0,1fr)); }
.showcase-heading { display:flex; align-items:baseline; justify-content:space-between; gap:8px 16px; flex-wrap:wrap; margin-bottom:12px; }
.showcase-heading h2 { margin:0; }
.shop-link { color:var(--accent); font-size:14px; text-underline-offset:3px; }
.product-card { grid-template-rows:auto 1fr auto; }
.product-card img { display:block; width:100%; aspect-ratio:16/10; object-fit:contain; border-radius:7px; background:var(--soft); }
@media(max-width:800px){.showcase-grid{grid-template-columns:repeat(2,minmax(0,1fr));}}

.color-control>div { grid-template-columns:46px minmax(0,1fr); }
.color-control input[type=color] { min-height:46px; padding:4px; }
.color-control [data-color] { min-height:44px; font-weight:600; }

.affiliate-panel {
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:12px 24px;
}
.affiliate-panel h2 { margin-bottom:5px; }
.affiliate-link {
  display:inline-flex;
  align-items:center;
  min-height:44px;
  padding:8px 14px;
  border-radius:9px;
  background:#284d40;
  color:#fff;
  text-decoration:none;
  font-weight:600;
}
.affiliate-link:hover { background:#356454; }

#effectsDialog {
  width:min(410px,calc(100% - 28px)); max-height:85dvh; overflow:auto;
  border:1px solid var(--line); border-radius:16px;
  background:#17181c; color:var(--ink); padding:16px;
}
#effectsDialog::backdrop { background:#0008; }
html[data-theme=light] #effectsDialog { background:#fff; }
#effectForm fieldset { border:0; padding:0; margin:0 0 12px; display:grid; gap:9px; }
#effectForm input[type=color] { min-height:40px; padding:3px; }
#effectForm input[type=range] { accent-color:var(--accent); }
#effectStatus { margin-block: 6px; }

#effectsDialog {
  width:auto; max-height:none; margin:0; border:0; border-top:1px solid var(--line);
  border-radius:0; padding:12px 16px; background:var(--glass);
}
#effectForm fieldset { grid-template-columns:repeat(auto-fit,minmax(min(100%,140px),1fr)); }
#effectForm fieldset p { grid-column:1/-1; }
#effectForm label { min-width:0; }
#cropFrame {
  position:absolute; left:0; top:0; transform-origin:0 0; z-index:2;
  border:2px solid #53dcff; box-shadow:0 0 0 1px #0008;
  pointer-events:none; direction:ltr;
}
#cropFrame span {
  position:absolute; width:32px; height:32px; border-radius:50%;
  pointer-events:auto; touch-action:none; cursor:nwse-resize;
  display:grid; place-items:center;
}
#cropFrame span::after { content:""; width:12px; height:12px; border:2px solid #0b667f; background:#fff; border-radius:3px; }
#cropFrame [data-edge=tl] { top:-16px; left:-16px; }
#cropFrame [data-edge=tr] { top:-16px; right:-16px; cursor:nesw-resize; }
#cropFrame [data-edge=bl] { bottom:-16px; left:-16px; cursor:nesw-resize; }
#cropFrame [data-edge=br] { bottom:-16px; right:-16px; }
#effectForm input[type=range] { min-height:32px; direction:ltr; }

.toolbar {
  display:grid; grid-template-columns:auto auto minmax(0,1fr);
  justify-content:initial; align-items:center; gap:8px; padding:9px;
}
.tool-group { display:flex; gap:4px; align-items:center; min-width:0; }
.tool-history { padding-inline-end:8px; border-inline-end:1px solid var(--line); }
.tool-view { justify-self:end; }
.tool-group button:not(.help-button),.tool-group select { min-height:40px; padding-inline:9px; }
.tool-history #undo,.tool-history #redo { width:40px; padding:0; font:23px/1 system-ui,sans-serif; }
#addText::before { content:"+"; margin-inline-end:5px; font-weight:700; }
#effectActions,#elementActions { display:grid; gap:6px; margin-top:10px; }
#effectActions { grid-template-columns:repeat(2,minmax(0,1fr)); }
#elementActions { grid-template-columns:repeat(3,minmax(0,1fr)); padding-top:9px; border-top:1px solid var(--line); }
#effectActions button,#elementActions button { width:100%; min-height:42px; padding-inline:4px; }
#effectActions button { background:var(--soft); }
#effectActions button[aria-pressed=true] { border-color:var(--accent); color:var(--accent); }
#remove { border-color:currentColor; }
@media(max-width:900px){
  .toolbar { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .tool-history { grid-column:1/-1; grid-row:1; padding:0; border:0; flex-wrap:wrap; }
  .tool-view { grid-column:2; grid-row:2; }
  .tool-edit { grid-column:1; grid-row:2; flex-wrap:wrap; }
}
@media(max-width:640px){
  .toolbar { gap:5px; padding:6px; }
  .tool-group button:not(.help-button),.tool-group select { padding-inline:5px; }
  .tool-history #undo,.tool-history #redo { width:34px; padding:0; }
  .tool-view .help-button { flex-shrink:0; width:24px; height:24px; min-height:24px; }
  .tool-view select { min-width:0; }
  #effectActions { grid-template-columns:repeat(4,minmax(0,1fr)); }
}

.media-tools { padding:12px; border-top:1px solid var(--line); }
.stack-header { display:flex; align-items:baseline; justify-content:space-between; gap:8px; margin-top:12px; }
.stack-header h2 { font-size:15px; }
.stack-header span { font-size:13px; color:var(--muted); }
#stackCards { display:flex; gap:6px; overflow:auto; padding:5px 2px 8px; }
#stackCards button {
  display:grid; grid-template-rows:30px auto; align-items:center; gap:4px;
  flex:0 0 90px; min-width:0; padding:6px; cursor:grab;
}
#stackCards button[aria-pressed=true] { border-color:var(--accent); background:var(--soft); }
#stackCards button>span:last-child { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
#stackCards img { justify-self:center; width:100%; height:30px; object-fit:contain; }
.stack-index { color:var(--muted); font-variant-numeric:tabular-nums; }
#stackControls { margin-top:4px; }

#lockElement { grid-column:1/-1; }
#lockElement[aria-pressed=true] { border-color:var(--accent); color:var(--accent); background:var(--soft); }

.workspace-tools { grid-column:2; grid-row:1; padding:0; min-width:0; }
.workspace-tabs { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:4px; padding:7px; border-bottom:1px solid var(--line); }
.workspace-tabs button { border:1px solid transparent; background:transparent; min-height:40px; }
.workspace-tabs button[aria-selected=true] { border-color:var(--line); background:var(--soft); color:var(--accent); }
.workspace-tools>section { padding:13px; }
.workspace-tools .layers { max-height:calc(clamp(360px,58vh,710px) + 110px); overflow:auto; }
#insertMenu { position:relative; }
#insertSummary { list-style:none; border:1px solid var(--line); border-radius:8px; padding:8px 10px; font-size:14px; cursor:pointer; background:var(--control); }
#insertSummary::-webkit-details-marker { display:none; }
#insertSummary span { font-weight:700; }
.insert-options { position:absolute; inset-block-start:calc(100% + 4px); inset-inline-end:0; min-width:175px; z-index:9; background:var(--surface); border:1px solid var(--line); border-radius:9px; padding:5px; box-shadow:0 7px 22px #0005; }
html[data-theme=light] .insert-options { background:#fff; }
.insert-options button { display:block; width:100%; text-align:start; margin-block:2px; }
#addText::before { content:none; }
@media(max-width:640px){
  .workspace-tools{grid-column:1;grid-row:auto}
  .workspace-tools .layers{max-height:none}
}

#exportSelected { grid-column:1/-1; border-color:var(--accent); color:var(--accent); }
#layersPane .media-tools { padding:10px 0 0; margin-top:10px; }
#layersPane .stack-header { margin-top:0; flex-wrap:wrap; }
#layersPane .stack-header h2 { margin:0; }
#layersPane #tree { max-height:300px; }
.audit summary { cursor:pointer; font-weight:600; }
.audit[open] summary { margin-bottom:8px; }
