:root {
  --bg: #0b0f14;
  --panel: #121821;
  --panel-border: #1e2733;
  --text: #dbe4ee;
  --text-dim: #8b98a8;
  --accent: #38bdf8;
  --accent-2: #67e8f9;
  --danger: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-bottom: 1px solid var(--panel-border);
  background: var(--panel);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#topbar h1 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#sidebar-toggle {
  display: none;
  width: auto;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
}
#sidebar-toggle:hover { background: rgba(56, 189, 248, 0.12); }

#sidebar-close {
  display: none;
  width: auto;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text);
}

#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 15;
}

.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-dim);
  display: inline-block;
}
.live-dot.ok { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); }
.live-dot.bad { background: var(--danger); }

#user-area a { color: var(--accent); text-decoration: none; font-size: 13px; }

#layout {
  display: flex;
  height: calc(100vh - 68px);
}

#sidebar {
  width: 280px;
  min-width: 280px;
  padding: 12px;
  overflow-y: auto;
  border-right: 1px solid var(--panel-border);
  background: var(--panel);
}

.panel {
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--panel-border);
}
.panel h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  margin: 0 0 8px;
}
.panel.hidden { display: none; }

#search-box {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}
#search-box:focus { outline: none; border-color: var(--accent); }

#search-results { margin-top: 6px; max-height: 220px; overflow-y: auto; }
.result-row {
  padding: 6px 8px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
}
.result-row:hover { background: rgba(56, 189, 248, 0.12); }
.result-row .rtype { color: var(--text-dim); font-size: 11px; }

#type-list { max-height: 260px; overflow-y: auto; font-size: 12px; }
.type-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.type-swatch { width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.type-row .tcount { color: var(--text-dim); margin-left: auto; }

button {
  width: 100%;
  padding: 8px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent-2);
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
button:hover { background: rgba(56, 189, 248, 0.22); }

.hint { font-size: 11px; color: var(--text-dim); margin: 8px 0 0; line-height: 1.5; }

#nd-name { font-size: 14px; color: var(--accent-2); }
#nd-type { font-size: 11px; color: var(--text-dim); margin-bottom: 8px; }
#nd-desc { font-size: 12px; line-height: 1.5; white-space: pre-wrap; }

.doc-links, .tt-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.doc-link {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  color: var(--accent-2);
  font-size: 11px;
  text-decoration: none;
}
.doc-link:hover { background: rgba(56, 189, 248, 0.15); }

#canvas-wrap { flex: 1; position: relative; overflow: hidden; touch-action: none; }
#graph-canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
#graph-canvas.panning { cursor: grabbing; }

#zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 5;
}
#zoom-controls button {
  width: 34px;
  height: 34px;
  padding: 0;
  font-size: 16px;
  background: var(--panel);
  opacity: 0.9;
}

#tooltip {
  position: absolute;
  max-width: 260px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  z-index: 10;
  transform: translate(-50%, -100%);
}
#tooltip.interactive { pointer-events: auto; }
#tooltip.hidden { display: none; }
#tooltip .tt-title { color: var(--accent-2); font-size: 13px; font-weight: 600; margin-bottom: 2px; }
#tooltip .tt-type { color: var(--text-dim); font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 6px; }
#tooltip .tt-desc { max-height: 120px; overflow-y: auto; white-space: pre-wrap; }
#tooltip .tt-remove {
  display: none;
  margin-top: 8px;
  width: auto;
  padding: 4px 8px;
  font-size: 11px;
  color: var(--danger);
  border-color: var(--danger);
  background: transparent;
  pointer-events: auto;
}
#tooltip.interactive .tt-remove { display: inline-block; }

@media (max-width: 768px) {
  #sidebar-toggle { display: inline-block; }
  #sidebar-close { display: block; }

  #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 20;
    width: 82vw;
    max-width: 320px;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  #sidebar.open { transform: translateX(0); }
  #sidebar-backdrop.open { display: block; }

  #layout { height: calc(100vh - 52px); }
  #topbar h1 { font-size: 14px; }
}

#statusbar {
  display: flex;
  gap: 20px;
  padding: 6px 16px;
  border-top: 1px solid var(--panel-border);
  background: var(--panel);
  font-size: 11px;
  color: var(--text-dim);
}
