/* Interactive detail panels keep the existing, source-labelled SVGs intact. */
.diagram-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 40px; min-height: 44px; color: var(--ink-2); font-size: var(--text-caption); }
.diagram-toolbar > p { margin: 0; }
.diagram-toolbar button, .diagram-detail button { min-height: 44px; padding: 8px 14px; border: 1px solid var(--line-strong); border-radius: 6px; color: var(--ink); background: var(--surface); font: 500 var(--text-caption) var(--font-display); cursor: pointer; }
.diagram-toolbar button:hover, .diagram-detail button:hover { border-color: var(--accent); color: var(--accent); }
.diagram-explorer .diagram { margin-top: 16px; }
[data-diagram-part][role='button'] { cursor: pointer; outline: none; }
[data-diagram-part][role='button']:is(:hover, [aria-expanded='true']) > rect { stroke: var(--accent); stroke-width: 2.5; fill: color-mix(in oklab, var(--accent) 7%, var(--surface)); }
[data-diagram-part][role='button']:focus-visible > rect { stroke: var(--accent); stroke-width: 3.5; vector-effect: non-scaling-stroke; }
.diagram-detail { border: 1px solid var(--line-strong); border-left: 3px solid var(--accent); background: var(--surface); border-radius: 10px; padding: 24px 28px; margin-top: 14px; scroll-margin-block: calc(var(--header-height) + 24px) 24px; }
.diagram-detail-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px 16px; }
.diagram-detail-head .label { margin: 0; color: var(--accent); }
.diagram-detail-controls { display: inline-flex; align-items: center; gap: 8px; }
.diagram-step-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 20px; }
.diagram-step-pill { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink-2); font: 500 var(--text-caption) / 1.3 var(--font-display); text-align: left; cursor: pointer; transition: border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), background-color var(--duration-fast) var(--ease); }
.diagram-step-pill:hover { border-color: var(--accent); color: var(--ink); }
.diagram-step-pill.is-active { border-color: var(--accent); background: color-mix(in oklab, var(--accent) 8%, var(--surface)); color: var(--ink); }
.diagram-step-num { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 600; color: var(--accent); flex: none; }
@media (max-width: 959px) {
  .diagram-step-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 479px) {
  .diagram-step-nav { grid-template-columns: minmax(0, 1fr); }
}
.diagram-detail h3 { font-size: 1.5rem; max-width: 38ch; margin: 16px 0; }
.diagram-detail h3:focus { outline: none; }
.diagram-detail > p { max-width: 66ch; color: var(--ink-2); }
.diagram-detail .text-link { display: inline-flex; align-items: center; min-height: 44px; }
.method-row > .wrap > .how-head .label, .method-copy > .label { font-size: 1.125rem; font-weight: 600; color: var(--accent); }
@media (prefers-reduced-motion: no-preference) {
  /* Animate outlines, never whole SVG groups: labels remain fully painted. */
  [data-diagram][data-stage='playing'] [data-diagram-part] > rect { animation: diagram-outline 1100ms ease-out; animation-delay: calc(var(--seq) * 340ms); }
  [data-diagram][data-stage='playing'] [data-diagram-edge] { stroke-dasharray: 1; animation: diagram-line 650ms both; animation-delay: calc(200ms + var(--seq) * 340ms); }
  [data-diagram][data-stage='playing'] .dg-edge-planned { animation: diagram-dashes 1200ms 1200ms; }
  [data-diagram][data-stage='following'] [data-diagram-part][data-played] > rect { animation: diagram-outline 1100ms ease-out; }
  .diagram-detail:not([hidden]) { animation: diagram-detail 200ms ease-out; }
}
/* Keyboard interaction must never be dimmed by a running sequence. */
[data-diagram-part]:is(:focus-within, [aria-expanded='true']) > rect { animation: none !important; }
@keyframes diagram-outline { from { stroke: var(--accent); stroke-width: 3; } }
@keyframes diagram-dashes { from { stroke-dashoffset: 12; } to { stroke-dashoffset: 0; } }
@keyframes diagram-line { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes diagram-detail { from { transform: translateY(4px); } to { transform: none; } }
@media (max-width: 767px) {
  .diagram-detail { padding: 18px; }
  .diagram-toolbar { align-items: start; }
  .diagram-toolbar button { flex: none; }
}

@media (max-width: 479px) {
  .diagram-toolbar { flex-wrap: wrap; gap: 12px; }
  .diagram-legend li { align-items: start; }
  .role-chip { flex: none; }
}
