/* The chart surface lifts gently between the two darker chapters. */
#study.section {
  --paper: var(--archive-slate);
  --panel: #202d3e;
  --ink: #e7eaf0;
  --result-text: #dce5ed;
  --quiet: #acb9c9;
  --modality-surface: #293b4c;
  --rule: #465466;
  --control-edge: #8494a5;
  --read-accent: #85dace;
  --surface-inset: #27384a;
  --graphite: #101724;
  --on-graphite: #e7eaf0;
  --family-image: #e8a470;
  --family-video: #6bc9ba;
  --family-generative: #e78da0;
  --family-world: #b59bdf;
  --family-language: #dbbd70;
  --family-geometry: #8caee5;
  --family-tactile: #adc686;
  --family-audio: #d6a2cb;
  color: var(--ink);
  color-scheme: dark;
  background: linear-gradient(to bottom, var(--archive-seam), var(--paper) 8rem, var(--paper) calc(100% - 8rem), #131c2a) var(--paper);
}
#study .probe-intro { color: var(--quiet) }
#study :is(.modality p, .finding-note p) { color: var(--result-text) }
#study :is(.probe-intro strong, .finding-note h3, .modality h4) { color: var(--ink) }
#study .probe-flow {
  position: relative;
  border-block: 1px solid var(--rule);
  padding-block: clamp(.9rem, 2vw, 1.65rem);
  margin-bottom: clamp(1.5rem, 3.4vw, 3.15rem);
  color: var(--ink);
}
#study .probe-flow-results span { border-color: var(--control-edge); color: var(--ink) }
#study .enc-controls .chart-switch { gap: .25rem; padding: 0; border: 0; background: transparent }
#study .enc-controls button {
  display: inline-flex; align-items: center; justify-content: start; gap: .55rem;
  min-height: 2.6rem; border: 0; border-radius: 0; padding: .5rem .7rem;
  color: var(--quiet); background: transparent; font: 600 .85rem/1.25 var(--body);
}
#study .enc-controls button::before {
  content: ""; flex: none; width: .55rem; aspect-ratio: 1; border-radius: 50%;
  border: 1px solid currentColor; box-sizing: border-box;
}
#study .enc-controls button:hover { color: var(--ink); background: var(--surface-inset) }
#study .enc-controls button[aria-pressed="true"] { color: #c8f6ed; background: #234347 }
#study .enc-controls button[aria-pressed="true"]::before { background: var(--read-accent); border-color: var(--read-accent) }
#study .enc-table .enc-hit.is-inspected .enc-disk { outline-offset: 3px }
#study .enc-insight { color: var(--read-accent); border-color: var(--read-accent) }
#study .enc-tooltip { background: var(--graphite); color: var(--on-graphite); border: 1px solid var(--control-edge); border-radius: 0 }
#study .enc-key { color: var(--quiet) }
@media (min-width: 1250px) {
  #study .encoded-matrix:has(.enc-controls:not([hidden])) {
    display: grid; grid-template-columns: 8.1rem minmax(0,1fr);
    column-gap: clamp(1rem, 2.3vw, 2.75rem);
    --enc-family-width: clamp(7.75rem,9.5vw,10rem);
    --enc-dot: clamp(1.7rem, 2.8vw, 2.7rem);
  }
  #study .enc-controls { align-self: start; margin: .35rem 0 0 }
  #study .enc-controls .chart-switch { display: grid; width: 100%; gap: .37rem; border-block: 1px solid var(--rule); padding-block: .55rem }
  #study .enc-controls button { width: 100% }
  #study .enc-stage { min-width: 0 }
  #study .encoded-matrix:has(.enc-controls:not([hidden])) figcaption { grid-column: 2 }
}
#study .finding-note { border-top-color: var(--rule) }
#study .finding-pair .finding-note {
  padding: clamp(1.1rem, 2vw, 1.8rem);
  background: var(--panel);
  border-top: 0;
}
#study .modalities { gap: clamp(1rem, 2.1vw, 2.25rem) }
#study .modality {
  display: block;
  padding: clamp(1rem, 1.65vw, 1.6rem);
  color: var(--ink);
  background: var(--modality-surface);
  border: 0;
  border-radius: .25rem;
  box-shadow: none;
}

#interventions.section {
  --paper: #080914; --panel: #121625; --surface-inset: #1b2936;
  --ink: #f3f2ef; --quiet: #bdc6d4; --rule: #444c60;
  --read-accent: #62f3e3; --control-edge: #788396;
  color: var(--ink); background: var(--paper); color-scheme: dark;
}
#interventions :is(h2, .probe-intro strong, .native h3, .native strong, .use-scatter h3, .native-result table) { color: var(--ink) }
#interventions :is(.probe-intro, .native h3 ~ p) { color: var(--body-copy) }
#interventions .use-scatter {
  --plot-ink: #e5e9f0; --plot-teal: #65f4dd; --plot-rule: #3e4b60;
  background: linear-gradient(118deg, #1b2939, #1b2537 86%);
  color: var(--ink); border: 1px solid var(--rule); border-top: 2px solid #739baf;
  border-radius: 0; box-shadow: none;
}
#interventions .intervention-tools { border-block: 1px solid var(--rule); padding-block: .8rem }
#interventions .chart-switch { border: 0; background: transparent; padding: 0; gap: .25rem }
#interventions .chart-switch button {
  padding: .45rem .7rem; min-height: 2.4rem; background: transparent;
  color: var(--quiet); border: 1px solid transparent; border-radius: .2rem;
}
#interventions .chart-switch button:hover { background: #242f40; color: var(--ink) }
#interventions .chart-switch button[aria-pressed="true"] { background: #71f6e5; color: #0e1c28; border-color: #71f6e5 }
#interventions .intervention-model select { color: var(--ink); background: #131b2b; border-radius: .15rem; }
#interventions .use-scatter__body { align-items: start; gap: clamp(1.25rem, 3vw, 3.5rem) }
#interventions .use-scatter__chart { padding-block: .65rem 0 }
#interventions .use-scatter__plot { height: clamp(13rem, 28cqw, 23rem); margin-top: .75rem }
#interventions .use-scatter__grid b { color: #c5cfdd; font-family: Arial,sans-serif }
#interventions .use-scatter__plot:has(.edit-highlight)::before,
#interventions .use-scatter__plot:has(.edit-highlight)::after {
  content: ""; position: absolute; z-index: 0; pointer-events: none;
}
#interventions .use-scatter__plot::before {
  left: calc(var(--inspect-r2) * 100% / 1.04); inset-block: 0;
  border-left: 1px dashed #709399;
}
#interventions .use-scatter__plot::after {
  bottom: calc((var(--inspect-loss) + .10) * 100% / 1.20); inset-inline: 0;
  border-bottom: 1px dashed #709399;
}
#interventions .use-scatter__points { z-index: 1 }
#interventions .use-scatter__points:has(.edit-highlight) { z-index: 2 }
#interventions .use-scatter__points li.edit-highlight { outline-color: #fff; outline-offset: 3px }
#interventions .use-scatter__sidebar { border: 0; padding: 0; min-width: 0; gap: 1.1rem }
#interventions .intervention-inspect {
  display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: start;
  margin: 0; padding: 1rem; gap: 1rem .5rem;
  background: #25394a; border: 1px solid #516e7a; border-left: 3px solid var(--read-accent);
}
#interventions .intervention-inspect[hidden] { display: none }
#interventions .edit-identity { grid-area: 1 / 1 }
#interventions .edit-identity strong { font: 500 clamp(1.2rem, 2.2vw, 1.8rem)/1.12 var(--serif) }
#interventions .edit-browse { grid-area: 1 / 2 }
#interventions .intervention-inspect dl { grid-area: 2 / 1 / 3 / -1; display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .55rem }
#interventions .intervention-inspect dl > div { border-top: 1px solid #637983; padding-top: .5rem }
#interventions .intervention-inspect dd { color: #a2fff1; font: 500 clamp(1.15rem,2vw,1.75rem)/1.25 Arial,sans-serif }
#interventions .use-scatter__key strong { font-size: clamp(1.12rem, 2vw, 1.7rem); line-height: 1.16 }
#interventions .loss-definition math { color: var(--ink) }
#interventions .native {
  border: 0; border-top: 1px solid #61717f; border-bottom: 1px solid var(--rule);
  background: #1c2839; border-radius: 0; box-shadow: none; align-items: center;
}
#interventions .native-result td { color: #ebfffa; font-family: Arial,sans-serif }
#interventions .native-result th { color: var(--ink) }
#interventions .native-result thead th { color: var(--quiet) }
@media (max-width: 800px) {
  #interventions .use-scatter__body { grid-template-columns: 1fr }
}
@media (max-width: 650px) {
  #study .enc-controls .chart-switch { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); width: 100%; gap: .15rem }
  #study .enc-controls button { padding: .45rem .3rem; gap: .3rem; font-size: .8rem }
  #interventions .use-scatter__plot { margin-left: 1.9rem; height: 14rem }
  #interventions .use-scatter__body { margin-bottom: 0 }
  #interventions .intervention-tools { display: grid; gap: .65rem; justify-content: stretch }
  #interventions .intervention-tools[hidden] { display: none }
  #interventions .intervention-tools .chart-switch { display: grid; grid-template-columns: 1.18fr .85fr 1fr 1fr }
  #interventions .intervention-tools .chart-switch button { padding-inline: .15rem; font-size: .8rem }
  #interventions .intervention-model { display: grid; grid-template-columns: auto minmax(0,1fr) }
}
@media print {
  #study.section {
    --ink: #171a2b; --result-text: #243344; --quiet: #485263; --read-accent: #006462;
    --modality-surface: #edf1f3; --panel: #f3f5f6;
    --family-image: #a35526; --family-video: #116d69; --family-generative: #a03961;
    --family-world: #715098; --family-language: #796019; --family-geometry: #3f5987;
    --family-tactile: #486729; --family-audio: #80437f;
    color-scheme: light; background: white;
  }
  #study .enc-disk { print-color-adjust: exact }
  #interventions.section { print-color-adjust: exact }
}
