.dg-section {
  --dg-ink: var(--ink);
  --dg-blue: var(--blue);
  --dg-amber: var(--ochre);
  --dg-coral: var(--ochre);
  color: var(--dg-ink);
  padding-block: var(--chapter-space);
}
.dg-shell { max-width: 82rem; }
.dg-section h2 { max-width: 21ch; margin: 0 0 1.5rem; font:var(--section-face); letter-spacing:var(--section-tracking); text-wrap: balance; }
.dg-controls { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem 1.6rem; margin-bottom: 1.5rem; border-bottom:1px solid var(--rule); }
.dg-controls[hidden], .dg-panel[hidden], .dg-replay[hidden] { display: none; }
.dg-tabs { display: flex; flex-wrap: wrap; gap: 0 1.25rem; }
.dg-tabs button,.dg-replay { background: transparent; color: #486168; border: 0; font:var(--tab-face); cursor: pointer; }
.dg-tabs button { border-bottom: 3px solid transparent; padding: .68rem .04rem .72rem; min-height: 44px; }
.dg-tabs button[aria-selected=true] { color: #1d5266; border-color: #30748b; font-weight: 650; }
.dg-replay { margin-left:auto; min-height: 44px; padding: .35rem .25rem; display: flex; align-items:center; gap: .38rem; }
.dg-replay span { font: 1.4rem/1 var(--sans,sans-serif); }
.dg-controls button:hover { color: #133e4f; }
.dg-controls button:focus-visible, .dg-source a:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.dg-panel { display: grid; align-items: center; grid-template-columns: minmax(0,.72fr) minmax(0,1.7fr); gap: clamp(1.5rem,3.15vw,3.3rem); }
.dg-shell:not([data-dg-ready]) .dg-panel + .dg-panel { margin-top: 2rem; }
.dg-copy h3 { max-width: 15ch; color: var(--dg-ink); font: 400 clamp(1.85rem,2.55vw,2.75rem)/1.08 var(--serif,Georgia,serif); letter-spacing: -.036em; text-wrap: balance; margin: 0 0 .72rem; }
.dg-copy p { color: #3f565c; font: 400 1rem/1.55 var(--sans,Arial,sans-serif); max-width: 41ch; margin: 0; }
.dg-figure { margin: 0; min-width: 0; }
.dg-plot { background: var(--surface); border: 1px solid var(--rule); border-radius:var(--panel-radius); display:grid; place-items: center; padding: clamp(.5rem,1.1vw,1rem); min-height: 15rem; }
.dg-mini-pair { display:grid; grid-template-columns: repeat(2,minmax(0,1fr)); width: 100%; align-items:center; gap:clamp(.55rem,1.4vw,1.4rem); }
.dg-svg { display: block; width: 100%; max-width: 34rem; height: auto; overflow: visible; }
.dg-mini-pair .dg-svg { max-width: none; }
.dg-svg text { font-family: var(--sans,Arial,sans-serif); }
.dg-tick { font-size:12px; fill:#4d5f63; font-variant-numeric:tabular-nums; }
.dg-ax-title { font-size:13px; font-weight:600; fill:#314b51; }
.dg-rowtitle,.dg-direct { font-size:14px; fill:#314b51; font-weight:540; }
.dg-end { font-size:14px; fill:#183b49; font-weight:680; font-variant-numeric: tabular-nums; }
.dg-note { font-size:11.5px; fill:#485f64; }
.dg-grid { stroke:#d9e1e4; stroke-width:1; }
.dg-band { fill:#e5c498; fill-opacity:.7; }
.dg-ref-line { stroke:#6a7882; stroke-width:1.3; stroke-dasharray:4 4; }
.dg-line { fill: none; stroke:currentColor; stroke-width:2.6; stroke-linejoin:round; stroke-linecap:round; }
.dg-mark { stroke: var(--surface); stroke-width:1.25; fill:currentColor; }
.dg-coral { color: var(--dg-coral); }
.dg-blue { color: var(--dg-blue); }
.dg-amber { color: var(--dg-amber); }
.dg-olive { color: #384e5b; }
.dg-warm,.dg-independent { color: #6a7882; }
.dg-independent { stroke-dasharray: 5 5; stroke-width: 1.8; }
.dg-bar { stroke:currentColor; stroke-width:10; }
.dg-mutedbar { color:var(--baseline); }
.dg-mark.dg-seed { fill:var(--surface); stroke:#354f58; stroke-width:1.35; }
.dg-figure figcaption { display: flex; flex-direction: column; gap: .22rem; margin-top: .64rem; font: .87rem/1.43 var(--sans,Arial,sans-serif); color:#4a6064; }
.dg-source { color:#53666b; }
.dg-source a { color:#2d6578; text-decoration:underline; text-underline-offset:.14em; }
@keyframes dg-draw { from { stroke-dashoffset:1; } to { stroke-dashoffset:0; } }
@keyframes dg-reveal { from { opacity:0; } to { opacity:1; } }
@keyframes dg-grow-bar { from { transform:scaleX(0); } to { transform:scaleX(1); } }
@media (prefers-reduced-motion: no-preference) {
  .dg-play .dg-line:not(.dg-independent) { stroke-dasharray:1; animation: dg-draw 1.05s cubic-bezier(.22,.65,.28,1) both; }
  .dg-play .dg-mark { animation: dg-reveal .22s calc(.09s + var(--i, 0) * .09s) both; }
  .dg-play .dg-band { animation: dg-reveal .8s both; }
  .dg-play .dg-bar { transform-box: fill-box; transform-origin:left; animation: dg-grow-bar .7s cubic-bezier(.22,.65,.28,1) both; }
}
@media (max-width: 900px) {
  .dg-panel { grid-template-columns:1fr; gap:1rem; }
  .dg-copy h3,.dg-copy p { max-width: 65ch; }
  .dg-copy h3 { margin-bottom:.45rem; }
  .dg-plot { min-height: 0; }
}
@media (max-width: 600px) {
  .dg-tabs { display:grid; grid-template-columns:1fr 1fr; gap:0 .65rem; flex:1; min-width:0; }
  .dg-tabs button { text-align:left; font-size:.88rem; padding:.5rem .03rem; }
  .dg-controls { align-items: start; gap:.2rem .35rem; margin-bottom:1.15rem; }
  .dg-replay { font-size:.82rem; padding-inline:0; }
  .dg-mini-pair { grid-template-columns:1fr; gap:.7rem; }
  .dg-mini-pair .dg-svg { max-width:24rem; margin-inline:auto; }
  .dg-svg { max-width:30rem; }
  .dg-svg .dg-ax-title { font-size:14px; }
  .dg-svg .dg-tick { font-size:13px; }
  .dg-copy p { font-size:.96rem; }
  .dg-plot { padding: .5rem .25rem; }
}
@media (max-width: 600px) {
  .dg-plot > .dg-svg :is(.dg-ax-title,.dg-direct,.dg-end,.dg-rowtitle) { font-size:16px; }
  .dg-plot > .dg-svg .dg-tick { font-size:15px; }
}
@media (min-width: 1100px) {
  .dg-shell { width:var(--project-width); max-width:none; }
}
@media (min-width: 1500px) {
  .dg-panel { grid-template-columns: minmax(0,.7fr) minmax(0,1.7fr); }
  .dg-plot > .dg-svg { max-width:min(100%,92svh,72rem); }
  .dg-mini-pair { max-width:min(100%,145svh); }
  .dg-figure figcaption { max-width:var(--reading-measure); }
}

.dg-notes { margin-top:1rem; border-top:1px solid var(--rule); }
.dg-notes p { max-width:70ch; margin:.5rem 0; font:var(--caption-face); color:var(--muted); }
