:root {
  --bg: #0a0a0f;
  --surface: #14141c;
  --surface-2: #1c1c28;
  --border: #2a2a38;
  --text: #f3f3f7;
  --muted: #8a8a9b;
  --accent: #8b5cf6;
  --accent-soft: rgba(139, 92, 246, .15);
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: 'Inter', system-ui, sans-serif; min-height: 100vh; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.glass {
  background: rgba(20, 20, 28, .7);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid var(--border);
}

.topbar {
  height: 60px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 50;
  border-radius: 0; border-left: 0; border-right: 0; border-top: 0;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: 'Space Grotesk', sans-serif; font-weight: 700; letter-spacing: .15em; font-size: 13px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; }
.logo::after { content: ''; width: 8px; height: 8px; background: var(--bg); border-radius: 2px; }

.device-toggle { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.device-toggle button { width: 32px; height: 28px; background: transparent; border: 0; color: var(--muted); border-radius: 7px; font-size: 14px; }
.device-toggle button.active { background: var(--surface-2); color: var(--text); box-shadow: var(--shadow); }

.header-actions { display: flex; align-items: center; gap: 12px; }
.saved { font-size: 10px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); padding: 7px 14px; border-radius: 999px; font-size: 12px; }
.btn-ghost:hover { background: var(--surface); }
.btn-primary { background: var(--text); color: var(--bg); border: 0; padding: 7px 16px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.btn-primary.published { background: #34d399; }

.workspace { display: grid; grid-template-columns: 280px 1fr 320px; height: calc(100vh - 60px); }
.panel { border-right: 1px solid var(--border); padding: 20px; overflow-y: auto; }
.panel.right { border-right: 0; border-left: 1px solid var(--border); }
.panel-title { font-size: 10px; text-transform: uppercase; letter-spacing: .2em; color: var(--muted); margin: 0 0 12px; font-weight: 600; }
.hint { font-size: 11px; color: var(--muted); margin: -8px 0 12px; }

.palette { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.palette button {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 10px 8px; border-radius: 10px; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: all .15s;
}
.palette button:hover { border-color: var(--accent); background: var(--accent-soft); transform: translateY(-1px); }
.palette button .ico { font-size: 18px; }

.block-list { display: flex; flex-direction: column; gap: 6px; }
.block-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; display: flex; align-items: center; gap: 10px; cursor: grab; font-size: 12px;
  user-select: none;
}
.block-item:hover { border-color: #3a3a4a; }
.block-item.selected { border-color: var(--accent); background: var(--accent-soft); }
.block-item.dragging { opacity: .4; }
.block-item .handle { color: var(--muted); cursor: grab; }
.block-item .label { flex: 1; }
.block-item .del { background: transparent; border: 0; color: var(--muted); font-size: 16px; padding: 0 4px; }
.block-item .del:hover { color: #f87171; }

.stage { position: relative; display: flex; align-items: center; justify-content: center; overflow: auto; background: rgba(0,0,0,.3); }
.glow { position: absolute; width: 500px; height: 500px; border-radius: 50%; background: var(--accent); opacity: .12; filter: blur(120px); pointer-events: none; }
.device-frame { position: relative; z-index: 1; transition: width .3s; }
.device-frame.mobile { width: 380px; }
.device-frame.tablet { width: 560px; }
.device-frame.desktop { width: 800px; }

.phone-preview {
  background: var(--bg); border: 1px solid var(--border); border-radius: 28px;
  padding: 28px 20px; min-height: 600px; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow);
}

/* Rendered blocks inside preview */
.pv-profile { text-align: center; margin-bottom: 24px; }
.pv-avatar { width: 88px; height: 88px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), #ec4899); margin: 0 auto 12px; display: grid; place-items: center; font-size: 32px; font-weight: 700; color: #fff; overflow: hidden; }
.pv-avatar img { width: 100%; height: 100%; object-fit: cover; }
.pv-name { font-weight: 700; font-size: 18px; margin: 0 0 4px; }
.pv-bio { color: var(--muted); font-size: 13px; margin: 0; }

.pv-text { text-align: center; padding: 8px 4px 16px; font-size: 14px; color: var(--text); line-height: 1.55; }
.pv-heading { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 18px; text-align: center; margin: 16px 0 8px; }

.pv-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 16px; border-radius: 12px; margin-bottom: 10px;
  text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px;
  min-height: 48px; transition: transform .15s, background .15s;
  border: 1px solid transparent; cursor: pointer;
}
.pv-btn:active { transform: scale(.98); }
.pv-btn.filled { background: var(--accent); color: #fff; }
.pv-btn.outline { border-color: var(--border); background: transparent; }
.pv-btn.glass { background: rgba(255,255,255,.06); border-color: var(--border); backdrop-filter: blur(8px); }

.pv-socials { display: flex; justify-content: center; gap: 12px; margin: 12px 0 16px; flex-wrap: wrap; }
.pv-socials a {
  width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-size: 18px;
  transition: all .15s;
}
.pv-socials a:hover { background: var(--accent-soft); border-color: var(--accent); transform: translateY(-2px); }

.pv-gallery { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.pv-gallery img, .pv-gallery .ph { aspect-ratio: 1; border-radius: 10px; background: var(--surface); object-fit: cover; width: 100%; display: grid; place-items: center; color: var(--muted); font-size: 22px; }

.pv-video { aspect-ratio: 16/9; border-radius: 12px; overflow: hidden; margin-bottom: 12px; background: #000; }
.pv-video iframe { width: 100%; height: 100%; border: 0; }

.pv-divider { height: 1px; background: var(--border); margin: 16px 0; }

.url-bar { position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 999px; font-size: 11px; font-family: ui-monospace, monospace; color: var(--muted); z-index: 2; }
.url-bar input { background: transparent; border: 0; outline: 0; color: var(--text); width: 100px; font-family: inherit; font-size: 11px; }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 10px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; outline: 0;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type="color"] { height: 36px; padding: 2px; cursor: pointer; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.stat span { font-size: 9px; text-transform: uppercase; letter-spacing: .15em; color: var(--muted); }
.stat strong { display: block; font-size: 16px; margin-top: 4px; }

.inspector-empty { font-size: 12px; color: var(--muted); padding: 16px; text-align: center; border: 1px dashed var(--border); border-radius: 10px; }

/* Modal preview */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(8px); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal[hidden] { display: none; }
.modal-inner { position: relative; }
.modal-close { position: absolute; top: -40px; right: 0; background: transparent; border: 0; color: #fff; font-size: 28px; cursor: pointer; }
.modal-inner .phone-preview { width: 380px; max-height: 85vh; }

@media (max-width: 1000px) {
  .workspace { grid-template-columns: 1fr; height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--border); max-height: 50vh; }
  .panel.right { border-left: 0; }
  .stage { min-height: 70vh; padding: 30px 10px 70px; }
}
