:root {
  --chalk: #ddd5bf;
  --paper: #f0e8d4;
  --paper-deep: #e4dac1;
  --ink: #2c302b;
  --ink-soft: #5e6056;
  --graphite: #77776d;
  --moss: #6d7357;
  --weathered-brown: #806e56;
  --brass: #9a8151;
  --rose: #a27c78;
  --order: #9a8151;
  --deep-time: #847f8f;
  --seam: #4e887f;
  --seam-bright: #8ad8c3;
  --serif: "AccanthisADFStdNo2-Regular", "Iowan Old Style", Georgia, serif;
  --sans: "LinuxBiolinumORegular", "Linux Biolinum O", Optima, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--chalk); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--chalk);
  font-family: var(--sans);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 6;
  pointer-events: none;
  opacity: .16;
  mix-blend-mode: multiply;
  background-image: repeating-linear-gradient(0deg, rgba(56,54,46,.025) 0 1px, transparent 1px 5px);
}

button, a { font: inherit; }

.back-link {
  position: fixed;
  top: clamp(18px, 3vw, 34px);
  left: clamp(18px, 3vw, 34px);
  z-index: 10;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: rgba(57,58,51,.68);
  border: 1px solid rgba(83,78,66,.28);
  border-radius: 50%;
  background: rgba(240,232,212,.52);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.back-link:hover,
.back-link:focus-visible {
  color: var(--ink);
  border-color: rgba(128,110,86,.58);
  background: rgba(240,232,212,.9);
  transform: translateX(-2px);
  outline: none;
}

.back-link svg { width: 22px; height: 22px; }
.back-link path { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

.world-scrim {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: .44;
}
.orbit {
  position: absolute;
  border: 1px solid rgba(87,82,69,.12);
  border-radius: 50%;
}
.orbit-one { width: 74vw; height: 74vw; left: 13vw; top: -31vw; }
.orbit-two { width: 48vw; height: 48vw; right: -19vw; bottom: -21vw; }
.mere-glow {
  position: absolute;
  inset: auto 10vw -18vh;
  height: 36vh;
  border-top: 1px solid rgba(91,105,98,.08);
  border-radius: 50%;
}

.connections-shell {
  position: relative;
  z-index: 2;
  width: min(1480px, calc(100% - 64px));
  margin: 0 auto;
  padding: clamp(74px, 9vw, 118px) 0 38px;
}

.connections-header { width: min(820px, 100%); margin: 0 auto; text-align: center; }
.eyebrow, .connections-footer, .filters button { text-transform: uppercase; letter-spacing: .17em; }
.eyebrow { margin: 0 0 16px; color: rgba(92,84,68,.68); font-size: .66rem; }
.connections-header h1 {
  margin: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(3.4rem, 8vw, 7.5rem);
  font-weight: 400;
  line-height: .86;
  letter-spacing: .025em;
  text-shadow: 0 1px 0 rgba(250,247,236,.4);
}
.lede {
  max-width: 640px;
  margin: 25px auto 0;
  color: rgba(47,49,43,.72);
  font-family: var(--serif);
  font-size: clamp(1rem, 1.5vw, 1.22rem);
  line-height: 1.6;
}

.filters {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 4px 18px;
  margin: 39px auto 26px;
  padding: 13px 0 11px;
  border-top: 1px solid rgba(88,81,67,.17);
  border-bottom: 1px solid rgba(88,81,67,.17);
}
.filters button {
  padding: 5px 0;
  color: rgba(54,55,49,.52);
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  font-size: .57rem;
}
.filters button:hover,
.filters button:focus-visible,
.filters button.is-active {
  color: var(--ink);
  border-bottom-color: rgba(128,105,74,.7);
  background: transparent;
  outline: none;
}
.filters button.is-active { color: rgba(81,69,51,.92); }

.connections-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 370px);
  gap: 18px;
  align-items: stretch;
}
.graph-viewport,
.profile-panel {
  border: 1px solid rgba(91,84,69,.24);
  background: rgba(239,231,211,.83);
  box-shadow: 0 14px 30px rgba(75,63,45,.08);
}
.graph-viewport {
  min-height: 690px;
  overflow: auto;
  scrollbar-color: rgba(113,100,79,.3) transparent;
}
.graph-viewport:focus-visible { outline: 1px solid rgba(100,88,68,.58); outline-offset: 3px; }
.graph-canvas {
  position: relative;
  min-width: 880px;
  min-height: 690px;
  padding: 36px;
  background-image:
    repeating-linear-gradient(0deg, rgba(81,77,65,.022) 0 1px, transparent 1px 28px),
    repeating-linear-gradient(90deg, rgba(81,77,65,.018) 0 1px, transparent 1px 28px);
}
.nodes {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr));
  grid-template-rows: repeat(5, minmax(100px, 1fr));
  width: 100%;
  min-height: 618px;
  gap: 14px;
}
.relationship-lines { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.line { stroke-width: 1; vector-effect: non-scaling-stroke; opacity: .28; transition: opacity 180ms ease, stroke-width 180ms ease, stroke 180ms ease; }
.line.is-connected { stroke-width: 1.8; opacity: .82; }
.type-community { stroke: #8b877a; }
.type-romantic { stroke: var(--rose); }
.type-ecological { stroke: #77887d; }
.type-ecological.is-connected { stroke: var(--seam); }
.type-adversarial { stroke: #9b735f; stroke-dasharray: 4 5; }
.type-institutional { stroke: var(--order); stroke-dasharray: 7 4; }
.type-deep-time { stroke: var(--deep-time); stroke-dasharray: 1 6; }

.character-node {
  --node-accent: #817c6e;
  grid-column: var(--column);
  grid-row: var(--row);
  align-self: center;
  justify-self: stretch;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 66px;
  padding: 9px 10px;
  color: var(--ink);
  text-align: left;
  border: 1px solid rgba(91,84,69,.22);
  border-radius: 0;
  background: rgba(244,237,219,.86);
  box-shadow: 0 5px 12px rgba(75,63,45,.055);
  cursor: pointer;
  transition: opacity 180ms ease, border-color 180ms ease, transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}
.character-node:hover,
.character-node:focus-visible,
.character-node.is-selected {
  border-color: color-mix(in srgb, var(--node-accent) 68%, #6d6555);
  background: rgba(246,240,224,.98);
  transform: translateY(-2px);
  outline: none;
}
.character-node.is-muted { opacity: .2; }
.character-node.is-selected { box-shadow: 0 8px 18px rgba(75,63,45,.1); }
.group-adjacent,
.group-ecological { --node-accent: #718079; }
.group-adjacent.is-selected,
.group-ecological.is-selected { --node-accent: var(--seam); }
.group-order { --node-accent: var(--order); }
.group-metaphysical { --node-accent: var(--deep-time); }
.group-pathfinder { --node-accent: #9b855d; }
.node-portrait {
  display: grid;
  place-items: center;
  width: 40px;
  aspect-ratio: 1;
  border: 1px solid color-mix(in srgb, var(--node-accent) 55%, transparent);
  border-radius: 50%;
  color: color-mix(in srgb, var(--node-accent) 82%, var(--ink));
  background: rgba(255,255,255,.13);
  font-family: var(--serif);
  font-size: .82rem;
}
.node-copy { min-width: 0; }
.node-copy strong, .node-copy small { display: block; }
.node-copy strong { overflow: hidden; text-overflow: ellipsis; font-family: var(--serif); font-size: 1rem; font-weight: 400; white-space: nowrap; }
.node-copy small { margin-top: 4px; overflow: hidden; color: rgba(58,59,52,.5); font-size: .55rem; letter-spacing: .06em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }

.profile-panel { min-height: 690px; padding: 27px; }
.panel-prompt { margin: 0; color: rgba(58,59,52,.48); font-family: var(--serif); font-size: 1.1rem; }
.profile-heading { display: grid; grid-template-columns: 76px 1fr; gap: 18px; align-items: center; padding-bottom: 22px; border-bottom: 1px solid rgba(83,78,66,.18); }
.profile-portrait {
  display: grid;
  place-items: center;
  width: 76px;
  aspect-ratio: 1;
  color: rgba(91,78,57,.86);
  border: 1px solid rgba(128,105,74,.46);
  border-radius: 50%;
  background: rgba(255,255,255,.16);
  font-family: var(--serif);
  font-size: 1.35rem;
}
.profile-heading p { margin: 0 0 5px; color: rgba(91,80,61,.62); font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; }
.profile-heading h2 { margin: 0; color: var(--ink); font-family: var(--serif); font-size: 2.15rem; font-weight: 400; line-height: 1; }
.profile-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; margin: 20px 0 0; background: rgba(102,91,73,.12); }
.profile-facts div { padding: 11px 12px; background: rgba(242,235,217,.92); }
.profile-facts dt { color: rgba(58,59,52,.44); font-size: .55rem; letter-spacing: .12em; text-transform: uppercase; }
.profile-facts dd { margin: 5px 0 0; color: rgba(45,47,41,.84); font-family: var(--serif); font-size: .94rem; }
.profile-summary { margin: 20px 0 0; color: rgba(45,47,41,.72); font-family: var(--serif); font-size: 1rem; line-height: 1.55; }
.profile-quote { margin: 21px 0 0; padding: 17px 0 0 17px; border-top: 1px solid rgba(83,78,66,.16); border-left: 1px solid rgba(154,129,81,.48); }
.profile-quote p { margin: 0; color: var(--ink); font-family: var(--serif); font-size: 1.08rem; line-height: 1.45; }
.profile-quote footer { margin-top: 9px; color: rgba(128,105,74,.7); font-size: .55rem; letter-spacing: .1em; text-transform: uppercase; }
.profile-quote.is-unknown p,
.profile-quote.is-unknown footer { color: rgba(58,59,52,.4); }
.related-list { margin-top: 23px; }
.related-list h3 { margin: 0 0 11px; color: rgba(58,59,52,.52); font-size: .58rem; font-weight: 400; letter-spacing: .14em; text-transform: uppercase; }
.related-list ul { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.related-list li { padding-top: 11px; border-top: 1px solid rgba(83,78,66,.13); }
.related-list button { display: flex; justify-content: space-between; gap: 12px; width: 100%; padding: 0; color: var(--ink); border: 0; background: none; cursor: pointer; text-align: left; }
.related-list button:hover span,
.related-list button:focus-visible span { color: var(--seam); }
.related-list button:focus-visible { outline: none; }
.related-list button span { font-family: var(--serif); }
.related-list button small { color: rgba(94,82,62,.54); font-size: .52rem; letter-spacing: .09em; text-transform: uppercase; }
.related-list li p { margin: 5px 0 0; color: rgba(58,59,52,.5); font-size: .73rem; line-height: 1.45; }

.connections-footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-top: 22px;
  padding-top: 14px;
  color: rgba(58,59,52,.4);
  border-top: 1px solid rgba(88,81,67,.13);
  font-size: .56rem;
}

@media (max-width: 1080px) {
  .connections-layout { grid-template-columns: 1fr; }
  .profile-panel { min-height: 0; }
}

@media (max-width: 700px) {
  .connections-shell { width: min(100% - 28px, 620px); padding-top: 88px; }
  .back-link { position: absolute; }
  .connections-header { text-align: left; }
  .connections-header h1 { font-size: clamp(3.3rem, 18vw, 5.3rem); }
  .lede { margin-left: 0; }
  .filters { justify-content: flex-start; margin-top: 30px; }
  .graph-viewport { min-height: 580px; }
  .graph-canvas { min-width: 780px; min-height: 580px; padding: 24px; }
  .nodes { min-height: 532px; grid-template-columns: repeat(5, minmax(120px, 1fr)); grid-template-rows: repeat(5, minmax(82px, 1fr)); }
  .character-node { grid-template-columns: 34px minmax(0, 1fr); min-height: 58px; }
  .node-portrait { width: 34px; }
  .profile-panel { padding: 22px; }
  .connections-footer { display: grid; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}