:root {
  --bg: #0b1020;
  --fg: #eaf0ff;
  --muted: rgba(234,240,255,.72);
  --panel: rgba(18,26,51,.92);
  --panel2: rgba(18,26,51,.70);
  --line: rgba(122,162,255,.22);
  --accent: #7aa2ff;
  --danger: #ff667a;
  --shadow: 0 12px 40px rgba(0,0,0,.45);
}
:root[data-theme="light"] {
  --bg: #f6f8ff;
  --fg: #0b1020;
  --muted: rgba(11,16,32,.70);
  --panel: rgba(255,255,255,.96);
  --panel2: rgba(255,255,255,.75);
  --line: rgba(12,23,60,.14);
  --accent: #2f6bff;
  --danger: #d7263d;
  --shadow: 0 12px 40px rgba(0,0,0,.14);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: radial-gradient(1200px 800px at 20% 10%, rgba(122,162,255,.22), var(--bg));
  color: var(--fg);
}

.topbar {
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(0,0,0,.12), transparent);
}
.brand { display:flex; align-items:center; gap: 12px; }
.logo {
  width: 36px; height: 36px;
  display:grid; place-items:center;
  border-radius: 10px;
  background: rgba(122,162,255,.18);
  border: 1px solid rgba(122,162,255,.35);
  font-weight: 700;
}
.title { font-weight: 650; }
.subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.actions { display:flex; align-items:center; gap: 10px; flex-wrap: wrap; }

.layout {
  display:grid;
  grid-template-columns: 300px 1fr;
  height: calc(100% - 66px);
}
.sidebar {
  padding: 14px;
  border-right: 1px solid var(--line);
  background: rgba(0,0,0,.06);
}
.sidebar h2 { margin: 4px 0 8px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.moduleList { display:grid; gap: 10px; margin-top: 12px; }
.hint {
  margin-top: 16px;
  padding: 12px;
  border-radius: 14px;
  background: var(--panel2);
  border: 1px solid var(--line);
}
.hint ul { margin: 8px 0 0; padding-left: 18px; color: var(--muted); font-size: 13px; }

.canvas {
  position: relative;
  overflow: hidden;
}

.btn {
  border: 1px solid rgba(122,162,255,.35);
  background: rgba(122,162,255,.18);
  color: var(--fg);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
}
.btn:hover { background: rgba(122,162,255,.28); }
.btn.secondary { background: rgba(234,240,255,.08); border-color: rgba(234,240,255,.18); }
:root[data-theme="light"] .btn.secondary { background: rgba(11,16,32,.06); border-color: rgba(11,16,32,.14); }
.btn.danger { background: rgba(255,102,122,.12); border-color: rgba(255,102,122,.35); }
.btn.danger:hover { background: rgba(255,102,122,.18); }

.win {
  position:absolute;
  top: 40px;
  left: 40px;
  width: 440px;
  height: 260px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.win:focus { outline: 2px solid rgba(122,162,255,.35); outline-offset: 2px; }
.win.minimized { height: 44px !important; }

.winBar {
  height: 44px;
  display:flex;
  align-items:center;
  justify-content: space-between;
  padding: 0 10px 0 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.06);
  cursor: grab;
  user-select: none;
}
.winTitle { font-weight: 650; }
.winBtns { display:flex; gap: 8px; }
.iconBtn {
  width: 32px; height: 28px;
  border-radius: 10px;
  border: 1px solid rgba(234,240,255,.18);
  background: rgba(234,240,255,.06);
  color: var(--fg);
  cursor: pointer;
}
:root[data-theme="light"] .iconBtn { border-color: rgba(11,16,32,.14); background: rgba(11,16,32,.05); }
.iconBtn:hover { background: rgba(122,162,255,.18); border-color: rgba(122,162,255,.35); }

.winBody {
  height: calc(100% - 44px);
  overflow: auto;
  padding: 12px;
}

/* Resize handles */
.resizeHandle { position:absolute; background: transparent; }
.resizeHandle.n { top:-6px; left:10px; right:10px; height:12px; cursor:n-resize; }
.resizeHandle.s { bottom:-6px; left:10px; right:10px; height:12px; cursor:s-resize; }
.resizeHandle.e { right:-6px; top:10px; bottom:10px; width:12px; cursor:e-resize; }
.resizeHandle.w { left:-6px; top:10px; bottom:10px; width:12px; cursor:w-resize; }
.resizeHandle.ne { right:-6px; top:-6px; width:16px; height:16px; cursor:ne-resize; }
.resizeHandle.nw { left:-6px; top:-6px; width:16px; height:16px; cursor:nw-resize; }
.resizeHandle.se { right:-6px; bottom:-6px; width:16px; height:16px; cursor:se-resize; }
.resizeHandle.sw { left:-6px; bottom:-6px; width:16px; height:16px; cursor:sw-resize; }

@media (max-width: 920px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); }
}
