:root {
  --bg: #ffffff;
  --text: #1f2421;
  --muted: #809694;
  --accent-red: #ef2d37;
  --accent-blue: #2e86f2;
  --line: rgba(31, 36, 33, 0.16);
  --line-strong: rgba(31, 36, 33, 0.28);
  --salary: #ef2d37;
  --postdocs: #2e86f2;
  --grads: rgba(46, 134, 242, 0.45);
  --ops: #809694;
  --writing: #ef2d37;
  --mentoring: #2e86f2;
  --hard-money: rgba(46, 134, 242, 0.42);
  --service: rgba(239, 45, 55, 0.38);
  --buffer: rgba(31, 36, 33, 0.14);
  --positive: rgba(46, 134, 242, 0.26);
  --negative: rgba(239, 45, 55, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
}

.ambient {
  display: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, calc(100% - 72px));
  margin: 52px auto 96px;
}

.panel {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.hero {
  padding-bottom: 24px;
}

.stat-label {
  font-size: 0.82rem;
  line-height: 1.2;
  letter-spacing: 0.06em;
  text-transform: none;
  font-weight: 500;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  max-width: none;
  font-size: clamp(1.55rem, 3.2vw, 3rem);
  line-height: 0.95;
  letter-spacing: -0.045em;
  font-weight: 500;
  white-space: nowrap;
}

.stat-meta,
.section-head span,
.legend-item span,
.chart-note,
.forecast-card span,
.assumptions li {
  color: var(--muted);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(220px, 240px) minmax(0, 1fr);
  gap: 72px;
  align-items: start;
}

.story-flow {
  display: grid;
  gap: 72px;
}

.stage-card[hidden] {
  display: none;
}

.stage-card {
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.stage-card > .section-head {
  margin-bottom: 20px;
}

.stage-split {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 40px;
  align-items: start;
}

.stage-main {
  min-width: 0;
}

.stage-image {
  margin: 0;
}

.stage-image img {
  display: block;
  width: 100%;
  height: auto;
}

.stage-intro {
  max-width: 44rem;
  margin-bottom: 28px;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
}

.stage-controls,
.advanced-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px 28px;
  align-items: end;
}

.stage-controls .control + .control,
.advanced-grid .control + .control {
  margin-top: 0;
}

.stage-controls-compact {
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.preview-card {
  margin-top: 30px;
}

.probability-summary {
  margin-bottom: 20px;
}

.stage-button {
  margin-top: 26px;
  padding: 10px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.stage-button:hover {
  background: var(--accent-blue);
  border-color: var(--accent-blue);
  color: #ffffff;
}

a {
  color: inherit;
  transition: color 160ms ease;
}

a:hover {
  color: var(--accent-blue);
}

.controls-panel {
  position: sticky;
  top: 32px;
  font-size: 0.92rem;
}

.controls-panel .section-head {
  gap: 12px;
  padding-top: 0;
  margin-bottom: 16px;
}

.controls-panel .section-head h2 {
  font-size: 0.76rem;
}

.controls-panel .section-head span {
  font-size: 0.74rem;
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  padding-top: 0;
  margin-bottom: 18px;
}

.section-head h2 {
  color: var(--accent-blue);
  font-size: 1rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.section-head span {
  font-size: 0.74rem;
  line-height: 1.35;
}

.stage-card > .section-head h2 {
  color: var(--text);
  font-size: clamp(1.7rem, 3vw, 2.5rem);
  line-height: 0.95;
  letter-spacing: -0.05em;
}

.control + .control {
  margin-top: 16px;
}

.control-top {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 6px;
}

.control-top label,
.control-top output {
  font-size: 0.82rem;
}

.control-top output {
  color: var(--text);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

input,
button,
textarea,
select {
  font: inherit;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 1px;
  background: var(--line-strong);
}

input[type="range"]::-moz-range-track {
  height: 1px;
  background: var(--line-strong);
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5.5px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
}

input:focus,
input:focus-visible {
  outline: none;
  border-color: var(--text);
}

.assumptions {
  margin-top: 36px;
}

.assumptions ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.assumptions li {
  position: relative;
  padding-left: 16px;
  font-size: 0.8rem;
  line-height: 1.55;
}

.assumptions li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.72em;
  width: 6px;
  height: 1px;
  background: var(--muted);
}

.results-column {
  display: grid;
  gap: 76px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 34px 48px;
}

.stat-card {
  padding-top: 0;
  border-top: 0;
}

.stat-label {
  color: var(--accent-blue);
}

.stat-value {
  margin: 18px 0 10px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: clamp(1.6rem, 2.4vw, 2.45rem);
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.stat-meta {
  max-width: 26rem;
  font-size: 0.88rem;
  line-height: 1.65;
}

.chart-grid {
  display: grid;
  gap: 72px;
}

.chart-card {
  padding: 0;
}

.chart-card .section-head {
  margin-bottom: 26px;
}

.stacked-bar {
  display: flex;
  width: 100%;
  min-height: 10px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(31, 36, 33, 0.08);
}

.time-bars {
  display: grid;
  gap: 10px;
}

.time-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) 56px;
  gap: 12px;
  align-items: center;
}

.time-year,
.time-total {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.78rem;
}

.time-total {
  text-align: right;
}

.time-track {
  display: flex;
  min-height: 10px;
  background: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(31, 36, 33, 0.08);
}

.time-slice {
  transition: width 550ms cubic-bezier(0.22, 1, 0.36, 1);
}

.time-bar {
  min-height: 12px;
}

.segment {
  transition: width 550ms cubic-bezier(0.22, 1, 0.36, 1);
}

.segment-salary {
  background: var(--salary);
}

.segment-postdocs {
  background: var(--postdocs);
}

.segment-grads {
  background: var(--grads);
}

.segment-ops {
  background: var(--ops);
}

.segment-writing {
  background: var(--writing);
}

.segment-mentoring {
  background: var(--mentoring);
}

.segment-service {
  background: var(--service);
}

.segment-buffer {
  background: var(--buffer);
}

.legend {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.legend-item {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.legend-swatch {
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
}

.legend-line {
  width: 22px;
  height: 0;
  border-top: 2px solid var(--text);
  position: relative;
  flex: 0 0 auto;
}

.legend-line::after {
  content: "";
  position: absolute;
  top: -4px;
  left: 9px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.legend-line-active {
  color: var(--accent-blue);
  border-top-color: var(--accent-blue);
}

.legend-line-admitted {
  color: var(--accent-red);
  border-top-color: var(--accent-red);
}

.legend-line-alumni-postdoc {
  color: var(--muted);
  border-top: 2px dashed var(--muted);
}

.legend-line-alumni-grad {
  color: var(--muted);
  border-top: 2px dotted var(--muted);
}

.legend-lab {
  margin-top: 0;
  margin-bottom: 16px;
}

.legend-chart {
  margin-top: 0;
  margin-bottom: 16px;
}

.legend-line-new {
  color: var(--accent-red);
  border-top-color: var(--accent-red);
}

.legend-line-renewal {
  color: var(--accent-blue);
  border-top-color: var(--accent-blue);
}

.legend-line-award-new {
  color: var(--accent-red);
  border-top: 2px dashed var(--accent-red);
}

.legend-line-award-renewal {
  color: var(--accent-blue);
  border-top: 2px dashed var(--accent-blue);
}

.r01-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.r01-chip {
  padding-top: 0;
  border-top: 0;
  transition: transform 200ms ease;
}

.r01-chip strong {
  display: block;
  margin-bottom: 8px;
  font-size: 0.96rem;
  font-weight: 500;
}

.r01-chip span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.55;
}

.r01-chip:hover {
  transform: translateY(-2px);
}

.chart-note {
  margin-top: 18px;
  max-width: 34rem;
  font-size: 0.85rem;
  line-height: 1.65;
}

#publicationPreviewChart,
#fundingChanceChart,
#forecastChart {
  display: block;
  width: 100%;
  height: auto;
}

.forecast-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.forecast-card {
  padding-top: 0;
  border-top: 0;
  display: grid;
  gap: 8px;
}

.forecast-card strong {
  color: var(--accent-red);
  font-weight: 500;
}

.forecast-card b {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-weight: 500;
  color: var(--text);
}

#submissionTimelineChart {
  display: block;
  width: 100%;
  height: auto;
}

#cumulativeSubmissionChart {
  display: block;
  width: 100%;
  height: auto;
}

#cumulativeAwardChart {
  display: block;
  width: 100%;
  height: auto;
}

#labSizeChart {
  display: block;
  width: 100%;
  height: auto;
}

#publicationsChart {
  display: block;
  width: 100%;
  height: auto;
}

.timeline-line {
  fill: none;
  stroke-width: 2.25;
}

.timeline-line-new {
  stroke: var(--accent-red);
}

.timeline-line-renewal {
  stroke: var(--accent-blue);
}

.timeline-line-total {
  stroke: var(--text);
}

.timeline-line-award {
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.timeline-line-award-new {
  stroke: var(--accent-red);
}

.timeline-line-award-renewal {
  stroke: var(--accent-blue);
}

.timeline-bar {
  shape-rendering: crispEdges;
}

.timeline-bar-new {
  fill: var(--accent-red);
}

.timeline-bar-renewal {
  fill: var(--accent-blue);
}

.timeline-dot {
  fill: var(--bg);
  stroke-width: 1.5;
}

.chart-hit-zone {
  fill: transparent;
  stroke: transparent;
  pointer-events: all;
}

.chart-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  width: min(280px, calc(100vw - 32px));
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid rgba(31, 36, 33, 0.16);
  box-shadow: 0 18px 32px rgba(31, 36, 33, 0.12);
  pointer-events: none;
}

.chart-tooltip[hidden] {
  display: none;
}

.chart-tooltip-title {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text);
}

.chart-tooltip-body {
  margin-top: 8px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--muted);
}

.chart-tooltip-line + .chart-tooltip-line {
  margin-top: 4px;
}

.chart-tooltip-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-tooltip-swatch {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: 0 0 auto;
}

.timeline-dot-new {
  stroke: var(--accent-red);
}

.timeline-dot-renewal {
  stroke: var(--accent-blue);
}

.timeline-dot-total {
  stroke: var(--text);
}

.timeline-dot-new-award {
  stroke: var(--accent-red);
}

.timeline-dot-renewal-award {
  stroke: var(--accent-blue);
}

.timeline-grid-line {
  stroke: rgba(31, 36, 33, 0.09);
  stroke-width: 1;
}

.timeline-legend-label {
  fill: var(--accent-red);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 12px;
}

.timeline-legend-label-total {
  fill: var(--text);
}

.timeline-legend-label-renewal {
  fill: var(--accent-blue);
}

.lab-line {
  fill: none;
  stroke: var(--accent-blue);
  stroke-width: 2.25;
}

.lab-line-admitted {
  stroke: var(--accent-red);
}

.lab-dot {
  stroke: #ffffff;
  stroke-width: 1.25;
}

.lab-dot-active {
  fill: var(--accent-blue);
}

.lab-dot-admitted {
  fill: var(--accent-red);
}

.lab-dot-alumni-postdoc,
.lab-dot-alumni-grad {
  fill: var(--muted);
}

.lab-line-alumni-postdoc {
  stroke: var(--muted);
  stroke-dasharray: 3 3;
}

.lab-line-alumni-grad {
  stroke: var(--muted);
  stroke-dasharray: 8 3 1 3;
}

.lab-grid-line {
  stroke: rgba(31, 36, 33, 0.09);
  stroke-width: 1;
}

.lab-year-line,
.pub-year-line,
.timeline-year-line,
.forecast-year-line {
  stroke: rgba(31, 36, 33, 0.08);
  stroke-width: 1;
}

.lab-tick-label {
  fill: var(--muted);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 12px;
}

.lab-legend-label {
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 12px;
}

.lab-legend-label-active {
  fill: var(--accent-blue);
}

.lab-legend-label-admitted {
  fill: var(--accent-red);
}

.lab-legend-label-alumni-postdoc {
  fill: var(--muted);
}

.lab-legend-label-alumni-grad {
  fill: var(--muted);
}

.pub-line {
  fill: none;
  stroke: var(--accent-blue);
  stroke-width: 2.25;
}

.chance-line {
  stroke: var(--text);
}

.chance-highlight-line {
  stroke: rgba(31, 36, 33, 0.18);
  stroke-width: 1;
}

.chance-highlight-dot {
  fill: var(--bg);
  stroke: var(--accent-red);
  stroke-width: 1.5;
}

.pub-dot {
  fill: var(--bg);
  stroke: var(--accent-blue);
  stroke-width: 1.5;
}

.pub-grid-line {
  stroke: rgba(31, 36, 33, 0.09);
  stroke-width: 1;
}

.pub-tick-label {
  fill: var(--muted);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 12px;
}

.timeline-tick-label,
.timeline-point-label {
  fill: var(--muted);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 12px;
}

@media (max-width: 720px) {
  .time-row {
    grid-template-columns: 34px minmax(0, 1fr) 50px;
    gap: 10px;
  }
}

.axis-label,
.tick-label,
.forecast-annotation {
  fill: var(--muted);
  font-family: "IBM Plex Sans", system-ui, sans-serif;
  font-size: 12px;
}

.forecast-line {
  fill: none;
  stroke: var(--text);
  stroke-width: 2.25;
}

.forecast-dot {
  fill: var(--bg);
  stroke: var(--text);
  stroke-width: 1.5;
}

.forecast-bar-positive {
  fill: var(--positive);
}

.forecast-bar-negative {
  fill: var(--negative);
}

.forecast-grid-line {
  stroke: rgba(31, 36, 33, 0.09);
  stroke-width: 1;
}

.forecast-zero-line {
  stroke: rgba(31, 36, 33, 0.28);
  stroke-width: 1;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero,
.controls-panel,
.stat-card,
.chart-card {
  animation: rise 520ms ease-out both;
}

@media (max-width: 980px) {
  .app-shell {
    width: min(100% - 40px, 1080px);
  }

  .stage-split {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .layout-grid {
    grid-template-columns: 1fr;
    gap: 52px;
  }

  .controls-panel {
    position: static;
  }

  .forecast-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 28px, 1080px);
    margin-top: 28px;
  }

  .hero {
    padding-bottom: 54px;
  }

  .stats-grid,
  .legend,
  .forecast-grid {
    grid-template-columns: 1fr;
  }

  .r01-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
