/* ---------------- Tool layout ---------------- */
.app{
  display:grid;
  grid-template-columns:1fr 380px 300px;
  grid-template-areas:"stage panel ads";
  min-height:calc(100vh - var(--header-h));
}
@media (max-width:1320px){
  .app{ grid-template-columns:1fr 380px; grid-template-areas:"stage panel" "ads ads"; }
}
@media (max-width:960px){
  .app{ grid-template-columns:1fr; grid-template-areas:"stage" "panel" "ads"; }
}
.stage{ grid-area:stage; }
.panel{ grid-area:panel; }
.ad-rail{ grid-area:ads; }

/* ---------------- Stage ---------------- */
.stage{
  position:relative;
  display:flex;
  flex-direction:column;
  min-height:420px;
  overflow:hidden;
  border-right:1px solid var(--border-soft);
  background:#14151b;
}
@media (max-width:960px){ .stage{border-right:none; border-bottom:1px solid var(--border-soft); min-height:60vh;} }

.stage-topbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  padding:16px;
}
.stage-actions{ display:flex; align-items:center; gap:8px; }
.icon-btn{
  width:34px;height:34px;
  display:flex;align-items:center;justify-content:center;
  background:rgba(255,255,255,0.06);
  backdrop-filter:blur(10px);
  border:1px solid rgba(255,255,255,0.08);
  border-radius:9px;
  color:#fff;
}
.icon-btn:hover{background:rgba(255,255,255,0.14);}

.preview-wrap{
  flex:1;
  display:flex;
  align-items:stretch;
  justify-content:stretch;
  min-height:0;
  padding:20px;
}
#previewFlex{
  display:flex;
  width:100%;
  height:100%;
  background:rgba(255,255,255,0.03);
  border:1px dashed rgba(255,255,255,0.14);
  border-radius:10px;
  padding:16px;
  overflow:auto;
}
.flex-item{
  position:relative;
  min-width:44px;min-height:44px;
  border-radius:9px;
  display:flex;align-items:center;justify-content:center;
  padding:10px 16px;
  box-shadow:0 4px 14px rgba(0,0,0,.25);
  cursor:grab;
  touch-action:none;
}
.flex-item.selected{ outline:2px solid #fff; outline-offset:-2px; }
.flex-item.dragging{ opacity:.55; cursor:grabbing; }
.flex-item .item-label{
  font-family:var(--mono);
  font-size:12.5px;
  font-weight:600;
  color:#0c0d17;
  outline:none;
  cursor:text;
  white-space:nowrap;
}
.flex-item .item-rm{
  position:absolute;
  top:4px; right:4px;
  background:rgba(12,13,17,0.18);
  border:none;
  color:#0c0d17;
  width:16px;height:16px;
  border-radius:50%;
  font-size:12px;line-height:1;
}
.flex-item .item-rm:hover{ background:rgba(12,13,17,0.32); }
.flex-item .resize-handle{
  position:absolute;
  right:-3px; top:50%;
  width:8px; height:26px;
  margin-top:-13px;
  border-radius:4px;
  background:rgba(12,13,17,0.25);
  cursor:ew-resize;
}

.stage-hint{
  text-align:center;
  font-family:var(--mono);
  font-size:11px;
  color:rgba(242,242,239,0.5);
  padding:0 16px 16px;
}

/* ---------------- Control panel ---------------- */
.panel{
  background:var(--surface);
  border-left:1px solid var(--border-soft);
  padding:22px 20px 40px;
  overflow-y:auto;
  max-height:calc(100vh - var(--header-h));
}
@media (max-width:960px){ .panel{border-left:none; max-height:none;} }
.panel h2{ font-family:var(--display); font-size:18px; font-weight:600; margin:0 0 4px; }
.panel .sub{ font-size:12.5px; color:var(--text-faint); margin:0 0 22px; line-height:1.5; }

select, input[type=number], input[type=text]{
  background:var(--surface);
  border:1px solid var(--border-soft);
  border-radius:6px;
  color:var(--text);
  font-family:var(--mono);
  font-size:11.5px;
  padding:6px 8px;
}
select{ width:100%; }
input[type=text]{ width:100%; }

/* ---------------- Item list (reused pattern) ---------------- */
.layer-list{ display:flex; flex-direction:column; gap:8px; }
.layer-row{
  display:flex;align-items:center;gap:10px;
  background:var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius:9px;
  padding:8px 10px;
  cursor:pointer;
}
.layer-row.selected{ border-color:var(--accent-dim); box-shadow:0 0 0 1px var(--accent-dim); }
.layer-swatch{ flex:0 0 auto; width:26px;height:26px; border-radius:7px; border:1px solid var(--border-soft); }
.layer-summary{
  flex:1; min-width:0;
  font-family:var(--mono); font-size:11.5px; color:var(--text-dim);
  display:flex; flex-direction:column; gap:2px;
}
.layer-summary .layer-color{ font-size:10.5px; color:var(--text-faint); }
.layer-row .rm{
  background:none;border:none;color:var(--text-faint);
  font-size:16px;line-height:1;padding:2px 4px;
}
.layer-row .rm:hover{ color:#f0729b; }

.basis-quick-row{ display:flex; gap:6px; margin-top:8px; flex-wrap:wrap; }
.basis-quick{
  font-size:11px;font-family:var(--mono);
  background:var(--surface-2); border:1px solid var(--border-soft);
  color:var(--text-dim);
  padding:4px 8px;border-radius:6px;
}
.basis-quick:hover{ border-color:var(--border); color:var(--text); }

/* ---------------- Presets ---------------- */
.preset-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.preset-btn{
  display:flex;flex-direction:column;align-items:center;gap:8px;
  min-width:0;
  background:var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius:11px;
  padding:10px 8px;
}
.preset-btn:hover{ border-color:var(--border); }
.preset-btn em{ font-style:normal; font-size:11px; color:var(--text-dim); text-align:center; }
.mini-flex{
  display:flex;
  width:100%;height:56px;
  min-width:0;
  padding:6px;
  overflow:hidden;
}
.mini-flex i{ display:block; border-radius:3px; min-width:6px; min-height:6px; }

/* ---------------- Export ---------------- */
.code-box{
  position:relative;
  background:var(--surface-2);
  border:1px solid var(--border-soft);
  border-radius:9px;
  padding:12px;
}
.code-box pre{
  margin:0;
  font-family:var(--mono);
  font-size:11.5px;
  line-height:1.6;
  white-space:pre-wrap;
  word-break:break-all;
  max-height:200px;
  overflow-y:auto;
}
.code-box .copy{
  position:absolute;top:8px;right:8px;
  font-family:var(--mono);
  font-size:10.5px;
  padding:4px 8px;
  background:var(--surface-3);
  border:1px solid var(--border);
  border-radius:6px;
  color:var(--text-dim);
}
.code-box .copy:hover{ color:var(--text); }
.code-tabs{ display:flex; gap:6px; margin-bottom:8px; flex-wrap:wrap; }
.code-tabs button{
  font-size:11px;font-family:var(--mono);
  background:none;border:1px solid var(--border-soft);
  color:var(--text-faint);
  padding:4px 9px;border-radius:6px;
}
.code-tabs button.active{ color:var(--accent-dim); border-color:var(--accent-dim); }
