/* panel-bibliography.css — bibliographies (050): the rail row, the column view
 * (list and editor; panel-column-view.js's shell) and the chat's Bibliography view.
 *
 * Tokens only, so both themes are already here. Builds on panel-projects.css
 * (.proj-input, .proj-label, .proj-link) and loads
 * after it and before glass-surface.css, which must stay last. */

/* The shared head: the way back and ×, as a project's page has; the name, in
   the serif, and the style on the row under it, wrapping before they clip. */
.bib-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 14px; }
.bib-name {
  flex: 1 1 200px; min-width: 0; margin: 0;
  font: 400 var(--fs-xl)/1.3 var(--serif, var(--sans));
}
.bib-style-wrap { display: flex; align-items: center; gap: 8px; margin: 0; min-width: 0; }
.bib-style-wrap .proj-label { margin: 0; }

.bib-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: 18px;
}
.bib-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
/* The action in a pane's heading wraps under the label sooner than it clips. */
.proj-label-row.bib-pane-head { margin-bottom: 8px; flex-wrap: wrap; row-gap: 6px; }
.bib-pane-head .proj-label { margin: 0; }
/* The ground is on the well and the scrolling is inside it: the edge fade is a
 * mask (pxScrollEdges), and on the same element it would fade the ground too. */
.bib-well {
  flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
  border-radius: var(--r-card);
  background: var(--s-quiet); box-shadow: var(--lit-card);
}
.bib-scroll { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px; }
.bib-empty { padding: 8px 4px; font: 400 var(--fs-base)/1.5 var(--sans); color: var(--t-faint); }

/* ---- sources, by chat ---- */
.bib-chat + .bib-chat { margin-top: 8px; }
.bib-chat-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 4px;
  cursor: pointer; list-style: none; border-radius: var(--r-ctl);
  font: 400 var(--fs-base)/1.3 var(--sans); color: var(--t-strong);
}
.bib-chat-head::-webkit-details-marker { display: none; }
.bib-chat-head:hover { background: var(--s-inter); }
.bib-chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bib-chat-count { font: 400 var(--fs-2xs)/1 var(--mono); color: var(--t-faint); }
.bib-src {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 5px 4px 5px 26px; cursor: pointer; border-radius: var(--r-ctl);
}
.bib-src:hover { background: var(--s-inter); }
.bib-chat input[type="checkbox"] { margin: 2px 0 0; accent-color: rgb(var(--rim-rgb)); flex-shrink: 0; cursor: pointer; }
.bib-src-text { flex: 1; display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.bib-src-title {
  font: 400 var(--fs-base)/1.35 var(--sans); color: var(--t-body);
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.bib-src-meta { font: 400 var(--fs-2xs)/1.2 var(--mono); letter-spacing: .06em; color: var(--t-faint); }

/* ---- references: hanging indent, as every one of these styles sets them ---- */
.bib-ref { padding: 8px 6px; border-radius: var(--r-ctl); }
.bib-ref + .bib-ref { margin-top: 2px; }
.bib-ref:hover { background: var(--s-inter); }
.bib-ref-text {
  margin: 0; padding-left: 2em; text-indent: -2em;
  font: 400 var(--fs-lg)/1.55 var(--serif, var(--sans)); color: var(--t-primary, var(--bone));
  overflow-wrap: anywhere;
}
.bib-ref-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 4px 0 0 2em; }
.bib-ref-tools .proj-link:disabled { opacity: .35; cursor: default; }
.bib-ref-missing { font: 400 var(--fs-2xs)/1 var(--mono); letter-spacing: .06em; color: var(--rim); margin-right: auto; }

.bib-edit {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 0 12px;
  margin: 10px 0 2px 2em; padding: 12px; border-radius: var(--r-card);
  background: var(--s-card); box-shadow: var(--lit-card);
}
.bib-field { display: block; }
.bib-field.is-wide { grid-column: 1 / -1; }
.bib-field .proj-input { margin-bottom: 10px; font-size: var(--fs-base); padding: 0 10px; }
.bib-field textarea.proj-input { resize: vertical; min-height: 60px; padding: 8px 10px; }
.bib-edit-url {
  grid-column: 1 / -1; margin: 0 0 10px;
  font: 400 var(--fs-xs)/1.4 var(--mono); color: var(--t-faint); overflow-wrap: anywhere;
}
.bib-edit .proj-form-error, .bib-edit .proj-form-actions { grid-column: 1 / -1; }
.bib-edit .proj-form-error { margin: 0 0 10px; }

/* ---- footer ----
 * Wraps before anything overflows. Copy, the format and Export wrap as one group,
 * and Delete stays out of it: a destructive action does not sit flush against Copy. */
.bib-foot { display: flex; align-items: center; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.bib-foot-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
#bibExportFmt { max-width: 240px; }
.bib-status { flex: 1; min-width: 160px; font: 400 var(--fs-md)/1.4 var(--sans); color: var(--t-meta); }
.bib-status.is-error { color: var(--rim); }
.bib-delete { margin-right: 16px; }
#bibDetails.is-working { animation: px-create-pulse 1.1s ease-in-out infinite; }

/* A narrow panel stacks the panes: sources above, references below. */
@media (max-width: 640px) {
  .bib-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 2fr) minmax(0, 3fr); }
  /* Two rows, so the panes keep the height: Delete with Copy well clear of it, then
     the format beside the Export it sets. A grid because it places them in the
     markup's order, so Tab reads as the eye does; no CSS order here. */
  .bib-foot { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; }
  .bib-status { grid-column: 1 / -1; }
  .bib-status:empty { display: none; }
  .bib-foot-actions { display: contents; }
  #bibCopy { grid-column: 3; }
  #bibExportFmt { grid-column: 1 / 3; max-width: none; }
}

/* ---- the rail row, under Projects ----
 * A .new-thread like its siblings. The 14px that closed the run under
 * Projects now closes it under this row instead. */
.new-thread.projects-btn { margin-bottom: 0; }
.new-thread.bib-btn { margin-top: 0; }
.bib-btn:focus-visible {
  outline: 1px solid rgba(var(--rim-rgb), .6); outline-offset: 2px; border-radius: var(--r-ctl);
}

/* ---- the column view's two states ----
 * The shared head, then everything else 16px in from both edges, as the
 * citation graph's and Memory's bodies are. */
.bib-list-view, .bib-editor { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.bib-view .bib-editor > :not(.search-view-head) { margin-inline: 16px; }
.bib-view #bibListBody { margin: 0; padding: var(--scroll-pad) 16px 24px; }
.bib-view .bib-foot { margin-bottom: 16px; }
.bib-list-view[hidden], .bib-editor[hidden] { display: none; }
.bib-back { flex-shrink: 0; }
.bib-filter { margin: 0 0 8px; padding: 0 10px; font-size: var(--fs-base); min-height: var(--ctl-h); border-radius: var(--r-ctl); }
.bib-chat-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.bib-chat-text .bib-chat-title { flex: none; }

/* ---- the chat's Bibliography view, in #runView ---- */
.bib-run { max-width: 760px; }
.bib-run-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 18px; }
.bib-run-bar px-select { max-width: 220px; }
.bib-run .bib-status { margin: 0 0 10px; }
.bib-run-list .bib-ref { padding: 6px 0; }
.bib-run-list .bib-ref:hover { background: none; }

/* The chat's source picker: a short well, so the references stay in view below it. */
.bib-run-pick { flex: none; max-height: 240px; margin-bottom: 14px; }
.bib-run-refs-head { margin: 4px 0 6px; }
