.page-graph {
  background: #efe9dc;
  color: var(--color-text-primary);
  accent-color: var(--color-accent-bronze);
}

.page-graph ::selection { background: #cdbb9d; color: #1c1914; }
.page-graph :focus-visible { outline: 3px solid #8b6743; outline-offset: 3px; }
.page-graph * { scrollbar-color: #9e8b70 #e5ddcf; scrollbar-width: thin; }
.page-graph button,
.page-graph input,
.page-graph select { font: inherit; }

.graph-page {
  width: min(100%, 1920px);
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 2rem);
}

.page-graph .graph-page {
  width: min(100%, 1920px);
  max-width: none;
}

.graph-intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: clamp(2rem, 5vw, 7rem);
  padding: clamp(1.5rem, 3vw, 3.5rem) 0 clamp(1.25rem, 2.5vw, 2.25rem);
}

.graph-intro h1 {
  max-width: 22ch;
  margin: 0 0 .75rem;
  font-family: var(--font-display);
  font-size: clamp(2.35rem, 4vw, 4.3rem);
  font-weight: 500;
  line-height: .94;
  letter-spacing: -.035em;
  text-wrap: balance;
}

.graph-intro > div > p {
  max-width: 67ch;
  margin: 0;
  color: #5d554a;
  font-size: clamp(.98rem, 1.2vw, 1.13rem);
  line-height: 1.6;
}

.graph-totals {
  display: flex;
  flex: 0 0 auto;
  gap: 1.5rem;
  margin: 0;
  padding: 0 0 .25rem;
  font-variant-numeric: tabular-nums;
}

.graph-totals div { min-width: 5.5rem; }
.graph-totals dt { color: #6b6256; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.graph-totals dd { margin: .25rem 0 0; font-family: var(--font-display); font-size: 1.55rem; }

.graph-workbench {
  display: grid;
  grid-template-columns: minmax(15rem, 18rem) minmax(30rem, 1fr) minmax(18rem, 24rem);
  height: clamp(42rem, calc(100vh - 6rem), 52rem);
  overflow: hidden;
  background: #f8f5ee;
  border: 1px solid #cfc5b5;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(53, 45, 34, .12);
}

.graph-controls,
.graph-evidence {
  min-width: 0;
  padding: 1.35rem;
  background: #f4efe5;
  overflow: auto;
}
.graph-evidence [hidden] { display: none !important; }

.graph-controls { border-right: 1px solid #d6cdbc; }
.graph-evidence { border-left: 1px solid #d6cdbc; }
.graph-mobile-filter-toggle { display: none; }

.graph-search > label,
.graph-filter-group legend {
  display: block;
  margin: 0 0 .65rem;
  color: #4c453c;
  font-size: .76rem;
  font-weight: 750;
  line-height: 1.35;
  letter-spacing: .035em;
  text-transform: uppercase;
}

.graph-search__field { position: relative; display: flex; }
.graph-search__field svg { position: absolute; top: .8rem; left: .75rem; width: 1rem; fill: none; stroke: #786b5a; stroke-width: 1.75; }
.graph-search__field input {
  width: 100%;
  min-height: 2.75rem;
  padding: .7rem 4rem .7rem 2.25rem;
  color: #25231f;
  background: #fffdf8;
  border: 1px solid #c7baa5;
  border-radius: 8px;
  caret-color: #8b6743;
}
.graph-search__field input::placeholder { color: #756d62; opacity: 1; }
.graph-search__field button,
.graph-path button {
  min-height: 2.35rem;
  color: #fffaf0;
  background: #6d5941;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.graph-search__field button { position: absolute; top: .22rem; right: .22rem; padding: 0 .7rem; font-size: .78rem; }
.graph-search__field button:hover,
.graph-path button:hover { background: #503f2d; }

.graph-search__results {
  position: relative;
  z-index: 5;
  max-height: 17rem;
  margin-top: .4rem;
  overflow: auto;
  background: #fffdf8;
  border: 1px solid #c7baa5;
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(53, 45, 34, .14);
}
.graph-search__results button {
  display: block;
  width: 100%;
  padding: .68rem .75rem;
  text-align: left;
  color: #2b2823;
  background: transparent;
  border: 0;
  border-bottom: 1px solid #eee6d9;
  cursor: pointer;
}
.graph-search__results button:hover { background: #eee7da; }
.graph-search__results small { display: block; margin-top: .15rem; color: #6e6559; }

.graph-filter-group {
  margin: 1.35rem 0 0;
  padding: 1.2rem 0 0;
  border: 0;
  border-top: 1px solid #d8cdbc;
}

.graph-filter-group--projection { margin-top: 1.1rem; }
.graph-select-label {
  display: grid;
  gap: .35rem;
  margin-top: .75rem;
  color: #5b5348;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.35;
  text-transform: uppercase;
}
.graph-select-label select {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem 2rem .55rem .65rem;
  color: #302c26;
  background: #fffdf8;
  border: 1px solid #c7baa5;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 500;
  text-transform: none;
}
.graph-select-pair { display: grid; grid-template-columns: 1fr 1fr; gap: .55rem; }
.graph-filter-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .45rem; margin-top: .8rem; }
.graph-filter-actions button {
  min-height: 2.75rem;
  padding: .5rem;
  color: #fffaf2;
  background: #6d5941;
  border: 1px solid #6d5941;
  border-radius: 6px;
  cursor: pointer;
}
.graph-filter-actions button:last-child { color: #4e473e; background: transparent; border-color: #bbae9a; }
.graph-filter-actions button:hover { background: #503f2d; }
.graph-filter-actions button:last-child:hover { background: #e9e1d4; }
.graph-filter-actions button:disabled { opacity: .55; cursor: wait; }

.graph-facets { margin-top: 1.25rem; border-top: 1px solid #d8cdbc; }
.graph-facets > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .6rem;
  padding: 1rem 0 .35rem;
  color: #423c34;
  font-family: var(--font-display);
  line-height: 1.2;
  cursor: pointer;
}
.graph-facets > summary::-webkit-details-marker { display: none; }
.graph-facets > summary svg { flex: 0 0 auto; width: 1rem; fill: none; stroke: currentColor; stroke-width: 1.5; transition: transform .2s var(--ease-out); }
.graph-facets[open] > summary svg { transform: rotate(180deg); }
.graph-facets__body { padding-bottom: .4rem; }
.graph-classification-filter { margin: .9rem 0 0; padding: .75rem 0 0; border: 0; border-top: 1px solid #ded5c7; }
.graph-classification-filter legend { color: #5b5348; font-size: .72rem; font-weight: 700; text-transform: uppercase; }

.graph-check {
  display: grid;
  grid-template-columns: 1.1rem 1fr;
  gap: .55rem;
  align-items: center;
  margin: .65rem 0;
  color: #464038;
  font-size: .86rem;
  cursor: pointer;
}
.graph-check input { position: absolute; opacity: 0; }
.graph-check span { width: 1.05rem; height: 1.05rem; border: 1px solid #998b77; border-radius: 3px; background: #fffdf8; }
.graph-check input:checked + span { background: #716c50; box-shadow: inset 0 0 0 3px #fffdf8; }
.graph-check input:focus-visible + span { outline: 3px solid #8b6743; outline-offset: 3px; }
.graph-check--compact { display: inline-grid; width: calc(50% - .2rem); margin: .32rem 0; font-size: .74rem; vertical-align: top; }
.graph-confidence { display: grid; grid-template-columns: 1fr auto; gap: .35rem; margin-top: .8rem; color: #5b5348; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.graph-confidence input { grid-column: 1 / -1; width: 100%; }
.graph-confidence output { font-variant-numeric: tabular-nums; }

.graph-segmented { display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; }
.graph-segmented button {
  padding: .55rem .35rem;
  color: #4e473e;
  background: transparent;
  border: 1px solid #c8bdab;
  border-radius: 6px;
  font-size: .75rem;
  cursor: pointer;
}
.graph-segmented button:hover { background: #e9e1d4; }
.graph-segmented button.is-active { color: #fffaf2; background: #62684e; border-color: #62684e; }
.graph-segmented--view { grid-template-columns: 1fr 1fr; }

.graph-path { margin-top: 1.25rem; border-top: 1px solid #d8cdbc; }
.graph-path summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 0 .4rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
  cursor: pointer;
}
.graph-path summary::-webkit-details-marker { display: none; }
.graph-path summary svg { width: 1rem; fill: none; stroke: currentColor; stroke-width: 1.5; transition: transform .2s var(--ease-out); }
.graph-path[open] summary svg { transform: rotate(180deg); }
.graph-path label { display: block; margin-top: .7rem; color: #5b5348; font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.graph-path input { width: 100%; margin-top: .3rem; padding: .6rem; background: #fffdf8; border: 1px solid #c7baa5; border-radius: 6px; font-size: .78rem; }
.graph-path button { width: 100%; margin-top: .75rem; }

.graph-collection { margin-top: 1rem; border-top: 1px solid #d8cdbc; }
.graph-collection summary { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: 1rem 0 .35rem; font-family: var(--font-display); cursor: pointer; }
.graph-collection summary span { display: grid; place-items: center; min-width: 1.55rem; height: 1.55rem; padding: 0 .3rem; color: #fffaf2; background: #696c50; border-radius: 999px; font-family: var(--font-ui); font-size: .68rem; font-weight: 750; }
.graph-collection [data-collection-list] > p { color: #6c6358; font-size: .76rem; }
.graph-collection__item { display: grid; grid-template-columns: 1fr 2.75rem; gap: .25rem; margin-top: .35rem; }
.graph-collection__item button { min-height: 2.75rem; color: #443d35; background: #fffdf8; border: 1px solid #cec2b0; border-radius: 6px; cursor: pointer; }
.graph-collection__item button:first-child { padding: .45rem .55rem; text-align: left; }
.graph-collection__item span, .graph-collection__item small { display: block; }
.graph-collection__item small { margin-top: .15rem; color: #786f63; }

.graph-legend { margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid #d8cdbc; }
.graph-legend h2 { margin: 0 0 .6rem; font-family: var(--font-display); font-size: 1rem; font-weight: 600; }
.graph-legend p { display: flex; align-items: center; gap: .55rem; margin: .45rem 0; color: #5d554a; font-size: .76rem; }
.legend-line { width: 1.7rem; height: 1px; background: #6b7050; }
.legend-line--proposed { height: 0; background: none; border-top: 1px dashed #9a7552; }
.legend-node { width: .8rem; height: .8rem; background: #8c6243; transform: rotate(45deg); }

.graph-stage { position: relative; min-width: 0; background: #ebe5d8; overflow: hidden; }
.graph-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, rgba(91, 81, 65, .19) .7px, transparent .8px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.78), transparent 92%);
}

.graph-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.graph-canvas.is-panning { cursor: grabbing; }
.graph-edge-hit { fill: none; stroke: transparent; stroke-width: 28; vector-effect: non-scaling-stroke; pointer-events: stroke; cursor: pointer; }
.graph-edge-hit.is-muted { pointer-events: none; }
.graph-edge { fill: none; stroke: #79745c; stroke-width: 1.4; opacity: .58; cursor: pointer; transition: opacity .18s; }
.graph-edge.is-proposed { stroke: #946e4b; stroke-dasharray: 7 6; opacity: .45; }
.graph-edge.is-muted { opacity: .06; pointer-events: none; }
.graph-edge:hover, .graph-edge.is-selected { opacity: 1; stroke-width: 3.5; }
.graph-edge:focus-visible { outline: none; opacity: 1; stroke: #3f4836; stroke-width: 4; }
#graph-arrow-accepted path { fill: #79745c; }
#graph-arrow-proposed path { fill: #946e4b; }
[data-graph-view="mindmap"] .graph-stage::before {
  background-image: linear-gradient(90deg, transparent 49.8%, rgba(91, 81, 65, .11) 50%, transparent 50.2%);
  background-size: 350px 100%;
  mask-image: linear-gradient(to right, transparent, #000 12%, #000 88%, transparent);
}
.graph-node { cursor: pointer; }
.graph-node:focus-visible { outline: none; }
.graph-node:focus-visible circle:not(.graph-node-hit),
.graph-node:focus-visible rect { stroke: #2d2923; stroke-width: 5; }
.graph-node-hit { fill: transparent; stroke: transparent; stroke-width: 36; vector-effect: non-scaling-stroke; pointer-events: all; }
.graph-label-leader { stroke: #9c927f; stroke-width: 1; vector-effect: non-scaling-stroke; pointer-events: none; }
.graph-label-leader.is-hidden { display: none; }
.graph-node circle:not(.graph-node-hit), .graph-node rect { stroke: #f8f4eb; stroke-width: 2.5; transition: filter .18s; }
.graph-node text { fill: #26231f; font-family: var(--font-ui); font-size: 20px; font-weight: 650; paint-order: stroke; stroke: #f0eade; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.graph-node:hover circle:not(.graph-node-hit), .graph-node:hover rect,
.graph-node.is-selected circle:not(.graph-node-hit), .graph-node.is-selected rect { stroke: #4f483e; stroke-width: 4; filter: drop-shadow(0 7px 7px rgba(57, 48, 36, .2)); }
.graph-node.is-muted { opacity: .08; pointer-events: none; }
.graph-node--passage rect { fill: #9a6947; }
.graph-node--author circle:not(.graph-node-hit), .graph-node--person circle:not(.graph-node-hit) { fill: #5f6952; }
.graph-node--concept circle:not(.graph-node-hit) { fill: #c29d6d; }
.graph-node--topos circle:not(.graph-node-hit), .graph-node--practice circle:not(.graph-node-hit) { fill: #6c7964; }
.graph-node--work circle:not(.graph-node-hit) { fill: #82715d; }
.graph-node--claim_or_event rect { fill: #9b574f; }
.graph-node--domain circle:not(.graph-node-hit), .graph-node--virtue circle:not(.graph-node-hit), .graph-node--tradition circle:not(.graph-node-hit) { fill: #65737a; }

.graph-toolbar {
  position: absolute;
  z-index: 3;
  top: .8rem;
  right: .8rem;
  display: flex;
  overflow: hidden;
  background: #fffdf8;
  border-radius: 8px;
  box-shadow: 0 6px 20px rgba(53,45,34,.14);
}
.graph-toolbar button { display: grid; place-items: center; width: 2.75rem; height: 2.75rem; color: #51493f; background: transparent; border: 0; border-right: 1px solid #e5dccf; cursor: pointer; }
.graph-toolbar button:last-child { border: 0; }
.graph-toolbar button:hover { color: #2d2923; background: #e9e1d4; }
.graph-toolbar svg { width: 1.05rem; fill: none; stroke: currentColor; stroke-width: 1.7; }

.graph-loading {
  position: absolute;
  z-index: 2;
  top: 50%; left: 50%;
  display: flex;
  align-items: center;
  gap: .65rem;
  transform: translate(-50%, -50%);
  color: #554d42;
  font-family: var(--font-display);
}
.graph-loading span { width: 1rem; height: 1rem; border: 2px solid #b9aa94; border-top-color: var(--color-accent-umber); border-radius: 50%; animation: graph-spin .8s linear infinite; }
@keyframes graph-spin { to { transform: rotate(360deg); } }
.graph-stage.is-ready .graph-loading { display: none; }
.graph-status { position: absolute; left: 1rem; bottom: .85rem; max-width: calc(100% - 2rem); padding: .4rem .65rem; color: #5b5348; background: rgba(248,245,238,.88); border-radius: 5px; font-size: .74rem; }

.graph-evidence__empty { display: grid; align-content: center; min-height: 100%; text-align: center; }
.graph-evidence__content { position: relative; }
.evidence-close { position: sticky; z-index: 2; top: 0; float: right; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; margin: -.45rem -.45rem .3rem .5rem; color: #51493f; background: #fffdf8; border: 1px solid #c9bdab; border-radius: 999px; cursor: pointer; }
.evidence-close svg { width: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.8; }
.graph-evidence__empty > svg { width: 3.5rem; margin: 0 auto 1.2rem; fill: none; stroke: #8a775e; stroke-width: 1.3; }
.graph-evidence h2 { margin: 0 0 .6rem; font-family: var(--font-display); font-size: clamp(1.4rem, 2vw, 2rem); font-weight: 500; line-height: 1.1; }
.graph-evidence p { color: #62594e; font-size: .9rem; line-height: 1.55; }
.evidence-type { margin: 0 0 .7rem; color: #756a5d; font-size: .7rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.evidence-status { display: inline-flex; margin: .2rem 0 1rem; padding: .3rem .55rem; color: #32402f; background: #dce4d6; border-radius: 999px; font-size: .7rem; font-weight: 750; }
.evidence-status.is-proposed { color: #6a4525; background: #ecddc9; }
.evidence-interpretation { margin: 1rem 0; padding: .9rem 0; border-top: 1px solid #d8cdbc; border-bottom: 1px solid #d8cdbc; font-family: var(--font-display); font-size: 1.05rem !important; color: #342f29 !important; }
.evidence-meta { margin: 1rem 0; }
.evidence-meta div { margin-bottom: .65rem; }
.evidence-meta dt { color: #776d61; font-size: .68rem; font-weight: 750; text-transform: uppercase; }
.evidence-meta dd { margin: .15rem 0 0; overflow-wrap: anywhere; color: #3f3932; font-size: .78rem; }
.evidence-sources { margin: 0; padding-left: 1.1rem; color: #574f45; font-size: .75rem; overflow-wrap: anywhere; }
.evidence-sources li { margin: .4rem 0; }
.evidence-sources a { color: #59452f; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.evidence-sources small { display: block; margin-top: .12rem; color: #776d61; }
.evidence-error { padding: .8rem; color: #642f29 !important; background: #f2dcd6; border: 1px solid #d7aaa0; border-radius: 6px; font-weight: 700; }
.evidence-representations details { margin: .45rem 0; padding: .6rem .7rem; background: #fffdf8; border: 1px solid #d4c9b8; border-radius: 6px; }
.evidence-representations summary { color: #453e36; font-size: .78rem; font-weight: 700; cursor: pointer; }
.evidence-representations p { white-space: pre-wrap; }
.evidence-representations small { color: #776d61; overflow-wrap: anywhere; }
.evidence-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: 1rem; }
.evidence-actions button, .evidence-actions a { padding: .55rem .7rem; color: #423a31; background: transparent; border: 1px solid #bbae9a; border-radius: 6px; font-size: .75rem; text-decoration: none; cursor: pointer; }
.evidence-actions button:hover, .evidence-actions a:hover { background: #e6ddcf; }
.evidence-note { width: 100%; min-height: 5rem; margin-top: .75rem; padding: .65rem; resize: vertical; color: #312d27; background: #fffdf8; border: 1px solid #c7baa5; border-radius: 6px; font-size: .8rem; }

.graph-text { margin: 1rem 0 2rem; padding: 1rem 1.2rem; background: #f8f5ee; border: 1px solid #d4c9b8; border-radius: 10px; }
.graph-text summary { font-family: var(--font-display); font-size: 1.05rem; cursor: pointer; }
.graph-text h3 { margin: 1.1rem 0 .4rem; font-family: var(--font-display); font-size: 1rem; }
.graph-text-list { columns: 3 18rem; margin-top: 1rem; }
.graph-text-list button { display: block; width: 100%; margin: 0 0 .45rem; padding: .45rem 0; text-align: left; color: #403a32; background: transparent; border: 0; border-bottom: 1px solid #e2d9ca; cursor: pointer; break-inside: avoid; }
.graph-text-list small { display: block; color: #746b5f; }
.graph-workbench:fullscreen { width: 100vw; height: 100vh; border: 0; border-radius: 0; }

@media (max-width: 1200px) {
  .graph-workbench { grid-template-columns: 15.5rem minmax(28rem, 1fr); }
  .graph-evidence { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; max-height: min(72vh, 42rem); min-height: 12rem; visibility: hidden; transform: translateY(100%); border: 1px solid #c9bdab; border-radius: 14px 14px 0 0; box-shadow: 0 -14px 38px rgba(53,45,34,.16); transition: visibility 0s linear .35s, transform .35s var(--ease-out); }
  .graph-evidence.has-content { visibility: visible; transform: translateY(0); transition-delay: 0s; }
  .graph-evidence__empty { min-height: 8rem; }
}

@media (max-width: 760px) {
  .graph-page { padding: .75rem; }
  .graph-intro { display: block; padding: 1.5rem 0 1rem; }
  .graph-intro h1 { max-width: 12ch; font-size: clamp(2.15rem, 12vw, 3.5rem); }
  .graph-totals { margin-top: 1.2rem; gap: .75rem; }
  .graph-totals div { min-width: 0; flex: 1; }
  .graph-totals dt { font-size: .62rem; }
  .graph-totals dd { font-size: 1.15rem; }
  .graph-workbench { display: flex; flex-direction: column; height: auto; min-height: 0; overflow: visible; }
  .graph-controls { border: 0; border-bottom: 1px solid #d6cdbc; }
  .graph-mobile-filter-toggle { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 2.75rem; margin-top: .75rem; padding: .55rem .7rem; color: #4a4238; background: #fffdf8; border: 1px solid #c7baa5; border-radius: 7px; cursor: pointer; }
  .graph-mobile-filter-toggle span { display: grid; place-items: center; min-width: 1.55rem; height: 1.55rem; padding: 0 .3rem; background: #e2d9ca; border-radius: 999px; font-size: .7rem; }
  .graph-mobile-filter-toggle span.has-active { color: #fffaf2; background: #6d5941; }
  .graph-filter-group, .graph-path, .graph-legend, .graph-collection { display: none; }
  .graph-facets { display: none; }
  .graph-controls.are-filters-open .graph-filter-group,
  .graph-controls.are-filters-open .graph-path,
  .graph-controls.are-filters-open .graph-legend,
  .graph-controls.are-filters-open .graph-collection,
  .graph-controls.are-filters-open .graph-facets { display: block; }
  .graph-stage { min-height: 62vh; }
  .graph-toolbar { top: .55rem; right: .55rem; }
  .graph-node text { font-size: 34px; stroke-width: 6px; }
  .graph-node-hit { stroke-width: 44; }
  .graph-text-list { columns: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .graph-loading span { animation: none; }
  .graph-evidence { transition: none; }
}
