:root {
  --green-900:#173d2b; --green-800:#24563b; --green-700:#31734c;
  --green-500:#55a974; --green-200:#cfe6d7; --green-100:#e8f4ec;
  --green-50:#f4faf6; --green-focus:rgba(49,115,76,.2);
}
.usage-notice { margin-bottom:0; }
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: #f5f5f5;
  color: #1a1a1a;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#sidebar {
  width: 260px;
  flex: none;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width 0.15s ease, padding 0.15s ease;
}
#sidebar.resizing { transition: none; }
#sidebar.collapsed {
  width: 0;
  padding: 0;
  border-right: none;
}

/* ── Sidebar resize handle ───────────────────────────────────────────────── */
#sidebar-resizer {
  flex: none;
  width: 7px;
  cursor: col-resize;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b5b5b5;
  font-size: 10px;
  user-select: none;
  touch-action: none;
}
#sidebar-resizer:hover, #sidebar-resizer.active { background: #ececec; color: #555; }
#sidebar-resizer::after { content: "⋮"; }
#sidebar.collapsed + #sidebar-resizer { width: 14px; border-right: 1px solid #e0e0e0; background: #fff; }
#sidebar.collapsed + #sidebar-resizer::after { content: "›"; font-size: 12px; }

/* Keep each section at its natural height so the sidebar scrolls instead of the
   sections shrinking and overlapping (e.g. with 3+ researchers). */
#sidebar > * { flex-shrink: 0; }
#app-brand { display:flex; align-items:center; gap:10px; padding:2px 3px 8px; color:var(--green-900); }
.brand-mark { width:38px; height:38px; flex:none; overflow:visible; }
.brand-mark path { fill:none; stroke:var(--green-500); stroke-width:2.2; }
.brand-mark circle { fill:var(--green-700); stroke:#fff; stroke-width:1.5; }
#app-brand div { display:flex; flex-direction:column; line-height:1.05; }
#app-brand strong { font-size:16px; letter-spacing:-.02em; }
#app-brand span { margin-top:3px; font-size:12px; color:var(--green-700); letter-spacing:.05em; }
.app-links { display:flex; justify-content:space-between; gap:12px; padding:0 3px 4px; font-size:11px; }
.app-links a, .empty-guide, #empty-state a { color:var(--green-800); text-underline-offset:3px; }
a:focus-visible { outline:2px solid var(--green-500); outline-offset:3px; }

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6e6e6e;
}

/* ── Collapsible section cards ───────────────────────────────────────────── */
.side-card {
  border: 1px solid #e6e6e6;
  border-radius: 6px;
  background: #fff;
}
.side-card > summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6e6e6e;
  cursor: pointer;
  user-select: none;
}
.side-card > summary::-webkit-details-marker { display: none; }
.side-card > summary::before {
  content: "▸";
  font-size: 9px;
  color: #9a9a9a;
  transition: transform 0.15s;
}
.side-card[open] > summary::before { transform: rotate(90deg); }
.side-card > summary:hover { color: var(--green-800); background:var(--green-50); }
.side-card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 2px 10px 12px;
}
#sec-advanced { order:100; }

.apply-hint { font-size: 11px; color: #767676; line-height: 1.35; }

/* ── Search ──────────────────────────────────────────────────────────────── */
#search-wrapper, #work-search-wrapper { display: flex; gap: 6px; }

#search-input, #work-search-input {
  flex: 1;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: #1a1a1a;
  background: #fff;
}
#search-input:focus, #work-search-input:focus { border-color:var(--green-700); box-shadow:0 0 0 3px var(--green-focus); }

.smooth-button {
  flex: none;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.smooth-button:hover { border-color:var(--green-700); color:var(--green-800); background:var(--green-50); }
.smooth-button:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible { outline:2px solid var(--green-500); outline-offset:2px; }

/* ── Institution Explorer ───────────────────────────────────────────────── */
.icon-button { min-width:44px; min-height:44px; border:1px solid #ddd; border-radius:6px; background:#fff; cursor:pointer; font-size:18px; }
.icon-button:hover { background:#f5f5f5; border-color:#aaa; }
#rank-institution-wrapper {
  display: flex;
  gap: 6px;
}
#rank-institution-input {
  flex: 1;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: #1a1a1a;
  background: #fff;
}
#rank-institution-search { flex: none; }
#rank-institution-input:focus { border-color: var(--green-700); box-shadow:0 0 0 3px var(--green-focus); }
#openalex-key-row {
  display: flex;
  gap: 6px;
}
#openalex-key-input {
  flex: 1;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  color: #1a1a1a;
  background: #fff;
}
#openalex-key-input:focus { border-color: var(--green-700); box-shadow:0 0 0 3px var(--green-focus); }
#openalex-key-save { flex: none; }
#openalex-key-status {
  min-height: 14px;
  font-size: 11px;
  line-height: 1.3;
  color: #767676;
}
.settings-help { margin:0; font-size:12px; line-height:1.45; color:#666; }
.settings-help a { color:var(--green-800); text-decoration:underline; }
#rank-primary-wrapper {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
  line-height: 1.3;
}
#rank-primary-wrapper input { accent-color: var(--green-700); cursor: pointer; }
#rank-status {
  min-height: 16px;
  font-size: 12px;
  line-height: 1.35;
  color: #767676;
}
#rank-results {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.graph-window {
  position:absolute;
  left:12px;
  bottom:190px;
  z-index:41;
  width:min(380px, calc(100vw - 24px));
  max-height:min(52vh, 520px);
  overflow:auto;
  background:rgba(255,255,255,.96);
  border:1px solid #d8d8d8;
  border-radius:8px;
  box-shadow:0 4px 18px rgba(0,0,0,.1);
}
.graph-window:has(+ #graph-legend.hidden) { bottom:12px; }
.graph-window-title { list-style:none; display:flex; align-items:center; gap:8px; min-height:44px; padding:0 12px; font-size:13px; font-weight:650; color:#333; cursor:pointer; }
.graph-window-title::-webkit-details-marker { display:none; }
.graph-window-title::before { content:"▸"; color:#888; transition:transform .15s; }
.graph-window[open] > .graph-window-title::before { transform:rotate(90deg); }
.info-button { position:relative; width:24px; height:24px; margin-left:auto; border:1px solid #aaa; border-radius:50%; background:#fff; color:#555; font:bold 12px Georgia,serif; cursor:help; }
.graph-window-body { padding:0 12px 12px; border-top:1px solid #eee; }
#home-institution-picker { padding-top:12px; }
#home-institution-picker > label { display:block; margin-bottom:6px; font-size:12px; font-weight:600; color:#444; }
#home-institution-pill { display:flex; align-items:center; gap:8px; margin-top:12px; padding:8px 9px; border:1px solid #d9e5dc; border-radius:7px; background:#f4faf6; }
#home-institution-name { flex:1; min-width:0; font-size:13px; font-weight:600; color:#284d35; overflow-wrap:anywhere; }
#home-institution-change { min-height:32px; border:0; background:transparent; color:#3d6749; font:600 12px inherit; text-decoration:underline; cursor:pointer; }
.explorer-actions { display:flex; align-items:center; gap:8px; margin-top:8px; }
.explorer-actions #rank-status { flex:1; }
.explorer-actions .icon-button { min-width:36px; min-height:36px; }
.rank-result { border:1px solid #e7e7e7; border-radius:7px; padding:8px; }
.rank-result:last-child { border-bottom: none; padding-bottom: 0; }
.rank-row {
  width: 100%;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  color: inherit;
  text-align: left;
  padding: 2px 0;
}
.rank-num {
  color: #aaa;
  font-size: 11px;
  text-align: right;
}
.rank-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: none;
  background: transparent;
  color: inherit;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.rank-main strong {
  color: #333;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.rank-main small {
  color: #888;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.rank-distance {
  color: #f5821e;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  grid-column:2;
  justify-self:start;
  border:0;
  background:transparent;
  padding:5px 0;
}
.rank-graph-btn {
  flex: none;
  padding: 4px 7px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  color: #555;
  font-size: 10.5px;
  font-family: inherit;
  cursor: pointer;
}
.rank-graph-btn { grid-column:2; min-height:36px; padding:7px 12px; justify-self:start; }
.rank-graph-btn:hover { border-color: #aaa; color: #222; background: #f5f5f5; }

/* ── Origin chips ────────────────────────────────────────────────────────── */
#origin-chips { display: flex; flex-direction: column; gap: 3px; min-height: 0; }

.researcher-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 6px 5px 8px;
  background: #f0f0f0;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  font-size: 12px;
  color: #333;
}
.researcher-chip .chip-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.researcher-chip .chip-remove {
  flex: none;
  border: none;
  background: none;
  color: #999;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  border-radius: 3px;
}
.researcher-chip .chip-remove:hover { color: #c0392b; background: #e6e6e6; }

/* ── Degrees of separation ───────────────────────────────────────────────── */
#degrees-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
#degrees-list > li {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 12px;
  line-height: 1.35;
  padding-bottom: 8px;
  border-bottom: 1px solid #f2f2f2;
}
#degrees-list > li:last-child { padding-bottom: 0; border-bottom: none; }
.degrees-pair { color: #333; font-weight: 600; }
.degrees-count { color: #f5821e; font-size: 11px; font-weight: 600; }
.degrees-arrow, .result-arrow {
  display: inline-block;
  transition: transform 0.15s;
}
.degrees-arrow.expanded, .result-arrow.expanded {
  transform: rotate(180deg);
}

/* Ordered shortest-path steps (names + paper per hop) */
.degrees-steps { list-style: none; margin: 4px 0 0; padding: 0; counter-reset: step; }
.degrees-steps li {
  display: flex;
  flex-direction: column;
  position: relative;
  padding: 3px 0 3px 16px;
  font-size: 11px;
  line-height: 1.3;
}
.degrees-steps li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 3px;
  color: #bbb;
  font-size: 10px;
  font-weight: 600;
}
.step-people { color: #444; }
.step-via { color: #999; font-style: italic; }
.step-via a { color: #555; text-decoration: underline; }

/* ── Section labels ──────────────────────────────────────────────────────── */
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6e6e6e;
  margin-top: 4px;
}

/* ── Edge toggles ────────────────────────────────────────────────────────── */
#edge-toggles, #work-edge-toggles { display: flex; flex-direction: column; gap: 5px; }
#edge-toggles label, #work-edge-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
}
#edge-toggles input[type="checkbox"], #work-edge-toggles input[type="checkbox"] { accent-color: var(--green-700); cursor: pointer; }

/* ── Neighborhood + label controls ───────────────────────────────────────── */
#neighborhood {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  font-family: inherit;
  color: #333;
  background: #fff;
  cursor: pointer;
}
#neighborhood:focus { outline: none; border-color: var(--green-700); box-shadow:0 0 0 3px var(--green-focus); }

#label-toggles label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #555;
  cursor: pointer;
}
#label-toggles input[type="checkbox"] { accent-color: var(--green-700); cursor: pointer; }

#layout-controls { display: flex; flex-direction: column; gap: 8px; }
#layout-controls label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: #555;
}
#layout-controls input[type="range"] { flex: 1; accent-color: var(--green-700); cursor: pointer; }

/* ── Node detail panel ───────────────────────────────────────────────────── */
#node-detail {
  border-top: 1px solid #f0f0f0;
  padding-top: 10px;
  margin-top: 4px;
}
#node-detail h3 {
  font-size: 13px;
  font-weight: 600;
  color: #1a1a1a;
  margin-bottom: 5px;
  line-height: 1.3;
}
#node-detail div {
  font-size: 12px;
  color: #666;
  margin-bottom: 3px;
}
#node-detail a {
  display: inline-block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--green-800);
  text-decoration: underline;
}

/* ── Graph area ──────────────────────────────────────────────────────────── */
#graph-area {
  flex: 1;
  min-width: 0; /* Let the canvas shrink when crossing the mobile breakpoint. */
  position: relative;
  background: #fafafa;
}

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

/* ── Progress overlay ────────────────────────────────────────────────────── */
#progress-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 7px 16px;
  font-size: 12px;
  color: #555;
  z-index: 50;
  pointer-events: auto;
  max-width: calc(100% - 100px);
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.hidden { display: none !important; }

/* ── Empty state ─────────────────────────────────────────────────────────── */
#empty-state {
  position: absolute;
  inset: 0;
  z-index: 10;
  overflow: hidden;
}

/* Decorative sample network sitting behind the prompt. */
#sample-graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: blur(5px);
  opacity: 0.85;
}
#sample-graph .s-edges line {
  stroke: #c9c9c9;
  stroke-width: 2;
}
#sample-graph .s-origin { fill: #f5821e; }
#sample-graph .s-path { fill: #5badd9; }
#sample-graph .s-neigh { fill: #9a9a9a; }
#sample-graph .s-work { fill: #7a5ea8; }

/* White wash over the blurred graph so the copy reads cleanly. */
#sample-wash {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.72);
}

#empty-state-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 12px;
  text-align: center;
  padding: 64px 24px 100px;
  overflow-y: auto;
}
#empty-state-content > * { flex-shrink:0; }
#empty-state h1 {
  font-size: 22px;
  font-weight: 700;
  color: #1a1a1a;
  letter-spacing: -0.01em;
}
#empty-state p {
  max-width: 400px;
  font-size: 13px;
  line-height: 1.5;
  color: #555;
}
#empty-example {
  margin-top: 4px;
  padding: 9px 16px;
  border: 1px solid #222;
  border-radius: 5px;
  background: #222;
  color: #fff;
  font-size: 12.5px;
  font-family: inherit;
  cursor: pointer;
}
#empty-example:hover { background: #444; }
#empty-state .empty-use-case { margin-top:12px; }
.empty-guide { max-width:400px; font-size:13px; line-height:1.5; }

/* ── Graph legend ────────────────────────────────────────────────────────── */
#graph-legend {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11px;
  color: #444;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  max-width: 250px;
}
.legend-title {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6e6e6e;
  cursor: pointer;
  user-select: none;
}
.legend-title::-webkit-details-marker { display: none; }
.legend-title::before {
  content: "▸";
  font-size: 9px;
  color: #9a9a9a;
  transition: transform 0.15s;
}
#graph-legend[open] > .legend-title::before { transform: rotate(90deg); }
.legend-title:hover { color: #333; }
.legend-row { display: flex; align-items: center; gap: 7px; line-height: 1.3; }
.legend-node {
  flex: none;
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.legend-diamond {
  border-radius: 0;
  width: 10px;
  height: 10px;
  background: #2e86ab;
  transform: rotate(45deg);
  margin: 0 1px;
}
.legend-line {
  flex: none;
  width: 22px;
  height: 0;
  border-top-width: 2px;
  border-top-color: #3a3a3a;
}
.legend-solid  { border-top-style: solid; }
.legend-dashed { border-top-style: dashed; }
.legend-dotted { border-top-style: dotted; }
.legend-authorship { border-top-color: #7fae8e; }

/* ── Author search modal ─────────────────────────────────────────────────── */
#search-modal { position: fixed; inset: 0; z-index: 500; }

#search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

#search-dialog {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: 90vw;
  max-height: 80vh;
  background: #fff;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

#search-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}
#search-title { font-size: 13px; font-weight: 600; color: #333; }
#search-close {
  border: none;
  background: none;
  font-size: 20px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0 4px;
}
#search-close:hover { color: #333; }

#search-results-list {
  list-style: none;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
}
#search-results-list > li.result-row {
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 10px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.4;
}
#search-results-list > li.result-row:last-child { margin-bottom: 0; }
#search-results-list > li.result-row:hover { border-color: #bbb; }

.result-row-main { display: flex; align-items: center; gap: 10px; }
.result-row-info { flex: 1; }
button.result-row-info {
  min-width: 0; border: 0; padding: 0; background: transparent;
  color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.add-btn-inline {
  flex: none;
  padding: 6px 12px;
  border: 1px solid var(--green-900);
  border-radius: 4px;
  background: var(--green-900);
  color: #fff;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}
.add-btn-inline:hover { background: var(--green-700); border-color: var(--green-700); }

#search-results-list > li.empty-state {
  padding: 20px 16px;
  font-size: 12px;
  color: #999;
  text-align: center;
  border: none;
}

.result-detail {
  margin: -11px 0 10px;
  padding: 8px 10px 10px;
  border: 1px solid #ddd;
  border-top: none;
  border-radius: 0 0 6px 6px;
  font-size: 11px;
  color: #555;
}
.works-table {
  width: 100%;
  border-collapse: collapse;
}
.works-table td {
  padding: 5px 8px;
  font-size: 11px;
}
.works-table td.rank { width: 22px; color: #999; text-align: right; }
.works-table td.title a { color: var(--green-800); text-decoration: underline; }
.works-table td.citations { width: 90px; text-align: right; color: #777; white-space: nowrap; }
.works-table tbody tr:nth-child(odd) { background: #fff; }
.works-table tbody tr:nth-child(even) { background: #f0f0f0; }

#search-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}
#search-pagination button {
  min-width: 26px;
  padding: 4px 7px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  color: #555;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
}
#search-pagination button:hover:not(:disabled) { border-color: #aaa; background: #f5f5f5; }
#search-pagination button:disabled { opacity: 0.35; cursor: not-allowed; }
#search-pagination button.current { background: #222; color: #fff; border-color: #222; }
#search-pagination .ellipsis { color: #999; padding: 0 4px; font-size: 11px; }

.page-jump { position: relative; display: inline-flex; align-items: center; }
.page-jump-input {
  width: 36px;
  min-width: 0;
  padding: 4px 5px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  color: #333;
  font-size: 11px;
  font-family: inherit;
  text-align: center;
}
.page-jump-input:focus { outline: none; border-color: var(--green-700); box-shadow:0 0 0 3px var(--green-focus); }
.page-jump-go {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  padding: 3px 8px;
  border: 1px solid var(--green-900);
  border-radius: 4px;
  background: var(--green-900);
  color: #fff;
  font-size: 10px;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.page-jump-go:hover { background: #444; }

/* ── Loading state ───────────────────────────────────────────────────────── */
#search-input:disabled, #work-search-input:disabled,
#rank-institution-input:disabled { background: #f5f5f5; color: #bbb; cursor: not-allowed; }
#search-btn:disabled, #work-search-btn:disabled,
#rank-institution-search:disabled { background: #f5f5f5; color: #bbb; cursor: not-allowed; }
.chip-remove:disabled { opacity: 0.3; cursor: not-allowed; }
#edge-toggles input:disabled,
#work-edge-toggles input:disabled,
#rank-primary-only:disabled,
#neighborhood:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Canvas action buttons ───────────────────────────────────────────────── */
#canvas-actions {
  order: 90;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

#canvas-actions button {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fff;
  color: #555;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  text-align: center;
}
#canvas-actions button:hover { border-color: var(--green-500); color: var(--green-800); background: var(--green-50); }
#canvas-actions .graph-action-row { display:flex; gap:5px; }
#canvas-actions button:disabled { opacity:.45; cursor:default; }
#stop-search { flex-shrink:0; background:#fff; border:1px solid #aaa; border-radius:4px; padding:4px 8px; cursor:pointer; }
.degrees-note { font-size:11px; line-height:1.45; color:#626b65; margin-top:4px; }
#clear-canvas:hover { border-color: #c0392b !important; color: #c0392b !important; background: #fff5f5 !important; }
#apply-options:hover:not(:disabled) { border-color: #2e7d32; color: #2e7d32; background: #f4faf4; }

/* ── Menu toggle (fold the sidebar) ──────────────────────────────────────── */
#menu-toggle {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 60;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.94);
  color: #444;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}
#menu-toggle:hover { background: var(--green-50); border-color: var(--green-500); color: var(--green-800); }

/* ── Graph/Menu view switcher (mobile only) ──────────────────────────────── */
#view-switcher { display: none; }

/* ── Hover tooltip ───────────────────────────────────────────────────────── */
#cy-tooltip {
  position: fixed;
  background: rgba(18, 18, 18, 0.90);
  color: #f0f0f0;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 11px;
  line-height: 1.6;
  pointer-events: none;
  z-index: 9999;
  max-width: 240px;
  word-wrap: break-word;
  display: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

/* ── Mobile mode ─────────────────────────────────────────────────────────── */
#institution-explorer-shell {
  --explorer-bottom:190px;
  --explorer-top-clearance:12px;
  --explorer-window-max:max(44px,min(58vh,570px,calc(100vh - var(--explorer-bottom) - var(--explorer-top-clearance))));
  position:absolute;
  left:12px;
  bottom:var(--explorer-bottom);
  z-index:41;
  display:flex;
  align-items:flex-start;
  gap:10px;
}
#institution-explorer-shell:has(+ #institution-info-tooltip + #graph-legend.hidden) { --explorer-bottom:12px; }
.graph-window { position:relative; inset:auto; width:min(390px, calc(100vw - 24px)); max-height:var(--explorer-window-max); overflow:hidden; display:block; border-color:var(--green-200); box-shadow:0 5px 22px rgba(23,61,43,.13); }
.graph-window-title { flex:none; color:var(--green-900); background:linear-gradient(90deg,var(--green-50),#fff); border-bottom:1px solid var(--green-200); }
.info-button { border-color:var(--green-500); color:var(--green-800); }
/* The bounded, scrollable region lives on .explorer-content (a plain div) rather
   than the .graph-window <details>, because a <details> element does not
   distribute flex to its children, so a scroll child there never gets bounded. */
.explorer-content { min-height:0; max-height:calc(var(--explorer-window-max) - 44px); overflow:hidden; display:flex; flex-direction:column; }
.explorer-header { position:sticky; top:0; z-index:2; flex:none; padding:10px 12px; background:rgba(255,255,255,.98); border-bottom:1px solid var(--green-200); }
.explorer-results-scroll { flex:1 1 auto; min-height:0; overflow-y:auto; overflow-x:hidden; overscroll-behavior:contain; scrollbar-gutter:stable; padding:9px 10px 11px; }
#home-institution-picker { padding:0; }
#home-institution-pill { margin:0; padding:5px 8px; border-color:var(--green-200); background:var(--green-50); }
#home-institution-name { font-size:12px; color:var(--green-900); }
#home-institution-change { min-height:26px; color:var(--green-700); }
.explorer-actions { min-height:28px; margin-top:6px; }
.explorer-actions .icon-button { min-width:28px; min-height:28px; width:28px; height:28px; padding:0; font-size:14px; color:var(--green-800); border-color:var(--green-200); }
.explorer-method-note { display:flex; align-items:center; gap:5px; margin:7px 0 0; color:#617267; font-size:10.5px; line-height:1.3; }
.explorer-method-note span { color:var(--green-700); font-weight:800; }
#explorer-loading { flex:1; display:flex; align-items:center; gap:7px; color:var(--green-800); font-size:12px; font-weight:600; }
.mini-spinner { width:14px; height:14px; flex:none; border:2px solid var(--green-200); border-top-color:var(--green-700); border-radius:50%; animation:spin .75s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }
#rank-results.is-refreshing { opacity:.48; pointer-events:none; }
.rank-result { border:1px solid #e2ebe5; border-left:4px solid var(--green-500); padding:9px 9px 9px 8px; transition:background .16s,border-color .16s; }
.rank-result:hover, .rank-result.selected { background:var(--green-50); border-color:var(--green-500); }
.rank-row { grid-template-columns:20px minmax(0,1fr); }
.rank-main { cursor:default; }
.rank-main .rank-affiliation { margin-top:2px; color:var(--green-700); font-weight:600; }
.rank-trust-row { display:flex; flex-wrap:wrap; gap:5px; margin-top:5px; }
.affiliation-status, .topic-similarity { display:inline-flex; align-items:center; width:max-content; max-width:100%; padding:3px 6px; border:1px solid var(--green-200); border-radius:999px; background:#fff; color:var(--green-800); font-size:9.5px; font-weight:650; line-height:1.2; }
.affiliation-status.verified-current { background:var(--green-100); border-color:var(--green-500); }
.affiliation-status.last-known { background:#fff8e8; border-color:#e5c978; color:#725817; }
.affiliation-status.unknown-status { background:#f4f4f4; border-color:#d9d9d9; color:#666; }
.topic-similarity { border-color:#d8dde8; background:#f5f7fb; color:#4f5e76; }
.rank-actions { grid-column:2; display:flex; align-items:center; justify-content:flex-end; flex-wrap:wrap; gap:6px; margin-top:4px; padding-right:2px; }
.rank-actions .rank-distance { margin-right:auto; }
.rank-distance { grid-column:auto; padding:0; cursor:default; color:#f5821e; }
.rank-view-btn, .rank-graph-btn { min-height:30px; padding:5px 8px; border:1px solid var(--green-200); border-radius:5px; background:#fff; color:var(--green-800); font:600 11px inherit; cursor:pointer; }
.rank-graph-btn { grid-column:auto; justify-self:auto; background:var(--green-800); border-color:var(--green-800); color:#fff; }
.rank-view-btn:hover { background:var(--green-100); border-color:var(--green-500); }
.rank-graph-btn:hover { background:var(--green-700); border-color:var(--green-700); color:#fff; }
#author-sidecar { position:relative; width:clamp(400px, calc(100vw - 440px), 600px); max-height:min(58vh,570px); overflow-y:auto; padding:20px; border:1px solid var(--green-200); border-radius:10px; background:linear-gradient(145deg,#fff,var(--green-50)); box-shadow:0 8px 28px rgba(23,61,43,.16); color:var(--green-900); }
#author-sidecar-close { position:sticky; float:right; top:0; z-index:2; width:34px; height:34px; margin:-9px -9px 2px 8px; border:1px solid var(--green-200); border-radius:50%; background:#fff; color:var(--green-800); font-size:21px; cursor:pointer; box-shadow:0 2px 8px rgba(23,61,43,.12); }
.author-card h2 { padding-right:28px; font-size:21px; letter-spacing:-.02em; }
.author-card .author-affiliation { margin-top:4px; color:var(--green-700); font-size:13px; }
.author-topic-list { display:flex; flex-wrap:wrap; gap:5px; margin:12px 0; }
.author-topic { padding:4px 7px; border-radius:999px; background:var(--green-100); color:var(--green-800); font-size:11px; font-weight:600; }
.author-metrics { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:12px 0; }
.author-metric { padding:9px; border:1px solid var(--green-200); border-radius:7px; background:rgba(255,255,255,.7); }
.author-metric strong { display:block; font-size:17px; }
.author-metric span { color:#617267; font-size:11px; }
.author-section { margin-top:16px; padding-top:13px; border-top:1px solid var(--green-200); }
.author-section h3 { margin-bottom:8px; font-size:12px; text-transform:uppercase; letter-spacing:.06em; color:var(--green-700); }
.author-links { display:flex; gap:12px; flex-wrap:wrap; }
.author-links a, #author-sidecar a { color:var(--green-800); text-decoration:underline; }
.author-path-affiliation { display:flex; flex-direction:column; gap:3px; margin:0 0 9px; padding:9px 10px; border:1px solid var(--green-200); border-radius:7px; background:rgba(255,255,255,.7); font-size:12px; color:var(--green-700); }
.author-path-affiliation strong { font-size:11px; color:var(--green-800); }
.author-path-affiliation span { color:#526359; line-height:1.45; }
.author-path-affiliation.last-known { border-color:#e5c978; background:#fffaf0; }
.author-path-affiliation.last-known strong { color:#725817; }
.author-path-affiliation.unknown-status { border-color:#d9d9d9; background:#f7f7f7; }
.path-verification { margin:8px 0 5px; padding:7px 9px; border-radius:6px; font-size:11px; line-height:1.4; }
.path-verification.verified { border:1px solid var(--green-200); background:var(--green-100); color:var(--green-800); }
.path-verification.unverified { border:1px solid #e5c978; background:#fff8e8; color:#725817; }
.evidence-path .step-via { margin-top:2px; color:#667169; font-style:normal; }
.evidence-path .step-via strong { color:var(--green-700); }
.evidence-path .evidence-unverified .step-via strong { color:#725817; }
.evidence-path .step-via a { overflow-wrap:anywhere; }
.sidecar-loading { display:flex; align-items:center; gap:8px; padding:14px 0; color:var(--green-700); }
.floating-tooltip { position:fixed; z-index:1000; width:min(280px,calc(100vw - 24px)); padding:10px 11px; border-radius:7px; background:var(--green-900); color:#fff; font-size:12px; line-height:1.45; box-shadow:0 5px 20px rgba(0,0,0,.24); pointer-events:none; }
#empty-example, #search-pagination button.current, #view-switcher button.active { background:var(--green-900); border-color:var(--green-900); }
#empty-example:hover { background:var(--green-700); }
#edge-toggles input, #work-edge-toggles input, #label-toggles input { accent-color:var(--green-700); }
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms!important; transition-duration:.01ms!important; } }
@media (max-width:1100px) and (min-width:781px) {
  /* Keep evidence in a viewport-bounded overlay. Stacking two independently
     vh-bounded panels could exceed 100vh and strand the panel's top offscreen. */
  #author-sidecar:not(.hidden) {
    position:fixed;
    inset:12px auto 12px 12px;
    z-index:43;
    width:min(600px,calc(100vw - 24px));
    min-width:0;
    max-height:none;
    margin:0;
  }
}

/* Below ~780px the 260px sidebar would take >1/3 of the width, so it becomes a
   full-screen overlay toggled by the Graph/Menu switcher instead of a column. */
@media (max-width: 780px) {
  #progress-overlay { top:58px; max-width:calc(100% - 16px); }
  #institution-explorer-shell {
    --explorer-bottom:72px;
    --explorer-top-clearance:56px;
    --explorer-window-max:max(44px,min(62vh,calc(100vh - var(--explorer-bottom) - var(--explorer-top-clearance))));
    left:8px;
    right:8px;
    display:block;
  }
  #institution-explorer-shell:has(+ #institution-info-tooltip + #graph-legend.hidden) { --explorer-bottom:72px; }
  #institution-explorer-shell:has(+ #institution-info-tooltip + #graph-legend[open]:not(.hidden)) { --explorer-bottom:194px; }
  .graph-window { width:100%; }
  #author-sidecar:not(.hidden) {
    position:fixed;
    inset:56px 8px 72px;
    z-index:43;
    width:auto;
    min-width:0;
    max-height:none;
    margin:0;
  }
  .info-button { width:32px; height:32px; }
  #menu-toggle,
  #sidebar-resizer { display: none !important; }

  #sidebar {
    position: fixed;
    inset: 0;
    width: 100% !important;   /* override inline resize width and .collapsed width:0 */
    max-width: 100%;
    padding: 56px 16px 16px;  /* clear the fixed switcher pill up top */
    border-right: none;
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  #sidebar.collapsed {        /* desktop collapse is neutralized; visibility is via the class below */
    width: 100% !important;
    padding: 56px 16px 16px;
    border-right: none;
  }
  body.mobile-menu-open #sidebar { transform: translateX(0); }

  #view-switcher {
    display: inline-flex;
    position: fixed;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 600;            /* above the full-screen sidebar so it stays tappable */
    gap: 2px;
    padding: 3px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid #ddd;
    border-radius: 999px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  }
  #view-switcher button {
    border: none;
    background: none;
    padding: 6px 20px;
    border-radius: 999px;
    font-size: 13px;
    font-family: inherit;
    color: #666;
    cursor: pointer;
  }
  #view-switcher button.active { background: var(--green-900); color: #fff; }
}
