.cayley-graph-section .graph-intro { margin-bottom: 24px; }

.cayley-graph-section .graph-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(260px, 1fr);
  align-items: start;
  gap: clamp(16px, 3vw, 28px);
}
.cayley-graph-section .graph-layout[hidden] { display: none; }

.cayley-graph-section .graph-figure, .cayley-graph-section .graph-controls {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: 16px;
  background: var(--card);
}
/* A light paper tone backs the three generator colors; the room page (cayley.css) sets its own surface per theme. */
.cayley-graph-section .graph-surface { background: #fbfcfe; }
.cayley-graph-section #plot {
  /* edge halos and dot rims are drawn in currentColor: keep it the surface colour */
  color: #f7f8ff;
  display: block;
  width: min(100%, 60vh);
  height: auto;
  margin-inline: auto;
  cursor: grab;
  touch-action: none;
}
.cayley-graph-section #plot:active { cursor: grabbing; }
.cayley-graph-section #plot [data-s] { cursor: pointer; }
.cayley-graph-section #plot:focus-visible { outline: 3px solid #7B45CF; outline-offset: -4px; }

.cayley-graph-section .graph-figure figcaption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  color: var(--body);
  font-size: 14px;
}
.cayley-graph-section .graph-figure .btn { min-height: 40px; padding: 5px 13px; }

.cayley-graph-section .graph-controls { padding: clamp(16px, 3vw, 24px); }
.cayley-graph-section .graph-choice { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.cayley-graph-section .graph-choice label { color: var(--ink); font-weight: 600; }
.cayley-graph-section .graph-choice select {
  min-width: 88px;
  min-height: 44px;
  padding: 3px 8px;
  border: 1px solid var(--ctl-border);
  border-radius: var(--radius-ctl);
  background: var(--tonal);
  color: var(--ink);
  font: 16px var(--font-mono);
}
.cayley-graph-section .graph-controls .graph-state {
  margin-top: 12px;
  color: var(--display);
  font: 500 clamp(38px, 6vw, 56px)/1.15 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.cayley-graph-section .graph-controls p { color: var(--body); }

.cayley-graph-section .graph-moves { display: grid; gap: 6px; margin-block: 16px 22px; }
.cayley-graph-section .graph-move {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 7px 8px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-ctl);
  background: var(--tonal);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}
.cayley-graph-section .graph-move:hover { background: var(--tonal-hover); }
.cayley-graph-section .graph-move strong {
  display: grid;
  place-items: center;
  min-width: 26px;
  min-height: 26px;
  border-radius: 6px;
  background: #f1f6fc;
}
.cayley-graph-section .graph-move span:last-child { font-family: var(--font-mono); white-space: nowrap; }

.cayley-graph-section .graph-controls h3 { margin-bottom: 8px; font-size: 25px; text-align: left; }
.cayley-graph-section .graph-isolate { display: flex; align-items: center; gap: 9px; min-height: 44px; margin-top: 7px; color: var(--ink); font-size: 14px; }
.cayley-graph-section .graph-isolate input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.cayley-graph-section .graph-metadata { margin-top: 16px; color: var(--body); font-size: 14px; }
.room .cayley-graph-section .graph-static { max-width: 760px; margin-inline: auto; }
.cayley-graph-section .graph-static img { display: block; width: 100%; height: auto; border-radius: 16px; }
.cayley-graph-section .graph-static figcaption { margin-top: 8px; color: var(--body); }

.cayley-graph-section :is(select, button, input):focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 3px;
}

@media (max-width: 720px) {
  .cayley-graph-section .graph-layout { grid-template-columns: minmax(0, 1fr); }
  .cayley-graph-section #plot { width: min(100%, 500px); }
}
