:root {
  --bg:            #070b10;
  --surface:       #0d1219;
  --surface-hi:    #141c26;
  --surface-hhi:   #1b2535;
  --border:        rgba(255,255,255,0.07);
  --border-bright: rgba(63,255,139,0.3);
  --primary:       #3fff8b;
  --primary-dim:   rgba(63,255,139,0.15);
  --primary-glow:  rgba(63,255,139,0.08);
  --secondary:     #6e9bff;
  --secondary-dim: rgba(110,155,255,0.15);
  --tertiary:      #e966ff;
  --tertiary-dim:  rgba(233,102,255,0.15);
  --danger:        #ff5572;
  --danger-dim:    rgba(255,85,114,0.15);
  --text:          #e8edf5;
  --text-muted:    #6b7585;
  --text-dim:      #9aa3b0;
  --radius-sm:     6px;
  --radius-md:     10px;
  --radius-lg:     16px;
  --mono:          'IBM Plex Mono', monospace;
  --head:          'Manrope', sans-serif;
}

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

body {
  font-family: var(--head);
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.material-symbols-outlined {
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  vertical-align: middle;
  font-size: 18px;
}

/* ─── CANVAS ─────────────────────────────────────────── */
#canvas-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 30% 40%, rgba(63,255,139,0.04) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 75% 70%, rgba(110,155,255,0.04) 0%, transparent 70%),
    var(--bg);
}

#canvas-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}

svg { width: 100%; height: 100%; }

/* ─── CANVAS TOOLBAR ─────────────────────────────────── */
#canvas-toolbar {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-pill {
  background: rgba(13,18,25,0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 100px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
}

.toolbar-pill button {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 100px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.toolbar-pill button.active {
  background: var(--primary);
  color: #004820;
}

.toolbar-pill button:hover:not(.active) {
  background: rgba(255,255,255,0.06);
  color: var(--text);
}

.toolbar-badge {
  background: rgba(13,18,25,0.85);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 0 16px;
  height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-badge span.label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.toolbar-badge span.value {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
}

/* ─── STATS BAR ──────────────────────────────────────── */
#stats-bar {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 10;
  display: flex;
  gap: 6px;
}

.stat-chip {
  background: rgba(13,18,25,0.8);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
#sidebar {
  width: 340px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#sidebar-header {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

#sidebar-header .brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#sidebar-header .brand-name {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

#sidebar-header .brand-sub {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 10px var(--primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(0.85); }
}

#sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-hhi) transparent;
}

#sidebar-scroll::-webkit-scrollbar { width: 4px; }
#sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
#sidebar-scroll::-webkit-scrollbar-thumb { background: var(--surface-hhi); border-radius: 4px; }

/* ─── CARDS ──────────────────────────────────────────── */
.card {
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.2s;
}

.card.selected {
  border-color: var(--border-bright);
  box-shadow: 0 0 24px rgba(63,255,139,0.06);
}

.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-title .material-symbols-outlined { font-size: 14px; color: var(--primary); }

.card-body { padding: 14px 16px; }

/* ─── PLACEHOLDER ────────────────────────────────────── */
#placeholder-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px 0;
  text-align: center;
}

#placeholder-text .icon-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

#placeholder-text p {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 200px;
}

/* ─── FORM ELEMENTS ──────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.field:last-child { margin-bottom: 0; }

label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.add-conn-label {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

input[type="text"],
select,
textarea {
  width: 100%;
  background: var(--surface-hhi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-family: var(--head);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(63,255,139,0.08);
}

input[type="text"]:read-only {
  background: rgba(255,255,255,0.03);
  color: var(--text-muted);
  cursor: not-allowed;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7585' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

select option { background: var(--surface-hi); }

textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}

/* ─── BUTTONS ────────────────────────────────────────── */
.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--head);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #003d20;
}

.btn-primary:hover { background: #5fffaa; box-shadow: 0 0 20px rgba(63,255,139,0.25); }
.btn-primary:active { transform: scale(0.98); }

.btn-ghost {
  background: rgba(255,255,255,0.05);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: rgba(255,255,255,0.09); color: var(--text); }

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(255,85,114,0.2);
}

.btn-danger:hover { background: rgba(255,85,114,0.25); }

.btn .material-symbols-outlined { font-size: 15px; }

/* ─── CONNECTIONS LIST ───────────────────────────────── */
.conn-item {
  background: var(--surface-hhi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.conn-item:last-child { margin-bottom: 0; }

.conn-arrow {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--primary);
  font-weight: 700;
  min-width: 16px;
  text-align: center;
}

.conn-details { flex: 1; }

.conn-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 2px;
}

.conn-type {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── SECTION DIVIDER ────────────────────────────────── */
.section-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 0;
}

/* ─── NODE TYPE BADGES ───────────────────────────────── */
.type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.type-Frontend   { background: rgba(110,155,255,0.15); color: #6e9bff; }
.type-Backend    { background: rgba(255,149,43,0.15);  color: #ff952b; }
.type-Database   { background: rgba(81,207,102,0.15);  color: #51cf66; }
.type-ThirdParty { background: rgba(204,93,232,0.15);  color: #cc5de8; }

/* ─── PATH INFO BLOCK ────────────────────────────────── */
.path-block {
  background: var(--surface-hhi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.path-block strong { color: var(--text); }
.path-block .arrow { color: var(--primary); font-size: 14px; }

/* ─── SIZE PICKER ────────────────────────────────────── */
.size-picker {
  display: flex;
  gap: 5px;
}

.size-radio {
  flex: 1;
  cursor: pointer;
  position: relative;
}

.size-radio input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.size-radio .size-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 48px;
  background: var(--surface-hhi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-weight: 700;
  color: var(--text-muted);
  transition: all 0.15s;
  cursor: pointer;
  user-select: none;
}

/* The node preview dot inside each size button */
.size-radio .size-btn .size-dot {
  border-radius: 50%;
  background: currentColor;
  opacity: 0.5;
  transition: all 0.15s;
}

.size-radio .size-btn .size-label {
  font-size: 9px;
  letter-spacing: 0.06em;
  line-height: 1;
}

/* Hover state */
.size-radio:hover .size-btn {
  border-color: rgba(255,255,255,0.15);
  color: var(--text-dim);
}

/* Checked/active state */
.size-radio input[type="radio"]:checked + .size-btn {
  background: var(--primary-dim);
  border-color: var(--border-bright);
  color: var(--primary);
}

.size-radio input[type="radio"]:checked + .size-btn .size-dot {
  opacity: 1;
  box-shadow: 0 0 6px currentColor;
}

/* ─── DIRECTION TOGGLE ───────────────────────────────── */
.direction-toggle {
  display: flex;
  gap: 5px;
}

.dir-btn {
  flex: 1;
  padding: 9px 8px;
  background: var(--surface-hhi);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
  white-space: nowrap;
}

.dir-btn:hover:not(.active) {
  border-color: rgba(255,255,255,0.15);
  color: var(--text-dim);
}

.dir-btn.active {
  background: var(--primary-dim);
  border-color: var(--border-bright);
  color: var(--primary);
}

/* ─── D3 GRAPH ELEMENTS ──────────────────────────────── */
.node circle {
  cursor: pointer;
  transition: filter 0.2s ease;
}

.node circle:hover { filter: brightness(1.2); }

.node text {
  font-family: 'Manrope', sans-serif;
  font-weight: 700;
  pointer-events: none;
  text-anchor: middle;
  fill: rgba(232,237,245,0.85);
  letter-spacing: 0.02em;
}

.link {
  transition: stroke-width 0.2s ease, stroke 0.2s ease;
}