:root {
  --bg: #0f0f13;
  --surface: #17171d;
  --surface2: #1e1e27;
  --surface3: #26262f;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --accent: #6c63ff;
  --accent2: #9d96ff;
  --accent-dim: rgba(108,99,255,0.15);
  --text: #e8e8f0;
  --text2: #9090a8;
  --text3: #55556a;
  --success: #3ecf8e;
  --warn: #f59e0b;
  --danger: #ef4444;
}

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

body {
  font-family: 'Golos Text', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── TOP BAR ── */
.topbar {
  height: 48px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 7px;
  flex-shrink: 0;
  z-index: 100;
}
.topbar-logo { font-size: 14px; font-weight: 600; color: var(--accent2); letter-spacing: -0.3px; white-space: nowrap; }
.topbar-logo span { color: var(--text3); font-weight: 400; }
.topbar-sep { width: 1px; height: 20px; background: var(--border2); flex-shrink: 0; }
.topbar-btn {
  height: 30px; padding: 0 10px; border-radius: 6px;
  border: 1px solid var(--border2); background: var(--surface2);
  color: var(--text2); font-size: 12px; cursor: pointer;
  display: flex; align-items: center; gap: 5px;
  transition: all 0.15s; font-family: inherit; white-space: nowrap; flex-shrink: 0;
}
.topbar-btn:hover { background: var(--surface3); color: var(--text); }
.topbar-btn.accent { background: var(--accent); color: #fff; border-color: var(--accent); }
.topbar-btn.accent:hover { background: #7c74ff; }
.topbar-spacer { flex: 1; }
.topbar-zoom { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text3); flex-shrink: 0; }
.topbar-zoom button { width: 24px; height: 24px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface2); color: var(--text2); cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; transition: all 0.1s; }
.topbar-zoom button:hover { background: var(--surface3); color: var(--text); }
.zoom-val { min-width: 38px; text-align: center; font-family: 'JetBrains Mono', monospace; font-size: 11px; }

/* ── DEVICE PICKER ── */
.device-picker { position: relative; flex-shrink: 0; }
.device-current-btn { gap: 6px; }
.device-dims { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text3); }
.device-menu {
  position: absolute; top: 38px; left: 0;
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 10px; min-width: 224px; z-index: 500;
  padding: 5px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  display: none;
}
.device-group-title { font-size: 9px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.08em; padding: 7px 8px 3px; }
.device-option {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; border-radius: 6px; cursor: pointer;
  transition: background 0.1s; font-size: 12px; color: var(--text2);
}
.device-option:hover { background: var(--surface3); color: var(--text); }
.device-option.active { background: var(--accent-dim); color: var(--accent2); }
.device-option .d-dims { font-family: 'JetBrains Mono', monospace; font-size: 10px; color: var(--text3); margin-left: auto; }

/* ── MAIN LAYOUT ── */
.main { display: flex; flex: 1; overflow: hidden; }

/* ── LEFT PANEL ── */
.left-panel {
  width: 236px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.search-wrap { padding: 8px; border-bottom: 1px solid var(--border); flex-shrink: 0; position: relative; }
.search-inp {
  width: 100%; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 8px; padding: 6px 8px 6px 28px; color: var(--text);
  font-size: 12px; font-family: inherit; outline: none; transition: border-color 0.15s;
}
.search-inp:focus { border-color: var(--accent); }
.search-inp::placeholder { color: var(--text3); }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text3); font-size: 12px; pointer-events: none; }
.elements-scroll { flex: 1; overflow-y: auto; padding: 4px 6px 8px; }
.elements-scroll::-webkit-scrollbar { width: 3px; }
.elements-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.group-title {
  font-size: 9.5px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 9px 4px 4px;
}
.el-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; }
.el-grid.g3 { grid-template-columns: repeat(3, 1fr); }
.el-btn {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 7px; padding: 7px 3px 5px;
  cursor: grab; text-align: center; transition: all 0.15s; user-select: none;
}
.el-btn:hover { background: var(--surface3); border-color: var(--accent); transform: translateY(-1px); }
.el-btn:active { cursor: grabbing; transform: scale(0.96); }
.el-btn .ico { font-size: 16px; display: block; line-height: 1.2; }
.el-btn .lbl { font-size: 9px; color: var(--text3); margin-top: 2px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.el-btn.hidden { display: none; }
.no-results { font-size: 11px; color: var(--text3); padding: 10px 12px; display: none; }
.group-block.hidden-group { display: none; }
.custom-add { padding: 8px; border-top: 1px solid var(--border); flex-shrink: 0; }
.custom-row { display: flex; gap: 4px; }
.custom-inp {
  flex: 1; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 6px; padding: 5px 8px; color: var(--text);
  font-size: 12px; font-family: inherit; outline: none;
}
.custom-inp:focus { border-color: var(--accent); }
.custom-inp::placeholder { color: var(--text3); }
.custom-add-btn {
  background: var(--accent-dim); border: 1px solid var(--accent);
  border-radius: 6px; color: var(--accent2); padding: 5px 10px;
  font-size: 14px; cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.custom-add-btn:hover { background: var(--accent); color: #fff; }

/* ── CANVAS ── */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  position: relative;
  background: var(--bg);
  background-image: radial-gradient(circle, rgba(255,255,255,0.025) 1px, transparent 1px);
  background-size: 20px 20px;
}
.canvas-scale { transform-origin: center center; transition: transform 0.2s; }

/* ── DEVICE FRAMES ── */
.device-frame {
  position: relative;
  background: var(--surface);
  box-shadow: 0 0 0 6px var(--surface2), 0 30px 80px rgba(0,0,0,0.5);
}
.device-frame.phone-type {
  border: 2px solid var(--border2);
  padding: 14px 10px 0;
}
.device-frame.tablet-type {
  border: 2px solid var(--border2);
  padding: 14px 10px 10px;
}
.device-frame.desktop-type {
  border: 1.5px solid var(--border2);
  padding: 0;
}
.phone-cam { width: 10px; height: 10px; border-radius: 50%; background: var(--surface3); border: 1.5px solid var(--border2); margin: 0 auto 10px; }
.phone-home-bar { width: 50px; height: 4px; background: var(--border2); border-radius: 3px; margin: 8px auto 6px; }
.tablet-cam { width: 8px; height: 8px; border-radius: 50%; background: var(--surface3); border: 1px solid var(--border2); margin: 0 auto 8px; }
.browser-chrome {
  height: 38px; background: var(--surface2); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 10px; gap: 8px;
  border-radius: 8px 8px 0 0;
}
.browser-dots { display: flex; gap: 5px; }
.browser-dot { width: 10px; height: 10px; border-radius: 50%; }
.browser-dot.red { background: #ff5f57; }
.browser-dot.yellow { background: #febc2e; }
.browser-dot.green { background: #28c840; }
.browser-urlbar {
  flex: 1; background: var(--surface3); border-radius: 5px;
  height: 22px; padding: 0 10px;
  display: flex; align-items: center;
  font-size: 10px; color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}

.device-screen {
  background: #fafafa;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.dark-screen .device-screen { background: #1a1a2e; }

/* ── SCREEN ELEMENTS ── */
.screen-el { position: absolute; cursor: move; user-select: none; }
.screen-el:hover .el-handles { opacity: 1; }
.screen-el.sel .el-handles { opacity: 1; }
.el-handles { opacity: 0; transition: opacity 0.1s; }
.el-body {
  width: 100%; height: 100%;
  display: flex; align-items: center;
  font-family: 'Golos Text', sans-serif;
  overflow: hidden; white-space: pre-wrap;
  word-break: break-word; line-height: 1.35;
  box-sizing: border-box;
}
.screen-el.sel .el-body { outline: 2px solid #6c63ff; outline-offset: 1px; }
.resize-handle {
  position: absolute; width: 8px; height: 8px;
  background: #6c63ff; border: 1.5px solid #fff;
  border-radius: 2px; z-index: 10;
}
.resize-handle.br { bottom: -4px; right: -4px; cursor: se-resize; }
.resize-handle.bm { bottom: -4px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-handle.mr { right: -4px; top: 50%; transform: translateY(-50%); cursor: e-resize; }
.del-btn {
  position: absolute; top: -8px; right: -8px;
  width: 17px; height: 17px; border-radius: 50%;
  background: #ef4444; color: #fff; font-size: 10px;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; z-index: 20; border: 1.5px solid #fff; line-height: 1;
}
.screen-el.sel .del-btn { display: flex; }

/* ── RIGHT PANEL ── */
.right-panel {
  width: 226px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.rp-header { flex-shrink: 0; }
.rp-title {
  font-size: 10px; font-weight: 600; color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.08em;
  padding: 9px 12px 6px; border-bottom: 1px solid var(--border);
}
.rp-empty { padding: 14px 12px; font-size: 12px; color: var(--text3); line-height: 1.8; }
.rp-fields { padding: 8px 10px; overflow-y: auto; flex: 1; min-height: 0; }
.rp-fields::-webkit-scrollbar { width: 3px; }
.rp-fields::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.field-row { margin-bottom: 8px; }
.field-label { font-size: 9.5px; color: var(--text3); margin-bottom: 3px; display: block; text-transform: uppercase; letter-spacing: 0.06em; }
.field-inp {
  width: 100%; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 5px; padding: 5px 7px; color: var(--text);
  font-size: 11px; font-family: inherit; outline: none; transition: border-color 0.15s;
}
.field-inp:focus { border-color: var(--accent); }
.field-inp[type=number] { font-family: 'JetBrains Mono', monospace; }
.field-textarea { resize: none; line-height: 1.4; }
.field-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.section-sep { height: 1px; background: var(--border); margin: 7px 0; }
.color-row { display: flex; gap: 4px; align-items: flex-start; }
.color-swatches { display: flex; flex-wrap: wrap; gap: 3px; flex: 1; }
.swatch {
  width: 18px; height: 18px; border-radius: 3px; cursor: pointer;
  border: 1.5px solid transparent; transition: all 0.1s; flex-shrink: 0;
}
.swatch.active { border-color: #fff !important; transform: scale(1.2); }
.swatch:hover { transform: scale(1.1); }
.color-custom {
  width: 24px; height: 24px; border: 1px solid var(--border2); border-radius: 4px;
  cursor: pointer; padding: 1px; background: var(--surface2); flex-shrink: 0;
}
.align-btns { display: flex; gap: 3px; }
.align-btn {
  flex: 1; height: 27px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text2); font-size: 13px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.1s;
}
.align-btn:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent2); }
.border-row { display: flex; gap: 4px; align-items: center; }
.toggle-wrap { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.toggle-wrap input { display: none; }
.toggle-pill {
  width: 32px; height: 17px; background: var(--surface3);
  border-radius: 20px; position: relative; transition: background 0.2s;
  border: 1px solid var(--border2); flex-shrink: 0;
}
.toggle-pill::after {
  content: ''; width: 13px; height: 13px; background: var(--text3);
  border-radius: 50%; position: absolute; top: 1px; left: 1px; transition: all 0.2s;
}
.toggle-wrap input:checked + .toggle-pill { background: var(--accent); border-color: var(--accent); }
.toggle-wrap input:checked + .toggle-pill::after { left: 16px; background: #fff; }
.layer-order-btns { display: flex; gap: 4px; }
.lo-btn {
  flex: 1; height: 26px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 4px; color: var(--text2); font-size: 10.5px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 3px;
  transition: all 0.1s; font-family: inherit;
}
.lo-btn:hover { background: var(--accent-dim); border-color: var(--accent); color: var(--accent2); }

.rp-layers { flex-shrink: 0; max-height: 150px; display: flex; flex-direction: column; overflow: hidden; }
.layer-list { overflow-y: auto; flex: 1; padding: 3px 5px; }
.layer-list::-webkit-scrollbar { width: 3px; }
.layer-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.layer-item {
  display: flex; align-items: center; gap: 5px; padding: 4px 6px;
  border-radius: 5px; cursor: pointer; font-size: 11px; color: var(--text2); transition: all 0.1s;
}
.layer-item:hover { background: var(--surface2); color: var(--text); }
.layer-item.active { background: var(--accent-dim); color: var(--accent2); }
.layer-ico { font-size: 12px; width: 16px; text-align: center; flex-shrink: 0; }

.rp-bottom { border-top: 1px solid var(--border); padding: 8px; display: flex; flex-direction: column; gap: 5px; flex-shrink: 0; }
.screen-toggle { display: flex; gap: 4px; }
.stoggle {
  flex: 1; padding: 5px; border-radius: 5px; border: 1px solid var(--border);
  background: transparent; color: var(--text3); font-size: 10px;
  cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.stoggle.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent2); }
.rp-btn {
  width: 100%; padding: 6px; border-radius: 6px; border: 1px solid var(--border2);
  background: var(--surface2); color: var(--text2); font-size: 11px; cursor: pointer;
  font-family: inherit; transition: all 0.15s; display: flex; align-items: center;
  justify-content: center; gap: 4px;
}
.rp-btn:hover { background: var(--surface3); color: var(--text); }
.rp-btn.danger:hover { background: rgba(239,68,68,0.1); border-color: #ef4444; color: #ef4444; }
.rp-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.rp-btn.primary:hover { background: #7c74ff; }
.rp-btn-row { display: flex; gap: 4px; }
.rp-btn.half { flex: 1; }

/* ── TOAST ── */
.toast {
  position: fixed; bottom: 18px; left: 50%;
  transform: translateX(-50%) translateY(60px);
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: 8px; padding: 7px 16px; font-size: 12px; color: var(--text);
  z-index: 9999; transition: transform 0.25s; pointer-events: none; white-space: nowrap;
}
.toast.show { transform: translateX(-50%) translateY(0); }
