/* moldui editor overlay — glassmorphism + neon glow theme */

:host {
  /* Brand accents */
  --moldui-primary: #22d3ee;           /* cyan */
  --moldui-primary-dim: #0891b2;
  --moldui-secondary: #60a5fa;         /* bright blue */
  --moldui-secondary-dim: #2563eb;     /* deep blue */
  --moldui-accent: #818cf8;            /* indigo-blue for swap/accents */
  --moldui-success: #34d399;
  --moldui-danger: #f87171;
  --moldui-warn: #fbbf24;

  /* Glass surfaces */
  --moldui-glass: rgba(13, 15, 24, 0.68);
  --moldui-glass-strong: rgba(13, 15, 24, 0.82);
  --moldui-glass-heavy: rgba(13, 15, 24, 0.94);
  --moldui-border: rgba(255, 255, 255, 0.08);
  --moldui-border-strong: rgba(255, 255, 255, 0.14);

  /* Neon glow mixes */
  --moldui-glow-cyan: 0 0 0 1px rgba(34, 211, 238, 0.35), 0 0 24px rgba(34, 211, 238, 0.25);
  --moldui-glow-blue: 0 0 0 1px rgba(96, 165, 250, 0.35), 0 0 24px rgba(96, 165, 250, 0.25);

  /* Text */
  --moldui-text: #e5e7eb;
  --moldui-text-dim: #9ca3af;
  --moldui-text-faint: #6b7280;
  --moldui-text-heading: #f3f4f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

.moldui-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 2147483646;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  color: var(--moldui-text);
}

/* Ambient background glow — tiny fixed gradient for the whole editor */
.moldui-overlay::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: -1;
  background:
    radial-gradient(600px circle at 10% 100%, rgba(34, 211, 238, 0.04), transparent 40%),
    radial-gradient(500px circle at 100% 0%, rgba(96, 165, 250, 0.06), transparent 40%);
}

/* ── Selection & Hover ──────────────────────────────── */

.moldui-selection-box {
  display: none; border: 1.5px solid var(--moldui-primary); border-radius: 3px;
  pointer-events: none; transition: all 0.12s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--moldui-glow-cyan), inset 0 0 0 1px rgba(34, 211, 238, 0.12);
}
.moldui-hover-box {
  display: none; border: 1px dashed rgba(34, 211, 238, 0.5); border-radius: 3px;
  pointer-events: none; transition: all 0.08s ease-out;
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.15);
}
.moldui-hover-label {
  display: none; padding: 3px 8px; border-radius: 5px;
  background: linear-gradient(135deg, var(--moldui-primary-dim), var(--moldui-primary));
  color: #0a0a14; font: 600 10px/1 'JetBrains Mono', ui-monospace, monospace;
  white-space: nowrap; pointer-events: none;
  box-shadow: 0 2px 12px rgba(34, 211, 238, 0.35);
  letter-spacing: 0.02em;
}

/* ── Resize Handles ─────────────────────────────────── */

.moldui-handles { display: none; pointer-events: none; }
.moldui-handle {
  position: absolute; width: 10px; height: 10px;
  background: #fff; border: 1.5px solid var(--moldui-primary); border-radius: 3px;
  pointer-events: auto; cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(34, 211, 238, 0.6), 0 2px 4px rgba(0,0,0,0.3);
}
.moldui-handle:hover {
  transform: scale(1.35);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.9), 0 2px 6px rgba(0,0,0,0.4);
}
.moldui-handle-nw { top: -5px; left: -5px; cursor: nw-resize; }
.moldui-handle-n  { top: -5px; left: calc(50% - 4px); cursor: n-resize; }
.moldui-handle-ne { top: -5px; right: -5px; cursor: ne-resize; }
.moldui-handle-e  { top: calc(50% - 4px); right: -5px; cursor: e-resize; }
.moldui-handle-se { bottom: -5px; right: -5px; cursor: se-resize; }
.moldui-handle-s  { bottom: -5px; left: calc(50% - 4px); cursor: s-resize; }
.moldui-handle-sw { bottom: -5px; left: -5px; cursor: sw-resize; }
.moldui-handle-w  { top: calc(50% - 4px); left: -5px; cursor: w-resize; }

/* ── Floating Toolbar ───────────────────────────────── */

.moldui-toolbar {
  display: none; position: fixed;
  background: var(--moldui-glass);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 12px;
  padding: 5px; gap: 2px; z-index: 4;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
}
.moldui-toolbar button {
  background: transparent; color: var(--moldui-text); border: none;
  padding: 7px 12px; border-radius: 8px;
  font: 500 11px/1 'Inter', system-ui, sans-serif; letter-spacing: 0.01em;
  cursor: pointer; transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap; position: relative;
}
.moldui-toolbar button:hover {
  background: rgba(34, 211, 238, 0.12);
  color: var(--moldui-primary);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.2);
}
.moldui-toolbar button:active { transform: scale(0.96); }

/* ── Style Panel ────────────────────────────────────── */

.moldui-style-panel {
  display: none; position: fixed; top: 8px; right: 8px;
  width: 288px; max-height: calc(100vh - 76px);
  background: var(--moldui-glass-strong);
  backdrop-filter: blur(28px) saturate(180%); -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 14px;
  overflow-y: auto; color: var(--moldui-text);
  font: 12px/1.5 'Inter', system-ui, sans-serif; z-index: 5;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.12) transparent;
  box-shadow: 0 12px 48px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
}
.moldui-style-panel::-webkit-scrollbar { width: 5px; }
.moldui-style-panel::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }

.moldui-sp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.06);
  position: sticky; top: 0; background: rgba(10,10,15,0.98); z-index: 1;
}
.moldui-sp-title { font: 600 12px/1 system-ui; color: #f3f4f6; }
.moldui-sp-close {
  background: none; border: none; color: #6b7280; font-size: 18px;
  cursor: pointer; padding: 0 4px; line-height: 1;
}
.moldui-sp-close:hover { color: #fff; }

.moldui-sp-section { padding: 10px 14px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.moldui-sp-section-title {
  font: 600 10px/1 system-ui; color: #6b7280; text-transform: uppercase;
  letter-spacing: 0.05em; margin-bottom: 8px;
}

.moldui-sp-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.moldui-sp-row label {
  flex: 0 0 60px; font: 11px/1 system-ui; color: #9ca3af; text-align: right;
}

.moldui-sp-row input[type="text"],
.moldui-sp-row input[type="number"] {
  flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px; padding: 5px 8px; color: #e5e7eb; font: 11px/1 monospace;
  outline: none; transition: border-color 0.15s;
}
.moldui-sp-row input:focus { border-color: #3b82f6; }

.moldui-sp-row select {
  flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px; padding: 5px 6px; color: #e5e7eb; font: 11px/1 system-ui;
  outline: none; cursor: pointer;
}
.moldui-sp-row select:focus { border-color: #3b82f6; }

.moldui-sp-row input[type="range"] {
  flex: 1; accent-color: #3b82f6; height: 4px;
}
.moldui-sp-range-val { font: 11px/1 monospace; color: #9ca3af; min-width: 30px; }

.moldui-sp-color-row { display: flex; align-items: center; gap: 6px; flex: 1; }
.moldui-sp-color-row input[type="color"] {
  width: 28px; height: 28px; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px; cursor: pointer; padding: 1px; background: transparent;
}
.moldui-sp-color-row input[type="text"] {
  flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px; padding: 5px 8px; color: #e5e7eb; font: 11px/1 monospace; outline: none;
}

/* Spacing box model */
.moldui-sp-spacing-box {
  position: relative; background: rgba(59,130,246,0.08);
  border: 1px dashed rgba(59,130,246,0.3); border-radius: 6px;
  padding: 22px 28px; margin: 4px 0;
}
.moldui-sp-padding-box {
  position: relative; background: rgba(16,185,129,0.08);
  border: 1px dashed rgba(16,185,129,0.3); border-radius: 4px;
  padding: 18px 24px;
}
.moldui-sp-content-box {
  background: rgba(255,255,255,0.05); border-radius: 3px;
  padding: 8px; text-align: center; font: 10px/1 monospace; color: #6b7280;
}
.moldui-sp-spacing-label {
  position: absolute; top: 2px; left: 6px; font: 9px/1 system-ui;
  color: #6b7280; text-transform: uppercase;
}
.moldui-sp-spacing-input {
  position: absolute; width: 28px; text-align: center;
  background: transparent; border: none; color: #d1d5db;
  font: 11px/1 monospace; outline: none; cursor: text;
}
.moldui-sp-spacing-input:focus { color: #3b82f6; }
.moldui-sp-spacing-input.top { top: 4px; left: calc(50% - 14px); }
.moldui-sp-spacing-input.right { top: calc(50% - 6px); right: 4px; }
.moldui-sp-spacing-input.bottom { bottom: 4px; left: calc(50% - 14px); }
.moldui-sp-spacing-input.left { top: calc(50% - 6px); left: 4px; }

/* ── Viewport Bar ───────────────────────────────────── */

.moldui-viewport-bar {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 2px;
  background: var(--moldui-glass);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 12px;
  padding: 5px; z-index: 4;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  pointer-events: auto;
}
.moldui-viewport-bar button {
  background: transparent; color: var(--moldui-text-faint); border: none;
  padding: 6px 13px; border-radius: 8px;
  font: 500 11px/1 'JetBrains Mono', ui-monospace, monospace;
  cursor: pointer; transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.02em;
}
.moldui-viewport-bar button:hover { color: var(--moldui-text); }
.moldui-viewport-bar button.active {
  background: linear-gradient(135deg, var(--moldui-secondary-dim), var(--moldui-secondary));
  color: #fff;
  box-shadow: 0 2px 12px rgba(96, 165, 250, 0.4), inset 0 1px 0 rgba(255,255,255,0.15);
}

/* ── Breadcrumb ─────────────────────────────────────── */

.moldui-breadcrumb {
  display: none; position: fixed; bottom: 32px; left: 8px;
  background: rgba(10,10,15,0.92); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 8px;
  padding: 6px 10px; font: 11px/1 monospace; color: #6b7280;
  align-items: center; gap: 4px; z-index: 4;
  pointer-events: auto; flex-wrap: wrap; max-width: calc(100vw - 300px);
}
.moldui-bc-item {
  cursor: pointer; padding: 2px 5px; border-radius: 4px;
  transition: all 0.12s; color: #9ca3af;
}
.moldui-bc-item:hover { background: rgba(59,130,246,0.15); color: #60a5fa; }
.moldui-bc-item.active { color: #3b82f6; font-weight: 600; }
.moldui-bc-sep { color: #374151; font-size: 10px; }

/* ── Shimmer Bar (AI Activity) ──────────────────────── */

.moldui-shimmer {
  display: none; position: fixed; bottom: 28px; left: 0; width: 100%;
  height: 36px; align-items: center; justify-content: center; z-index: 6;
  pointer-events: none;
}
.moldui-shimmer::before {
  content: ''; position: absolute; inset: 0;
  backdrop-filter: blur(8px);
}
.moldui-shimmer-working {
  background: linear-gradient(90deg, #0891b2, #22d3ee, #60a5fa, #22d3ee, #0891b2);
  background-size: 300% 100%;
  animation: moldui-shimmer-move 1.8s linear infinite;
  box-shadow: 0 -8px 32px rgba(34, 211, 238, 0.3);
}
.moldui-shimmer-synced {
  background: linear-gradient(90deg, #059669, #34d399, #67e8f9, #34d399, #059669);
  background-size: 300% 100%;
  animation: moldui-shimmer-move 0.8s linear forwards, moldui-shimmer-fade 0.5s 2s ease forwards;
  box-shadow: 0 -8px 32px rgba(52, 211, 153, 0.3);
}
.moldui-shimmer-error {
  background: linear-gradient(90deg, #b91c1c, #f87171, #fca5a5, #f87171, #b91c1c);
  background-size: 300% 100%;
  animation: moldui-shimmer-move 1.5s linear infinite;
  box-shadow: 0 -8px 32px rgba(248, 113, 113, 0.3);
}
.moldui-shimmer-text {
  position: relative; z-index: 1; color: #fff; font: 500 12px/1 system-ui;
  text-shadow: 0 1px 3px rgba(0,0,0,0.4); letter-spacing: 0.01em;
}

@keyframes moldui-shimmer-move {
  0% { background-position: 0% 50%; }
  100% { background-position: 100% 50%; }
}
@keyframes moldui-shimmer-fade {
  to { opacity: 0; }
}

/* ── Status Bar ─────────────────────────────────────── */

.moldui-status-bar {
  position: fixed; bottom: 8px; left: 8px;
  background: var(--moldui-glass);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--moldui-border); border-radius: 10px;
  color: var(--moldui-text-faint);
  font: 500 10px/1 'JetBrains Mono', ui-monospace, monospace;
  padding: 7px 12px; letter-spacing: 0.03em;
  display: flex; align-items: center; gap: 8px; z-index: 4;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  pointer-events: auto;
}
.moldui-status-bar span { color: var(--moldui-text-dim); }
.moldui-status-bar .moldui-sb-dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--moldui-success); box-shadow: 0 0 8px currentColor;
  animation: moldui-sb-pulse 2s ease-in-out infinite;
}
.moldui-status-bar .moldui-sb-dot.offline { background: var(--moldui-danger); animation: none; }
@keyframes moldui-sb-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.9); }
}

/* ── Dimensions Label ───────────────────────────────── */

.moldui-dim-label {
  display: none; background: #3b82f6; color: #fff;
  font: 500 10px/1 monospace; padding: 3px 7px; border-radius: 4px;
  z-index: 4; pointer-events: none; white-space: nowrap;
  box-shadow: 0 2px 6px rgba(59,130,246,0.3);
}

/* ── Drag Ghost ─────────────────────────────────────── */

.moldui-drag-placeholder {
  background: #3b82f6; border-radius: 2px; margin: 2px 0;
  transition: all 0.15s ease; pointer-events: none;
}

/* ── Spacing Guides (Figma-like) ────────────────────── */

.moldui-guides {
  display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  pointer-events: none; z-index: 3;
}
.moldui-guide-line {
  background: #f43f5e; pointer-events: none;
}
.moldui-guide-label {
  background: #f43f5e; color: #fff;
  font: 500 9px/1 monospace; padding: 2px 5px; border-radius: 3px;
  pointer-events: none; white-space: nowrap;
  box-shadow: 0 1px 4px rgba(244,63,94,0.3);
}

/* ── Drop Target Highlight ──────────────────────────── */

.moldui-drop-target {
  outline: 2px dashed #3b82f6 !important;
  outline-offset: 2px;
}

/* ── Editing Active State ───────────────────────────── */

[contenteditable="true"] {
  outline: 2px solid #3b82f6 !important;
  outline-offset: 1px;
  cursor: text !important;
  min-width: 20px;
  min-height: 1em;
}

/* ── Enhanced Selection ─────────────────────────────── */

.moldui-selection-box {
  box-shadow: 0 0 0 1px rgba(59,130,246,0.3);
}

/* ── Toolbar separator ──────────────────────────────── */

.moldui-toolbar-sep {
  width: 1px; height: 20px; background: rgba(255,255,255,0.1);
}

/* ── Action Bar (Undo / Redo / Save) ────────────────── */

.moldui-action-bar {
  position: fixed; top: 8px; right: 8px;
  display: flex; align-items: center; gap: 2px;
  background: var(--moldui-glass);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 12px;
  padding: 5px 7px; z-index: 4;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  pointer-events: auto;
}

.moldui-ab-btn {
  background: transparent; color: var(--moldui-text); border: none;
  padding: 7px 13px; border-radius: 8px;
  font: 500 11px/1 'Inter', system-ui, sans-serif; letter-spacing: 0.01em;
  cursor: pointer; transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap; position: relative;
}
.moldui-ab-btn:hover:not(:disabled) {
  background: rgba(34, 211, 238, 0.12); color: var(--moldui-primary);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.2);
}
.moldui-ab-btn:active:not(:disabled) { transform: scale(0.95); }
.moldui-ab-btn:disabled { cursor: default; }

.moldui-ab-sep { width: 1px; height: 20px; background: var(--moldui-border); margin: 0 4px; }

.moldui-ab-save { color: var(--moldui-text-dim); }

.moldui-ab-dirty {
  background: linear-gradient(135deg, var(--moldui-primary-dim), var(--moldui-primary)) !important;
  color: #0a0a14 !important;
  opacity: 1 !important;
  box-shadow: 0 2px 16px rgba(34, 211, 238, 0.4), inset 0 1px 0 rgba(255,255,255,0.2) !important;
  font-weight: 600 !important;
}
.moldui-ab-dirty:hover {
  background: linear-gradient(135deg, var(--moldui-primary), #67e8f9) !important;
  box-shadow: 0 2px 24px rgba(34, 211, 238, 0.6), inset 0 1px 0 rgba(255,255,255,0.25) !important;
}
.moldui-ab-saving {
  background: rgba(34, 211, 238, 0.18) !important;
  color: var(--moldui-primary) !important;
  box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.3) !important;
  animation: moldui-pulse 1.2s ease-in-out infinite;
}
.moldui-ab-saved {
  background: rgba(52, 211, 153, 0.18) !important;
  color: var(--moldui-success) !important;
  box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.3) !important;
}

.moldui-ab-badge {
  display: none; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--moldui-accent), #6366f1);
  color: #fff; font: 700 9px/1 'Inter', system-ui, sans-serif;
  min-width: 18px; height: 18px; border-radius: 9px; padding: 0 5px;
  margin-left: 3px;
  box-shadow: 0 0 12px rgba(129, 140, 248, 0.5);
}

@keyframes moldui-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* ═══════════════════════════════════════════════════════════ */
/* v2.0 — Figma-level features                                  */
/* ═══════════════════════════════════════════════════════════ */

/* Multi-select */
.moldui-multi-boxes { display: none; position: fixed; top: 0; left: 0; pointer-events: none; z-index: 2; }
.moldui-multi-box {
  border: 2px solid #60a5fa; border-radius: 2px;
  box-shadow: 0 0 0 1px rgba(96, 165, 250, 0.3);
  pointer-events: none;
}

/* Context menu */
.moldui-context-menu {
  display: none; position: fixed;
  background: rgba(10,10,15,0.96); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
  padding: 4px; min-width: 180px; z-index: 8;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: auto;
}
.moldui-cm-item {
  padding: 7px 12px; color: #d1d5db; font: 400 12px/1 system-ui;
  border-radius: 5px; cursor: pointer; transition: all 0.1s;
}
.moldui-cm-item:hover { background: rgba(59,130,246,0.2); color: #fff; }

/* Layers Panel */
.moldui-layers-panel {
  display: none; position: fixed; top: 56px; left: 8px;
  width: 240px; max-height: calc(100vh - 100px);
  flex-direction: column;
  background: rgba(10,10,15,0.96); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 10px;
  color: #d1d5db; font: 11px/1.4 system-ui; z-index: 5;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  overflow: hidden; pointer-events: auto;
}
.moldui-lp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.moldui-lp-title { font: 600 12px/1 system-ui; color: #f3f4f6; }
.moldui-lp-toggle {
  background: none; border: none; color: #6b7280;
  cursor: pointer; padding: 2px 4px; font-size: 11px;
}
.moldui-lp-toggle:hover { color: #fff; }
.moldui-lp-tree {
  flex: 1; overflow-y: auto; padding: 4px 0;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
.moldui-lp-tree::-webkit-scrollbar { width: 5px; }
.moldui-lp-tree::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
.moldui-lp-node {
  display: flex; align-items: center; gap: 4px;
  padding: 3px 8px; cursor: pointer; user-select: none;
  color: #9ca3af; transition: background 0.1s;
}
.moldui-lp-node:hover { background: rgba(59,130,246,0.1); color: #d1d5db; }
.moldui-lp-node.selected { background: rgba(59,130,246,0.25); color: #60a5fa; }
.moldui-lp-caret { width: 12px; font-size: 9px; color: #6b7280; flex-shrink: 0; }
.moldui-lp-icon { width: 14px; text-align: center; color: #6b7280; font-size: 10px; flex-shrink: 0; }
.moldui-lp-label {
  font: 11px/1 monospace; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Cmd+K Palette */
.moldui-palette {
  display: none; position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  width: 540px; max-width: calc(100vw - 40px);
  background: rgba(10,10,15,0.97); backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  z-index: 10; overflow: hidden; pointer-events: auto;
}
.moldui-palette-input {
  width: 100%; background: transparent; border: none; outline: none;
  color: #f3f4f6; font: 400 14px/1.4 system-ui;
  padding: 16px 20px; border-bottom: 1px solid rgba(255,255,255,0.06);
  box-sizing: border-box;
}
.moldui-palette-input::placeholder { color: #4b5563; }
.moldui-palette-results {
  max-height: 400px; overflow-y: auto; padding: 6px;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
.moldui-palette-results::-webkit-scrollbar { width: 5px; }
.moldui-palette-results::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
.moldui-palette-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border-radius: 7px; cursor: pointer;
  color: #d1d5db; transition: background 0.1s;
}
.moldui-palette-row:hover, .moldui-palette-row.selected {
  background: rgba(59,130,246,0.2); color: #fff;
}
.moldui-palette-label { font: 500 12px/1 monospace; color: #60a5fa; flex-shrink: 0; }
.moldui-palette-text {
  font: 400 12px/1.4 system-ui; color: #9ca3af;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.moldui-palette-empty { padding: 20px; text-align: center; color: #4b5563; font: 13px/1 system-ui; }

/* AI Chat Panel */
.moldui-chat-panel {
  display: none; position: fixed; bottom: 70px; right: 12px;
  width: 360px; height: 480px; flex-direction: column;
  background: rgba(10,10,15,0.96); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 12px;
  color: #d1d5db; font: 12px/1.4 system-ui; z-index: 7;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: auto;
}
.moldui-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.moldui-chat-title { font: 600 13px/1 system-ui; color: #f3f4f6; }
.moldui-chat-close {
  background: none; border: none; color: #6b7280; cursor: pointer;
  font-size: 14px; padding: 0 4px;
}
.moldui-chat-close:hover { color: #fff; }
.moldui-chat-messages {
  flex: 1; overflow-y: auto; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: #333 transparent;
}
.moldui-chat-msg { display: flex; }
.moldui-chat-msg-user { justify-content: flex-end; }
.moldui-chat-msg-ai { justify-content: flex-start; }
.moldui-chat-bubble {
  padding: 8px 12px; border-radius: 10px; max-width: 85%;
  font: 12px/1.45 system-ui; white-space: pre-wrap; word-break: break-word;
}
.moldui-chat-msg-user .moldui-chat-bubble { background: #3b82f6; color: #fff; }
.moldui-chat-msg-ai .moldui-chat-bubble { background: rgba(255,255,255,0.06); color: #d1d5db; }
.moldui-chat-input-wrap {
  display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(255,255,255,0.06);
}
.moldui-chat-input {
  flex: 1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px; padding: 8px 10px; color: #e5e7eb;
  font: 12px/1.4 system-ui; outline: none; resize: none;
}
.moldui-chat-input:focus { border-color: #3b82f6; }
.moldui-chat-send {
  background: #3b82f6; color: #fff; border: none;
  padding: 0 14px; border-radius: 6px; font: 500 12px/1 system-ui;
  cursor: pointer; transition: background 0.15s;
}
.moldui-chat-send:hover { background: #2563eb; }
.moldui-chat-hint {
  padding: 6px 14px; font: 400 10px/1.3 system-ui; color: #6b7280;
  border-top: 1px solid rgba(255,255,255,0.04);
}

/* Image Replace */
.moldui-img-replace-btn {
  background: transparent; color: #10b981; border: none;
  padding: 7px 11px; border-radius: 7px; font: 500 11px/1 system-ui;
  cursor: pointer; transition: all 0.15s; margin-left: 3px;
  border-left: 1px solid rgba(255,255,255,0.08); padding-left: 14px;
}
.moldui-img-replace-btn:hover { background: rgba(16,185,129,0.2); }

/* Shortcut Cheatsheet */
.moldui-cheatsheet {
  display: none; position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 520px; max-height: 80vh;
  flex-direction: column;
  background: rgba(10,10,15,0.98); backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 14px;
  color: #d1d5db; font: 12px/1.4 system-ui; z-index: 9;
  box-shadow: 0 16px 48px rgba(0,0,0,0.6);
  pointer-events: auto; overflow: hidden;
}
.moldui-cs-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.06);
}
.moldui-cs-title { font: 600 14px/1 system-ui; color: #f3f4f6; }
.moldui-cs-close {
  background: none; border: none; color: #6b7280;
  cursor: pointer; font-size: 14px; padding: 0 4px;
}
.moldui-cs-close:hover { color: #fff; }
.moldui-cs-body {
  flex: 1; overflow-y: auto; padding: 8px 8px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px 16px;
}
.moldui-cs-section { padding: 8px 12px; }
.moldui-cs-section-title {
  font: 600 10px/1 system-ui; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px;
}
.moldui-cs-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 0; font: 12px/1.3 system-ui;
}
.moldui-cs-key {
  background: rgba(255,255,255,0.06); padding: 3px 8px;
  border: 1px solid rgba(255,255,255,0.08); border-radius: 4px;
  font: 500 11px/1 monospace; color: #60a5fa; white-space: nowrap;
}
.moldui-cs-desc { color: #9ca3af; margin-left: 12px; text-align: right; }

/* Onboarding Tour */
.moldui-tour-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.35); z-index: 8; pointer-events: auto;
}
.moldui-tour-bubble {
  display: none; max-width: 320px;
  background: rgba(10,10,15,0.98); backdrop-filter: blur(24px);
  border: 1px solid rgba(59,130,246,0.3); border-radius: 12px;
  padding: 16px 18px; z-index: 9;
  box-shadow: 0 8px 32px rgba(59,130,246,0.2);
  pointer-events: auto;
}
.moldui-tour-text { color: #e5e7eb; font: 13px/1.5 system-ui; margin-bottom: 10px; }
.moldui-tour-progress {
  color: #6b7280; font: 10px/1 system-ui; margin-bottom: 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.moldui-tour-btns { display: flex; justify-content: flex-end; gap: 6px; }
.moldui-tour-skip {
  background: transparent; color: #9ca3af; border: none;
  padding: 6px 12px; border-radius: 6px; font: 500 11px/1 system-ui;
  cursor: pointer;
}
.moldui-tour-skip:hover { color: #fff; }
.moldui-tour-next {
  background: #3b82f6; color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px; font: 500 11px/1 system-ui;
  cursor: pointer;
}
.moldui-tour-next:hover { background: #2563eb; }

/* Zoom Badge */
.moldui-zoom-badge {
  position: fixed; bottom: 62px; right: 12px;
  background: rgba(10,10,15,0.92); backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 6px;
  padding: 5px 10px; font: 500 11px/1 monospace; color: #9ca3af;
  cursor: pointer; z-index: 4; pointer-events: auto;
  transition: color 0.15s;
}
.moldui-zoom-badge:hover { color: #fff; }

/* ═══════════════════════════════════════════════════════════ */
/* v2.2 — Hi-tech polish                                        */
/* ═══════════════════════════════════════════════════════════ */

/* Hi-tech tooltip (any button with data-moldui-tip) */
[data-moldui-tip] { position: relative; }
[data-moldui-tip]::after {
  content: attr(data-moldui-tip);
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  background: var(--moldui-glass-heavy);
  color: var(--moldui-text);
  border: 1px solid var(--moldui-border-strong);
  padding: 5px 10px; border-radius: 6px;
  font: 500 10px/1.3 'Inter', system-ui, sans-serif;
  white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s ease 0.3s;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
  letter-spacing: 0.01em;
}
[data-moldui-tip]:hover::after { opacity: 1; }

/* Hi-tech welcome / empty state card */
.moldui-welcome {
  position: fixed; bottom: 56px; left: 50%; transform: translateX(-50%);
  min-width: 320px; max-width: 420px;
  background: var(--moldui-glass-strong);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 14px;
  padding: 18px 20px; z-index: 5;
  box-shadow: 0 12px 48px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06);
  pointer-events: auto;
  animation: moldui-welcome-in 0.4s cubic-bezier(0.2, 0, 0.2, 1);
}
.moldui-welcome.hiding {
  animation: moldui-welcome-out 0.25s ease forwards;
}
@keyframes moldui-welcome-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
@keyframes moldui-welcome-out {
  to { opacity: 0; transform: translate(-50%, 12px); }
}
.moldui-welcome-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.moldui-welcome-title {
  font: 600 13px/1 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-heading);
  display: flex; align-items: center; gap: 8px;
}
.moldui-welcome-title::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--moldui-primary);
  box-shadow: 0 0 12px var(--moldui-primary);
  animation: moldui-sb-pulse 2s ease-in-out infinite;
}
.moldui-welcome-close {
  background: transparent; border: none; color: var(--moldui-text-faint);
  cursor: pointer; font-size: 16px; padding: 0 4px; line-height: 1;
  transition: color 0.15s;
}
.moldui-welcome-close:hover { color: var(--moldui-text); }
.moldui-welcome-body {
  font: 12px/1.5 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-dim);
  margin-bottom: 12px;
}
.moldui-welcome-body strong { color: var(--moldui-primary); font-weight: 600; }
.moldui-welcome-tips {
  display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px;
  padding-top: 10px; border-top: 1px solid var(--moldui-border);
}
.moldui-welcome-tip {
  display: flex; align-items: center; gap: 8px;
  font: 11px/1.3 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-dim);
}
.moldui-welcome-kbd {
  display: inline-flex; align-items: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--moldui-border);
  padding: 2px 6px; border-radius: 4px;
  font: 500 10px/1 'JetBrains Mono', ui-monospace, monospace;
  color: var(--moldui-primary);
  min-width: 24px; justify-content: center;
}

/* Guided nudge — transient hint */
.moldui-nudge {
  position: fixed; bottom: 56px; left: 50%; transform: translate(-50%, 8px);
  background: var(--moldui-glass-strong);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(34, 211, 238, 0.35); border-radius: 10px;
  padding: 10px 14px; z-index: 5;
  font: 500 12px/1.4 'Inter', system-ui, sans-serif;
  color: var(--moldui-text); white-space: nowrap;
  box-shadow: 0 8px 32px rgba(34, 211, 238, 0.15), 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0; pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.2, 0, 0.2, 1);
}
.moldui-nudge.show {
  opacity: 1; transform: translate(-50%, 0); pointer-events: auto;
}
.moldui-nudge::before {
  content: '✦'; color: var(--moldui-primary); margin-right: 6px;
  text-shadow: 0 0 8px currentColor;
}

/* ═══════════════════════════════════════════════════════════ */
/* v2.3 — Auto-sync: Apply panel + Claude progress + Suggest    */
/* ═══════════════════════════════════════════════════════════ */

/* Apply panel — shows after Save with Accept / Reject */
.moldui-apply-panel {
  position: fixed; bottom: 52px; right: 8px; width: 320px;
  background: var(--moldui-glass-strong);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 14px;
  padding: 14px; z-index: 7;
  box-shadow: 0 12px 48px rgba(0,0,0,0.55), 0 0 32px rgba(34, 211, 238, 0.15);
  animation: moldui-welcome-in 0.35s cubic-bezier(0.2, 0, 0.2, 1);
}
.moldui-ap-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.moldui-ap-icon {
  color: var(--moldui-primary); font-size: 14px;
  text-shadow: 0 0 8px currentColor;
}
.moldui-ap-title {
  font: 600 13px/1 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-heading);
}
.moldui-ap-files { margin-bottom: 12px; padding: 8px 10px; background: rgba(255,255,255,0.03); border-radius: 8px; border: 1px solid var(--moldui-border); }
.moldui-ap-files-label {
  font: 600 9px/1 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-faint); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 5px;
}
.moldui-ap-file {
  font: 400 11px/1.4 'JetBrains Mono', ui-monospace, monospace;
  color: var(--moldui-text-dim);
}
.moldui-ap-btns { display: flex; gap: 6px; }
.moldui-ap-btn-reject, .moldui-ap-btn-apply {
  flex: 1; padding: 8px 12px; border-radius: 8px; cursor: pointer;
  font: 600 12px/1 'Inter', system-ui, sans-serif;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1); border: none;
}
.moldui-ap-btn-reject {
  background: rgba(255,255,255,0.06); color: var(--moldui-text-dim);
  border: 1px solid var(--moldui-border);
}
.moldui-ap-btn-reject:hover { background: rgba(248, 113, 113, 0.12); color: var(--moldui-danger); border-color: rgba(248, 113, 113, 0.3); }
.moldui-ap-btn-apply {
  background: linear-gradient(135deg, var(--moldui-primary-dim), var(--moldui-primary));
  color: #0a0a14;
  box-shadow: 0 2px 16px rgba(34, 211, 238, 0.4), inset 0 1px 0 rgba(255,255,255,0.2);
}
.moldui-ap-btn-apply:hover:not(:disabled) {
  box-shadow: 0 2px 24px rgba(34, 211, 238, 0.6), inset 0 1px 0 rgba(255,255,255,0.25);
  transform: translateY(-1px);
}
.moldui-ap-btn-apply:disabled { opacity: 0.6; cursor: default; }

/* Claude progress strip (below apply panel) */
.moldui-claude-progress {
  position: fixed; bottom: 52px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 10px;
  background: var(--moldui-glass-strong);
  backdrop-filter: blur(20px) saturate(180%); -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(34, 211, 238, 0.35); border-radius: 10px;
  padding: 9px 14px; z-index: 7;
  box-shadow: 0 8px 32px rgba(34, 211, 238, 0.2);
  font: 500 12px/1 'Inter', system-ui, sans-serif;
  color: var(--moldui-text);
}
.moldui-cp-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--moldui-primary);
  box-shadow: 0 0 12px currentColor;
  animation: moldui-sb-pulse 1s ease-in-out infinite;
}
.moldui-cp-text { letter-spacing: 0.01em; }

/* AI Suggest button in toolbar */
.moldui-suggest-btn {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.15), rgba(129, 140, 248, 0.15)) !important;
  color: var(--moldui-secondary) !important;
  border: 1px solid rgba(96, 165, 250, 0.3) !important;
  padding: 7px 10px !important; border-radius: 8px; font-size: 13px;
  cursor: pointer; transition: all 0.18s; margin-left: 3px;
}
.moldui-suggest-btn:hover {
  background: linear-gradient(135deg, rgba(96, 165, 250, 0.3), rgba(129, 140, 248, 0.3)) !important;
  color: #fff !important;
  box-shadow: 0 0 16px rgba(96, 165, 250, 0.4);
  transform: scale(1.05);
}

/* Suggest result panel */
.moldui-suggest-panel {
  position: fixed; top: 60px; right: 8px; width: 360px;
  max-height: calc(100vh - 120px); display: flex; flex-direction: column;
  background: var(--moldui-glass-strong);
  backdrop-filter: blur(24px) saturate(180%); -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid var(--moldui-border-strong); border-radius: 14px;
  z-index: 7; overflow: hidden;
  box-shadow: 0 12px 48px rgba(0,0,0,0.55), 0 0 32px rgba(96, 165, 250, 0.15);
}
.moldui-sgp-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--moldui-border);
}
.moldui-sgp-title {
  font: 600 13px/1 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-heading);
}
.moldui-sgp-close {
  background: none; border: none; color: var(--moldui-text-faint);
  cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
}
.moldui-sgp-close:hover { color: var(--moldui-text); }
.moldui-sgp-body {
  padding: 14px 16px; overflow-y: auto;
  font: 12px/1.6 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-dim);
  white-space: pre-wrap; word-break: break-word;
}

/* Swap-drag target highlight (hold Alt while dragging) */
.moldui-swap-highlight {
  display: none; border: 2px solid var(--moldui-accent); border-radius: 4px;
  background: rgba(129, 140, 248, 0.08);
  pointer-events: none; transition: all 0.08s ease-out;
  box-shadow: 0 0 20px rgba(129, 140, 248, 0.4), inset 0 0 0 1px rgba(129, 140, 248, 0.25);
}
.moldui-swap-highlight::before {
  content: '⇄ Swap';
  position: absolute; top: -26px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, #6366f1, var(--moldui-accent));
  color: #fff;
  padding: 4px 10px; border-radius: 6px;
  font: 700 10px/1 'Inter', system-ui, sans-serif;
  letter-spacing: 0.02em; white-space: nowrap;
  box-shadow: 0 2px 12px rgba(129, 140, 248, 0.5);
}

/* ═══════════════════════════════════════════════════════════ */
/* v2.4 — Launch polish                                         */
/* ═══════════════════════════════════════════════════════════ */

/* Spacing preset chips in style panel */
.moldui-sp-presets {
  padding: 10px 14px;
  border-bottom: 1px solid var(--moldui-border);
  background: rgba(255, 255, 255, 0.02);
}
.moldui-sp-preset-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.moldui-sp-preset-row:last-child { margin-bottom: 0; }
.moldui-sp-preset-label {
  font: 500 10px/1 'Inter', system-ui, sans-serif;
  color: var(--moldui-text-faint);
  text-transform: uppercase; letter-spacing: 0.06em;
  width: 52px; flex-shrink: 0;
}
.moldui-sp-preset-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--moldui-border);
  color: var(--moldui-text);
  padding: 4px 10px; border-radius: 6px;
  font: 500 11px/1 'JetBrains Mono', ui-monospace, monospace;
  cursor: pointer; transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  flex: 1; min-width: 0;
}
.moldui-sp-preset-chip:hover {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.4);
  color: var(--moldui-primary);
  transform: translateY(-1px);
}
.moldui-sp-preset-chip:active { transform: translateY(0); }

/* Locked element indicator (subtle lock icon on hover) */
[data-moldui-locked]::after {
  content: '🔒';
  position: absolute; top: 2px; right: 2px;
  font-size: 10px;
  opacity: 0.5;
  pointer-events: none;
}

/* Apply panel summary */
.moldui-ap-summary {
  margin-bottom: 12px; padding: 10px 12px;
  background: rgba(34, 211, 238, 0.06);
  border: 1px solid rgba(34, 211, 238, 0.2);
  border-radius: 8px;
}
.moldui-ap-summary-line {
  font: 500 11px/1.4 'Inter', system-ui, sans-serif;
  color: var(--moldui-primary);
  margin-top: 4px;
}
