/* Similar-papers graph (Graph tab). Colors derive from the site's theme tokens. */
.graph-panel {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 34px;
  color: var(--text);
}

.graph-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px 28px;
  margin-bottom: 18px;
}

.graph-header h2 {
  margin: 4px 0 6px;
  font-size: 28px;
  line-height: 1.15;
}

.graph-scope {
  max-width: 62ch;
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.graph-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
}

.graph-control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.graph-control input,
.graph-control select {
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface, var(--bg));
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 400;
}

.graph-origin-control { flex: 1 1 420px; }

/* Origin search combobox */
.graph-combobox {
  position: relative;
  width: min(460px, 100%);
}

.graph-combobox-icon {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--text-muted);
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}

.graph-control .graph-combobox input {
  width: 100%;
  padding-left: 34px;
  border-radius: 10px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.graph-control .graph-combobox input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.graph-combobox input[aria-expanded="true"] {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.graph-combobox-list {
  position: absolute;
  z-index: 20;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  max-height: min(360px, 60vh);
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.06);
  overscroll-behavior: contain;
}

.graph-combobox-list[hidden] { display: none; }

.graph-combobox-heading {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.graph-combobox-option {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.graph-combobox-option.is-active { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.graph-combobox-option.is-current .graph-combobox-title { color: var(--accent); }

.graph-combobox-title {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--text);
}

.graph-combobox-title mark {
  padding: 0 1px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: inherit;
}

.graph-combobox-meta {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
}

.graph-combobox-empty {
  padding: 12px 10px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-muted);
}

.graph-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 18px;
  align-items: start;
}

.graph-canvas-wrap {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: color-mix(in srgb, var(--surface, var(--bg)) 80%, var(--bg));
  overflow: hidden;
}

.graph-svg {
  display: block;
  width: 100%;
  height: auto;
  max-height: 72vh;
}

.graph-edge {
  stroke: color-mix(in srgb, var(--text) 45%, transparent);
  stroke-linecap: round;
  transition: stroke 0.15s ease, opacity 0.15s ease;
}

.graph-edge.is-active { stroke: var(--accent); }
.graph-svg.has-focus .graph-edge { opacity: 0.25; }
.graph-svg.has-focus .graph-edge.is-active { opacity: 1; }

.graph-node { cursor: pointer; outline: none; }

.graph-node circle {
  fill: color-mix(in srgb, var(--accent) var(--graph-shade, 70%), var(--bg));
  stroke: color-mix(in srgb, var(--accent) 70%, var(--text));
  stroke-width: 1;
  transition: opacity 0.15s ease, stroke-width 0.15s ease;
}

.graph-node.is-origin circle {
  stroke: var(--text);
  stroke-width: 3;
}

/* Faded nodes stay opaque so the dimmed edges behind them do not show through. */
.graph-svg.has-focus .graph-node:not(.is-linked) circle {
  fill: color-mix(in srgb, var(--accent) 10%, var(--bg));
  stroke: color-mix(in srgb, var(--text) 16%, var(--bg));
}
.graph-svg.has-focus .graph-node:not(.is-linked) .graph-label { opacity: 0.4; }
.graph-node.is-selected circle,
.graph-node:focus-visible circle { stroke: var(--text); stroke-width: 3; }

.graph-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
  text-anchor: middle;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 3px;
  stroke-linejoin: round;
  pointer-events: none;
}

.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}

.graph-legend span { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend i { display: inline-block; flex: 0 0 auto; }
.graph-legend-size { width: 12px; height: 12px; border-radius: 50%; background: color-mix(in srgb, var(--accent) 70%, var(--bg)); box-shadow: -9px 2px 0 -2px color-mix(in srgb, var(--accent) 70%, var(--bg)); margin-left: 8px; }
.graph-legend-year { width: 30px; height: 10px; border-radius: 5px; background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 28%, var(--bg)), var(--accent)); }
.graph-legend-line { width: 22px; height: 2px; background: color-mix(in srgb, var(--text) 45%, transparent); }
.graph-legend-origin { width: 11px; height: 11px; border-radius: 50%; border: 3px solid var(--text); }

.graph-tooltip {
  position: absolute;
  z-index: 2;
  max-width: 300px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.14);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
}

.graph-tooltip strong { display: block; margin-bottom: 2px; }
.graph-tooltip span { color: var(--text-muted); }

.graph-side {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  max-height: calc(72vh + 44px);
  overflow: auto;
}

.graph-selected {
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface, var(--bg));
}

.graph-selected-kicker {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.graph-selected h3 { margin: 6px 0; font-size: 16px; line-height: 1.3; }
.graph-selected-meta { margin: 0 0 8px; font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.graph-selected-desc { margin: 0 0 10px; font-size: 13px; line-height: 1.5; }
.graph-selected-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.graph-action {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.graph-action:hover { border-color: var(--accent); color: var(--accent); }
.graph-action-primary { border-color: var(--accent); background: var(--accent); color: var(--bg); }
.graph-action-primary:hover { color: var(--bg); filter: brightness(1.08); }

.graph-list-title {
  margin: 4px 0 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.graph-list { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.graph-loading { padding: 8px 0; color: var(--text-muted); font-size: 13px; }

.graph-list-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.graph-list-item:hover { background: color-mix(in srgb, var(--text) 5%, transparent); }
.graph-list-item.is-selected { background: color-mix(in srgb, var(--accent) 13%, transparent); }
.graph-list-name { font-size: 13.5px; font-weight: 600; line-height: 1.3; }
.graph-list-meta { font-size: 12px; color: var(--text-muted); }

.desk-graph-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.desk-graph-link:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 900px) {
  .graph-panel { padding: 18px 16px 32px; }
  .graph-body { grid-template-columns: minmax(0, 1fr); }
  .graph-side { max-height: none; overflow: visible; }
  .graph-header h2 { font-size: 23px; }
}
