.kg-playground {
  --kg-paper: var(--paper, #f8f7f2);
  --kg-ink: var(--ink, #30362e);
  --kg-green: var(--green, #52623e);
  --kg-line: var(--line, #dedfd4);
  width: 100%;
  min-width: 0;
  color: var(--kg-ink);
}

.kg-result-message {
  margin: 0;
  overflow-wrap: anywhere;
}

.kg-plot {
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  width: 100%;
  height: clamp(330px, 70vw, 560px);
  overflow: hidden;
  border: 1px solid var(--kg-line);
  border-radius: 5px 8px 7px 4px;
  background-color: var(--kg-paper);
  background-image: radial-gradient(circle, #52623e24 0.7px, transparent 0.9px);
  background-position: 10px 10px;
  background-size: 20px 20px;
  cursor: crosshair;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.kg-plot:focus-visible {
  outline: 2px solid var(--kg-green);
  outline-offset: 4px;
}

.kg-playground .kg-ink {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.kg-ink-path,
.kg-live-stroke {
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kg-reference-edge {
  stroke: #97a189;
  stroke-width: 1;
  stroke-dasharray: 3 6;
  opacity: 0.34;
}

.kg-reference-note {
  position: absolute;
  right: 12px;
  bottom: 8px;
  color: #78816c;
  font: 9px/1.5 var(--mono);
  pointer-events: none;
}

.kg-pointer-trail {
  fill: none;
  stroke: #a85e52;
  stroke-width: 1.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 2px #b76a5a66);
  opacity: 0;
}

.kg-pointer-tip {
  fill: #a85e52;
  filter: drop-shadow(0 0 2px #b76a5a66);
  opacity: 0;
}

.kg-paper-cue {
  position: absolute;
  bottom: 8px;
  left: 12px;
  color: #78816c;
  font: italic 11px/1.5 var(--serif, Georgia, serif);
  pointer-events: none;
}

[data-graph-state="drawing"] .kg-paper-cue {
  opacity: 0;
}

.kg-ink-known {
  stroke: var(--kg-stroke-color, var(--kg-green));
}

.kg-ink-playful {
  stroke-dasharray: 5 4;
}

.kg-ink-path {
  stroke: var(--kg-stroke-color, var(--kg-green));
  opacity: 0.9;
}

.kg-live-stroke {
  stroke: var(--kg-ink);
  stroke-width: 1.7;
  opacity: 0.72;
}

.kg-node {
  position: absolute;
  z-index: 1;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: calc(25% - 14px);
  min-height: 44px;
  margin: 0;
  padding: 6px 7px;
  transform: translate(-50%, -50%);
  border: 1px solid transparent;
  border-radius: 4px;
  background: var(--kg-paper);
  color: var(--kg-ink);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.72rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: left;
  text-transform: none;
  white-space: normal;
  cursor: pointer;
}

.kg-node-face {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: 100%;
  min-width: 0;
  pointer-events: none;
  transform: translate(var(--kg-dx, 0px), var(--kg-dy, 0px)) rotate(var(--kg-tilt, 0deg));
}

[data-graph-motion="running"] .kg-node-face {
  will-change: transform;
}

.kg-node-face::before {
  flex: 0 0 6px;
  width: 6px;
  height: 6px;
  border: 1px solid var(--kg-green);
  border-radius: 50%;
  background: var(--kg-paper);
  content: "";
}

.kg-node-label {
  min-width: 0;
  overflow-wrap: anywhere;
}
.kg-node-label-compact { display: none; }
[data-graph-compact="true"] .kg-node-label-full { display: none; }
[data-graph-compact="true"] .kg-node-label-compact { display: inline; }
[data-graph-compact="true"] .kg-node { width: 44px; min-width: 44px; max-width: 44px; height: 44px; padding: 2px; font-size: 0.56rem; text-align: center; }
[data-graph-compact="true"] .kg-node-face { flex-direction: column; gap: 2px; width: 100%; }
[data-graph-compact="true"] .kg-node[data-node-id="microsoft"],
[data-graph-compact="true"] .kg-node[data-node-id="stashbird"] { width: 53px; min-width: 53px; max-width: 53px; padding: 1px; }

.kg-node:hover,
.kg-node:focus-visible,
.kg-node.kg-is-candidate,
.kg-node.kg-is-pending {
  border-color: #b7c0a9;
  background: #edf0e5;
}

.kg-node:hover .kg-node-face::before,
.kg-node:focus-visible .kg-node-face::before,
.kg-node.kg-is-candidate .kg-node-face::before,
.kg-node.kg-is-pending .kg-node-face::before {
  background: var(--kg-green);
}

.kg-node:focus-visible,
.kg-action:focus-visible,
.kg-source:focus-visible {
  outline: 2px solid var(--kg-green);
  outline-offset: 3px;
}

.kg-underneath {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  margin-top: 0.45rem;
}

.kg-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; }
.kg-actions button:disabled { opacity: 0.35; cursor: default; }
.kg-actions button:disabled:hover { border-color: transparent; background: transparent; }

.kg-action {
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin: 0;
  padding: 0.5rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--kg-ink);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.73rem;
  font-weight: 400;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.kg-action:hover,
.kg-action:focus-visible {
  border-color: var(--kg-line);
  background: #edf0e5;
}

.kg-status {
  min-height: 6rem;
  margin-top: 0.8rem;
  padding: 0.85rem 0 0.5rem;
  border-top: 1px solid var(--kg-line);
}

.kg-status.kg-sr-only { min-height: 0; margin: 0; padding: 0; border: 0; }

.kg-result-kind {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--kg-green);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.67rem;
  line-height: 1.5;
  letter-spacing: 0.04em;
}

.kg-result-message {
  max-width: 72ch;
  font-size: 0.9rem;
  line-height: 1.65;
}

.kg-result-route {
  margin: 0 0 0.65rem;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.78rem;
}

.kg-result-leg {
  margin: 0 0 0.7rem;
}

.kg-result-leg-label {
  display: block;
  color: var(--kg-green);
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.68rem;
  line-height: 1.6;
}

.kg-limit-note {
  margin: 0.4rem 0 0;
  color: var(--kg-green);
  font-size: 0.78rem;
  line-height: 1.6;
}

.kg-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 1rem;
}

.kg-source {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--kg-green);
  font-size: 0.8rem;
  line-height: 1.5;
  text-decoration: underline;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.kg-source:hover,
.kg-source:focus-visible {
  color: var(--kg-ink);
  text-decoration-thickness: 2px;
}

.kg-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 650px) {
  .kg-result-message { font-size: 1rem; }
  .kg-result-route, .kg-limit-note, .kg-source { font-size: 0.875rem; }
}

@media (max-width: 620px) {
  .kg-node {
    max-width: calc(50% - 18px);
  }
  .kg-reference-note { top: 8px; bottom: auto; font-size: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .kg-node-face { transform: none; will-change: auto; }
  .kg-pointer-trail, .kg-pointer-tip { display: none; }
}
