.graphwrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  height: 100%;
  min-height: 0;
  background: #141b18;
}

.gcanvas {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background-color: #141b18;
  background-image: url("/assets/thought-armillary-bg.webp");
  background-position: center;
  background-size: cover;
}

.gcanvas::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 0;
  pointer-events: none;
  background: rgba(10, 15, 13, 0.44);
}

.gstage-head {
  position: absolute;
  z-index: 7;
  top: 16px;
  right: 18px;
  left: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.gstage-heading {
  max-width: 300px;
  color: #eee6d8;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.72);
}

.gstage-kicker {
  display: block;
  color: #d0aa67;
  font-size: 10px;
  letter-spacing: 2px;
}

.gstage-name {
  display: block;
  margin-top: 5px;
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0;
}

.gview-switch {
  display: inline-flex;
  flex: 0 0 auto;
  pointer-events: auto;
}

.gview-mode {
  min-width: 54px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(224, 205, 169, 0.38);
  background: rgba(17, 25, 22, 0.82);
  color: rgba(237, 228, 212, 0.7);
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}

.gview-mode:first-child {
  border-radius: 5px 0 0 5px;
}

.gview-mode:last-child {
  margin-left: -1px;
  border-radius: 0 5px 5px 0;
}

.gview-mode[aria-selected="true"] {
  position: relative;
  z-index: 1;
  border-color: #d0aa67;
  background: #8a6a3d;
  color: #fffaf0;
}

.gview-mode:focus-visible,
.g3d-label:focus-visible {
  outline: 2px solid #f1d49a;
  outline-offset: 3px;
}

.g3d,
#gsvg {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.g3d[hidden],
#gsvg[hidden] {
  display: none;
}

.g3d {
  cursor: grab;
  touch-action: none;
}

.g3d.is-dragging {
  cursor: grabbing;
}

.g3d-canvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
}

.g3d-label-layer {
  position: absolute;
  z-index: 3;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.g3d-label {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 142px;
  min-height: 28px;
  padding: 5px 7px 5px 9px;
  border: 0;
  border-left: 2px solid var(--g3d-node-color, #d0aa67);
  border-radius: 3px;
  background: rgba(13, 20, 18, 0.84);
  box-shadow: 0 5px 16px rgba(0, 0, 0, 0.26);
  color: #e8e0d2;
  font: inherit;
  font-size: 11px;
  line-height: 1.35;
  text-align: left;
  overflow-wrap: anywhere;
  cursor: pointer;
  pointer-events: auto;
  transform: translate(-50%, 16px);
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}

.g3d-label.is-related {
  color: #fff9ed;
  background: rgba(30, 42, 36, 0.92);
}

.g3d-label.is-selected {
  z-index: 2;
  border-left-width: 4px;
  background: rgba(91, 67, 36, 0.96);
  box-shadow: 0 0 0 1px rgba(224, 188, 119, 0.52), 0 8px 22px rgba(0, 0, 0, 0.36);
  color: #fffaf0;
}

.g3d-label[style*="visibility: hidden"] {
  pointer-events: none;
}

.g3d-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 5px;
  border-radius: 50%;
  background: #5f8055;
  color: #fff;
  font-family: "SFMono-Regular", Menlo, monospace;
  font-size: 9px;
  vertical-align: 1px;
}

.g3d-mark[hidden] {
  display: none;
}

.g3d-mark.is-doubt {
  background: #bd7c37;
}

.g3d-status {
  position: absolute;
  z-index: 4;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(237, 228, 212, 0.76);
  font-size: 13px;
  letter-spacing: 2px;
  pointer-events: none;
}

.g3d-status[hidden] {
  display: none;
}

.glegend {
  position: absolute;
  z-index: 6;
  bottom: 14px;
  left: 16px;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 4px 14px;
  padding: 8px 10px;
  border: 1px solid rgba(224, 205, 169, 0.25);
  border-radius: 6px;
  background: rgba(14, 21, 18, 0.78);
  color: rgba(232, 224, 210, 0.76);
  font-size: 10px;
  line-height: 1.5;
}

.glegend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: middle;
}

#gsvg {
  cursor: grab;
  background: rgba(239, 232, 217, 0.88);
}

.gedge {
  stroke: #a9997b;
  stroke-width: 1.2;
}

.gedge.hl {
  stroke: #9b6d32;
  stroke-width: 2;
}

.gelabel {
  fill: #746b5d;
  font-family: inherit;
  font-size: 9.5px;
  pointer-events: none;
}

.gnode {
  cursor: pointer;
}

.gnode circle {
  stroke: #fffdf8;
  stroke-width: 2;
  transition: 120ms ease;
}

.gnode text {
  fill: #23201b;
  font-family: inherit;
  font-size: 11.5px;
  text-anchor: middle;
  pointer-events: none;
}

.gnode.dim {
  opacity: 0.28;
}

.gnode.sel circle {
  stroke: #17130f;
  stroke-width: 3;
}

.ginfo {
  min-width: 0;
  overflow-y: auto;
  padding: 24px 20px 44px;
  border-left: 1px solid rgba(224, 205, 169, 0.2);
  background: #202823;
  color: #e7dfd2;
}

.ginfo h2 {
  margin-bottom: 4px;
  color: #d2ad68;
  font-size: 14px;
  letter-spacing: 2px;
}

.ginfo .csub {
  color: #9eaa9f;
  font-size: 11px;
  line-height: 1.6;
}

.ginfo .empty {
  margin-top: 20px;
  color: #aeb7b0;
  font-size: 12.5px;
  font-style: normal;
  line-height: 1.9;
}

.ginfo .gtag {
  display: inline-block;
  margin: 22px 0 10px;
  padding: 3px 9px;
  border-radius: 3px;
  color: #fffdf8;
  font-size: 10px;
}

.ginfo .gname {
  margin-bottom: 12px;
  color: #fff9ee;
  font-size: 21px;
  letter-spacing: 0;
}

.ginfo .gbrief {
  margin-bottom: 18px;
  color: #d8ddd8;
  font-size: 14px;
  line-height: 1.9;
}

.ginfo .grel {
  margin-bottom: 18px;
  padding-top: 14px;
  border-top: 1px solid rgba(224, 205, 169, 0.18);
  color: #bdc6bf;
  font-size: 12px;
  line-height: 1.85;
}

.ginfo .grel b {
  color: #e0b96f;
}

.ginfo .markctl {
  border-color: rgba(224, 205, 169, 0.3);
}

.ginfo .gbtn {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  padding: 9px 12px;
  border: 1px solid rgba(224, 205, 169, 0.32);
  border-radius: 5px;
  background: rgba(255, 253, 248, 0.04);
  color: #dfc18a;
  font-family: inherit;
  font-size: 12px;
  letter-spacing: 1px;
  text-align: left;
  cursor: pointer;
}

.ginfo .gbtn:hover {
  border-color: #d2ad68;
  background: rgba(255, 253, 248, 0.08);
}

@media (max-width: 850px) {
  #view-graph {
    overflow-y: auto;
  }

  .graphwrap {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 100%;
  }

  .gcanvas {
    flex: 0 0 auto;
    width: 100%;
    height: 58dvh;
    min-height: 460px;
  }

  .gstage-head {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .gstage-name {
    font-size: 16px;
  }

  .g3d-label {
    max-width: 104px;
    padding: 4px 6px 4px 7px;
    font-size: 10px;
  }

  .glegend {
    right: 12px;
    bottom: 10px;
    left: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 3px 8px;
  }

  .ginfo {
    flex: 0 0 auto;
    min-height: 320px;
    overflow-y: visible;
    padding: 24px 18px 54px;
    border-top: 1px solid rgba(224, 205, 169, 0.2);
    border-left: 0;
  }
}

@media (max-width: 430px) {
  .gstage-heading {
    max-width: 175px;
  }

  .gstage-kicker {
    font-size: 9px;
    letter-spacing: 1px;
  }

  .gstage-name {
    font-size: 14px;
  }

  .gview-mode {
    min-width: 48px;
    padding: 0 9px;
  }

  .glegend {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  .g3d-label,
  .gnode circle {
    transition: none;
  }
}
