:root {
  --text: #e8e8e8;
  --text-muted: rgba(232, 232, 232, 0.7);
  --text-faint: rgba(232, 232, 232, 0.5);
  --bg: #0a0a14;
  --surface: rgba(18, 18, 18, 0.6);
  --surface-strong: rgba(18, 18, 18, 0.85);
  --border: rgba(232, 232, 232, 0.12);
  --border-strong: rgba(232, 232, 232, 0.22);
  --accent: #4f73d9;
  --accent-soft: rgba(79, 115, 217, 0.18);
  --accent-secondary: #789bff;
  --gold: #deb680;
}

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, sans-serif;
  overflow: hidden;
}

#sigma { position: fixed; inset: 0; }

/* Header */
header {
  position: fixed; top: 14px; left: 14px;
  display: flex; gap: 12px; align-items: center;
  z-index: 10;
}
.brand { display: flex; align-items: center; opacity: 0.85; transition: opacity 0.15s; }
.brand:hover { opacity: 1; }
.brand img { width: 32px; height: 32px; display: block; }

/* Search */
#search-wrap { position: relative; }
#search {
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: inherit;
  padding: 8px 12px;
  border-radius: 10px;
  width: 240px;
  font: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#search::placeholder { color: var(--text-faint); }
#search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#suggestions {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 4px 0;
  list-style: none;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 320px; overflow-y: auto;
  z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
}
#suggestions[hidden] { display: none; }
#suggestions li {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
}
#suggestions li:hover, #suggestions li.active { background: var(--accent-soft); color: var(--accent-secondary); }
#suggestions li .usage { font-size: 11px; color: var(--text-faint); font-variant-numeric: tabular-nums; }

/* Edges toggle */
#edges-toggle {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: color 0.15s, border-color 0.15s;
}
#edges-toggle:hover { color: var(--text); border-color: var(--border-strong); }
#edges-toggle input { margin: 0; cursor: pointer; accent-color: var(--accent); }

#status { font-size: 12px; color: var(--text-faint); }

#clusters-toggle {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: color 0.15s, border-color 0.15s;
}
#clusters-toggle:hover { color: var(--text); border-color: var(--border-strong); }
#clusters-toggle input { margin: 0; cursor: pointer; accent-color: var(--accent); }

/* Cluster labels (rendered at centroids, fade with zoom) */
#cluster-labels { position: fixed; inset: 0; pointer-events: none; z-index: 4; }
.cluster-label {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow: 0 1px 4px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.7);
  white-space: nowrap;
  transition: opacity 0.2s;
}
#cluster-labels[hidden] { display: none; }

/* Hover label */
#hover-label {
  position: fixed;
  pointer-events: none;
  z-index: 5;
  transform: translate(-50%, -100%);
  padding: 4px 10px;
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
}
#hover-label[hidden] { display: none; }

/* Side panel */
#panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px;
  background: rgba(7, 16, 35, 0.95);
  border-left: 1px solid var(--border);
  padding: 18px 22px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: -4px 0 24px rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
}
#panel[hidden] { display: none; }
#panel-close {
  position: absolute; top: 10px; right: 14px;
  background: none; border: none; color: inherit;
  font-size: 24px; cursor: pointer;
  opacity: 0.5;
  transition: opacity 0.15s;
}
#panel-close:hover { opacity: 1; }
#panel h2 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
#panel h3 {
  margin: 18px 0 8px;
  font-size: 11px;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 600;
}
#panel-aliases, #panel-degree { font-size: 12px; color: var(--text-faint); margin-bottom: 2px; }
#panel-teammates { list-style: none; margin: 0; padding: 0; }
#panel-teammates li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: color 0.12s;
}
#panel-teammates li:hover { color: var(--accent-secondary); }
#panel-teammates .meta { display: block; font-size: 11px; color: var(--text-faint); margin-top: 2px; }

/* Attribution */
#attribution, #credits {
  position: fixed;
  bottom: 12px;
  z-index: 9;
  font-size: 11px;
  color: var(--text-faint);
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  backdrop-filter: blur(4px);
}
#attribution { left: 14px; }
#credits { right: 14px; }
#attribution a, #credits a { color: var(--accent-secondary); text-decoration: none; }
#attribution a:hover, #credits a:hover { color: var(--text); text-decoration: underline; }
