/* ============================================================
   EDITOR LAYOUT
   ============================================================ */
html,body{ height:100%; overflow:hidden; }
body.editor-body{ display:flex; flex-direction:column; background:var(--paper-deep); }

/* ---- Top toolbar ---- */
.editor-toolbar{
  height:60px; flex-shrink:0; display:flex; align-items:center; gap:14px;
  padding:0 16px; background:var(--surface); border-bottom:1px solid var(--line-soft);
  z-index:40;
}
.tb-group{ display:flex; align-items:center; gap:4px; padding:0 10px; border-right:1px solid var(--line-soft); height:34px; }
.tb-group:last-of-type{ border-right:none; }
.tb-btn{
  width:34px; height:34px; border-radius:9px; border:1px solid transparent; background:transparent;
  display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--ink-soft);
  transition:background .15s, color .15s;
}
.tb-btn:hover{ background:var(--paper); color:var(--ink); }
.tb-btn:disabled{ opacity:.35; cursor:not-allowed; }
.tb-btn.danger:hover{ background:#F6E4E1; color:var(--danger); }
.tb-select{
  height:34px; border-radius:9px; border:1px solid var(--line); background:var(--surface);
  font-family:var(--font-body); font-size:.8rem; padding:0 10px; color:var(--ink); cursor:pointer;
}
.tb-spacer{ flex:1; }
.tb-zoom{ display:flex; align-items:center; gap:6px; font-family:var(--font-mono); font-size:.76rem; color:var(--ink-soft); }
.tb-brand{ display:flex; align-items:center; gap:8px; font-family:var(--font-display); font-weight:600; font-size:.98rem; padding-right:10px; }
.tb-brand .brand-mark{ width:24px; height:24px; }

.dropdown{ position:relative; }
.dropdown-menu{
  position:absolute; top:44px; right:0; background:var(--surface); border:1px solid var(--line-soft);
  border-radius:12px; box-shadow:var(--shadow-lift); min-width:220px; padding:8px; display:none; z-index:60;
}
.dropdown.open .dropdown-menu{ display:block; }
.dropdown-item{
  display:flex; align-items:center; gap:10px; padding:10px 12px; border-radius:8px; cursor:pointer; font-size:.86rem;
}
.dropdown-item:hover{ background:var(--paper); }
.dropdown-item small{ display:block; color:var(--ink-faint); font-size:.72rem; }

/* ---- Main body: rail + panel + canvas + right panel ---- */
.editor-main{ flex:1; display:flex; min-height:0; }

.rail{
  width:76px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--line-soft);
  display:flex; flex-direction:column; align-items:center; padding:14px 0; gap:4px; overflow-y:auto;
}
.rail-btn{
  width:58px; padding:10px 4px 8px; border-radius:12px; border:none; background:transparent; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:5px; color:var(--ink-soft);
}
.rail-btn svg{ width:19px; height:19px; }
.rail-btn span{ font-size:.62rem; font-weight:600; letter-spacing:.01em; }
.rail-btn:hover{ background:var(--paper); color:var(--ink); }
.rail-btn.active{ background:var(--paper-deep); color:var(--brass-deep); }

.side-panel{
  width:296px; flex-shrink:0; background:var(--surface); border-right:1px solid var(--line-soft);
  overflow-y:auto; padding:18px;
}
.side-panel h3{ font-family:var(--font-display); font-size:1rem; margin:0 0 4px; }
.side-panel .hint{ font-size:.78rem; color:var(--ink-faint); margin:0 0 16px; line-height:1.5; }

.panel-section{ margin-bottom:22px; }
.panel-section > label{
  display:block; font-size:.72rem; font-weight:700; letter-spacing:.05em; text-transform:uppercase;
  color:var(--ink-faint); margin-bottom:10px;
}

.tpl-grid{ display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.tpl-thumb{
  aspect-ratio:1.75/1; border-radius:9px; padding:9px 10px; cursor:pointer; position:relative; overflow:hidden;
  display:flex; flex-direction:column; justify-content:space-between; border:1px solid var(--line-soft);
  transition:transform .15s;
}
.tpl-thumb:hover{ transform:translateY(-2px); box-shadow:var(--shadow-soft); }
.tpl-thumb .tn{ font-size:.62rem; font-weight:700; }
.tpl-thumb .tc{ font-size:.5rem; opacity:.7; text-transform:uppercase; letter-spacing:.04em; }

.tool-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.tool-btn{
  aspect-ratio:1; border-radius:10px; border:1px solid var(--line-soft); background:var(--paper);
  display:flex; align-items:center; justify-content:center; cursor:pointer; color:var(--ink-soft);
}
.tool-btn:hover{ border-color:var(--brass); color:var(--brass-deep); }

.field{ margin-bottom:12px; }
.field label{ display:block; font-size:.76rem; color:var(--ink-soft); margin-bottom:6px; }
.field input[type=text], .field input[type=tel], .field input[type=email], .field input[type=url], .field select, .field textarea{
  width:100%; padding:9px 11px; border:1px solid var(--line); border-radius:9px; background:var(--surface);
  color:var(--ink); font-family:var(--font-body); font-size:.86rem;
}
.field textarea{ resize:vertical; min-height:60px; }
.field-row{ display:flex; gap:8px; }
.field-row .field{ flex:1; }

.swatches{ display:flex; flex-wrap:wrap; gap:8px; }
.swatch{ width:26px; height:26px; border-radius:8px; cursor:pointer; border:2px solid var(--surface); box-shadow:0 0 0 1px var(--line); }
.swatch:hover{ transform:scale(1.1); }
.swatch.active{ box-shadow:0 0 0 2px var(--brass); }

.upload-drop{
  border:1.5px dashed var(--line); border-radius:12px; padding:26px 14px; text-align:center; cursor:pointer;
  color:var(--ink-faint); font-size:.82rem;
}
.upload-drop:hover{ border-color:var(--brass); color:var(--brass-deep); }

.layer-row{
  display:flex; align-items:center; gap:8px; padding:8px 8px; border-radius:9px; margin-bottom:4px; cursor:pointer;
  border:1px solid transparent;
}
.layer-row:hover{ background:var(--paper); }
.layer-row.active{ border-color:var(--brass); background:var(--paper); }
.layer-row .ln{ flex:1; font-size:.8rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.layer-row button{ width:22px; height:22px; border:none; background:transparent; color:var(--ink-faint); cursor:pointer; display:flex; align-items:center; justify-content:center; }
.layer-row button:hover{ color:var(--ink); }

/* ---- Canvas stage ---- */
.stage-wrap{
  flex:1; min-width:0; position:relative; overflow:auto;
  background-image: radial-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 18px 18px;
  display:flex; align-items:center; justify-content:center;
}
.canvas-shell{
  position:relative; box-shadow:var(--shadow-lift); border-radius:2px; background:#fff;
}
.canvas-shell canvas{ display:block; }
.bleed-overlay{ position:absolute; inset:0; pointer-events:none; }

.side-panel.right{ border-right:none; border-left:1px solid var(--line-soft); }
.prop-empty{ color:var(--ink-faint); font-size:.85rem; text-align:center; padding:40px 10px; }
.prop-empty svg{ opacity:.4; margin-bottom:10px; }

.slider-row{ display:flex; align-items:center; gap:10px; }
.slider-row input[type=range]{ flex:1; }
.slider-row span{ font-family:var(--font-mono); font-size:.72rem; width:34px; text-align:right; color:var(--ink-soft); }

.seg{ display:flex; border:1px solid var(--line); border-radius:9px; overflow:hidden; }
.seg button{
  flex:1; padding:8px 0; background:var(--surface); border:none; cursor:pointer; color:var(--ink-soft);
  border-right:1px solid var(--line);
}
.seg button:last-child{ border-right:none; }
.seg button.active{ background:var(--brass); color:#fff; }

.toast{
  position:fixed; bottom:22px; left:50%; transform:translateX(-50%) translateY(12px); opacity:0;
  background:var(--ink); color:var(--paper); padding:11px 20px; border-radius:999px; font-size:.84rem;
  box-shadow:var(--shadow-lift); transition:opacity .25s, transform .25s; z-index:200; pointer-events:none;
}
.toast.show{ opacity:1; transform:translateX(-50%) translateY(0); }

@media (max-width: 980px){
  .side-panel{ width:240px; }
}
