/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #fafaf8;
  --text: #1a1a1a;
  --text-muted: #666;
  --border: #ddd;
  --accent: #2c5f8a;
  --link: #2c5f8a;

  --status-predicted: #999;
  --status-draft: #c49020;
  --status-preprint: #2c5f8a;
  --status-published: #2a7d4f;

  --claim-stub: #999;
  --claim-derived: #2c5f8a;
  --claim-tested: #c49020;
  --claim-survived: #2a7d4f;
  --claim-needs-revision: #b05030;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: baseline; gap: 0.75rem; }

.site-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}

.subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.view-toggle { display: flex; gap: 0; }

.toggle {
  padding: 0.35rem 1rem;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.toggle:first-child { border-radius: 4px 0 0 4px; }
.toggle:last-child { border-radius: 0 4px 4px 0; border-left: none; }
.toggle.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Main content */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

main.graph-mode {
  max-width: none;
  padding: 0;
  height: calc(100vh - 52px);
}

/* Wiki styles */
h1 { font-family: Georgia, 'Times New Roman', serif; font-size: 1.75rem; margin-bottom: 0.5rem; }
h2 { font-family: Georgia, 'Times New Roman', serif; font-size: 1.25rem; margin: 1.5rem 0 0.5rem; color: var(--text); }
h3 { font-size: 0.95rem; margin: 1rem 0 0.35rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

p { margin-bottom: 0.75rem; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.description { color: var(--text-muted); margin-bottom: 1.5rem; font-size: 0.95rem; }

/* Abstract */
.abstract {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  border-left: 3px solid var(--accent);
  padding: 0.75rem 1rem;
  margin: 0 0 1.5rem 0;
  background: #fff;
}

/* Coverage bar */
.coverage-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.coverage-track {
  width: 80px;
  height: 6px;
  background: #eee;
  border-radius: 3px;
  overflow: hidden;
}

.coverage-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.3s;
}

/* Status badge */
.status {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-predicted { background: #f0f0f0; color: var(--status-predicted); }
.status-draft { background: #fef3dc; color: var(--status-draft); }
.status-preprint { background: #e3eef7; color: var(--status-preprint); }
.status-published { background: #e3f3ea; color: var(--status-published); }

/* Claim status badge */
.claim-status {
  display: inline-block;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 2px;
  font-weight: 500;
}
.claim-stub { background: #f0f0f0; color: var(--claim-stub); }
.claim-derived { background: #e3eef7; color: var(--claim-derived); }
.claim-tested { background: #fef3dc; color: var(--claim-tested); }
.claim-survived { background: #e3f3ea; color: var(--claim-survived); }
.claim-needs-revision { background: #fce8e3; color: var(--claim-needs-revision); }

/* Canopy card */
.canopy-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
  background: #fff;
  transition: border-color 0.15s;
}
.canopy-card:hover { border-color: var(--accent); }

.canopy-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.canopy-card .card-title {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
}
.canopy-card .card-title a { color: var(--text); }

.canopy-card .card-description {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.canopy-card .card-meta {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Node list */
.node-list { list-style: none; }

.node-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid #f0f0f0;
}
.node-item:last-child { border-bottom: none; }

.node-item .node-name { flex: 1; }
.node-item .node-name a { color: var(--text); font-weight: 500; }
.node-item .node-role {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Claims */
.claim-item {
  padding: 0.75rem 0;
  border-bottom: 1px solid #eee;
  font-size: 0.9rem;
}
.claim-item:last-child { border-bottom: none; }

.claim-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.claim-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0.35rem 0 0.25rem 0;
  padding-left: 0.75rem;
  border-left: 2px solid var(--border);
  color: var(--text);
}

.claim-summary {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0.25rem 0;
  padding-left: 0.75rem;
}

.claim-deps {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Dependency / Emergence sections */
.nav-section { margin-bottom: 1rem; }

.nav-section .nav-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.nav-section .nav-label .arrow { font-size: 0.85rem; }

.dep-arrow { color: var(--status-draft); }
.emg-arrow { color: var(--status-preprint); }
.peer-label { color: var(--status-published); }

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

.nav-link {
  font-size: 0.8rem;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: #fff;
}
.nav-link:hover { border-color: var(--accent); text-decoration: none; }

/* Breadcrumb */
.breadcrumb {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { margin: 0 0.35rem; }

/* Metrics row */
.metrics {
  display: flex;
  gap: 1.5rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.metric {
  text-align: center;
}
.metric .metric-value {
  font-size: 1.5rem;
  font-weight: 600;
  font-family: Georgia, 'Times New Roman', serif;
}
.metric .metric-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

/* PDF link */
.pdf-link {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  color: var(--accent);
  font-weight: 500;
  font-size: 0.85rem;
  transition: all 0.15s;
}
.pdf-link:hover {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

/* Graph view */
#graph-container {
  width: 100%;
  height: 100%;
}

#graph-container svg {
  width: 100%;
  height: 100%;
}

.graph-node { cursor: pointer; }
.graph-node circle { stroke: #fff; stroke-width: 2; }
.graph-node circle.in-cycle { stroke: #e03030; stroke-width: 3; }
.graph-node text {
  font-size: 11px;
  fill: var(--text);
  pointer-events: none;
}

.graph-link { fill: none; stroke-opacity: 0.6; }
.graph-link-dep { stroke: var(--status-draft); stroke-width: 2; }
.graph-link-emg { stroke: var(--status-preprint); stroke-width: 1.5; stroke-dasharray: 4 2; }

.graph-tooltip {
  position: absolute;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 200;
}

.graph-controls {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 150;
}

.graph-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.graph-controls button:hover { border-color: var(--accent); }

/* Graph legend */
.graph-legend {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  background: rgba(255,255,255,0.95);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  z-index: 150;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  text-transform: capitalize;
  color: var(--text-muted);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.legend-toggle { cursor: pointer; user-select: none; }
.legend-toggle:hover { opacity: 0.8; }
.legend-toggle.legend-off { opacity: 0.35; }
.legend-toggle.legend-off .legend-dot { background: #ccc !important; }
.legend-count {
  font-size: 0.65rem;
  color: #aaa;
  margin-left: auto;
  padding-left: 0.5rem;
}

/* Graph sidebar */
.graph-sidebar {
  position: absolute;
  top: 0;
  right: 0;
  width: 300px;
  height: 100%;
  background: #fff;
  border-left: 1px solid var(--border);
  padding: 1rem;
  overflow-y: auto;
  z-index: 150;
  transform: translateX(100%);
  transition: transform 0.2s;
}
.graph-sidebar.open { transform: translateX(0); }
.graph-sidebar h2 { font-size: 1.1rem; margin-bottom: 0.5rem; }
.graph-sidebar .close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--text-muted);
}

/* Header right group */
.header-right { display: flex; align-items: center; gap: 0.75rem; }

/* Help button */
.help-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.help-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Help overlay */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.help-overlay[hidden] { display: none; }

.help-modal {
  background: #fff;
  border-radius: 8px;
  max-width: 640px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem 2.5rem;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.help-modal h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

.help-modal h2 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 1.1rem;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.help-modal p { font-size: 0.9rem; line-height: 1.6; margin-bottom: 0.5rem; }

.help-intro { color: var(--text-muted); }
.help-intro em { color: var(--text); font-style: italic; }

.help-close {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}
.help-close:hover { color: var(--text); }

.help-statuses {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  margin: 0.25rem 0 0.5rem;
}
.help-statuses > div {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.help-statuses .status,
.help-statuses .claim-status { flex-shrink: 0; }
