.scale-story {
  --scale-compact: 1;
  --story-column-gap: 40px;
  --story-header-height: 40px;
  --story-headline-top: 8px;
  margin: 0;
}

.scale-story-layout {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 9fr);
  align-items: start;
  align-content: start;
  gap: var(--story-column-gap);
}

.scale-story-episode,
.scale-story-charts {
  min-width: 0;
  margin: 0;
}

.scale-story-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--story-header-height);
  margin: 0 0 12px;
}

.scale-story-toolbar h4,
.scale-story-chart-heading {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}

.scale-story-toolbar h4 span,
.scale-story-chart-heading span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
  white-space: nowrap;
}

.scale-story-correlation {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin: 0;
}

.scale-story-correlation h3 {
  margin: 0;
  color: var(--ink);
  font-size: var(--story-headline-size, 22px);
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
}

.scale-story-correlation a {
  display: block;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
}

.scale-story-correlation a:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 5px;
}

.scale-story-correlation img,
.scale-story-correlation svg {
  display: block;
  width: 100%;
  height: auto;
}

.scale-story[data-scale-ready] .scale-story-correlation {
  position: absolute;
  top: var(--story-evidence-top, 44px);
  right: var(--story-evidence-right, 0px);
  width: var(--story-evidence-width, 48%);
  height: var(--story-evidence-height);
  justify-content: flex-start;
  opacity: 0;
  visibility: hidden;
}

.scale-story-correlation h3 strong {
  color: var(--blue);
  font-weight: 700;
}

.scale-story[data-scale-ready] .scale-story-correlation h3 {
  position: absolute;
  top: var(--story-evidence-heading-offset, -52px);
  left: 0;
  width: 100%;
  opacity: 0;
}

.scale-story[data-scale-ready] .scale-story-correlation a,
.scale-story[data-scale-ready] .scale-story-correlation svg {
  height: 100%;
}

.scale-story-video {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1;
  border-radius: 6px;
  background: #eeeee8;
}

.scale-story-video video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scale-story-actions {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scale-story-actions svg {
  display: block;
  width: 100%;
  height: 100%;
}

.scale-story-episode-note {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  margin-top: 10px;
  min-height: 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.scale-story-stage {
  color: #72766f;
}

.scale-story-charts {
  position: relative;
  transform-origin: 0 0;
  min-height: var(--scale-chart-height, clamp(340px, 45vw, 440px));
}

.scale-story-connectors {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}

.scale-story-takeaway {
  position: absolute;
  top: var(--story-headline-top);
  right: auto;
  width: max-content;
  margin: 0;
  color: var(--ink);
  text-align: left;
  font-size: 22px;
  line-height: 1.3;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
}

.scale-story-takeaway strong {
  display: inline;
  color: var(--blue);
  font-size: inherit;
  font-weight: 700;
}

.scale-story-takeaway span {
  display: inline;
  font-size: inherit;
  font-weight: 400;
}

.scale-story-chart-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: var(--story-header-height);
  padding-left: 9.0625%;
  margin-bottom: 12px;
  color: var(--muted);
}

.scale-story-progress > svg,
.scale-story-progress > img,
.scale-story-mixture > svg,
.scale-story-mixture > img {
  display: block;
  width: 100%;
  height: auto;
}

.scale-story-mixture {
  overflow: hidden;
  margin-top: 12px;
}

.scale-story-mixture-fallback {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  text-align: center;
}

.scale-story-explanation {
  display: grid;
  gap: 10px;
  margin: 28px 0 0;
  max-width: none;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.65;
  text-align: left;
  text-wrap: pretty;
}

.scale-story-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  max-width: 100%;
  color: #72766f;
}

.scale-story-step-number {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: 3px 0 0;
  padding: 0;
  border: 1px solid #bdc8ce;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  transition: color .2s, background-color .2s, border-color .2s;
}

/* A comfortable hit target without enlarging the small numbered markers. */
.scale-story-step-number::after {
  content: "";
  position: absolute;
  inset: -6px -8px;
}

.scale-story-step-number:disabled {
  cursor: default;
}

.scale-story-step-number:not(:disabled):hover,
.scale-story-step-number[aria-current="step"] {
  background: #2b679a;
  border-color: #2b679a;
  color: var(--paper);
}

.scale-story-step-number:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 4px;
}

.scale-story-step-copy {
  transition: color .35s ease;
}

.scale-story-step[data-step-state="complete"] .scale-story-step-copy {
  color: #536f63;
}

.scale-story-step[data-step-state="complete"] .scale-story-step-number:not(:hover) {
  color: #397f6b;
  border-color: #9bbdb0;
  background: #edf4ee;
}

.scale-story-step[data-step-state="active"] .scale-story-step-copy {
  color: #2b679a;
}

@media (prefers-reduced-motion: reduce) {
  .scale-story-step-copy,
  .scale-story-step-number {
    transition: none;
  }
}

.analysis-evidence-grid {
  margin-top: var(--content-space);
}

.analysis-evidence-plot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 250px;
}

.analysis-evidence-plot .scales-explorer {
  width: 100%;
}

.analysis-evidence-correlation .analysis-evidence-plot > a {
  width: 100%;
  max-width: 330px;
}

@media (min-width: 761px) and (max-width: 1000px) {
  .scale-story {
    --story-column-gap: 28px;
  }

  .scale-story-layout {
    grid-template-columns: minmax(0, 4fr) minmax(0, 7fr);
  }

  .scale-story-charts {
    min-height: var(--scale-chart-height, 360px);
  }
}

@media (max-width: 760px) {
  .scale-story-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .scale-story-episode {
    width: 100%;
    max-width: 280px;
    margin: 0 auto;
  }

  .scale-story-charts {
    min-height: var(--scale-chart-height, 420px);
    width: 100%;
    max-width: 576px;
    margin: 0 auto;
  }

  .analysis-evidence-plot {
    height: auto;
  }

  .analysis-evidence-grid {
    gap: 36px;
  }
}

@media (max-width: 1100px) {
  .scale-story-episode-note {
    min-height: 40px;
  }

  .scale-story {
    --story-header-height: 64px;
  }

  .scale-story-toolbar,
  .scale-story-chart-heading {
    align-items: flex-end;
  }

  .scale-story-takeaway {
    font-size: clamp(16px, 4.8vw, 22px);
  }
}

@media (max-width: 760px) {
  .scale-story {
    --story-header-height: 32px;
  }

  .scale-story-episode-note {
    min-height: 40px;
  }

  .scale-story-explanation {
    gap: 12px;
    font-size: 17px;
    line-height: 1.6;
  }

  .scale-story-step-number {
    margin-top: 2px;
  }
}
