:root {
  --bg: #080a0f;
  --panel-bg: rgba(15, 23, 42, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --panel-border-hover: rgba(255, 255, 255, 0.18);
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --color-concept: #a855f7;
  --color-entity: #10b981;
  --color-digest: #f59e0b;
  --color-note: #3b82f6;
  --color-guide: #06b6d4;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body, html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  font-family: var(--font);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Background Atmosphere */
#graph-container {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  background: radial-gradient(circle at 50% 50%, rgba(30, 41, 59, 0.4) 0%, rgba(8, 10, 15, 1) 100%);
  cursor: grab;
}
#graph-container:active {
  cursor: grabbing;
}

/* Top Navigation Bar */
.top-bar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  z-index: 20;
  pointer-events: none;
}

.top-bar > * {
  pointer-events: auto;
}

.brand-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 8px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.1);
  transition: all 0.2s ease;
}
.back-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  transform: translateX(-2px);
}

.title-group h1 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.title-group p {
  font-size: 11px;
  color: var(--text-muted);
}

/* Search Bar */
.search-wrapper {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.search-input {
  width: 100%;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px 14px 10px 38px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: all 0.2s ease;
}
.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}
.search-input::placeholder {
  color: var(--text-dim);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-dim);
  font-size: 14px;
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--panel-border-hover);
  border-radius: 10px;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 16px 36px rgba(0,0,0,0.6);
  display: none;
}
.search-results.active {
  display: block;
}
.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.15s ease;
}
.search-item:last-child {
  border-bottom: none;
}
.search-item:hover {
  background: rgba(255,255,255,0.06);
}
.search-item-info {
  display: flex;
  align-items: center;
  gap: 10px;
}
.search-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.search-item-title {
  font-size: 13px;
  font-weight: 500;
}
.search-item-type {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* Actions Menu */
.actions-card {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-ctrl {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.btn-ctrl:hover {
  color: var(--text);
  border-color: var(--panel-border-hover);
  background: rgba(30, 41, 59, 0.85);
}

/* Floating Filters */
.filter-bar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 30px;
  padding: 6px 10px;
  z-index: 20;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}

.filter-pill {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.filter-pill:hover {
  color: var(--text);
  background: rgba(255,255,255,0.06);
}
.filter-pill.active {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  font-weight: 600;
}
.filter-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

/* Legend Badge */
.legend-badge {
  position: absolute;
  bottom: 24px;
  left: 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 11px;
  color: var(--text-muted);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

/* Inspector Drawer (Right Panel) */
.inspector-drawer {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--panel-border-hover);
  border-radius: 16px;
  z-index: 30;
  box-shadow: -10px 0 40px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  transform: translateX(calc(100% + 24px));
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}
.inspector-drawer.open {
  transform: translateX(0);
}

.drawer-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.drawer-type-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 8px;
}
.drawer-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.drawer-close {
  background: rgba(255,255,255,0.06);
  border: none;
  color: var(--text-muted);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  transition: all 0.2s ease;
}
.drawer-close:hover {
  background: rgba(255,255,255,0.15);
  color: var(--text);
}

.drawer-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.drawer-meta-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-dim);
}
.drawer-meta-item strong {
  color: var(--text-muted);
}

.drawer-summary {
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 20px;
  border-left: 3px solid var(--accent);
}

.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 10px;
}

.tags-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}
.tag-badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255,255,255,0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255,255,255,0.04);
}

.connections-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}
.connection-pill {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 8px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.connection-pill:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
  transform: translateX(3px);
}
.connection-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Tooltip */
.graph-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--panel-border-hover);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  z-index: 50;
  display: none;
}

@media (max-width: 768px) {
  .top-bar {
    flex-wrap: wrap;
  }
  .search-wrapper {
    order: 3;
    max-width: 100%;
    width: 100%;
  }
  .filter-bar {
    width: calc(100% - 32px);
    overflow-x: auto;
    justify-content: flex-start;
  }
  .legend-badge {
    display: none;
  }
  .inspector-drawer {
    top: auto;
    left: 16px;
    right: 16px;
    bottom: 16px;
    width: auto;
    max-width: none;
    height: 60vh;
    transform: translateY(calc(100% + 24px));
  }
  .inspector-drawer.open {
    transform: translateY(0);
  }
}
