/* ============================================================================
 * GTNH Thaumonomicon Research Tree Explorer — Stylesheet
 * Arcane dark palette with modern 2D panning canvas and interactive DAG cards
 * ============================================================================ */

:root {
  --bg-deep: #0b0914;
  --bg-panel: #131022;
  --bg-card: #1b1630;
  --bg-card-hover: #251e42;
  --bg-input: #0e0b1a;

  --border-subtle: #2c244d;
  --border-focus: #8b5cf6;
  --border-gold: #d97706;

  --text-main: #f1effa;
  --text-secondary: #b5aed4;
  --text-muted: #78709c;

  --accent-gold: #f59e0b;
  --accent-purple: #a855f7;
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-crimson: #f43f5e;
  --accent-amber: #fbbf24;

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --left-sidebar-w: 340px;
  --right-sidebar-w: 340px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.4;
}

body {
  display: flex;
  flex-direction: column;
}

body.resizing-sidebars {
  cursor: col-resize !important;
  user-select: none !important;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 1.25rem;
  background: linear-gradient(90deg, #130f26 0%, #191332 50%, #130f26 100%);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 20;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, #a855f7, #4c1d95);
  border: 1px solid #c084fc;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(168, 85, 247, 0.45);
}

.brand-book-img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  filter: invert(1) sepia(0.35) saturate(2.5) hue-rotate(5deg);
}

.app-header h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: #fde68a;
}

.subtitle {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.stats-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid rgba(168, 85, 247, 0.4);
  color: #e9d5ff;
  font-weight: 500;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.03);
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--text-main);
  border-color: var(--accent-purple);
  background: rgba(168, 85, 247, 0.12);
}

.about-icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(168, 85, 247, 0.14);
  color: #e9d5ff;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.about-icon-btn:hover {
  color: #fde68a;
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.2);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

/* Main Workspace Layout */
.workspace {
  flex: 1;
  display: flex;
  position: relative;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 10;
}

.left-sidebar {
  width: var(--left-sidebar-w);
  border-right: 1px solid var(--border-subtle);
}

.right-sidebar {
  width: var(--right-sidebar-w);
  border-left: 1px solid var(--border-subtle);
}

.sidebar.collapsed {
  width: 0 !important;
  min-width: 0 !important;
  border: none !important;
  overflow: hidden !important;
}

.sidebar-resizer {
  width: 6px;
  margin: 0 -3px;
  cursor: col-resize;
  z-index: 18;
  flex-shrink: 0;
  position: relative;
  background: transparent;
  transition: background 0.15s ease;
}

.sidebar-resizer:hover,
.sidebar-resizer.active {
  background: rgba(168, 85, 247, 0.55);
}

.sidebar-resizer.hidden {
  display: none;
}

.sidebar-collapse-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  padding: 0.2rem 0.45rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.sidebar-collapse-btn:hover {
  color: var(--text-main);
  border-color: var(--accent-purple);
  background: var(--bg-card-hover);
}

.inspector-header-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Floating About Dialog */
.about-dialog {
  padding: 0;
  border: 1px solid var(--border-focus);
  border-radius: 12px;
  background: var(--bg-panel);
  color: var(--text-main);
  max-width: 480px;
  width: calc(100vw - 2rem);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 24px rgba(168, 85, 247, 0.25);
}

.about-dialog::backdrop {
  background: rgba(6, 4, 14, 0.72);
  backdrop-filter: blur(4px);
}

.about-dialog-card {
  display: flex;
  flex-direction: column;
}

.about-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.9rem 1.15rem;
  background: linear-gradient(90deg, #16112b 0%, #1f173d 100%);
  border-bottom: 1px solid var(--border-subtle);
}

.about-dialog-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.about-brand-icon {
  width: 28px;
  height: 28px;
}

.about-brand-icon .brand-book-img {
  width: 18px;
  height: 18px;
}

.about-dialog-header h2 {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: #fde68a;
}

.about-close-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.about-close-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
}

.about-dialog-body {
  padding: 1rem 1.15rem;
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.about-dialog-body p {
  margin: 0 0 0.85rem;
}

.about-dialog-body h3 {
  margin: 0.9rem 0 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-main);
}

.about-dialog-body a {
  color: #c4b5fd;
  text-decoration: underline;
}

.about-dialog-body a:hover {
  color: #fde68a;
}

.about-shortcuts-list {
  margin: 0 0 0.85rem;
  padding-left: 1.15rem;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
}

.about-shortcuts-list code {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #fde68a;
}

.about-attribution-box {
  margin: 0 !important;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  font-size: 0.78rem;
}

.about-attribution-box p {
  margin: 0 0 0.45rem;
}

.about-attribution-box p:last-child {
  margin-bottom: 0;
}

.about-dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.75rem 1.15rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(11, 9, 20, 0.45);
}

.panel-section {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.section-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.small-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.small-muted {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.section-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.section-title {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
}

/* Search Box & Dropdown */
.search-wrap {
  position: relative;
}

#research-search-input {
  width: 100%;
  padding: 0.55rem 2rem 0.55rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.85rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#research-search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.25);
}

.icon-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.icon-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: #18132c;
  border: 1px solid var(--border-focus);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.65);
  z-index: 100;
}

.search-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0.45rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.1s ease;
}

.search-option:hover,
.search-option.active {
  background: rgba(168, 85, 247, 0.22);
}

.search-option-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.search-option-name {
  font-weight: 600;
  color: var(--text-main);
  font-size: 0.83rem;
}

.search-option-tab {
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  white-space: nowrap;
}

.search-option-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Filters & Presets */
.filter-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.65rem;
}

.filter-item select {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border-radius: 5px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-input);
  color: var(--text-main);
  font-size: 0.78rem;
  outline: none;
}

.filter-item select:focus {
  border-color: var(--border-focus);
}

.kami-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.65rem;
  padding: 0.42rem 0.6rem;
  border-radius: 6px;
  background: rgba(168, 85, 247, 0.1);
  border: 1px solid rgba(168, 85, 247, 0.3);
  font-size: 0.76rem;
  color: #e9d5ff;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.kami-toggle-row:hover {
  background: rgba(168, 85, 247, 0.18);
  border-color: rgba(168, 85, 247, 0.5);
}

.kami-toggle-row input[type="checkbox"] {
  accent-color: var(--accent-purple);
  cursor: pointer;
  margin: 0;
}

.presets-group {
  margin-top: 0.7rem;
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.preset-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.73rem;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover,
.preset-chip.active {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--accent-gold);
  color: #fde68a;
}

/* Metrics Summary Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.metric-value {
  font-size: 1.05rem;
  font-weight: 700;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.accent-gold { color: var(--accent-gold); }
.accent-cyan { color: var(--accent-cyan); }
.accent-purple { color: #c084fc; }
.accent-crimson { color: var(--accent-crimson); }

.scan-summary-box {
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px dashed var(--border-subtle);
}

.badge-list {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.scan-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
  cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease;
}

.scan-badge:hover {
  filter: brightness(1.2);
}

.scan-badge.cond-warp,
.node-cond-tag.cond-warp {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.55);
  color: #fde68a;
}

.scan-badge.cond-event,
.node-cond-tag.cond-event {
  background: rgba(236, 72, 153, 0.2);
  border: 1px solid rgba(236, 72, 153, 0.5);
  color: #fbcfe8;
}

.scan-badge.cond-kami,
.node-cond-tag.cond-kami {
  background: rgba(168, 85, 247, 0.22);
  border: 1px solid rgba(168, 85, 247, 0.55);
  color: #e9d5ff;
}

.node-cond-tag {
  font-size: 0.62rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.45);
  color: #6ee7b7;
  white-space: nowrap;
  max-width: 118px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Checklist Section */
.checklist-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 220px;
  border-bottom: none;
}

.helper-note {
  margin: 0 0 0.5rem;
  font-size: 0.73rem;
  color: var(--text-muted);
}

.unlock-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.unlock-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.12s ease;
}

.unlock-item:hover {
  background: var(--bg-card-hover);
  border-color: #4c3d82;
}

.unlock-item.selected {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
}

.unlock-item.completed {
  opacity: 0.55;
}

.unlock-item.completed .unlock-item-title {
  text-decoration: line-through;
}

.unlock-step-num {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-width: 22px;
}

.unlock-item-body {
  flex: 1;
  min-width: 0;
}

.unlock-item-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.unlock-item-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.4rem;
}

/* Center Canvas Stage */
.canvas-stage {
  position: relative;
  flex: 1;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background-color: var(--bg-deep);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(88, 28, 135, 0.12) 0%, transparent 70%),
    radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 100% 100%, 24px 24px;
  overflow: hidden;
}

/* 2D Panning Scroll Container (follows modern-web-guidance 2d-panning) */
.pan-viewport {
  inline-size: 100%;
  block-size: 100%;
  overflow: auto;
  scroll-axis-lock: none;
  overscroll-behavior: none;
  touch-action: none;
  cursor: grab;
  user-select: none;
  position: relative;
}

.pan-viewport.dragging {
  cursor: grabbing;
}

.pan-viewport:focus-visible {
  outline: 2px solid var(--accent-purple);
  outline-offset: -2px;
}

.pan-surface {
  position: relative;
  transform-origin: 0 0;
}

.edges-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}

.nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Floating Overlays on Canvas */
.canvas-overlay-top {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  pointer-events: none;
  z-index: 15;
}

.canvas-overlay-top-right {
  position: absolute;
  top: 12px;
  right: 12px;
  pointer-events: none;
  z-index: 16;
}

.sidebar-restore-btn {
  pointer-events: auto;
  background: rgba(19, 16, 34, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent-purple);
  color: #e9d5ff;
  font-size: 0.76rem;
  font-weight: 600;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  transition: all 0.15s ease;
}

.sidebar-restore-btn:hover {
  background: rgba(168, 85, 247, 0.25);
  color: #fff;
}

.legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  background: rgba(19, 16, 34, 0.88);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  color: var(--text-secondary);
  pointer-events: auto;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}

.dot-root { background: #10b981; }
.dot-prereq { background: #8b5cf6; }
.dot-target { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
.dot-unlock { background: #38bdf8; }

.legend-line {
  width: 18px;
  height: 0;
  display: inline-block;
}

.line-solid {
  border-top: 2px solid #a855f7;
}

.line-dashed {
  border-top: 2px dashed #38bdf8;
}

.canvas-controls {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem;
  border-radius: 8px;
  background: rgba(19, 16, 34, 0.92);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
  z-index: 15;
}

.ctrl-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.35rem 0.65rem;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.ctrl-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-purple);
}

.ctrl-divider {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
  margin: 0 2px;
}

.zoom-readout {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  min-width: 46px;
  text-align: center;
  color: var(--text-secondary);
}

/* Graph Node Cards */
.tree-node {
  position: absolute;
  width: 224px;
  min-height: 78px;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  background: rgba(27, 22, 48, 0.95);
  border: 1.5px solid #3b3066;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
  pointer-events: auto;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.tree-node:hover {
  transform: translateY(-2px);
  border-color: #a855f7;
  box-shadow: 0 6px 18px rgba(168, 85, 247, 0.28);
  z-index: 5;
}

.tree-node.node-root {
  border-color: rgba(16, 185, 129, 0.65);
  background: linear-gradient(160deg, rgba(6, 78, 59, 0.42), rgba(27, 22, 48, 0.95));
}

.tree-node.node-target {
  border-color: var(--accent-gold);
  border-width: 2px;
  background: linear-gradient(160deg, rgba(120, 53, 15, 0.55), rgba(27, 22, 48, 0.98));
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.4);
}

.tree-node.node-unlock {
  border-color: rgba(56, 189, 248, 0.6);
  background: linear-gradient(160deg, rgba(12, 74, 110, 0.4), rgba(27, 22, 48, 0.95));
}

.tree-node.node-selected {
  outline: 2px solid #fde68a;
  outline-offset: 2px;
  z-index: 6;
}

.tree-node.node-completed {
  opacity: 0.52;
  border-style: dashed;
}

.tree-node.node-dimmed {
  opacity: 0.25;
}

.node-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.35rem;
}

.node-tab-tag {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
  max-width: 145px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.node-badges {
  display: flex;
  align-items: center;
  gap: 3px;
}

.node-warp-tag {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(244, 63, 94, 0.22);
  border: 1px solid rgba(244, 63, 94, 0.5);
  color: #fda4af;
}

.node-scan-tag {
  font-size: 0.64rem;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.node-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0.25rem 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.node-bottom-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.68rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.node-key-text {
  max-width: 145px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* SVG Edges */
.edge-path {
  fill: none;
  stroke-width: 2px;
  transition: stroke 0.15s ease, stroke-width 0.15s ease, opacity 0.15s ease;
}

.edge-standard {
  stroke: #7c3aed;
  opacity: 0.78;
}

.edge-hidden {
  stroke: #38bdf8;
  stroke-dasharray: 6 4;
  opacity: 0.82;
}

.edge-unlock {
  stroke: #0ea5e9;
  opacity: 0.65;
}

.edge-highlighted {
  stroke: #fbbf24 !important;
  stroke-width: 3px !important;
  opacity: 1 !important;
}

.edge-dimmed {
  opacity: 0.15;
}

/* Right Sidebar Inspector */
.inspector-content {
  border-bottom: none;
}

.tab-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 5px;
  background: rgba(168, 85, 247, 0.2);
  border: 1px solid rgba(168, 85, 247, 0.45);
  color: #e9d5ff;
}

.btn-primary-sm {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  border: 1px solid #a855f7;
  color: #fff;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  cursor: pointer;
}

.btn-primary-sm:hover {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.text-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.72rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
}

.text-btn:hover {
  color: var(--text-main);
  border-color: var(--text-secondary);
}

.insp-title {
  margin: 0.35rem 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 700;
  color: #fde68a;
}

.insp-key-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.insp-key-row code {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: #93c5fd;
  word-break: break-all;
}

.icon-btn-sm {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  cursor: pointer;
}

.icon-btn-sm:hover {
  color: var(--text-main);
  border-color: var(--accent-purple);
}

.completed-toggle-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-size: 0.8rem;
}

.completed-toggle-row input {
  accent-color: var(--accent-emerald);
  width: 16px;
  height: 16px;
}

.insp-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.85rem;
}

.insp-stat {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}

.insp-stat strong {
  font-size: 0.9rem;
  font-family: var(--font-mono);
}

.insp-block {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

.warning-block {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  padding: 0.6rem 0.75rem;
}

.block-title {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.notes-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.76rem;
  color: #fde68a;
}

.aspects-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.aspect-pill {
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.4);
  color: #ddd6fe;
}

.rel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.rel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.12s ease;
}

.rel-item:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-purple);
}

.rel-item-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.rel-item-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-main);
}

.rel-item-sub {
  font-size: 0.68rem;
  color: var(--text-muted);
}

.rel-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.badge-p {
  background: rgba(168, 85, 247, 0.2);
  color: #e9d5ff;
}

.badge-ph {
  background: rgba(56, 189, 248, 0.2);
  color: #bae6fd;
}

/* Mobile Navigation & Backdrop (hidden on desktop) */
.mobile-tab-bar {
  display: none;
}

.mobile-backdrop {
  display: none;
}

@media (max-width: 1180px) {
  :root {
    --left-sidebar-w: 300px;
    --right-sidebar-w: 290px;
  }
}

@media (max-width: 860px) {
  .app-header {
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .app-header .subtitle,
  .app-header .stats-pill {
    display: none;
  }

  .app-header h1 {
    font-size: 0.92rem;
  }

  .header-nav {
    gap: 0.35rem;
  }

  .nav-link {
    font-size: 0.72rem;
    padding: 0.25rem 0.5rem;
  }

  .sidebar-resizer,
  .sidebar-restore-btn {
    display: none !important;
  }

  .sidebar {
    position: absolute;
    top: 0;
    bottom: 0;
    width: min(88vw, 360px) !important;
    max-width: 100%;
    z-index: 30;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.75);
    transition: transform 0.2s ease;
  }

  .left-sidebar {
    left: 0;
    transform: translateX(-105%);
  }

  .right-sidebar {
    right: 0;
    transform: translateX(105%);
  }

  .sidebar.collapsed {
    width: min(88vw, 360px) !important;
  }

  .left-sidebar.mobile-open {
    transform: translateX(0);
    border-right: 1px solid var(--border-subtle) !important;
    overflow-y: auto !important;
  }

  .right-sidebar.mobile-open {
    transform: translateX(0);
    border-left: 1px solid var(--border-subtle) !important;
    overflow-y: auto !important;
  }

  .mobile-backdrop {
    display: block;
    position: absolute;
    inset: 0;
    background: rgba(5, 4, 10, 0.62);
    backdrop-filter: blur(2px);
    z-index: 25;
  }

  .mobile-backdrop[hidden] {
    display: none;
  }

  .canvas-overlay-top {
    top: 8px;
    left: 8px;
    right: 8px;
  }

  .legend-bar {
    gap: 0.45rem;
    padding: 0.3rem 0.5rem;
    font-size: 0.66rem;
  }

  .canvas-controls {
    bottom: 10px;
    left: 8px;
    right: 8px;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.3rem;
  }

  .ctrl-btn {
    font-size: 0.72rem;
    padding: 0.3rem 0.5rem;
  }

  .mobile-tab-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #130f26;
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
    z-index: 35;
  }

  .mobile-tab-btn {
    background: transparent;
    border: none;
    border-top: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.65rem 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
  }

  .mobile-tab-btn.active {
    color: #fde68a;
    border-top-color: var(--accent-gold);
    background: rgba(245, 158, 11, 0.1);
  }
}

/* ============================================================================
 * Client-side Texture Loader Dialog & Pixelated Research Icons
 * ============================================================================ */

.textures-nav-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-family: var(--font-sans);
}

.textures-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
  display: inline-block;
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.textures-dot.partial {
  background: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}

.textures-dot.loaded {
  background: var(--accent-emerald);
  box-shadow: 0 0 6px var(--accent-emerald);
}

.textures-dialog {
  max-width: 560px;
}

.textures-intro {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.textures-status-card {
  padding: 0.7rem 0.85rem;
  border-radius: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.85rem;
}

.textures-status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.textures-status-title {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
}

.textures-status-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text-secondary);
}

.textures-status-badge.partial {
  background: rgba(245, 158, 11, 0.2);
  border: 1px solid rgba(245, 158, 11, 0.5);
  color: #fde68a;
}

.textures-status-badge.loaded {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.textures-progress-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
  margin: 0.4rem 0;
}

.textures-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #8b5cf6, #10b981);
  transition: width 0.15s ease;
}

.textures-status-detail {
  margin: 0 !important;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.textures-source-box {
  padding: 0.75rem 0.9rem;
  border-radius: 8px;
  background: rgba(27, 22, 48, 0.65);
  border: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.textures-source-box:last-child {
  margin-bottom: 0;
}

.textures-source-box.drag-over {
  border-color: var(--accent-gold);
  background: rgba(245, 158, 11, 0.12);
}

.textures-source-box h3 {
  margin: 0 0 0.35rem !important;
  font-size: 0.8rem !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: #fde68a !important;
}

.textures-source-box p {
  margin: 0 0 0.6rem !important;
  font-size: 0.76rem;
}

.textures-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.textures-fallback-check {
  margin-top: 0.55rem;
  font-size: 0.73rem;
  padding: 0.35rem 0.55rem;
}

.textures-dialog-footer {
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.textures-footer-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.danger-text-btn:hover {
  color: #fda4af;
  border-color: rgba(244, 63, 94, 0.6);
  background: rgba(244, 63, 94, 0.12);
}

/* Pixelated In-game Research Icon Elements */
.node-main-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.2rem 0;
  min-height: 28px;
}

.node-icon-img {
  width: 26px;
  height: 26px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 4px;
  background: rgba(11, 9, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 2px;
}

.node-main-row .node-title {
  margin: 0;
  flex: 1;
  min-width: 0;
}

.insp-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0 0.25rem;
}

.insp-title-row .insp-title {
  margin: 0;
}

.insp-icon-img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 6px;
  background: rgba(11, 9, 20, 0.65);
  border: 1px solid var(--border-subtle);
  padding: 3px;
}

.unlock-item-icon,
.rel-item-icon,
.search-option-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
  border-radius: 4px;
  background: rgba(11, 9, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 2px;
}

.rel-item-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
}

.preset-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.preset-chip-icon {
  width: 15px;
  height: 15px;
  object-fit: contain;
  image-rendering: pixelated;
  flex-shrink: 0;
}


