body {
  margin: 0;
  font-family: 'IBM Plex Mono', 'Courier New', monospace;
  background: #0a0a0a;
  color: #eee;
  overflow: hidden;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

:root {
  /* Top-left control cluster (filters + stats) */
  --network-controls-left: 20px;
  /* Below fixed header (.network-header); extra gap so controls aren’t squeezed */
  --network-controls-top: 92px;
  --network-controls-gap: 12px;
  /* Filled by JS so the stats pill can sit under the filter column */
  --network-filter-stack-height: 0px;
}

/* Network canvas */
#network {
  width: 100%;
  height: 100%;
  background: #0a0a0a;
  min-height: 400px; /* Ensure minimum height */
  border: 1px solid rgba(255,255,255,0.1); /* Debug border */
}

/* Pixel grid effect */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: 
    repeating-linear-gradient(
      0deg,
      rgba(0,255,0,0.02) 0px,
      transparent 1px,
      transparent 4px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(0,255,0,0.02) 0px,
      transparent 1px,
      transparent 4px
    );
  opacity: 0.35;
  z-index: 1;
  display: none;
}

/* CRT scan effect */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255,255,255,0.01) 0px,
    rgba(255,255,255,0.01) 2px,
    rgba(0,0,0,0.02) 2px,
    rgba(0,0,0,0.02) 4px
  );
  opacity: 0.18;
  z-index: 2;
  display: none;
}

@keyframes scan {
  0% { transform: translateY(0); }
  100% { transform: translateY(20px); }
}

.network-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: rgba(28, 28, 28, 0.95);
  border-bottom: 2px solid #333;
  padding: 0.6rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 100;
}

.network-header-groups {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-left: auto;
}

.header-group {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.24rem 0.42rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05);
}

.header-group-dm {
  opacity: 0.98;
}

.header-group-actions .btn-reset {
  padding: 0.4rem 0.7rem;
  font-size: 0.82rem;
  min-width: 40px;
}

.network-header h1 {
  font-size: 1.2rem;
  margin: 0;
  color: #86A436;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.02em;
}

/* Feed-like search bar — longer and more visible */
.network-search {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 520px;
}

.network-search-wrap {
  position: relative;
  flex: 1;
  min-width: 320px;
}

.network-search-input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 11px 14px;
  color: #fff;
  font-size: 1rem;
  outline: none;
  font-family: 'Inter', sans-serif;
}
.network-search-input::placeholder {
  color: rgba(255,255,255,0.45);
}
.network-search-input:focus {
  border-color: rgba(95,191,127,0.6);
  box-shadow: 0 0 0 3px rgba(95,191,127,0.18);
}

.network-search-go {
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.95rem;
  flex: 0 0 auto;
}
.network-search-go:hover { background: rgba(255,255,255,0.10); }

.network-search-suggestions {
  position: fixed;
  left: var(--network-controls-left);
  top: calc(var(--network-controls-top) + var(--network-filter-stack-height) + var(--network-controls-gap));
  width: 320px;
  max-width: calc(100vw - var(--network-controls-left) - 24px);
  right: auto;
  background: #1c1c1c;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  overflow: hidden;
  display: none;
  z-index: 2000;
  box-shadow: 0 10px 30px rgba(0,0,0,0.55);
  max-height: 380px;
  overflow-y: auto;
}

.network-search-suggestions .suggestion-tag,
.network-search-suggestions .suggestion-secondary {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.tree-back img {
  height: 40px;
  width: 40px;
  border-radius: 6px;
  object-fit: cover;
}

.network-search input {
  background: #222;
  border: none;
  border-radius: 6px;
  padding: 10px 14px;
  color: white;
  font-size: 1rem;
  flex: 1;
  min-width: 160px;
}

#searchGo {
  background: #444;
  color: white;
  padding: 10px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* Search suggestions: same look when dropdown is used (top-left aligned) */
#searchSuggestions {
  /* Position inherited from .network-search-suggestions (fixed, top-left) */
}

.suggestion-tag {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #222;
}

.suggestion-tag:hover {
  background: #2b2b2b;
}

.tag-icon-small {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  object-fit: contain;
}

.suggestion-secondary {
  padding: 10px 12px;
  background: #1f1f1f;
  color: #aaa;
  cursor: pointer;
}

.suggestion-secondary:hover {
  background: #2b2b2b;
}

/* Matrix toggle (3-state, draggable) */
.matrix-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(10, 10, 10, 0.65);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
}

.matrix-labels {
  display: flex;
  align-items: center;
  gap: 6px;
}

.matrix-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
  color: rgba(255,255,255,0.7);
  cursor: pointer;
}

.matrix-label.active {
  border-color: rgba(134,164,54,0.55);
  background: rgba(134,164,54,0.12);
  color: #86A436;
}

/* If we decide to remove duplicate controls later, we can hide labels via a single class */
.matrix-toggle.labels-hidden .matrix-labels {
  display: none;
}

/* Physics Controls (legacy - hidden now) */
.physics-controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem 0.8rem;
  background: rgba(81, 175, 229, 0.1);
  border: 1px solid rgba(81, 175, 229, 0.3);
  border-radius: 6px;
  font-size: 0.7rem;
}

.physics-controls label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: #51AFE5;
  font-weight: 500;
}

.physics-controls input[type="range"] {
  width: 80px;
  height: 4px;
  background: rgba(81, 175, 229, 0.2);
  border-radius: 2px;
  outline: none;
  -webkit-appearance: none;
}

/* Center notch for mid value on Gravity */
.physics-controls input.mid-notch[type="range"] {
  position: relative;
  background-image: linear-gradient(to right, transparent 49.5%, rgba(255,255,255,0.6) 50%, transparent 50.5%);
  background-size: 100% 100%;
}

.physics-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: #51AFE5;
  border-radius: 50%;
  cursor: pointer;
}

.physics-controls input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: #51AFE5;
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.btn-physics {
  padding: 0.3rem 0.6rem;
  background: rgba(81, 175, 229, 0.2);
  border: 1px solid #51AFE5;
  border-radius: 4px;
  color: #51AFE5;
  font-size: 0.7rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.btn-physics:hover {
  background: rgba(81, 175, 229, 0.3);
  box-shadow: 0 0 10px rgba(81, 175, 229, 0.5);
}

.btn-physics.off {
  background: rgba(255, 255, 255, 0.1);
  border-color: #666;
  color: #999;
}

.badge-neutral {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(255,255,255,0.12);
  color: #ccc;
  font-size: 10px;
  font-weight: 600;
}

/* Focus indicator */
.focus-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(134, 164, 54, 0.15);
  border: 1px solid #86A436;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.75rem;
  margin-left: auto;
}

.focus-indicator.hidden {
  display: none;
}

.focus-icon {
  font-size: 1rem;
}

.btn-exit-focus {
  background: #86A436;
  color: #000;
  border: none;
  padding: 0.3rem 0.6rem;
  border-radius: 3px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.7rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-exit-focus:hover {
  background: #9fbe5f;
  transform: scale(1.05);
}

.nav-link {
  color: #999;
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: 3px;
  transition: all 0.1s ease;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
}

.nav-link:hover {
  background: #333;
  color: #fff;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

#searchInput {
  background: #222;
  border: 2px solid #444;
  border-radius: 4px;
  padding: 0.4rem 0.8rem;
  color: #fff;
  font-size: 0.8rem;
  font-family: 'IBM Plex Mono', monospace;
  width: 180px;
  flex: 1;
  max-width: 250px;
}

#searchInput:focus {
  outline: none;
  border-color: #86A436;
  box-shadow: 0 0 8px rgba(134, 164, 54, 0.3);
}

.btn-secondary {
  background: #333;
  color: #86A436;
  border: 2px solid #444;
  padding: 0.4rem 0.8rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.8rem;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  transition: all 0.1s ease;
}

.btn-secondary:hover {
  background: #444;
  border-color: #86A436;
  box-shadow: 0 0 8px rgba(134, 164, 54, 0.3);
}

.btn-viewmode {
  white-space: nowrap;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  padding: 0.42rem 0.7rem;
  border-radius: 6px;
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.82);
  background: rgba(255,255,255,0.04);
}

.btn-viewmode:hover {
  border-color: rgba(120,255,200,0.22);
  box-shadow: 0 0 16px rgba(120,255,200,0.10);
}

.btn-viewmode.active {
  border-color: rgba(120,255,200,0.35);
  background: rgba(120,255,200,0.08);
  box-shadow: 0 0 18px rgba(120,255,200,0.16);
}

/* View mode dropdown (replaces cycle button) */
.view-mode-dropdown-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.view-mode-label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.7);
  white-space: nowrap;
}

.view-mode-select {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.30);
  color: rgba(255,255,255,0.90);
  cursor: pointer;
  min-width: 150px;
  outline: none;
}

.view-mode-select:hover {
  border-color: rgba(255,255,255,0.26);
}

.view-mode-select:focus {
  border-color: rgba(95,191,127,0.6);
  box-shadow: 0 0 0 3px rgba(95,191,127,0.18);
}

.view-mode-iso-hint {
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.5);
}

.view-mode-iso-hint.hidden {
  display: none;
}

.btn-timebias {
  white-space: nowrap;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.72rem;
  padding: 0.42rem 0.7rem;
  border-radius: 6px;
  border-color: rgba(255,255,255,0.18);
  color: rgba(255,255,255,0.82);
  background: rgba(255,255,255,0.04);
}

.btn-timebias:hover {
  border-color: rgba(81,175,229,0.30);
  box-shadow: 0 0 16px rgba(81,175,229,0.12);
}

.btn-timebias.active {
  border-color: rgba(81,175,229,0.45);
  background: rgba(81,175,229,0.10);
  box-shadow: 0 0 18px rgba(81,175,229,0.18);
  color: rgba(255,255,255,0.90);
}

/* Optional: subtle hint that voxel renderer is active (does not change layout) */
body.voxel-mode .network-header {
  border-bottom-color: rgba(120,255,200,0.22);
}

/* ISO mode: keep UI subtle, let the grid breathe */
body.iso-mode {
  background: #07090c;
}

body.iso-mode #network {
  background: transparent;
}

body.iso-mode .network-header {
  border-bottom-color: rgba(210, 230, 255, 0.18);
}

.btn-toggle {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  border: 1px solid rgba(255,255,255,0.2);
  padding: 0.42rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.72rem;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  transition: all 0.16s ease;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.btn-toggle:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.34);
  box-shadow: 0 6px 16px rgba(0,0,0,0.28);
}

.btn-toggle.active {
  background: rgba(95,191,127,0.16);
  border-color: rgba(95,191,127,0.52);
  color: rgba(255,255,255,0.95);
  box-shadow: 0 0 16px rgba(95,191,127,0.2);
}

.network-container {
  position: relative;
  height: calc(100vh - 50px);
  display: flex;
  overflow: hidden;
}

/* Floating filter buttons on left side */
.floating-filters {
  position: fixed;
  left: var(--network-controls-left);
  top: var(--network-controls-top);
  transform: none;
  display: flex;
  z-index: 250;
  flex-direction: column;
  gap: 12px;
}

.field-filter {
  padding: 10px;
  width: 52px;
  height: 52px;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0.85;
}

.field-filter img {
  width: 26px;
  height: 26px;
  filter: brightness(0) invert(1);
  transition: all 0.2s ease;
}

.field-filter:hover {
  transform: scale(1.05);
  opacity: 1;
}

.field-filter.active {
  border: 2px solid white;
  box-shadow: 0 0 16px var(--field-color), 0 0 8px white;
  opacity: 1;
  transform: scale(1.08);
}

.field-filter.active img {
  filter: brightness(0) invert(1) drop-shadow(0 0 3px rgba(255,255,255,0.8));
}

/* Stats overlay bottom-left */
.network-stats-overlay {
  border: none;
  cursor: pointer;
  text-align: left;
  position: fixed;
  left: var(--network-controls-left);
  top: calc(var(--network-controls-top) + var(--network-filter-stack-height) + var(--network-controls-gap));
  bottom: auto;
  background-color: rgba(18, 18, 18, 0.78);
  backdrop-filter: blur(10px);
  z-index: 200;
  padding: 10px 14px;
  border-radius: 8px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.55);
  border: 1px solid var(--stats-accent-border, rgba(255,255,255,0.16));
  box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.network-stats-overlay.hidden {
  display: none;
}

/* Group spread hint: shown when hovering a field group, scroll to spread */
.group-spread-hint {
  position: fixed;
  bottom: 90px;
  left: 20px;
  padding: 8px 12px;
  background: rgba(134, 164, 54, 0.25);
  border: 1px solid rgba(134, 164, 54, 0.5);
  border-radius: 6px;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.9);
  z-index: 199;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.group-spread-hint.hidden {
  display: none;
}

/* When anchored to a field button (appears next to it) */
.network-stats-overlay.anchored {
  bottom: auto;
  right: auto;
  max-width: 440px;
  width: 400px;
  z-index: 250;
}

/* When a science row is expanded: allow panel to push down and scroll instead of squeezing */
.network-stats-overlay.anchored.stats-expanded {
  max-height: min(90vh, 900px);
  overflow-y: hidden;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.field-stats-overlay {
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.field-stats-overlay.is-search-results {
  flex: 0 1 auto;
}

.field-stats-overlay.hidden {
  display: none;
}

.field-stats-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #ffffff;
  margin-bottom: 2px;
}

.field-stats-list {
  display: grid;
  gap: 6px;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
  min-height: 0;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.field-stats-list.is-search-results {
  flex: 0 1 auto;
  max-height: min(60vh, 400px);
}

.field-stats-row {
  display: grid;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  min-height: 38px;
  box-sizing: border-box;
  align-content: start;
}

.field-stats-row.expanded {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.12);
}

.field-stats-row-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  min-width: 0;
}

.field-stats-row .name {
  color: rgba(var(--field-rgb, 255,255,255), 0.95);
  font-family: 'Inter', sans-serif;
  font-size: 0.9rem;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Lighter text only for Formal sciences (field color #565BAF is dark on dark background) */
.field-stats-row[data-field="Formal"] .name {
  color: rgba(255,255,255,0.92);
  color: color-mix(in srgb, white 48%, rgb(var(--field-rgb, 255, 255, 255)));
}

.field-stats-row .name.multi-field {
  color: rgba(var(--field-rgb, 220,220,220), 0.95);
}

.field-stats-row .count {
  color: rgba(255,255,255,0.70);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.85rem;
}

.field-stats-row[role="button"] {
  cursor: pointer;
}
.field-stats-row:hover {
  background: rgba(255,255,255,0.08);
}

.field-stats-row.match {
  outline: 1px solid rgba(95, 191, 127, 0.35);
  box-shadow: 0 0 0 1px rgba(95, 191, 127, 0.12) inset;
}

.field-stats-row-tags {
  margin-top: -2px;
  padding: 0 6px 6px;
}

.field-stats-tags {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 4px 2px;
  border-top: 1px solid rgba(var(--field-rgb, 255,255,255), 0.18);
  max-height: min(55vh, 380px);
  overflow-y: auto;
  min-height: 120px;
  -webkit-overflow-scrolling: touch;
}
.field-stats-tags-dm {
  max-height: min(70vh, 420px);
}
.field-stats-tag {
  font-family: 'Inter', sans-serif;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.4;
  padding: 6px 8px;
  min-height: 28px;
  box-sizing: border-box;
  border-radius: 4px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}
.field-stats-tag:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.95);
}
.field-stats-tag-more {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
  padding: 4px 8px;
  flex-shrink: 0;
}

/* In-panel search results (Option C: search results inside stats) */
.field-stats-search-header {
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-top: 10px;
  margin-bottom: 4px;
  padding: 2px 0;
}
.field-stats-search-header:first-child {
  margin-top: 0;
}
.field-stats-search-empty {
  opacity: 0.7;
  font-size: 0.9rem;
  padding: 8px 4px;
}

.network-stats-overlay span {
  color: rgba(255,255,255,0.72);
  display: block;
  margin: 3px 0;
  font-weight: 500;
}

.stats-count-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-top: 6px;
  margin-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.10);
  flex: 0 0 auto;
  position: relative;
  z-index: 1;
}

.stats-count-row span {
  display: inline;
  margin: 0;
  white-space: nowrap;
}

.stats-open-hint {
  margin-top: 6px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.65;
  flex: 0 0 auto;
}

.network-stats-overlay:hover {
  box-shadow: 0 16px 36px rgba(0,0,0,0.55), 0 0 20px rgba(120,255,200,0.06);
}

.network-stats-overlay:active {
  transform: scale(0.99);
}

.dm-unused-panel {
  position: fixed;
  z-index: 260;
  left: 0;
  top: 0;
  width: min(360px, calc(100vw - 24px));
  max-height: min(74vh, 560px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(16, 16, 20, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 34px rgba(0,0,0,0.5);
}

.dm-unused-panel.hidden {
  display: none;
}

.dm-unused-header {
  display: grid;
  gap: 4px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.09);
}

.dm-unused-title {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  font-size: 0.95rem;
}

.dm-unused-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.56);
}

.dm-unused-tags-cloud {
  position: relative;
  display: block;
  overflow-y: auto;
  min-height: 80px;
  max-height: min(62vh, 470px);
  padding-right: 4px;
}

.dm-unused-tags-cloud::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 25%, rgba(var(--field-rgb, 255,255,255), 0.10), transparent 55%),
    radial-gradient(circle at 75% 65%, rgba(var(--field-rgb, 255,255,255), 0.08), transparent 60%),
    radial-gradient(circle at 55% 20%, rgba(255,255,255,0.05), transparent 62%);
  opacity: 0.9;
}

.dm-unused-loading,
.dm-unused-empty {
  position: relative;
  padding: 14px 8px;
  color: rgba(255,255,255,0.65);
  font-family: 'Inter', sans-serif;
}

.dm-unused-row {
  position: relative;
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 8px;
  align-items: start;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  margin-bottom: 8px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.22);
  animation: dmParticleDrift 5.2s ease-in-out infinite;
  animation-delay: var(--delay, 0s);
}
.dm-unused-row:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}

.dm-unused-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  background: rgba(var(--field-rgb, 255,255,255), 0.75);
  box-shadow: 0 0 12px rgba(var(--field-rgb, 255,255,255), 0.35);
}

.dm-unused-text {
  color: rgba(255,255,255,0.92);
  font-family: 'Inter', sans-serif;
  font-size: 0.92rem;
  line-height: 1.25;
  word-break: break-word;
}

.dm-unused-more {
  position: relative;
  padding: 8px 8px 2px;
  color: rgba(255,255,255,0.55);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

@keyframes dmParticleDrift {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-2px) scale(1.02); }
}

.network-canvas {
  flex: 1;
  background: #0a0a0a;
}

.detail-panel {
  position: fixed;
  right: 0;
  top: 80px;
  bottom: 0;
  width: 350px;
  background: rgba(15, 15, 15, 0.98);
  border-left: 1px solid rgba(255,255,255,0.10);
  box-shadow: -10px 0 34px rgba(0,0,0,0.78);
  /* Extra top padding so the close button never overlaps the tag header */
  padding: 3.4rem 1.5rem 1.5rem;
  overflow-y: auto;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 90;
  font-family: 'Inter', 'IBM Plex Mono', sans-serif;
}

.detail-panel.hidden {
  transform: translateX(100%);
}

.close-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  background: #F65248;
  border: 2px solid #fff;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: all 0.1s ease;
  z-index: 5;
}

.close-panel:hover {
  background: #fff;
  color: #F65248;
  transform: rotate(90deg);
}

.close-panel:active {
  transform: scale(0.9) rotate(90deg);
}

.detail-panel h3 {
  color: rgba(255,255,255,0.92);
  margin: 0 0 1rem 0;
  font-size: 1.2rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  padding-bottom: 0.5rem;
}

/* Panel tag header: keep term visible, squeeze science first */
.panel-tag-header {
  position: relative;
  overflow: hidden; /* collapsed: crop to one line */
  cursor: default;
  /* Override .detail-panel h3 uppercase styling for readability */
  text-transform: none;
  letter-spacing: 0;
}

.panel-tag-textwrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0; /* enable ellipsis in children */
  flex: 1;
}

.panel-tag-science {
  min-width: 0;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: rgba(255,255,255,0.88);
  font-weight: 500;
  opacity: 0.9;
  flex: 0 1 auto; /* shrink first */
}

.panel-tag-term {
  min-width: 0;
  flex: 1 1 auto; /* keep as much space as possible */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #ffffff;
  font-weight: 600;

  /* show the END of the term when cropped (so main tag stays visible) */
  direction: rtl;
  text-align: left;
  unicode-bidi: plaintext;
}

/* Hover “unfold”: show full science + term, readable and multi-line */
.panel-tag-header:hover {
  overflow: visible; /* allow header to expand naturally */
}

.panel-tag-header:hover .panel-tag-textwrap {
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.panel-tag-header:hover .panel-tag-science {
  max-width: 100%;
  opacity: 0.92;
}

.panel-tag-header:hover .panel-tag-science,
.panel-tag-header:hover .panel-tag-term {
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
}

.panel-tag-header:hover .panel-tag-term {
  direction: ltr;
  text-align: left;
}

/* Legacy tooltip (kept in DOM by JS). Hide it since we unfold in-place. */
.panel-tag-hover { display: none !important; }

.detail-panel h4 {
  color: #999;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 1rem 0 0.5rem 0;
}

.empty-msg {
  color: #666;
  font-size: 0.85rem;
  font-style: italic;
  margin: 0.5rem 0;
}

.panel-info {
  margin-bottom: 1rem;
  padding: 0.8rem;
  background: rgba(20, 20, 20, 0.5);
  border: 2px solid #333;
  border-radius: 3px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px dotted rgba(255,255,255,0.1);
}

.info-row:last-child {
  border-bottom: none;
}

.info-label {
  color: #777;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 700;
}

.info-value {
  color: rgba(255,255,255,0.88);
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.9rem;
}

.panel-info-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  border-bottom: 1px solid #333;
}

.panel-info-item:last-child {
  border-bottom: none;
}

.panel-info-label {
  color: #999;
  font-size: 0.9rem;
}

.panel-info-value {
  color: rgba(255,255,255,0.88);
  font-weight: 600;
  font-family: 'IBM Plex Mono', monospace;
}

.panel-connections {
  margin-bottom: 1.5rem;
}

.panel-connections h4 {
  color: #ccc;
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.panel-section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.panel-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  color: rgba(255,255,255,0.78);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px;
  font-weight: 700;
}

.connection-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.connection-tag {
  display: inline-block;
  padding: 5px 10px;
  border-radius: 3px;
  font-size: 0.75rem;
  font-family: 'IBM Plex Mono', monospace;
  color: white;
  border: 2px solid var(--tag-color, #777);
  cursor: pointer;
  transition: all 0.1s ease;
  background: rgba(0,0,0,0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.connection-tag:hover {
  background: var(--tag-color, #777);
  box-shadow: 0 0 10px var(--tag-color, #777);
  transform: scale(1.05);
}

.connection-tag:active {
  transform: scale(0.95);
}

.connection-item {
  padding: 0.5rem;
  background: #222;
  border-radius: 6px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.connection-item:hover {
  background: #333;
  transform: translateX(4px);
}

.panel-content {
  margin-top: 1.5rem;
}

.panel-content h4 {
  color: #ccc;
  font-size: 1rem;
  margin-bottom: 0.8rem;
}

.content-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.content-item {
  padding: 0.6rem;
  background: rgba(20, 20, 20, 0.5);
  border: 1px solid rgba(255,255,255,0.1);
  border-left: 1px solid rgba(255,255,255,0.10);
  border-radius: 2px;
  cursor: default;
  transition: all 0.1s ease;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.content-item:hover {
  background: rgba(30, 30, 30, 0.8);
  border-left-color: rgba(255,255,255,0.16);
}

.content-thumb {
  width: 56px;
  height: 38px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.35);
}

.content-thumb.placeholder {
  display: grid;
  place-items: center;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.70);
}

.content-meta {
  min-width: 0;
  flex: 1;
}

.content-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.content-type {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 2px;
  color: rgba(255,255,255,0.78);
  font-size: 0.65rem;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.content-type.video {
  background: rgba(81, 175, 229, 0.2);
  border-color: rgba(81, 175, 229, 0.5);
  color: #51AFE5;
}

.content-type.quest {
  background: rgba(240, 173, 40, 0.2);
  border-color: rgba(240, 173, 40, 0.5);
  color: #F0AD28;
}

.content-type.cluster {
  background: rgba(236, 65, 188, 0.2);
  border-color: rgba(236, 65, 188, 0.5);
  color: #EC41BC;
}

.content-title {
  color: #ddd;
  font-weight: 400;
  font-size: 0.8rem;
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  color: #86A436;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 2px;
  animation: pixelPulse 1s ease-in-out infinite;
}

@keyframes pixelPulse {
  0%, 100% { 
    opacity: 1; 
    text-shadow: 0 0 10px #86A436;
  }
  50% { 
    opacity: 0.6; 
    text-shadow: 0 0 5px #86A436;
  }
}

/* Tag badge styles for consistency */
.tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  color: white;
  line-height: 1;
  white-space: nowrap;
  margin: 2px;
}

.tag-icon-small {
  width: 14px;
  height: 14px;
  filter: brightness(0) invert(1);
}

/* ======================= HOLOGRAPHIC MODAL ======================= */
.holo-overlay.hidden { display: none; }

.holo-overlay {
  position: fixed;
  inset: 0;
  z-index: 2500;
  display: grid;
  place-items: center;
}

.holo-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 600px at 40% 20%, rgba(120,255,200,0.08), transparent 55%),
    radial-gradient(700px 500px at 80% 70%, rgba(81,175,229,0.07), transparent 60%),
    rgba(0,0,0,0.62);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
}

.holo-window {
  position: relative;
  width: min(900px, calc(100vw - 28px));
  height: min(620px, calc(100vh - 96px));
  border-radius: 12px;
  border: 1px solid #2d2d2d;
  background: #141414;
  box-shadow: 0 24px 80px rgba(0,0,0,0.70);
  overflow: hidden;
  z-index: 1;
  font-family: 'Inter', sans-serif;
}

.holo-window::before {
  content: none;
}

.holo-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #1e1e1e;
  border-bottom: 1px solid #333;
}

.holo-title {
  font-family: 'IBM Plex Mono', monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  color: rgba(255,255,255,0.80);
}

.holo-actions { display: flex; align-items: center; gap: 10px; }

.holo-btn {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid #3a3a3a;
  background: #2a2a2a;
  color: rgba(255,255,255,0.86);
  cursor: pointer;
}
.holo-btn:hover {
  background: #303030;
  border-color: #555;
}
.holo-btn:active { transform: scale(0.98); }
.holo-btn-danger {
  background: rgba(255, 70, 70, 0.12);
  border-color: rgba(255, 90, 90, 0.25);
}
.holo-btn-danger:hover {
  background: rgba(255, 70, 70, 0.22);
  border-color: rgba(255, 90, 90, 0.40);
}

.holo-body {
  position: relative;
  padding: 14px 16px 16px;
  height: calc(100% - 58px);
  overflow: auto;
}

.holo-subtitle {
  font-size: 13px;
  line-height: 1.35;
  color: rgba(255,255,255,0.82);
  margin-bottom: 10px;
}

.holo-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

.holo-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #202020;
  border: 1px solid #2f2f2f;
  color: rgba(255,255,255,0.86);
  font-size: 12px;
  line-height: 1.25;
  max-width: 100%;
}

.holo-chip strong {
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
  color: #ffffff;
}

.holo-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.holo-field {
  border: 1px solid #2d2d2d;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1a1a;
}

.holo-field-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #202020;
  border-bottom: 1px solid #2d2d2d;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.82);
}

.holo-field-header img {
  width: 18px;
  height: 18px;
  filter: brightness(0) invert(1);
}

.holo-science {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  cursor: pointer;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.86);
  font-family: 'Inter', sans-serif;
  line-height: 1.35;
  text-align: left;
}

.holo-science:hover { background: rgba(255,255,255,0.07); }
.holo-science:active { background: rgba(255,255,255,0.12); }

.holo-science .count {
  font-family: 'IBM Plex Mono', monospace;
  color: rgba(255,255,255,0.70);
}

.holo-science .science-name {
  color: rgba(var(--field-rgb, 255,255,255), 0.95);
}

.holo-science.active {
  background: rgba(255,255,255,0.10);
  outline: 1px solid rgba(255,255,255,0.20);
}

.holo-hint {
  margin-top: 10px;
  font-size: 12px;
  color: rgba(255,255,255,0.55);
}

@media (max-width: 860px) {
  .holo-list { grid-template-columns: 1fr; }
}

/* ===================== DARK MATTER TOGGLE ===================== */
.btn-darkmatter {
  background: rgba(160, 140, 255, 0.08);
  border-color: rgba(160,140,255,0.34);
  letter-spacing: 0.05em;
}
.btn-darkmatter:hover {
  box-shadow: 0 6px 16px rgba(80,70,150,0.35);
}
.btn-darkmatter.active {
  background: rgba(160,140,255,0.18);
  border-color: rgba(160,140,255,0.58);
  box-shadow: 0 0 18px rgba(140,100,255,0.22);
}

/* ===================== TAGGER4 PANEL (right-side taxonomy browser) ===================== */
.tagger4-panel {
  position: fixed;
  /* Keep clear of the floating field buttons (left:20, width:52, gap:12) */
  left: 92px;
  top: 0;
  bottom: 0;
  width: 480px;
  max-width: calc(100vw - 92px);
  background: rgba(10,10,18,0.55);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 150;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.4,0,0.2,1);
  font-family: 'Inter', sans-serif;
}
.tagger4-panel.visible {
  transform: translateX(0);
}
.tagger4-panel.hidden {
  pointer-events: none;
}

/* When dark matter is OFF, panel must be fully invisible (no sliver) */
.tagger4-panel.dm-off {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
  left: -9999px !important;
}

/* ---- header ---- */
.tagger4-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
  position: relative;
}
.tagger4-search {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  color: #fff;
  padding: 7px 10px;
  font-size: 13px;
  font-family: 'IBM Plex Mono', monospace;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.tagger4-search:focus {
  border-color: rgba(255,255,255,0.25);
}
.tagger4-search::placeholder {
  color: rgba(255,255,255,0.3);
}
.tagger4-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  font-size: 17px;
  cursor: pointer;
  padding: 4px 6px;
  z-index: 2;
}
.tagger4-close:hover { color: #fff; }

/* ---- two-column body ---- */
.tagger4-body {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}
.tagger4-col {
  overflow-y: auto;
  padding: 4px 0;
}
.tagger4-sciences {
  width: 48%;
  border-right: 1px solid rgba(255,255,255,0.05);
}
.tagger4-tags {
  width: 52%;
}

/* ---- science items ---- */
.t4-sci {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  color: rgba(255,255,255,0.72);
  transition: background 0.12s;
  border-left: 3px solid transparent;
}
.t4-sci:hover {
  background: rgba(255,255,255,0.035);
}
.t4-sci.active {
  background: rgba(255,255,255,0.055);
  color: #fff;
}
.t4-sci-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.t4-sci-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  flex-shrink: 0;
  margin-left: 6px;
}

/* ---- tag items ---- */
.t4-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.12s;
  line-height: 1.35;
}
.t4-tag:hover {
  background: rgba(255,255,255,0.035);
}
.t4-tag-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.t4-tag-name {
  color: rgba(255,255,255,0.82);
}
.t4-tag.dark .t4-tag-name {
  color: rgba(255,255,255,0.32);
}
.t4-tag.dark .t4-tag-dot {
  opacity: 0.25;
}
.t4-tag.used .t4-tag-name {
  color: rgba(255,255,255,0.92);
  font-weight: 500;
}

.t4-section-label {
  padding: 10px 14px 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.22);
}
.t4-empty {
  padding: 20px 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.25);
}

/* ---- footer ---- */
.tagger4-footer {
  padding: 8px 12px;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
  display: flex;
  justify-content: flex-end;
}
.tagger4-full-btn {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.45);
  font-size: 11px;
  font-family: 'IBM Plex Mono', monospace;
  padding: 5px 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.tagger4-full-btn:hover {
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
}

/* ===================== SCIENCE CONTENT POPUP ===================== */
.science-popup {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.science-popup.hidden {
  display: none;
}
.science-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(4px);
}
.science-popup-window {
  position: relative;
  background: #141414;
  border: 1px solid #2d2d2d;
  border-radius: 12px;
  width: 92vw;
  max-width: 860px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.science-popup-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #333;
  background: #1e1e1e;
}
.science-popup-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}
.science-popup-badge img {
  width: 20px;
  height: 20px;
  filter: brightness(0) invert(1);
}
.science-popup-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
}
.science-popup-close:hover { color: #fff; }

.science-popup-grid {
  padding: 16px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}
.science-popup-card {
  background: #1a1a1a;
  border: 1px solid #2d2d2d;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.science-popup-card:hover {
  border-color: #555;
  transform: translateY(-2px);
}
.science-popup-card-thumb {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  background: #222;
  display: block;
}
.science-popup-card-body {
  padding: 10px 11px;
}
.science-popup-card-type {
  font-size: 10px;
  font-family: 'IBM Plex Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.58;
  margin-bottom: 4px;
}
.science-popup-card-title {
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.science-popup-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
}

/* Header content-type filters: media / quests / clusters */
.content-type-filters {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.content-type-filter {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.72);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.content-type-filter:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.92);
}

.content-type-filter.active {
  border-color: rgba(134, 164, 54, 0.75);
  background: rgba(134, 164, 54, 0.18);
  color: #d7f0a0;
  box-shadow: 0 0 10px rgba(134, 164, 54, 0.18);
}