:root {
  --bg: var(--rm-bg, #fafafa);
  --card: var(--rm-surface, #fff);
  --text: var(--rm-text, rgba(0, 0, 0, 0.87));
  --muted: var(--rm-text-muted, rgba(0, 0, 0, 0.62));
  --accent: var(--rm-primary, #4051b5);
  --banner: #fff3cd;
  --border: var(--rm-border, rgba(0, 0, 0, 0.12));
}
* { box-sizing: border-box; }
body {
  margin: 0;
  line-height: 1.6;
}
.content { max-width: 61rem; margin: 0 auto; padding: 1.75rem 1rem 3rem; }
.search-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 1rem 0;
}
.search-form input[type="search"],
.search-form input[type="text"] {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 0.55rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}
button.btn-secondary {
  background: #e8ecf1;
  color: var(--text);
}
button.btn-llm {
  background: #059669;
}
.report-actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  width: 100%;
}
.report-form input[type="search"] {
  width: 100%;
}
.llm-status {
  margin: 0.75rem 0;
}
.badge.llm-ready {
  background: #d1fae5;
  color: #065f46;
}
.hint { color: var(--muted); font-size: 0.95rem; }
.error { color: #b00020; }
.cards { display: grid; gap: 1rem; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 0 0.2rem rgba(0, 0, 0, 0.05);
  padding: 1rem;
}
.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  background: #e8ecf1;
  margin-right: 0.35rem;
}
.badge.type { background: #dbeafe; }
.badge.conf-high { background: #d1fae5; }
.badge.conf-medium { background: #fef3c7; }
.badge.conf-low { background: #fee2e2; }
.score { float: right; color: var(--muted); font-size: 0.85rem; }
.id { font-family: monospace; color: var(--muted); }
.map-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 0.75rem;
  min-height: 70vh;
}
.map-search-form input[type="text"] {
  width: 10rem;
}
.map-search-form select {
  padding: 0.6rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.map-clear-entity {
  align-self: center;
  font-size: 0.85rem;
  white-space: nowrap;
}
.map-note {
  margin: 0.25rem 0 0.5rem;
  font-size: 0.85rem;
}
.cy-wrap {
  position: relative;
  min-height: 70vh;
}
.cy-container {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  height: 70vh;
  min-height: 480px;
}
.map-legend-panel {
  position: absolute;
  left: 8px;
  bottom: 8px;
  z-index: 10;
  max-width: min(420px, calc(100% - 16px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.3;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
.map-legend-panel summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}
.map-legend-panel[open] summary {
  margin-bottom: 0.35rem;
}
.legend-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.65rem;
}
.leg-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}
.legend-inactive {
  opacity: 0.3;
}
.leg-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0, 0, 0, 0.12);
}
.leg-dot-resource { background: #2563eb; }
.leg-dot-person { background: #059669; }
.leg-dot-grant { background: #d97706; }
.leg-dot-course { background: #7c3aed; }
.leg-dot-publication { background: #db2777; }
.leg-line {
  display: inline-block;
  width: 22px;
  height: 0;
  flex-shrink: 0;
  border: none;
  border-top-width: 3px;
  border-top-style: solid;
}
.leg-dot-output { background: #0891b2; }
.leg-dot-unit { background: #475569; }
.map-readme {
  margin: 0.5rem 0 0;
  font-size: 0.92rem;
  max-width: 52rem;
}
.leg-line-ownership { border-top-color: #0f766e; border-top-width: 3px; }
.leg-line-participation { border-top-color: #2563eb; border-top-width: 2px; }
.leg-line-participation-director { border-top-color: #1e40af; border-top-style: dashed; border-top-width: 2px; }
.leg-line-participation-grant { border-top-color: #d97706; border-top-width: 2px; }
.leg-line-participation-scholarly { border-top-color: #db2777; border-top-width: 2px; }
.leg-line-peer {
  border-top-color: #64748b;
  border-top-style: dotted;
  border-top-width: 2px;
}
.leg-line-direct { border-top-color: #1e40af; }
.leg-line-affiliated { border-top-color: #64748b; border-top-style: dashed; border-top-width: 2px; }
.leg-line-collaborates { border-top-color: #7c3aed; border-top-style: dotted; border-top-width: 2px; }
.leg-line-grant { border-top-color: #d97706; }
.leg-line-course { border-top-color: #7c3aed; }
.leg-line-admin { border-top-color: #9ca3af; border-top-style: dotted; border-top-width: 2px; }
.leg-line-contact { border-top-color: #64748b; border-top-width: 2px; }
.leg-line-scholarly { border-top-color: #db2777; border-top-width: 2px; }
.node-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  font-size: 0.9rem;
  overflow-y: auto;
  max-height: 520px;
}
.edge-list {
  margin: 0.25rem 0 0 1rem;
  padding: 0;
  font-size: 0.85rem;
}
.map-empty {
  padding: 2rem;
  text-align: center;
}
.report-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin: 0.75rem 0 1rem;
}
.llm-narrative {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.report-llm-stats-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 0.92rem;
  color: #14532d;
}
.report-llm-stats-item strong {
  font-weight: 600;
  margin-right: 0.25rem;
}
.report-llm-stats-sub {
  color: #166534;
  font-size: 0.88rem;
  margin-left: 0.15rem;
}
.report-llm-stats-sep {
  color: #4ade80;
  font-weight: 600;
}
.llm-narrative h2 {
  margin: 0 0 0.35rem;
  font-size: 1.25rem;
}
.llm-disclaimer {
  margin: 0 0 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.report-record h2 {
  margin: 0 0 0.75rem;
  font-size: 1.1rem;
  color: var(--muted);
}
.markdown-body {
  font-size: 1rem;
  line-height: 1.6;
}
.markdown-body h3,
.markdown-body h4 {
  margin: 1.25rem 0 0.5rem;
  line-height: 1.3;
}
.markdown-body h3:first-child,
.markdown-body h4:first-child {
  margin-top: 0;
}
.markdown-body p {
  margin: 0.75rem 0;
}
.markdown-body ul,
.markdown-body ol {
  margin: 0.5rem 0 0.75rem;
  padding-left: 1.5rem;
}
.markdown-body li {
  margin: 0.35rem 0;
}
.markdown-body a {
  color: var(--accent);
  text-decoration: none;
}
.markdown-body a:hover {
  text-decoration: underline;
}
.markdown-body strong {
  font-weight: 600;
}
.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.75rem 0 1rem;
  font-size: 0.95rem;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}
.markdown-body th {
  background: #f1f5f9;
  font-weight: 600;
}
.markdown-body .footnote {
  font-size: 0.88rem;
  color: var(--muted);
}
.markdown-body .footnote-ref a {
  text-decoration: none;
  font-weight: 600;
}
.report-provenance {
  margin-top: 1.25rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}
.report-provenance summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
}
.report-provenance-dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.35rem 1rem;
  margin: 0.75rem 0 0.5rem;
}
.report-provenance-dl dt {
  font-weight: 600;
  color: var(--muted);
}
.report-provenance-dl dd {
  margin: 0;
}
.report-md {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  white-space: pre-wrap;
  overflow-x: auto;
  font-size: 0.85rem;
  margin: 0;
}
.report-llm-progress {
  margin: 1rem 0 1.25rem;
  padding: 0.85rem 1rem 1rem;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 6px;
  color: #1e3a5f;
}
.report-llm-progress.is-active {
  animation: report-llm-fade-in 0.2s ease-out;
}
.report-llm-progress-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.report-llm-progress-detail {
  margin: 0.55rem 0 0.75rem;
  font-size: 0.92rem;
  color: #334155;
}
.report-llm-progress-error {
  margin: 0 0 0.75rem;
}
.report-page-loading {
  opacity: 0.55;
  pointer-events: none;
}
.report-llm-elapsed {
  margin-left: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  color: #475569;
}
.report-llm-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid #93c5fd;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: report-llm-spin 0.8s linear infinite;
  flex-shrink: 0;
}
.report-llm-progress-track {
  height: 4px;
  background: #dbeafe;
  border-radius: 999px;
  overflow: hidden;
}
.report-llm-progress-bar {
  display: block;
  width: 40%;
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #60a5fa);
  border-radius: 999px;
  animation: report-llm-indeterminate 1.4s ease-in-out infinite;
}
@keyframes report-llm-spin {
  to { transform: rotate(360deg); }
}
@keyframes report-llm-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}
@keyframes report-llm-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.stats { border-collapse: collapse; width: 100%; max-width: 600px; }
.stats th, .stats td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
}
.edge-evidence {
  margin: 0.75rem 0;
  padding: 0.65rem 0.75rem;
  background: #f8fafc;
  border-left: 3px solid var(--accent);
  font-size: 0.95rem;
}
.chain-section {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}
.chain-toggle {
  font-size: 0.85rem;
  padding: 0.35rem 0.65rem;
}
.chain-panel {
  margin-top: 0.75rem;
}
.chain-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.9rem;
}
.chain-step {
  margin: 0.5rem 0;
}
.chain-step code {
  font-size: 0.8rem;
}
@media (max-width: 768px) {
  .map-layout { grid-template-columns: 1fr; }
}
