/* ===================================================================
   Solon — Collaborative Bayesian Network
   A prototype of "The Web of Belief" decision support system.
   =================================================================== */

:root {
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --bg-panel: #ffffff;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --accent-strong: #1d4ed8;
  --rebut: #ef4444;
  --rebut-soft: #fee2e2;
  --node: #cbd5e1;
  --node-hub: #475569;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 28px rgba(15, 23, 42, 0.12);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg-soft);
  font-size: 14px;
  line-height: 1.45;
}

body {
  display: flex;
  flex-direction: column;
}

/* -------------------- Top bar -------------------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 10px 20px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 10px; }
.logo {
  width: 36px; height: 36px;
  border-radius: 8px;
  background: var(--accent-soft);
  display: grid; place-items: center;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-tag  { font-size: 11px; color: var(--text-muted); margin-top: -2px; }

.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-btn {
  border: 0;
  background: transparent;
  font: inherit;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
}
.nav-btn:hover { background: var(--bg-soft); color: var(--text); }
.nav-btn.active { color: var(--accent); background: var(--accent-soft); }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
}
.search {
  width: 280px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--bg-soft);
  outline: none;
}
.search:focus { border-color: var(--accent); background: white; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #2563eb);
  color: white; font-weight: 600; font-size: 12px;
  display: grid; place-items: center;
  cursor: pointer;
  border: 0;
  font-family: inherit;
}
.avatar.large {
  width: 40px; height: 40px;
  font-size: 14px;
}
.avatar.guest {
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

/* FR-18: user dropdown menu */
.user-menu { position: relative; }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  z-index: 60;
}
.user-dropdown.hidden { display: none; }
.user-dropdown-header {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 4px 4px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.user-name { font-weight: 600; font-size: 13px; }
.small { font-size: 11px; }
.user-dropdown-section + .user-dropdown-section {
  border-top: 1px solid var(--border);
  margin-top: 10px;
  padding-top: 10px;
}
.user-dropdown-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 6px;
  font-weight: 600;
}
.user-list { list-style: none; padding: 0; margin: 0; max-height: 200px; overflow-y: auto; }
.user-list-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.user-list-item:hover { background: var(--bg-soft); }
.user-list-item.current { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.user-list-item .mini-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #94a3b8, #475569);
  color: white;
  font-size: 10px;
  font-weight: 600;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.dropdown-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 7px 6px;
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.dropdown-btn:hover { background: var(--bg-soft); }
.dropdown-btn.danger { color: var(--rebut); }
.dropdown-btn.danger:hover { background: var(--rebut-soft); }

/* FR-18: readonly state for the detail card when signed out */
.detail-card.readonly .credence-slider,
.detail-card.readonly .anchor-toggle,
.detail-card.readonly .ghost-btn,
.detail-card.readonly .primary-btn { opacity: 0.55; cursor: not-allowed; }
.detail-card.readonly .credence-slider::-webkit-slider-thumb { cursor: not-allowed; }
.detail-card.readonly .comment-form input { background: var(--bg-soft); }

/* Chip for the current user — subtle highlight */
.chip.self { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

/* FR-19: saved-graphs list */
.saved-graphs-list { list-style: none; padding: 0; margin: 0 0 6px; max-height: 160px; overflow-y: auto; }
.saved-graph-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  position: relative;
}
.saved-graph-item:hover { background: var(--bg-soft); }
.saved-graph-item.current {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.saved-graph-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.saved-graph-when {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
}
.saved-graph-delete {
  background: transparent;
  border: 0;
  padding: 0 4px;
  margin: 0;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  visibility: hidden;
}
.saved-graph-item:hover .saved-graph-delete { visibility: visible; }
.saved-graph-delete:hover { color: var(--rebut); }
.saved-graphs-empty {
  padding: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

/* FR-24: save indicator in the topbar */
.save-indicator {
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
  display: inline-block;
}
.save-indicator:empty { display: none; }

/* FR-25: cloud status pill in the dropdown label */
.cloud-status {
  float: right;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
.cloud-status.online {
  background: #d1fae5;
  color: #065f46;
  border-color: #6ee7b7;
}
.cloud-error {
  color: var(--rebut);
  min-height: 1em;
}
.hidden { display: none !important; }

/* FR-20: profile modal preview */
.profile-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 6px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.primary-btn {
  background: var(--accent);
  color: white;
  border: 0;
  border-radius: 999px;
  width: 32px; height: 32px;
  font-size: 18px;
  cursor: pointer;
  display: grid; place-items: center;
  box-shadow: var(--shadow-sm);
}
.primary-btn:hover { background: var(--accent-strong); }
.primary-btn.small {
  width: auto; height: auto;
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
}
.primary-btn.wide { width: auto; height: auto; padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 500; }

.secondary-btn {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.secondary-btn:hover { background: white; border-color: var(--border-strong); }

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
}
.ghost-btn:hover  { background: var(--bg-soft); }
.ghost-btn.small  { padding: 4px 10px; font-size: 11px; }
.ghost-btn.danger { color: var(--rebut); border-color: #fecaca; }
.ghost-btn.danger:hover { background: var(--rebut-soft); }

.ghost-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* -------------------- Layout -------------------- */
.layout {
  flex: 1;
  display: grid;
  --left-w:  220px;
  --right-w: 360px;
  grid-template-columns: var(--left-w) 1fr var(--right-w);
  min-height: 0;
}
.layout.left-collapsed  { --left-w:  0px; }
.layout.right-collapsed { --right-w: 0px; }
.layout.left-collapsed  > .left-panel  { display: none; }
.layout.right-collapsed > .right-panel { display: none; }

.left-panel,
.right-panel {
  position: relative;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.left-panel  { grid-column: 1; }
.canvas-wrap { grid-column: 2; }
.right-panel {
  grid-column: 3;
  border-right: 0;
  border-left: 1px solid var(--border);
}

/* "Hide help" button — a small dismissal affordance in the top-right
   of the left panel. Once clicked, the help panes go away and only
   the topbar's info icon brings them back. */
.hide-help-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px; height: 22px;
  border: 0;
  background: transparent;
  border-radius: 4px;
  font-size: 18px;
  line-height: 1;
  color: var(--text-faint);
  cursor: pointer;
  z-index: 2;
}
.hide-help-btn:hover { background: var(--bg-soft); color: var(--text); }

/* Topbar info icon — the only way to bring helpers back after dismissal.
   Sized like the other topbar action buttons so it sits naturally
   between Clear and the avatar. */
.info-btn {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.info-btn:hover { background: var(--bg-soft); color: var(--accent); border-color: var(--accent); }
.info-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }

.left-panel h3,
.right-panel h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 16px 0 8px;
  font-weight: 600;
}
.left-panel h3:first-child { margin-top: 0; }

.legend { list-style: none; padding: 0; margin: 0; }
.legend li {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  flex-shrink: 0;
}
.dot-prop     { background: var(--node); }
.dot-hub      { background: var(--node-hub); }
.dot-selected { background: var(--accent); }
.line {
  width: 22px; height: 0;
  border-top: 2px solid var(--text-faint);
  flex-shrink: 0;
}
.line-support { border-color: #94a3b8; }
.line-rebut   { border-color: var(--rebut); border-top-style: dashed; }

.hints { list-style: none; padding: 0; margin: 0; }
.hints li {
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-muted);
}
kbd {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--text);
  margin-right: 4px;
}

.coherence { padding-top: 4px; }
.coherence-row {
  display: flex; justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}
.meter, .aggregate-meter {
  background: var(--bg-soft);
  border-radius: 4px;
  height: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.meter-bar, .aggregate-bar {
  height: 100%;
  background: linear-gradient(90deg, #93c5fd, #2563eb);
  width: 0%;
  transition: width 350ms ease;
}
.hint { font-size: 12px; color: var(--text-muted); margin: 8px 0 0; }

/* -------------------- Canvas -------------------- */
.canvas-wrap {
  position: relative;
  background:
    radial-gradient(circle at 12px 12px, rgba(15,23,42,0.04) 1px, transparent 1px) 0 0/24px 24px,
    #ffffff;
  overflow: hidden;
}

.canvas-toolbar {
  position: absolute;
  top: 12px; left: 12px;
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}
.tool-btn {
  border: 0; background: transparent;
  width: 28px; height: 28px;
  border-radius: 6px;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
}
.tool-btn:hover { background: var(--bg-soft); color: var(--text); }
.tool-btn.text  { width: auto; padding: 0 10px; font-size: 12px; }
.tool-btn.active { background: var(--accent-soft); color: var(--accent); }
.tool-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.tool-btn:disabled:hover { background: transparent; color: var(--text-muted); }
.separator {
  width: 1px; height: 18px; background: var(--border); margin: 0 4px;
}
.zoom-readout {
  font-size: 11px; color: var(--text-muted);
  width: 42px; text-align: center;
  font-variant-numeric: tabular-nums;
}

.graph {
  width: 100%;
  height: 100%;
  cursor: grab;
  user-select: none;
}
.graph.grabbing { cursor: grabbing; }

/* Edge styles */
.edge {
  stroke: #cbd5e1;
  stroke-width: 1;
  fill: none;
  transition: stroke 200ms, stroke-width 200ms, opacity 200ms;
  pointer-events: none;
}
.edge.rebut    { stroke: #fca5a5; stroke-dasharray: 5 3; }
.edge.meta     { stroke-dasharray: 2 4; }     /* FR-8: meta-edges */
.edge.active   { stroke: var(--accent); stroke-width: 1.6; }
.edge.active.rebut { stroke: var(--rebut); }
.edge.selected { stroke: var(--accent); stroke-width: 2.2; }
.edge.selected.rebut { stroke: var(--rebut); }
.edge.dim      { opacity: 0.08; }

/* Invisible hit-target for clicking edges (FR-5) */
.edge-hit {
  stroke: transparent;
  stroke-width: 12;
  fill: none;
  cursor: pointer;
  pointer-events: stroke;
}

/* FR-17c: trailing chevrons for stronger inferences (1–2 in addition
   to the main arrowhead, for a total of 1, 2, or 3 tips). */
.edge-chevron {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
  transition: opacity 200ms;
}
.edge-chevron.dim { opacity: 0.08; }

/* Node styles */
.node-group { cursor: pointer; }
.node-circle {
  stroke: #fff;
  stroke-width: 1.5;
  transition: r 200ms, stroke 200ms;
}
.node-group.adjacent .node-circle { stroke: var(--accent); stroke-width: 2; }
.node-group.dim       .node-circle { opacity: 0.12; }
.node-group.dim       .node-label  { opacity: 0.15; }
.node-group:hover     .node-circle { stroke: var(--accent); stroke-width: 2.5; }

/* Selection ring drawn behind the active node */
.node-selection-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 3 2;
  opacity: 0.6;
}

/* FR-17a: credence ring around every node.
   Background = full circle at low opacity (where 100% would be).
   Foreground = arc whose length is the node's credence (0..1). */
.credence-ring-bg {
  fill: none;
  stroke: #e2e8f0;
  stroke-width: 1.5;
  pointer-events: none;
}
.credence-ring-fg {
  fill: none;
  stroke-width: 2.2;
  stroke-linecap: round;
  pointer-events: none;
  transition: stroke-dasharray 200ms;
}
.node-group.dim .credence-ring-bg,
.node-group.dim .credence-ring-fg { opacity: 0.15; }

/* FR-6: smaller default font.
   FR-2: halo via paint-order + white stroke so the label is readable
   wherever edges cross behind it.
   FR-7: the runtime applies a scale() transform per node so the on-
   screen size scales sub-linearly with zoom. */
.node-label {
  font-size: 9px;
  fill: var(--text);
  text-anchor: middle;
  pointer-events: none;
  font-weight: 500;
  paint-order: stroke fill;
  stroke: #ffffff;
  stroke-width: 3px;
  stroke-linejoin: round;
}
.node-group.active .node-label { font-weight: 700; }

/* Card-style node for the zoomed-in inferential view */
.node-card-bg {
  fill: white;
  stroke: var(--border-strong);
  stroke-width: 1;
  filter: drop-shadow(0 2px 6px rgba(15,23,42,0.08));
  rx: 8; ry: 8;
}
.node-card-title {
  font-size: 11px; font-weight: 600; fill: var(--text);
}
.node-card-text {
  font-size: 10px; fill: var(--text-muted);
}
.node-card-bar-bg {
  fill: var(--bg-soft);
  rx: 2; ry: 2;
}
.node-card-bar-fg {
  fill: var(--accent);
  rx: 2; ry: 2;
}

/* -------------------- Right panel: detail card -------------------- */
.right-panel { padding: 0; }

.empty-state {
  padding: 24px 20px;
  display: flex; flex-direction: column; gap: 24px;
  height: 100%;
}
.empty-state .hero {
  text-align: center;
  margin-top: 12px;
}
.empty-state h2 {
  margin: 12px 0 6px;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.empty-state p {
  color: var(--text-muted);
  margin: 0;
  font-size: 13px;
}
.quick-pick { padding: 0; }
.quick-pick-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-muted); margin: 0 0 8px;
}
.quick-btn {
  display: block; width: 100%; text-align: left;
  padding: 10px 12px;
  margin-bottom: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-panel);
  cursor: pointer;
  font: inherit;
  color: var(--text);
}
.quick-btn:hover { border-color: var(--accent); background: var(--bg-soft); }
.quick-btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.quick-btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.detail-card.hidden, .empty-state.hidden { display: none; }

.detail-card {
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge.rebut { background: var(--rebut-soft); color: var(--rebut); }
.badge.hub   { background: #f1f5f9; color: var(--node-hub); }

.icon-btn {
  border: 0; background: transparent;
  width: 28px; height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
}
.icon-btn:hover { background: var(--bg-soft); color: var(--text); }

.detail-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.detail-desc {
  margin: 0 0 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.credence-block {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}
.credence-row {
  display: flex; justify-content: space-between;
  font-size: 13px;
  margin-bottom: 8px;
}
.credence-label { color: var(--text-muted); }
.credence-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Credence is the answer; prior is just an input. They were rendering
   at identical visual weight, which made them read as equal partners.
   The top (credence) row gets the prominent value treatment; the
   second (prior) row stays compact and muted. */
.credence-row#credence-top {
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.credence-row#credence-top .credence-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.credence-row#credence-top .credence-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
/* Make the posterior bar a touch chunkier so it reads as the primary indicator. */
.credence-bar-wrap { height: 8px; }

/* Subordinate "Prior" row — compact, muted, secondary. */
.credence-block .credence-row#prior-row {
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.credence-block .credence-row#prior-row .credence-label {
  font-size: 11px;
}
.credence-block .credence-row#prior-row .credence-value {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.credence-slider {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  height: 6px;
  border-radius: 4px;
  background: linear-gradient(to right, var(--accent) 0%, var(--accent) 50%, #e2e8f0 50%, #e2e8f0 100%);
  outline: none;
  margin-bottom: 12px;
}
.credence-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: white;
  border: 2px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.credence-slider::-moz-range-thumb {
  width: 16px; height: 16px;
  background: white;
  border: 2px solid var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

.aggregate-row {
  display: flex; justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

/* Posterior bar — visual companion to the prominent posterior number.
   Same width-as-value treatment as .aggregate-bar, but accented to
   match the credence-slider's filled section so it reads as the
   primary truth-value indicator on the card. */
.credence-bar-wrap {
  height: 6px;
  background: #e2e8f0;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 10px;
}
.credence-bar {
  height: 100%;
  background: var(--accent);
  width: 0%;
  transition: width 120ms ease;
}

/* Divider between the posterior block and the prior block, so the
   two equal-prominence numbers read as distinct concepts. */
.credence-divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 14px 0 12px;
}

.contributors h4,
.comments-block h4,
.links-block h4 { margin-top: 0; }

.contributors-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
}
.chip .mini-avatar {
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px; font-weight: 700;
  display: grid; place-items: center;
}

.comments-block { margin: 16px 0; }
.comments-list { list-style: none; padding: 0; margin: 0 0 12px; }
.comment {
  display: flex; gap: 8px;
  margin-bottom: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.comment:last-child { border-bottom: 0; }
.comment .mini-avatar { flex-shrink: 0; }
.comment-author { font-weight: 600; font-size: 12px; }
.comment-body { font-size: 13px; margin-top: 2px; }
.muted { color: var(--text-muted); font-weight: 400; }

.comment-form {
  display: flex; gap: 6px;
}
.comment-form input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: var(--bg-soft);
}
.comment-form input:focus { background: white; border-color: var(--accent); outline: none; }

.links-list { list-style: none; padding: 0; margin: 0; }
.links-list li { margin-bottom: 4px; font-size: 13px; }
.links-list a { color: var(--accent); text-decoration: none; }
.links-list a:hover { text-decoration: underline; }

/* -------------------- FR-12: anchor toggle on the credence row -------------------- */
.anchor-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 8px 2px 6px;
  margin-left: 6px;
  font: inherit;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 120ms, color 120ms, border-color 120ms;
}
.anchor-toggle:hover { background: white; color: var(--text); }
.anchor-toggle.anchored {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}
.anchor-toggle .anchor-icon { font-size: 11px; }

/* Lock badge above an anchored node in the graph */
.anchor-badge {
  font-size: 11px;
  text-anchor: middle;
  paint-order: stroke fill;
  stroke: #ffffff;
  stroke-width: 3px;
}

/* Derivation badge ("ƒ") on internal nodes — their truth value is
   derived from incoming inferences, not stipulated. */
.derived-badge {
  font-size: 12px;
  font-style: italic;
  font-family: "Times New Roman", Georgia, serif;
  fill: var(--text-muted);
  text-anchor: middle;
  paint-order: stroke fill;
  stroke: #ffffff;
  stroke-width: 3px;
}

/* When the selected node has incoming inferences, the prior is still
   editable, but the detail card surfaces a derived-truth-value row
   beneath it. Nothing to dim — the slider stays active. */

.hint.small { font-size: 11.5px; margin: 4px 0 10px; }

/* -------------------- FR-13: evidence row -------------------- */
.evidence-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.evidence-row strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.evidence-delta {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 11px;
}
.delta-ok   { background: #d1fae5; color: #047857; }
.delta-warn { background: #fef3c7; color: #b45309; }
.delta-bad  { background: #fee2e2; color: #b91c1c; }
.evidence-row .ghost-btn.small { padding: 2px 8px; font-size: 11px; }

/* -------------------- FR-15: sensitivity list -------------------- */
.sensitivity-block { margin: 16px 0; }
.sensitivity-list { list-style: none; padding: 0; margin: 0; }
.sens-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0;
  font-size: 12px;
  border-bottom: 1px dashed var(--border);
}
.sens-row:last-child { border-bottom: 0; }
.sens-link {
  background: transparent;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-align: left;
  flex: 1;
}
.sens-link:hover { text-decoration: underline; }
.sens-score {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

/* -------------------- FR-11: pulse on the Propagate button -------------------- */
.tool-btn.just-fired {
  background: var(--accent);
  color: white;
  transition: background 180ms, color 180ms;
}

/* -------------------- Detail card actions -------------------- */
.detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.detail-actions .ghost-btn { flex: 1; }

/* -------------------- Modal -------------------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid; place-items: center;
  z-index: 100;
  animation: fade-in 120ms ease;
}
.modal-backdrop.hidden { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-panel);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 600; }

.modal-body {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.field > span,
.field > legend {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
}
.field > span small { text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 500; margin-left: 6px; }

.field input[type="text"],
.field textarea,
.field select {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  font: inherit;
  outline: none;
  resize: vertical;
}
.field input[type="text"]:focus,
.field textarea:focus,
.field select:focus { background: white; border-color: var(--accent); }
.field input[type="range"] { padding: 0; margin: 6px 0; }

.field-row { display: flex; gap: 12px; }

.connect-field {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px 12px;
  margin: 4px 0 0;
}
.connect-field legend { padding: 0 6px; }

/* FR-9: color picker */
.color-picker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  outline: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  transition: transform 100ms, box-shadow 100ms;
}
.swatch:hover { transform: scale(1.08); }
.swatch.selected {
  outline: 2px solid var(--text);
  box-shadow: 0 0 0 2px white inset;
}

/* FR-5: edge detail card */
.edge-summary {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 13px;
}
.edge-summary .muted { display: inline-block; min-width: 36px; }
.credence-block select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: white;
  font: inherit;
  font-size: 12px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

/* -------------------- Mode banner (add-edge) -------------------- */
.mode-banner {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 8px 12px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  animation: rise-in 140ms ease;
}
.mode-banner.hidden { display: none; }
.mode-banner select {
  background: rgba(255,255,255,0.12);
  color: white;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  padding: 2px 6px;
  font: inherit;
}
.mode-banner .ghost-btn {
  background: transparent;
  color: white;
  border-color: rgba(255,255,255,0.25);
}
.mode-banner .ghost-btn:hover { background: rgba(255,255,255,0.08); }
@keyframes rise-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to   { opacity: 1; transform: translate(-50%, 0);    }
}

.graph.edge-mode .node-circle { cursor: crosshair; }
.graph.edge-mode .node-group:not(.active) .node-circle { stroke: var(--accent); stroke-dasharray: 3 3; }

/* -------------------- Footer -------------------- */
.footer {
  padding: 8px 20px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--bg-panel);
  text-align: center;
}

/* -------------------- Responsive -------------------- */
@media (max-width: 1100px) {
  .layout { --left-w: 180px; --right-w: 320px; }
  .search { width: 200px; }
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .left-panel, .right-panel { display: none; }
}
