.editor-body { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }

.ed-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(10, 10, 20, 0.85);
  flex: 0 0 auto;
}
.ed-hint { font-size: 13px; font-weight: 400; margin: 0; color: var(--muted); }
.ed-topbar-actions { display: flex; gap: 10px; }

.ed-note { font-size: 12px; color: rgba(154, 160, 181, 0.85); line-height: 1.5; margin-top: 8px; }

.tag-alert {
  font-size: 12.5px; font-weight: 600; color: #fbbf24;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 9px; padding: 8px 11px; margin: -2px 0 10px;
  animation: tag-alert-in 0.18s ease;
}
@keyframes tag-alert-in {
  from { opacity: 0; transform: translateY(-3px); }
  to { opacity: 1; transform: translateY(0); }
}

.ed-layout { flex: 1; display: flex; min-height: 0; }

/* ---------- Sidebar ---------- */
.ed-sidebar {
  width: 318px; flex: 0 0 auto; overflow-y: auto;
  padding: 18px 16px 40px;
  border-right: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--bg-soft);
  scrollbar-width: thin;
}
.ed-group { margin-bottom: 24px; }
.ed-group h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin-bottom: 10px; font-family: var(--font);
}
.ed-row { display: flex; gap: 8px; margin-top: 8px; }
.w-half { flex: 1; justify-content: center; font-size: 13.5px; padding: 9px 8px; }

.mini-btn {
  flex: 1; padding: 7px 6px; font-size: 12.5px; font-weight: 600;
  background: var(--card); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 9px; cursor: pointer;
}
.mini-btn:hover { background: rgba(255, 255, 255, 0.09); }
.mini-btn.danger:hover { background: rgba(244, 63, 94, 0.18); border-color: rgba(244, 63, 94, 0.4); }

.slide-list { display: flex; flex-wrap: wrap; gap: 7px; }
.slide-chip {
  width: 44px; height: 64px; border-radius: 9px; cursor: pointer;
  border: 1.5px solid var(--card-border); background: var(--card);
  display: grid; place-items: center; position: relative; overflow: hidden;
  font-size: 13px; font-weight: 700; color: var(--muted);
  background-size: cover; background-position: top center;
  padding: 0;
}
.slide-chip.active { border-color: var(--c1); color: var(--text); box-shadow: 0 0 12px rgba(99, 102, 241, 0.4); }
.slide-chip .num {
  position: absolute; bottom: 3px; right: 3px;
  font-size: 10px; line-height: 1; padding: 3px 6px; border-radius: 6px;
  background: rgba(5, 5, 10, 0.78); color: #fff;
}
.slide-chip.has-img.active { border-color: var(--c1); }

.upload-zone {
  display: block; text-align: center; padding: 20px 12px;
  border: 1.5px dashed rgba(139, 92, 246, 0.5); border-radius: 12px;
  cursor: pointer; font-size: 13.5px; color: var(--muted);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.upload-zone:hover, .upload-zone.drag { background: rgba(139, 92, 246, 0.09); border-color: var(--c1); }
.upload-zone small { color: rgba(154, 160, 181, 0.7); }

.tpl-swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tpl-swatch {
  height: 54px; border-radius: 10px; cursor: pointer; border: 1.5px solid transparent;
  display: flex; align-items: flex-end; padding: 6px 8px;
  font-size: 11px; font-weight: 700; color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
}
.tpl-swatch:hover { transform: translateY(-2px); }
.tpl-swatch.active { border-color: #fff; }

.color-field {
  flex: 1; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 9px; padding: 6px 10px;
}
.color-field input[type="color"] {
  width: 30px; height: 26px; border: none; background: none; cursor: pointer; padding: 0;
}

.range-field { display: block; font-size: 13px; color: var(--muted); margin-top: 10px; }
.range-field input { width: 100%; accent-color: var(--c1); margin-top: 4px; }

.text-field { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.text-field input,
.text-field textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px;
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: 9px; color: var(--text); font-size: 14px; font-family: var(--font);
  box-sizing: border-box;
}
.text-field textarea { resize: vertical; min-height: 58px; line-height: 1.45; }
.text-field input:focus,
.text-field textarea:focus { outline: none; border-color: var(--c1); }

.sel {
  flex: 1.4; padding: 8px 10px; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--card-border); border-radius: 9px; font-size: 13.5px;
}

.seg { display: flex; background: var(--card); border: 1px solid var(--card-border); border-radius: 10px; padding: 3px; }
.seg button {
  flex: 1; padding: 7px 4px; font-size: 13px; font-weight: 600; color: var(--muted);
  background: none; border: none; border-radius: 8px; cursor: pointer;
}
.seg button.active { background: linear-gradient(135deg, var(--c1), var(--c2)); color: #fff; }

.size-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.size-list label {
  display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--muted);
  padding: 7px 10px; background: var(--card); border: 1px solid var(--card-border);
  border-radius: 9px; cursor: pointer;
}
.size-list input { accent-color: var(--c1); }
.size-list b { color: var(--text); font-weight: 600; }

.ed-status { font-size: 12.5px; color: #a7f3d0; margin-top: 10px; min-height: 18px; }
.ed-privacy { font-size: 12px; color: rgba(154, 160, 181, 0.75); text-align: center; line-height: 1.5; }

/* ---------- Stage ---------- */
.ed-stage {
  flex: 1; display: grid; place-items: center; overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(99, 102, 241, 0.12), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(217, 70, 239, 0.10), transparent 45%),
    var(--bg);
  perspective: 1400px;
  padding: 24px;
}
.canvas-tilt { transform-style: preserve-3d; transition: transform 0.25s ease; }
#preview {
  height: min(82vh, 780px); width: auto;
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.ed-stage.mode-3d .canvas-tilt { transform: rotateX(8deg) rotateY(-14deg); }
.ed-stage.mode-3d #preview { box-shadow: -40px 50px 90px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1); }

/* ---------- Feature Graphic Studio ---------- */
.fg-badge {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 600; color: var(--text);
  margin: 0; padding: 7px 16px; border-radius: 100px;
  background: rgba(139, 92, 246, 0.12); border: 1px solid rgba(139, 92, 246, 0.35);
}
.fg-badge em { font-style: normal; color: var(--muted); font-weight: 500; }

.fg-main {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 26px clamp(16px, 3vw, 44px) 70px;
  background:
    radial-gradient(circle at 18% 8%, rgba(99, 102, 241, 0.10), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(217, 70, 239, 0.08), transparent 40%),
    var(--bg);
}

.fg-stage { display: grid; place-items: center; perspective: 1400px; padding: 12px 0 4px; }
#fgPreview {
  width: min(100%, 1000px); height: auto;
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.fg-stage.mode-3d .canvas-tilt { transform: rotateX(6deg) rotateY(-10deg); }
.fg-stage.mode-3d #fgPreview { box-shadow: -40px 50px 90px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.1); }

.fg-chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 18px 0 30px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12.5px; color: var(--muted);
  padding: 8px 15px; border-radius: 100px;
  background: var(--card); border: 1px solid var(--card-border);
}
label.chip { cursor: pointer; color: var(--text); }
.chip input { accent-color: var(--c1); }

.fg-controls {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 14px; max-width: 1180px; margin: 0 auto;
}
.fg-card {
  background: var(--card); border: 1px solid var(--card-border);
  border-radius: var(--radius); padding: 18px;
  transition: border-color 0.2s ease, opacity 0.2s ease;
}
.fg-card:hover { border-color: rgba(139, 92, 246, 0.35); }
.fg-card h3 {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); margin-bottom: 12px; font-family: var(--font);
}
.fg-card.disabled { opacity: 0.38; pointer-events: none; }

.fg-stack { display: grid; gap: 14px; align-content: start; }

.layout-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.layout-btn {
  display: grid; gap: 4px; place-items: center;
  padding: 7px 5px; border-radius: 10px; cursor: pointer;
  background: var(--bg-soft); border: 1.5px solid var(--card-border);
  color: var(--muted); font-size: 11.5px; font-weight: 600; font-family: var(--font);
}
.layout-btn svg { width: 100%; height: 20px; opacity: 0.9; }
.layout-btn:hover { color: var(--text); }
.layout-btn.active {
  border-color: var(--c1); color: var(--text);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.35);
}

.upload-zone.slim { padding: 13px 10px; }
.upload-zone.slim + .upload-zone.slim { margin-top: 10px; }

.add-sub { display: block; width: 100%; margin-bottom: 10px; padding: 8px 6px; }

/* ---------- Icon Studio ---------- */
.icon-previews {
  display: flex; flex-wrap: wrap; gap: 26px;
  justify-content: center; align-items: center;
  padding: 10px 0;
}
.icon-tile { display: grid; gap: 10px; justify-items: center; }
.icon-tile span { font-size: 12px; font-weight: 600; color: var(--muted); }
.icon-tile canvas {
  width: 148px; height: 148px;
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.07);
  background:
    repeating-conic-gradient(rgba(255,255,255,0.05) 0% 25%, transparent 0% 50%)
    0 0 / 22px 22px; /* checkerboard hints at transparency under dark/tinted */
}
.icon-tile .mask-squircle { border-radius: 24%; }
.icon-tile .mask-circle { border-radius: 50%; }
.icon-tile .mask-rounded { border-radius: 14%; }
.icon-tile.phone canvas {
  width: 190px; height: auto;
  box-shadow: none; background: none; border-radius: 0;
}

@media (max-width: 900px) {
  .editor-body { overflow: auto; height: auto; }
  .ed-layout { flex-direction: column-reverse; }
  .ed-sidebar { width: 100%; border-right: none; border-top: 1px solid rgba(255,255,255,.07); }
  .ed-stage { min-height: 70vh; }
  .ed-topbar-mid { display: none; }

  /* Action buttons wrap onto their own horizontally-scrollable strip instead
     of overflowing the viewport or squeezing labels onto two lines. */
  .ed-topbar { flex-wrap: wrap; row-gap: 10px; }
  .ed-topbar-actions {
    width: 100%; flex-wrap: nowrap; justify-content: flex-start;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    padding-bottom: 4px; margin: 0 -20px; padding-left: 20px; padding-right: 20px;
  }
  .ed-topbar-actions::-webkit-scrollbar { height: 4px; }
  .ed-topbar-actions::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 4px; }
  .ed-topbar-actions .btn {
    flex: 0 0 auto; white-space: nowrap;
    padding: 8px 14px; font-size: 13px;
  }
}

@media (max-width: 420px) {
  .logo { font-size: 17px; }
  .logo-mark { width: 22px; height: 22px; }
}
