/* ============================================================
   Dev hub — layered creative canvas
============================================================ */

.designer-app {
  /* Light: :root has no --surface; dark overridden below */
  --surface: #f5f6f8;
  --surface-muted: #eef0f4;
  --text-muted: #5c6470;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] .designer-app {
  --surface: #1c1f28;
  --surface-muted: #252830;
  --text-muted: #9aa3b2;
}

html[data-theme="soft"] .designer-app {
  --surface: #323846;
  --surface-muted: #3d4454;
  --text-muted: #a0a8b8;
}

.designer-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.designer-topbar h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.designer-tagline {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  flex: 1 1 200px;
}

.designer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.designer-topbar .designer-toolbar {
  flex: 1 1 100%;
}

.designer-toolbar-secondary {
  padding-top: 8px;
  margin-top: 2px;
  border-top: 1px solid var(--border);
}

.designer-template-select {
  min-width: 168px;
  height: 32px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
}

.designer-toolbar-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-right: 4px;
}

.designer-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 14px;
  gap: 10px;
}

.designer-text-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.designer-text-toolbar.hidden {
  display: none !important;
}

.designer-text-toolbar .fmt-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-muted);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}

.designer-text-toolbar .fmt-btn:hover {
  background: var(--bg);
}

.designer-text-toolbar .fmt-select {
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-muted);
  color: var(--text);
  font-size: 12px;
}

.designer-text-toolbar .fmt-color {
  width: 32px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.designer-canvas-wrap {
  flex: 1;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 280px;
  overflow: auto;
  padding: 16px;
  background: repeating-conic-gradient(#e8e8e8 0% 25%, #f4f4f4 0% 50%) 50% / 16px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
}

html[data-theme="dark"] .designer-canvas-wrap,
html[data-theme="soft"] .designer-canvas-wrap {
  background: repeating-conic-gradient(#252830 0% 25%, #1c1f28 0% 50%) 50% / 16px 16px;
}

#messageDesignerArtboard {
  position: relative;
  flex-shrink: 0;
  min-width: 560px;
  min-height: 400px;
  box-shadow: var(--dialog-shadow);
  border: 1px solid var(--dialog-border);
  border-radius: 4px;
  overflow: hidden;
  background: #ffffff;
  touch-action: none;
}

html[data-theme="dark"] #messageDesignerArtboard,
html[data-theme="soft"] #messageDesignerArtboard {
  border-color: var(--border);
}

#messageDesignerArtboard.md-exporting .md-handle,
#messageDesignerArtboard.md-exporting .md-drag-strip {
  opacity: 0 !important;
  pointer-events: none !important;
}

.md-layer {
  position: absolute;
  box-sizing: border-box;
  min-width: 48px;
  min-height: 36px;
  outline: none;
}

.md-layer--selected {
  z-index: 9000 !important;
  box-shadow: 0 0 0 2px var(--accent);
}

.md-drag-strip {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 22px;
  display: flex;
  align-items: center;
  padding: 0 6px;
  background: rgba(42, 77, 143, 0.12);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  cursor: grab;
  z-index: 2;
  font-size: 10px;
  color: var(--text-muted);
  user-select: none;
}

html[data-theme="dark"] .md-drag-strip,
html[data-theme="soft"] .md-drag-strip {
  background: rgba(138, 180, 248, 0.12);
  border-bottom-color: var(--border);
}

.md-drag-strip:active {
  cursor: grabbing;
}

.md-layer--text .md-text-body {
  position: absolute;
  left: 0;
  right: 0;
  top: 22px;
  bottom: 0;
  padding: 8px;
  overflow: auto;
  outline: none;
  font-size: 16px;
  line-height: 1.35;
  color: #1a1a1a;
  background: transparent;
}

html[data-theme="dark"] .md-layer--text .md-text-body,
html[data-theme="soft"] .md-layer--text .md-text-body {
  color: var(--text);
}

.md-layer--image img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  display: block;
  pointer-events: none;
  user-select: none;
}

.md-layer--image .md-drag-strip {
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.2);
}

.md-layer--frame .md-frame-inner {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
}

.md-layer--shape .md-shape-inner {
  position: absolute;
  inset: 0;
  box-sizing: border-box;
}

.md-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px;
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 2px;
  z-index: 10;
  box-sizing: border-box;
}

.md-handle[data-h="nw"] {
  left: 0;
  top: 0;
  cursor: nwse-resize;
}
.md-handle[data-h="n"] {
  left: 50%;
  top: 0;
  margin-left: -5px;
  cursor: ns-resize;
}
.md-handle[data-h="ne"] {
  right: 0;
  top: 0;
  cursor: nesw-resize;
}
.md-handle[data-h="e"] {
  right: 0;
  top: 50%;
  margin-top: -5px;
  cursor: ew-resize;
}
.md-handle[data-h="se"] {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}
.md-handle[data-h="s"] {
  left: 50%;
  bottom: 0;
  margin-left: -5px;
  cursor: ns-resize;
}
.md-handle[data-h="sw"] {
  left: 0;
  bottom: 0;
  cursor: nesw-resize;
}
.md-handle[data-h="w"] {
  left: 0;
  top: 50%;
  margin-top: -5px;
  cursor: ew-resize;
}

.md-layer:not(.md-layer--selected) .md-handle {
  display: none;
}

.designer-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.designer-hint kbd {
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 11px;
  background: var(--surface-muted);
}

.composer-budget-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.composer-budget-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  background: var(--surface-muted, #f8fafc);
  flex-shrink: 0;
}

.composer-budget-reload-btn {
  font-weight: 700;
}

.composer-budget-toolbar-hint {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  line-height: 1.3;
}

.composer-budget-frame {
  flex: 1;
  width: 100%;
  min-height: 0;
  border: 0;
  background: var(--bg, #fff);
}
