:root {
  --bg: #0a0a0c;
  --bg-warm: #0d0c0a;
  --panel: #111113;
  --panel-elevated: #18181b;
  --text: #e8e6e3;
  --text-muted: #6b6b6b;
  --text-warm: #c4b8a5;
  --accent: #d4a574;
  --accent-glow: rgba(212, 165, 116, 0.15);
  --accent-bright: #e8c4a0;

  /* Node Colors - warmer palette */
  --book-source: #c45c4a;
  --book-cited: #4a6fa5;
  --author-fill: rgba(212, 165, 116, 0.03);
  --author-stroke: rgba(212, 165, 116, 0.15);

  --edge: #2a2a2f;
  --edge-highlight: var(--accent);

  /* Citation card colors */
  --card-bg: rgba(20, 20, 22, 0.7);
  --card-border: rgba(212, 165, 116, 0.1);
  --card-hover: rgba(212, 165, 116, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

/* Subtle noise texture overlay */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  z-index: 9999;
}

/* === Canvas === */
#graph-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* === Label Overlay === */
#label-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  overflow: hidden;
}

.node-label {
  position: absolute;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--text-warm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  transform: translate(-50%, -100%);
  text-shadow:
    -1px -1px 0 var(--bg),
     1px -1px 0 var(--bg),
    -1px  1px 0 var(--bg),
     1px  1px 0 var(--bg),
     0   -2px 0 var(--bg),
     0    2px 0 var(--bg),
    -2px  0   0 var(--bg),
     2px  0   0 var(--bg);
  letter-spacing: 0.02em;
}

.node-label.visible {
  opacity: 1;
}

/* === Axis Overlay === */
#axis-overlay {
  position: fixed;
  top: 0;
  right: 0;
  width: 100px;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.axis-tick {
  position: absolute;
  right: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: #999;
  transform: translateY(-50%);
  white-space: nowrap;
  text-shadow: 0 0 6px rgba(0,0,0,0.8), 0 0 12px rgba(0,0,0,0.5);
}

/* === Tooltip === */
#tooltip {
  position: fixed;
  background: rgba(17, 17, 19, 0.95);
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid rgba(212, 165, 116, 0.2);
  pointer-events: none;
  font-size: 13px;
  font-family: "Cormorant Garamond", Georgia, serif;
  display: none;
  z-index: 100;
  max-width: 280px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  color: var(--text);
}

/* === Header === */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 16px 32px 12px;
  background: linear-gradient(180deg, rgba(10, 10, 12, 0.98) 0%, rgba(10, 10, 12, 0.92) 70%, transparent 100%);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  z-index: 10;
  pointer-events: none;
}

header > * {
  pointer-events: auto;
}

/* Flatten .header-content so its children participate in header flex layout */
.header-content {
  display: contents;
}

h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-warm);
}

.github-link {
  color: var(--text-muted);
  transition: color 0.2s ease;
  vertical-align: middle;
  margin-left: 8px;
  display: inline-block;
}

.github-link:hover {
  color: var(--text-warm);
}

.info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(212, 165, 116, 0.15);
  background: none;
  color: var(--text-muted);
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  cursor: pointer;
  margin-left: 8px;
  vertical-align: middle;
  transition: all 0.2s ease;
}

.info-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

/* Title + controls on first row, shelf on second */
.header-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
  order: 1;
}

#controls {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  order: 2;
  margin-left: auto;
}

#shelf-section {
  order: 3;
  flex-basis: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.shelf-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

#header-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 134px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 2px 0;
  scrollbar-width: thin;
}

#header-shelf::-webkit-scrollbar {
  width: 4px;
}

#header-shelf::-webkit-scrollbar-thumb {
  background: rgba(212, 165, 116, 0.2);
  border-radius: 2px;
}

.cover-image {
  height: 60px;
  flex-shrink: 0;
  border-radius: 2px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 1px 4px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(212, 165, 116, 0.1);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
  cursor: pointer;
}

.cover-image:hover {
  transform: scale(1.6);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.8);
  z-index: 100;
  position: relative;
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  letter-spacing: 0.02em;
}

#loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 18px;
  color: var(--text-muted);
  z-index: 100;
  letter-spacing: 0.1em;
  display: none;
}

.search-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(212, 165, 116, 0.15);
  border-radius: 2px;
  padding: 10px 16px;
  color: var(--text);
  font-size: 14px;
  font-family: "JetBrains Mono", monospace;
  outline: none;
  width: 220px;
  transition: border-color 0.3s ease, background 0.3s ease;
}

.search-box:focus {
  border-color: var(--accent);
  background: rgba(212, 165, 116, 0.05);
}

.search-box::placeholder {
  color: var(--text-muted);
}

/* === LEFT CITATION PANEL === */
#citation-panel {
  position: fixed;
  left: -420px;
  top: 0;
  width: 420px;
  height: 100vh;
  background: var(--panel);
  transition: left 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
  border-right: 1px solid rgba(212, 165, 116, 0.08);
  display: flex;
  flex-direction: column;
}

#citation-panel.visible {
  left: 0;
}

#citation-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
  pointer-events: none;
}

.citation-panel-header {
  position: relative;
  padding: 40px 32px 24px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.08);
  flex-shrink: 0;
}

.citation-panel-header h2 {
  font-size: 24px;
  font-weight: 400;
  margin: 0;
  line-height: 1.3;
  color: var(--text);
  padding-right: 48px;
}

.citation-panel-subtitle {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  letter-spacing: 0.02em;
}

#citation-panel-close {
  position: absolute;
  top: 32px;
  right: 32px;
  background: none;
  border: 1px solid rgba(212, 165, 116, 0.15);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#citation-panel-close:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.citation-panel-body {
  display: flex;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

.citation-col {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
  min-width: 0;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

.citation-col:first-child {
  border-right: 1px solid rgba(212, 165, 116, 0.06);
}

.citation-col h3 {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin: 0 16px 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.08);
}

.citation-col-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(212, 165, 116, 0.1);
  padding: 2px 6px;
  border-radius: 2px;
  margin-left: 4px;
}

.citation-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.citation-list-item {
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.citation-list-item:hover {
  background: var(--card-hover);
  border-left-color: rgba(212, 165, 116, 0.3);
}

.citation-list-item.active {
  background: var(--accent-glow);
  border-left-color: var(--accent);
}

.citation-item-name {
  font-size: 14px;
  color: var(--text);
  line-height: 1.3;
}

.citation-item-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.citation-col::-webkit-scrollbar {
  width: 4px;
}

.citation-col::-webkit-scrollbar-track {
  background: transparent;
}

.citation-col::-webkit-scrollbar-thumb {
  background: rgba(212, 165, 116, 0.15);
  border-radius: 2px;
}

.citation-col-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

/* === MINI DETAIL CARD (right side, focus mode) === */
#detail-card {
  position: fixed;
  right: -280px;
  top: 50%;
  transform: translateY(-50%);
  width: 260px;
  background: var(--panel);
  border: 1px solid rgba(212, 165, 116, 0.12);
  border-radius: 4px;
  padding: 20px 24px;
  z-index: 18;
  transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

#detail-card.visible {
  right: 24px;
}

#detail-card:hover {
  border-color: rgba(212, 165, 116, 0.3);
  background: var(--panel-elevated);
}

#detail-card-type {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  display: block;
  margin-bottom: 6px;
}

#detail-card-title {
  font-size: 18px;
  font-weight: 400;
  margin: 0;
  line-height: 1.3;
  color: var(--text);
}

#detail-card-meta {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
}

/* === RIGHT DETAIL PANEL === */
#info-panel {
  position: fixed;
  right: -520px;
  top: 0;
  width: 520px;
  height: 100vh;
  background: var(--panel);
  overflow-y: auto;
  transition: right 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
  border-left: 1px solid rgba(212, 165, 116, 0.08);
  display: flex;
  flex-direction: column;
}

#info-panel.visible {
  right: 0;
}

#info-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(180deg, var(--accent-glow) 0%, transparent 100%);
  pointer-events: none;
}

#panel-header {
  position: relative;
  padding: 40px 32px 24px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.08);
  flex-shrink: 0;
}

#panel-type {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 8px;
  display: block;
}

#panel-title {
  font-size: 28px;
  font-weight: 400;
  margin: 0;
  line-height: 1.3;
  color: var(--text);
}

#panel-meta {
  margin-top: 12px;
  font-size: 14px;
  color: var(--text-muted);
  font-style: italic;
}

#panel-close {
  position: absolute;
  top: 32px;
  right: 32px;
  background: none;
  border: 1px solid rgba(212, 165, 116, 0.15);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#panel-close:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

#panel-content {
  padding: 24px 32px 40px;
  flex: 1;
  overflow-y: auto;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
}

/* Stats row for books */
.panel-stats {
  display: flex;
  gap: 24px;
  padding: 16px 0;
  border-bottom: 1px solid rgba(212, 165, 116, 0.08);
  margin-bottom: 20px;
}

.panel-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-stat-value {
  font-family: "JetBrains Mono", monospace;
  font-size: 14px;
  color: var(--text);
}

.panel-stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

/* Description */
.panel-description {
  font-size: 16px;
  line-height: 1.8;
  color: var(--text);
  margin-bottom: 32px;
}

/* === CITATION CARDS === */
.citations-section {
  margin-top: 32px;
}

.citations-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.08);
}

.citations-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin: 0;
}

.citations-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(212, 165, 116, 0.1);
  padding: 3px 8px;
  border-radius: 2px;
}

.citation-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 4px;
  margin-bottom: 16px;
  overflow: hidden;
  transition: all 0.3s ease;
  animation: cardSlideIn 0.4s ease forwards;
}

.citation-card:hover {
  background: var(--card-hover);
  border-color: rgba(212, 165, 116, 0.25);
  transform: translateX(-4px);
}

.citation-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.citation-card:hover::before {
  opacity: 1;
}

.citation-card-inner {
  padding: 20px 24px;
}

.citation-number {
  position: absolute;
  top: 16px;
  right: 16px;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.5;
}

.citation-quote {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text);
  font-style: italic;
  margin: 0;
  padding-right: 32px;
}

.citation-quote::before {
  content: open-quote;
  font-size: 24px;
  color: var(--accent);
  opacity: 0.5;
  margin-right: 4px;
  line-height: 0;
  vertical-align: -0.3em;
}

.citation-quote::after {
  content: close-quote;
  font-size: 24px;
  color: var(--accent);
  opacity: 0.5;
  margin-left: 4px;
  line-height: 0;
  vertical-align: -0.3em;
}

/* Expandable citation card */
.citation-card.expandable .citation-quote {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.citation-card.expandable.expanded .citation-quote {
  display: block;
  -webkit-line-clamp: unset;
}

.citation-expand {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(212, 165, 116, 0.1);
}

.citation-card.expandable .citation-expand {
  display: block;
}

.citation-expand-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  cursor: pointer;
  padding: 0;
  opacity: 0.8;
  transition: opacity 0.2s;
}

.citation-expand-btn:hover {
  opacity: 1;
}

.citation-card.expanded .citation-expand-btn {
  display: none;
}

/* Link button */
.panel-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  background: transparent;
  border: 1px solid rgba(212, 165, 116, 0.2);
  color: var(--accent);
  text-decoration: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  border-radius: 2px;
  transition: all 0.3s ease;
  margin-top: 24px;
}

.panel-link:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

.panel-link svg {
  width: 14px;
  height: 14px;
}

/* Hero Section */
#hero {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 720px;
  text-align: center;
  z-index: 5;
}

#hero h2 {
  font-size: 36px;
  font-weight: 400;
  margin: 0 0 24px;
  color: var(--text-warm);
  letter-spacing: 0.02em;
}

#hero p {
  color: var(--text-muted);
  font-size: 17px;
  line-height: 1.8;
  margin: 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
}

.control-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

#search-results {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--accent);
  white-space: nowrap;
}

#hero.hidden {
  display: none;
}

/* Mobile hint */
#mobile-hint {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(212, 165, 116, 0.2);
  color: var(--text-muted);
  padding: 12px 20px;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  z-index: 100;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

#mobile-hint strong {
  color: var(--accent);
}

#mobile-hint-close {
  background: none;
  border: none;
  color: var(--text-muted);
  margin-left: 12px;
  cursor: pointer;
  font-size: 14px;
}

/* Focus Mode */
#focus-exit {
  position: fixed;
  top: 100px;
  left: 32px;
  background: var(--panel);
  border: 1px solid rgba(212, 165, 116, 0.2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 4px;
  cursor: pointer;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  letter-spacing: 0.05em;
  display: none;
  align-items: center;
  gap: 8px;
  z-index: 15;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#focus-exit:hover {
  background: var(--accent-glow);
  border-color: var(--accent);
}

#focus-exit.visible {
  display: flex;
}

#focus-exit svg {
  width: 16px;
  height: 16px;
}

/* Focus mode info badge */
#focus-info {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid rgba(212, 165, 116, 0.15);
  color: var(--text-warm);
  padding: 10px 20px;
  border-radius: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.05em;
  display: none;
  z-index: 15;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

#focus-info.visible {
  display: block;
}

#focus-info strong {
  color: var(--accent);
}

/* Empty state for no citations */
.empty-citations {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-citations-icon {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.3;
}

/* Scrollbar styling */
#info-panel::-webkit-scrollbar,
#panel-content::-webkit-scrollbar {
  width: 6px;
}

#info-panel::-webkit-scrollbar-track,
#panel-content::-webkit-scrollbar-track {
  background: transparent;
}

#info-panel::-webkit-scrollbar-thumb,
#panel-content::-webkit-scrollbar-thumb {
  background: rgba(212, 165, 116, 0.2);
  border-radius: 3px;
}

#info-panel::-webkit-scrollbar-thumb:hover,
#panel-content::-webkit-scrollbar-thumb:hover {
  background: rgba(212, 165, 116, 0.4);
}

/* Animation for cards appearing */
@keyframes cardSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.citation-card:nth-child(1) { animation-delay: 0.05s; }
.citation-card:nth-child(2) { animation-delay: 0.1s; }
.citation-card:nth-child(3) { animation-delay: 0.15s; }
.citation-card:nth-child(4) { animation-delay: 0.2s; }
.citation-card:nth-child(5) { animation-delay: 0.25s; }
.citation-card:nth-child(6) { animation-delay: 0.3s; }
.citation-card:nth-child(7) { animation-delay: 0.35s; }
.citation-card:nth-child(8) { animation-delay: 0.4s; }

/* === DONUT CHARTS (Citation Panel) === */
#citation-charts {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(212, 165, 116, 0.08);
  flex-shrink: 0;
  position: relative;
}

#citation-charts::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20px;
  right: 20px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(212, 165, 116, 0.15), transparent);
}

.citation-charts-desc {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.4;
  opacity: 0;
  animation: chartFadeIn 0.5s ease 0.1s forwards;
}

.citation-charts-row {
  display: flex;
  justify-content: space-around;
  gap: 8px;
}

.donut-chart {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.donut-chart-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  opacity: 0;
  animation: chartFadeIn 0.4s ease 0.05s forwards;
}

.donut-chart-ring {
  position: relative;
  line-height: 0;
}

.donut-chart-ring svg {
  filter: drop-shadow(0 0 8px rgba(212, 165, 116, 0.1));
}

.donut-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px 8px;
  max-width: 130px;
  opacity: 0;
  animation: chartFadeIn 0.5s ease 0.4s forwards;
}

.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-family: "JetBrains Mono", monospace;
  font-size: 8px;
  color: var(--text-muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.donut-legend-swatch {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

@keyframes chartFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* === INFO OVERLAY === */
#info-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

#info-overlay.visible {
  display: flex;
}

.info-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.info-card {
  position: relative;
  background: var(--panel);
  border: 1px solid rgba(212, 165, 116, 0.12);
  border-radius: 8px;
  padding: 32px;
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.5);
  z-index: 1;
}

.info-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: 1px solid rgba(212, 165, 116, 0.15);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.info-close:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
}

.info-card h2 {
  font-size: 22px;
  font-weight: 400;
  margin: 0 0 12px;
  color: var(--text-warm);
  letter-spacing: 0.05em;
}

.info-card > p {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 24px;
}

.info-section {
  margin-bottom: 20px;
}

.info-section:last-child {
  margin-bottom: 0;
}

.info-section h3 {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin: 0 0 8px;
}

.info-section p {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  margin: 0;
}

.info-section strong {
  color: var(--accent);
  font-weight: 500;
}

.info-section ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.info-section li {
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  padding: 2px 0 2px 16px;
  position: relative;
}

.info-section li::before {
  content: "\b7";
  position: absolute;
  left: 4px;
  color: var(--accent);
}

.color-source {
  color: var(--book-source);
}

.color-cited {
  color: var(--book-cited);
}

/* ============================================
   MOBILE RESPONSIVE STYLES
   ============================================ */

/* Tablet breakpoint */
@media (max-width: 900px) {
  #mobile-hint {
    display: block;
  }

  header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 12px;
  }

  h1 {
    font-size: 18px;
  }

  .header-subtitle {
    display: none;
  }

  #controls {
    gap: 12px;
  }

  .search-box {
    width: 160px;
    padding: 8px 12px;
    font-size: 13px;
  }

  #header-shelf {
    max-height: 56px;
  }

  .cover-image {
    height: 50px;
  }

  .cover-image:hover {
    transform: scale(1.3) translateY(10px);
  }

  #citation-charts {
    padding: 14px 12px 10px;
  }

  .donut-chart-ring svg {
    width: 100px;
    height: 100px;
  }

  .donut-legend {
    max-width: 110px;
  }

  /* Citation panel - narrower on tablet */
  #citation-panel {
    width: 320px;
    left: -320px;
  }

  .citation-panel-header {
    padding: 24px 20px 16px;
  }

  .citation-panel-header h2 {
    font-size: 20px;
  }

  #detail-card {
    width: 220px;
    padding: 16px 20px;
  }

  #detail-card-title {
    font-size: 16px;
  }

  /* Panel - narrower on tablet */
  #info-panel {
    width: 400px;
    right: -400px;
  }

  #info-panel.visible {
    right: 0;
  }

  #panel-header {
    padding: 24px 20px 16px;
  }

  #panel-content {
    padding: 16px 20px 32px;
  }

  #panel-title {
    font-size: 22px;
  }

  /* Focus mode controls */
  #focus-exit {
    top: 80px;
    left: 16px;
    padding: 10px 14px;
    font-size: 11px;
  }

  #focus-info {
    top: 80px;
    font-size: 10px;
    padding: 8px 14px;
    max-width: 70%;
  }
}

/* Phone breakpoint */
@media (max-width: 600px) {
  header {
    padding: 8px 12px 6px;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    background: linear-gradient(180deg, rgba(10, 10, 12, 0.99) 0%, rgba(10, 10, 12, 0.95) 80%, transparent 100%);
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
  }

  /* Title row above the shelf */
  .header-text {
    order: -1;
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  /* Cover shelf: single scrollable row */
  #header-shelf {
    flex-wrap: nowrap;
    max-height: none;
    gap: 4px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  #header-shelf::-webkit-scrollbar {
    display: none;
  }

  h1 {
    font-size: 14px;
    letter-spacing: 0.1em;
    white-space: nowrap;
  }

  #controls {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    gap: 8px;
  }

  .control-group {
    flex: 1;
    min-width: 0;
  }

  .control-label {
    font-size: 8px;
  }

  .search-box {
    width: 100%;
    min-width: 0;
    padding: 6px 10px;
    font-size: 12px;
  }

  .cover-image {
    height: 40px;
  }

  .cover-image:hover {
    transform: none;
  }

  #detail-card {
    display: none;
  }

  /* Citation panel - full width on phone */
  #citation-panel {
    width: 100%;
    left: -100%;
  }

  .citation-panel-header {
    padding: 20px 16px 12px;
  }

  .citation-panel-header h2 {
    font-size: 20px;
    padding-right: 40px;
  }

  #citation-panel-close {
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
  }

  /* Panel - full width on phone */
  #info-panel {
    width: 100%;
    right: -100%;
  }

  #info-panel.visible {
    right: 0;
  }

  #panel-header {
    padding: 20px 16px 12px;
  }

  #panel-content {
    padding: 12px 16px 24px;
  }

  #panel-title {
    font-size: 20px;
    padding-right: 40px;
  }

  #panel-close {
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
  }

  #panel-type {
    font-size: 9px;
  }

  .panel-description {
    font-size: 15px;
  }

  .citation-card-inner {
    padding: 14px 16px;
  }

  .citation-quote {
    font-size: 14px;
  }

  /* Focus exit */
  #focus-exit {
    top: auto;
    bottom: 20px;
    left: 16px;
    transform: none;
    padding: 10px 14px;
    border-radius: 20px;
    font-size: 11px;
    background: var(--panel);
    border: 1px solid var(--accent);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  }

  #focus-exit svg {
    width: 14px;
    height: 14px;
  }

  #focus-info {
    top: 120px;
    left: 12px;
    right: 12px;
    transform: none;
    text-align: center;
    font-size: 10px;
    padding: 8px 12px;
    max-width: none;
  }

  #hero {
    padding: 0 20px;
  }

  #hero h2 {
    font-size: 24px;
  }

  #hero p {
    font-size: 14px;
  }

  .node-label {
    font-size: 10px;
  }
}

/* Portrait mode phones - bottom sheet panels */
@media (max-width: 600px) and (orientation: portrait) {
  #info-overlay {
    align-items: flex-end;
  }

  .info-card {
    max-width: 100%;
    width: 100%;
    border-radius: 16px 16px 0 0;
    max-height: 70vh;
    padding: 24px 20px;
  }

  #citation-panel {
    width: 100%;
    height: 55vh;
    max-height: 55vh;
    top: auto;
    bottom: -55vh;
    left: 0;
    border-right: none;
    border-top: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 16px 16px 0 0;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  #citation-panel.visible {
    bottom: 0;
    left: 0;
  }

  #citation-panel.expanded {
    height: 90vh;
    max-height: 90vh;
  }

  #citation-panel::before {
    height: 100px;
    border-radius: 16px 16px 0 0;
  }

  #citation-panel::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(212, 165, 116, 0.3);
    border-radius: 2px;
  }

  #citation-charts {
    display: none;
  }

  .citation-panel-body {
    flex-direction: column;
  }

  .citation-col:first-child {
    border-right: none;
    border-bottom: 1px solid rgba(212, 165, 116, 0.06);
  }

  .citation-panel-header {
    padding: 20px 16px 10px;
    touch-action: none;
  }

  .citation-panel-header h2 {
    font-size: 18px;
    padding-right: 36px;
  }

  #citation-panel-close {
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  #info-panel {
    width: 100%;
    height: 45vh;
    max-height: 45vh;
    top: auto;
    bottom: -45vh;
    right: 0;
    left: 0;
    border-left: none;
    border-top: 1px solid rgba(212, 165, 116, 0.15);
    border-radius: 16px 16px 0 0;
    transition: bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1), max-height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  #info-panel.visible {
    bottom: 0;
    right: 0;
  }

  #info-panel.expanded {
    height: 90vh;
    max-height: 90vh;
  }

  #info-panel::before {
    height: 100px;
    border-radius: 16px 16px 0 0;
  }

  /* Drag handle indicator */
  #info-panel::after {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: rgba(212, 165, 116, 0.3);
    border-radius: 2px;
  }

  #panel-header {
    padding: 20px 16px 10px;
    touch-action: none;
  }

  #panel-title {
    font-size: 18px;
    padding-right: 36px;
  }

  #panel-close {
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    font-size: 16px;
  }

  #panel-meta {
    font-size: 12px;
    margin-top: 6px;
  }

  #panel-content {
    padding: 8px 16px 20px;
  }

  .panel-stats {
    gap: 16px;
    padding: 10px 0;
    margin-bottom: 12px;
  }

  .panel-description {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
    max-height: 80px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
  }

  .citations-section {
    margin-top: 16px;
  }

  .citations-header {
    margin-bottom: 12px;
    padding-bottom: 8px;
  }

  .citation-card {
    margin-bottom: 10px;
  }

  .citation-card-inner {
    padding: 10px 12px;
  }

  .citation-quote {
    font-size: 13px;
    line-height: 1.5;
  }

  #focus-exit {
    bottom: auto;
    top: 70px;
    left: 12px;
    padding: 0;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    justify-content: center;
    gap: 0;
  }

  #focus-exit .focus-exit-text {
    display: none;
  }

  #focus-exit svg {
    width: 16px;
    height: 16px;
    margin: 0;
  }

  #focus-info {
    top: 120px;
    bottom: auto;
    left: 56px;
    right: auto;
    transform: none;
    padding: 6px 12px;
    font-size: 9px;
    border-radius: 12px;
    white-space: nowrap;
  }

  #focus-exit {
    top: 116px;
  }
}

/* Extra small phones */
@media (max-width: 380px) {
  h1 {
    font-size: 14px;
  }

  .cover-image {
    height: 40px;
  }

  #panel-title {
    font-size: 18px;
  }
}

/* Touch-specific: larger tap targets */
@media (pointer: coarse) {
  #citation-panel-close {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .citation-list-item {
    padding: 14px 16px;
  }

  #panel-close {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }

  .panel-link {
    padding: 14px 20px;
    font-size: 13px;
  }

  .citation-expand-btn {
    padding: 8px 0;
    font-size: 12px;
  }
}
