:root {
  --bg: #161310;
  --bg-2: #201c18;
  --ink: #f3eadc;
  --muted: #b7aa98;
  --line: #3a322b;
  --in: #7eb8a8;
  --in-dim: #2a403b;
  --out: #d4896a;
  --out-dim: #3f2c24;
  --hub: #e4c27a;
  --hub-dim: #3d3420;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 50% -10%, #2a241c, var(--bg));
  color: var(--ink);
  font-family: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
}

button,
input {
  font: inherit;
}

.top {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1rem 1.5rem 0.4rem;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  min-width: 0;
}

.brand-mark {
  font-size: 1.35rem;
  letter-spacing: 0.04em;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.92rem;
}

.jump {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--muted);
  margin-left: auto;
}

.jump input {
  width: min(22rem, 70vw);
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  cursor: pointer;
}

.ghost:hover {
  color: var(--ink);
}

.legend {
  margin: 0 1.5rem 0.4rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.swatch {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin: 0 0.3rem 0 0.7rem;
  vertical-align: -0.05rem;
}

.swatch.in {
  background: var(--in);
}

.swatch.out {
  background: var(--out);
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(12rem, 1fr) minmax(16rem, 24rem) minmax(12rem, 1fr);
  gap: 3.5rem;
  padding: 0.5rem 1.25rem 2rem;
  min-height: calc(100vh - 7rem);
  align-items: center;
  overflow: visible;
}

.wires {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  overflow: visible;
}

.col {
  position: relative;
  z-index: 2;
}

.col.incoming {
  justify-self: end;
  width: min(22rem, 100%);
}

.col.outgoing {
  justify-self: start;
  width: min(22rem, 100%);
}

.col h2 {
  margin: 0 0 0.75rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.node {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  background: var(--bg-2);
  color: inherit;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.node:hover {
  border-color: #6b5d4d;
}

.node .name {
  display: block;
  font-size: 1.1rem;
}

.node .meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.node.incoming {
  border-color: #35574f;
  background: linear-gradient(180deg, #243330, var(--bg-2));
}

.node.outgoing {
  border-color: #5a3c30;
  background: linear-gradient(180deg, #33241f, var(--bg-2));
}

.edge-link {
  display: none;
  margin-top: 0.45rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
}

.node.hub {
  cursor: default;
  border-color: #6d5a2e;
  background: linear-gradient(180deg, #3a3018, var(--bg-2));
  padding: 1.1rem 1.15rem 1.2rem;
}

.node.hub .name {
  font-size: 1.8rem;
}

.taxonomy {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.tax-link {
  border: 0;
  padding: 0;
  background: none;
  color: var(--hub);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  font: inherit;
}

.overview {
  margin: 0.75rem 0 0;
  color: #e8dcc8;
  line-height: 1.45;
  font-size: 0.98rem;
}

.overview strong,
.sheet strong {
  font-weight: 650;
}

.md-ref {
  color: var(--hub);
}

.listen {
  margin: 1rem 0 0;
}

.listen h3 {
  margin: 0 0 0.4rem;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.listen ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.listen li {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 0.7rem;
  padding: 0.35rem 0;
  border-top: 1px solid #3a322b;
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.listen li:first-child {
  border-top: 0;
}

.listen-title {
  grid-column: 1;
  font-size: 0.88rem;
  color: var(--ink);
}

.listen-by {
  grid-column: 1;
  font-size: 0.75rem;
  color: var(--muted);
}

.listen-links {
  grid-column: 2;
  grid-row: 1 / span 2;
  align-self: center;
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.listen-links a {
  color: var(--hub);
  text-decoration: none;
}

.listen-links a:hover {
  text-decoration: underline;
}

.empty {
  color: var(--muted);
  font-style: italic;
  padding: 0.6rem 0;
}

.wire {
  pointer-events: stroke;
  cursor: pointer;
}

.wire-hit {
  pointer-events: stroke;
  cursor: pointer;
}

.wire.is-hot {
  stroke-width: 3.2;
  stroke-opacity: 1;
}

.edge-dot {
  pointer-events: all;
  cursor: pointer;
}

.sheet {
  width: min(42rem, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #221d18;
  color: var(--ink);
  padding: 1.2rem 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}

.sheet::backdrop {
  background: rgba(8, 6, 5, 0.62);
}

.sheet .close {
  float: right;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 1.5rem;
  cursor: pointer;
}

.sheet h3 {
  margin: 0 1.5rem 0.35rem 0;
  font-size: 1.45rem;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.6rem 0 1rem;
}

.chip {
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.75rem;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: #332c25;
  color: var(--muted);
}

.chip.strong {
  color: var(--hub);
}

.sheet p {
  line-height: 1.5;
  color: #eadfce;
}

.sheet h4 {
  margin: 1.1rem 0 0.3rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-family: ui-sans-serif, system-ui, sans-serif;
}

.sheet .meta {
  color: var(--muted);
  font-size: 0.88em;
}

.shared-item {
  margin: 0.45rem 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #3a322b;
  border-radius: 10px;
  background: #1b1714;
}

.shared-name {
  margin: 0 0 0.5rem;
  font-size: 1.02rem;
}

.shared-kind {
  margin-left: 0.45rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
}

.shared-spell {
  display: block;
  margin-top: 0.25rem;
  letter-spacing: 0.04em;
  color: var(--hub);
}

.shared-cite {
  margin: 0.28rem 0 0;
  font-size: 0.92rem;
}

.shared-role {
  display: inline-block;
  min-width: 5.2rem;
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.shared-note {
  margin: 0.55rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.sheet .listen-links {
  display: inline;
  margin-left: 0.4rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .legend {
    margin: 0 1rem 0.35rem;
  }

  .stage {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "hub hub"
      "in out";
    gap: 1.6rem 1.4rem;
    padding: 0.4rem 0.85rem 2rem;
    align-items: start;
  }

  .col.hub {
    grid-area: hub;
    width: 100%;
  }

  .col.incoming {
    grid-area: in;
    justify-self: stretch;
    width: 100%;
  }

  .col.outgoing {
    grid-area: out;
    justify-self: stretch;
    width: 100%;
  }

  .edge-link {
    display: inline-block;
    color: var(--hub);
  }

  .node.incoming .edge-link {
    color: var(--in);
  }

  .node.outgoing .edge-link {
    color: var(--out);
  }
}
