:root {
  --bg: #0b0d10;
  --panel: #12151a;
  --muted-bg: #161a21;
  --hover: #222833;
  --border: #2a3140;
  --text: #e8eaed;
  --secondary: #a8b0bd;
  --muted: #7a8494;
  --accent: #6b9fff;
  --accent-soft: rgba(107, 159, 255, 0.14);
  --group: #e8a05c;
  --group-bg: rgba(232, 160, 92, 0.08);
  --font: ui-monospace, "Cascadia Mono", "Consolas", "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body, #root {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
}

.app {
  display: grid;
  grid-template-columns: 300px 1fr;
  height: 100%;
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-head {
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.brand {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

.hub-link {
  color: var(--secondary);
  text-decoration: none;
  font-size: 11px;
  border: 1px solid var(--border);
  padding: 4px 8px;
}

.hub-link:hover {
  color: var(--text);
  border-color: var(--text);
}

.search {
  width: 100%;
  background: var(--muted-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 12px;
  border-radius: 0;
  outline: none;
}

.search:focus {
  border-color: var(--accent);
}

.cats {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 8px;
}

.cat-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 10px;
  padding: 3px 7px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.cat-chip.active,
.cat-chip:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-soft);
}

.palette {
  overflow: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tool {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  background: var(--muted-bg);
  cursor: grab;
  text-align: left;
  color: inherit;
  font-family: inherit;
}

.tool:hover {
  background: var(--hover);
  border-color: #3d475a;
}

.tool-icon {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  background: #0b0d10;
  border: 1px solid var(--border);
  overflow: hidden;
}

.tool-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.placeholder {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}

.tool-name {
  font-size: 12px;
  font-weight: 600;
}

.tool-cat {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}

.canvas-wrap {
  position: relative;
  min-width: 0;
  min-height: 0;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

.topbar > * {
  pointer-events: auto;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--panel) 92%, transparent);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 8px 12px;
  cursor: pointer;
  backdrop-filter: blur(6px);
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.react-flow {
  width: 100%;
  height: 100%;
  background:
    radial-gradient(circle at 1px 1px, #2a3140 1px, transparent 0);
  background-size: 22px 22px;
  background-color: var(--bg);
}

.react-flow__controls {
  border: 1px solid var(--border) !important;
  border-radius: 0 !important;
  overflow: hidden;
  box-shadow: none !important;
}

.react-flow__controls-button {
  background: var(--panel) !important;
  border-bottom-color: var(--border) !important;
  fill: var(--secondary) !important;
}

.react-flow__minimap {
  background: var(--panel) !important;
  border: 1px solid var(--border) !important;
  border-radius: 0 !important;
}

.tech-node {
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.tech-node.selected {
  border-color: var(--accent);
}

.tech-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--muted-bg);
}

.tech-head img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.tech-title {
  font-size: 12px;
  font-weight: 700;
}

.tech-body {
  padding: 8px 10px 10px;
  font-size: 10px;
  color: var(--secondary);
  max-width: 220px;
  line-height: 1.35;
}

.group-node {
  width: 100%;
  height: 100%;
  border: 2px solid var(--group);
  background: var(--group-bg);
  border-radius: 4px;
  position: relative;
}

.group-node.selected {
  border-color: #ffc27a;
}

.group-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 28px;
  display: flex;
  align-items: center;
  padding: 0 8px;
  background: rgba(232, 160, 92, 0.22);
  border-bottom: 1px solid rgba(232, 160, 92, 0.45);
}

.group-label input {
  width: 100%;
  background: transparent;
  border: 0;
  color: #ffd7a8;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  outline: none;
}

.group-resize {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 14px;
  height: 14px;
  opacity: 0.7;
  background:
    linear-gradient(135deg, transparent 50%, var(--group) 50%) no-repeat,
    linear-gradient(135deg, transparent 65%, var(--group) 65%) no-repeat;
  background-size: 100% 100%, 70% 70%;
  background-position: right bottom, right bottom;
  pointer-events: none;
}

.react-flow__handle {
  width: 8px !important;
  height: 8px !important;
  border-radius: 0 !important;
  background: var(--accent) !important;
  border: 1px solid #0b0d10 !important;
}

.toast {
  position: absolute;
  z-index: 20;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--secondary);
}

@media (max-width: 800px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
