* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  color: #222;
  background: #f6f7f9;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: #101827;
  color: #fff;
  border-bottom: 1px solid #0a0f1a;
}

header h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.5px;
}

.mode-toggle button {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #334155;
  padding: 6px 12px;
  margin-left: 6px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}

.mode-toggle button.active {
  background: #2563eb;
  color: white;
  border-color: #2563eb;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.settings-wrap {
  position: relative;
}

#settings-btn {
  background: transparent;
  color: #cbd5e1;
  border: 1px solid #334155;
  width: 32px;
  height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#settings-btn:hover { background: #1e293b; color: white; }
#settings-btn.active { background: #2563eb; color: white; border-color: #2563eb; }

.settings-panel {
  position: absolute;
  top: 40px;
  right: 0;
  width: 260px;
  background: white;
  color: #111;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  padding: 12px;
  z-index: 50;
}

.settings-panel h4 {
  margin: 0 0 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: #111;
  cursor: pointer;
  line-height: 1.35;
}

.toggle-row input { margin-top: 2px; }

.perf-legend { margin-top: 10px; }
.perf-scale {
  height: 10px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    #991b1b 0%, #ef4444 25%, #94a3b8 50%, #22c55e 75%, #15803d 100%
  );
}
.perf-scale-labels {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #6b7280;
  margin-top: 4px;
}

main {
  display: flex;
  height: calc(100vh - 48px);
}

#sidebar {
  width: 320px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  overflow-y: auto;
  padding: 12px;
}

.panel {
  padding: 10px 4px;
  border-bottom: 1px solid #eef0f3;
  margin-bottom: 8px;
}

.panel h3 {
  font-size: 13px;
  margin: 4px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}

.panel label {
  display: block;
  font-size: 13px;
  color: #374151;
  margin: 6px 0 4px;
}

.panel select,
.panel input[type="text"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  font-size: 13px;
}

.panel button {
  margin-top: 6px;
  padding: 6px 10px;
  border: none;
  background: #2563eb;
  color: white;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.panel button:hover { background: #1d4ed8; }

.hidden { display: none; }

.disabled-row {
  color: #9ca3af;
  cursor: not-allowed;
}
.disabled-row input { cursor: not-allowed; }

#canvas-wrap {
  flex: 1;
  position: relative;
  background: #f9fafb;
}

#cy {
  width: 100%;
  height: 100%;
}

#status {
  position: absolute;
  bottom: 10px;
  left: 10px;
  font-size: 12px;
  color: #6b7280;
  background: rgba(255,255,255,0.85);
  padding: 4px 8px;
  border-radius: 4px;
  pointer-events: none;
}

.loader {
  position: absolute;
  inset: 0;
  background: rgba(249, 250, 251, 0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 100;
  pointer-events: none;
}
.loader.hidden { display: none; }
.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e5e7eb;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: bcm-spin 0.9s linear infinite;
}
@keyframes bcm-spin {
  to { transform: rotate(360deg); }
}
.loader-msg {
  font-size: 13px;
  color: #374151;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.95);
  padding: 6px 12px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  max-width: 70%;
  text-align: center;
  white-space: pre-line;
  line-height: 1.4;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}
.dot.ticker { background: #2563eb; }
.dot.drug { background: #10b981; }
.dot.disease { background: #f59e0b; }
.dot.moa { background: #8b5cf6; }
.dot.investor { background: #ec4899; clip-path: polygon(50% 0%, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); border-radius: 0; }

.edge {
  display: inline-block;
  width: 22px;
  height: 0;
  margin-right: 6px;
  vertical-align: middle;
  border-top: 2px solid #64748b;
}
.edge.dashed { border-top: 2px dashed #64748b; }

#details-body p { margin: 4px 0; font-size: 13px; }
#details-body .prop { color: #6b7280; font-weight: 600; font-size: 12px; margin-right: 4px; }
#details-body .desc { background: #f3f4f6; padding: 8px; border-radius: 4px; font-size: 12px; line-height: 1.4; white-space: pre-wrap; }

.legend ul { list-style: none; padding: 0; margin: 0; font-size: 12px; }
.legend li { padding: 3px 0; color: #374151; }

.segmented {
  display: flex;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  overflow: hidden;
  margin-top: 4px;
}
.segmented button {
  flex: 1;
  background: white;
  color: #374151;
  border: none;
  border-right: 1px solid #e5e7eb;
  padding: 6px 4px;
  font-size: 11px;
  cursor: pointer;
  margin: 0;
  border-radius: 0;
}
.segmented button:last-child { border-right: none; }
.segmented button.active { background: #2563eb; color: white; }
.hint { font-size: 11px; color: #6b7280; margin: 6px 2px 0; }

#pair-items { max-height: 220px; overflow-y: auto; }

input[type="range"] { width: 100%; }

.explain-btn {
  background: none;
  border: 1px solid #2563eb;
  color: #2563eb;
  font-size: 11px;
  padding: 2px 8px;
  margin-left: 6px;
  border-radius: 3px;
  cursor: pointer;
}
.explain-btn:hover { background: #2563eb; color: white; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: white;
  width: min(720px, 92vw);
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: #101827;
  color: white;
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head button {
  background: transparent;
  color: white;
  border: none;
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
}
.modal-sub {
  padding: 8px 16px;
  font-size: 12px;
  color: #374151;
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}
.modal-body {
  padding: 14px 18px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.55;
  color: #111;
}
.modal-body h1, .modal-body h2, .modal-body h3 {
  font-size: 14px;
  margin: 10px 0 4px;
  color: #111;
}
.modal-body p { margin: 6px 0; }
.modal-body ul { margin: 4px 0; padding-left: 20px; }
.modal-body code {
  background: #f3f4f6;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}
.modal-foot {
  padding: 8px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 12px;
}

#md-copy-btn {
  background: #2563eb;
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
#md-copy-btn:hover { background: #1d4ed8; }

.md-export-pre {
  margin: 0;
  padding: 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  border-radius: 4px;
  white-space: pre;
  overflow-x: auto;
  user-select: text;
}

#holders-body { margin-top: 8px; max-height: 280px; overflow-y: auto; }
#holders-meta { margin: 0 0 6px; }
#holders-list { list-style: none; padding: 0; margin: 0; font-size: 12px; }
#holders-list li {
  padding: 6px 8px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
#holders-list li.starred {
  background: #fef2f2;
  border-left: 3px solid #dc2626;
  padding-left: 5px;
}
#holders-list .h-name { color: #111; font-weight: 500; }
#holders-list .h-meta { color: #6b7280; white-space: nowrap; font-size: 11px; }

#search-results, #similar-results {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  font-size: 13px;
}
#search-results li, #similar-results li {
  padding: 6px 8px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
}
#search-results li:hover, #similar-results li:hover { background: #f3f4f6; }
#search-results .score, #similar-results .score {
  color: #6b7280;
  font-size: 11px;
  margin-left: 6px;
}
