:root {
  --bg: #f5efe3;
  --panel: rgba(255, 251, 245, 0.84);
  --panel-strong: rgba(255, 251, 245, 0.94);
  --ink: #1f2933;
  --muted: #5a6872;
  --line: rgba(31, 41, 51, 0.12);
  --teal: #0f766e;
  --teal-soft: rgba(15, 118, 110, 0.14);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.12);
  --rose: #b91c1c;
  --navy: #123247;
  --shadow: 0 20px 60px rgba(18, 50, 71, 0.12);
  --display:
    "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  --ui: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--ui);
  color: var(--ink);
  background:
    radial-gradient(
      circle at top left,
      rgba(15, 118, 110, 0.18),
      transparent 28%
    ),
    radial-gradient(
      circle at top right,
      rgba(217, 119, 6, 0.15),
      transparent 24%
    ),
    linear-gradient(180deg, #f8f2e9 0%, #efe3d3 100%);
  overflow-x: hidden;
}

.page-glow {
  position: fixed;
  width: 28rem;
  height: 28rem;
  border-radius: 999px;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.48;
  z-index: 0;
}

.page-glow-left {
  top: -8rem;
  left: -8rem;
  background: rgba(15, 118, 110, 0.22);
}

.page-glow-right {
  right: -8rem;
  bottom: 10rem;
  background: rgba(217, 119, 6, 0.18);
}

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1500px;
  margin: 0 auto;
  padding: 28px 24px 56px;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 26px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  padding: 28px;
  overflow: hidden;
  position: relative;
}

.hero-copy-block {
  align-self: stretch;
}

.hero::after {
  content: "";
  position: absolute;
  inset: auto -5% -30% 35%;
  height: 180px;
  background: linear-gradient(
    90deg,
    rgba(15, 118, 110, 0.14),
    rgba(217, 119, 6, 0.08)
  );
  transform: rotate(-6deg);
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.73rem;
  font-weight: 700;
  color: var(--teal);
}

h1,
h2,
h3 {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
}

h1 {
  font-size: clamp(2.4rem, 4vw, 4.4rem);
  line-height: 0.92;
  max-width: 49ch;
  color: var(--navy);
}

h2 {
  font-size: 1.7rem;
  color: var(--navy);
}

h3 {
  font-size: 1rem;
  color: var(--navy);
}

.hero-copy {
  max-width: 62ch;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.65;
  margin: 14px 0 0;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  align-self: stretch;
  align-content: start;
}

.metric-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 16px 18px 14px;
}

.metric-card strong {
  display: block;
  font-size: 1.5rem;
  color: var(--navy);
}

.metric-card span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.4;
}

.studio-layout,
.analysis-grid,
.insight-stack,
.context-row,
.insight-grid {
  display: grid;
  gap: 22px;
  margin-top: 22px;
}

.studio-layout {
  grid-template-columns: 260px minmax(0, 1fr);
  align-items: stretch;
}

.studio-main {
  display: grid;
  gap: 22px;
}

.studio-main > .analysis-grid {
  margin-top: 0;
}

.analysis-grid {
  grid-template-columns: minmax(0, 1.9fr) 320px;
  align-items: stretch;
}

.insight-stack {
  margin-top: 0;
  display: flex;
  flex-direction: column;
}

.insight-stack > .decision-panel {
  flex: 1;
}

.context-row {
  margin-top: 22px;
}

.controls-band {
  margin-top: 22px;
}

.insight-grid {
  grid-template-columns: 1fr 1fr;
}

.panel-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 18px;
}

.panel-head-compact {
  margin-bottom: 14px;
}

.panel-head .eyebrow {
  margin-bottom: 0;
}

.rail-panel,
.panel-main,
.decision-panel,
.controls-band,
.context-row > .panel,
.insight-grid > .panel {
  padding: 24px;
}

.rail-panel {
  position: sticky;
  top: 24px;
}

.student-list,
.decision-scroll {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 190px);
  overflow: auto;
  padding-right: 6px;
}

.student-list {
  padding-top: 4px;
  padding-bottom: 6px;
}

.student-card {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.58);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.student-card:hover,
.student-card.active {
  transform: translateY(-2px);
  border-color: rgba(15, 118, 110, 0.45);
  box-shadow: 0 14px 34px rgba(15, 118, 110, 0.12);
}

.student-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.student-card-name {
  font-weight: 700;
}

.student-card-score {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 3px;
}

.risk-pill,
.delta-pill,
.tag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(18, 50, 71, 0.08);
  color: var(--navy);
}

.risk-critical,
.delta-negative {
  background: rgba(185, 28, 28, 0.12);
  color: var(--rose);
}

.risk-watch {
  background: var(--amber-soft);
  color: var(--amber);
}

.risk-stable,
.delta-positive {
  background: var(--teal-soft);
  color: var(--teal);
}

.risk-strong {
  background: rgba(18, 50, 71, 0.1);
  color: var(--navy);
}

.score-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.panel-main {
  padding: 26px 26px 22px;
  display: flex;
  flex-direction: column;
}
#scoreSummary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.score-tile {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
}

.score-tile > strong {
  display: block;
  font-size: 1.55rem;
  color: var(--navy);
}

.score-tile > span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.score-meta {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(31, 41, 51, 0.08);
}

.score-meta div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.score-meta label {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.score-meta b {
  color: var(--navy);
  font-size: 0.86rem;
}

.score-meta .tag-pill {
  justify-self: end;
}

.scenario-feedback {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(18, 50, 71, 0.06);
}

.scenario-feedback strong,
.scenario-feedback span {
  display: block;
}

.scenario-feedback strong {
  color: var(--navy);
  font-size: 0.96rem;
}

.scenario-feedback span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.scenario-feedback.is-success {
  background: rgba(15, 118, 110, 0.1);
  border-color: rgba(15, 118, 110, 0.18);
}

.scenario-feedback.is-edited {
  background: rgba(217, 119, 6, 0.09);
  border-color: rgba(217, 119, 6, 0.14);
}

.scenario-feedback.is-neutral {
  background: rgba(18, 50, 71, 0.06);
}

#predictionChart {
  width: 100%;
  flex: 1;
  min-height: 0;
  display: block;
}

#scatterChart,
#correlationChart {
  width: 100%;
  height: auto;
  display: block;
}

.recommendations,
.coefficient-list {
  display: grid;
  gap: 10px;
}

.recommendation-card,
.coefficient-card,
.control-card,
.context-card {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.recommendation-card-header,
.coefficient-card-header,
.context-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.recommendation-card p,
.coefficient-card p,
.control-card p,
.context-card p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.92rem;
}

.subsection {
  margin-top: 18px;
}

.recommendation-actions {
  margin-top: 12px;
}

.recommendation-card-empty {
  background: rgba(18, 50, 71, 0.04);
}

.recommendation-apply {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: var(--teal);
  color: white;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    background 180ms ease;
}

.recommendation-apply:hover {
  transform: translateY(-1px);
  background: #0c635c;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.16);
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 18px;
}

.preset-button,
.reset-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(18, 50, 71, 0.08);
  color: var(--navy);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease;
}

.reset-button {
  color: rgba(255, 0, 0, 0.8);
}

.preset-button:hover,
.reset-button:hover {
  transform: translateY(-1px);
  background: rgba(15, 118, 110, 0.14);
}

.controls-grid-inner,
.context-grid {
  display: grid;
  gap: 12px;
}

.controls-grid-band {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.control-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.control-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.control-side-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-info-inline {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 1px solid rgba(18, 50, 71, 0.2);
  background: rgba(255, 255, 255, 0.82);
  color: var(--navy);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease;
}

.control-info-inline:hover {
  transform: translateY(-1px);
  border-color: rgba(15, 118, 110, 0.4);
  box-shadow: 0 8px 14px rgba(18, 50, 71, 0.14);
}

.control-state {
  padding-inline: 8px;
}

.control-value {
  color: var(--navy);
  font-size: 1rem;
  font-weight: 700;
}

.control-card.changed {
  border-color: rgba(15, 118, 110, 0.24);
  box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.08);
}

.control-card.focused {
  border-color: rgba(15, 118, 110, 0.44);
  box-shadow: 0 18px 32px rgba(15, 118, 110, 0.12);
}

.controls-band .control-card,
.decision-panel .recommendation-card,
.decision-panel .coefficient-card {
  background: rgba(255, 255, 255, 0.72);
}

.decision-panel {
  position: sticky;
  top: 24px;
}

.control-card strong,
.context-card strong,
.recommendation-card strong,
.coefficient-card strong {
  display: block;
}

.cohort-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 50, 71, 0.42);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
  z-index: 90;
}

.cohort-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.cohort-modal {
  width: min(80vw, 1200px);
  height: min(80vh, 860px);
  background: rgba(255, 251, 245, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 24px;
  box-shadow: 0 24px 70px rgba(18, 50, 71, 0.28);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.cohort-modal-header {
  padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}

.cohort-modal-body {
  padding: 16px 22px;
  display: grid;
  grid-template-rows: minmax(240px, 1fr) auto;
  gap: 14px;
  min-height: 0;
}

.cohort-modal-chart {
  position: relative;
  min-height: 0;
  height: 100%;
  display: flex;
  justify-content: center;
}

#modalScatterChart {
  width: 100%;
  height: 100%;
  max-height: none;
  display: block;
}

.chart-tooltip {
  position: absolute;
  pointer-events: none;
  opacity: 0;
  background: white;
  border: 0.5px solid #ccc;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  transition: opacity 0.15s;
  white-space: nowrap;
  z-index: 10;
}

.cohort-modal-controls-wrap {
  border-top: 1px solid var(--line);
  padding-top: 12px;
  display: grid;
  gap: 10px;
}

.cohort-modal-controls-wrap h3 {
  font-size: 0.95rem;
}

.modal-controls-grid {
  min-height: 82px;
}

.modal-focus-control {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px 14px;
}

.modal-focus-control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.modal-focus-control-empty {
  color: var(--muted);
  font-size: 0.92rem;
}

.cohort-modal-footer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
}

.cohort-modal-done {
  border: 0;
  border-radius: 999px;
  padding: 10px 20px;
  background: var(--teal);
  color: white;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.cohort-modal-done:hover {
  transform: translateY(-1px);
  background: #0c635c;
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
}

input[type="range"] {
  width: 100%;
  margin-top: 12px;
  accent-color: var(--teal);
}

select {
  width: 100%;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fffdf8;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.96rem;
}

.chart-label,
.axis-label {
  fill: var(--muted);
  font-size: 14px;
}

.chart-title {
  fill: var(--navy);
  font-size: 16px;
  font-weight: 700;
}

.chart-subtitle {
  fill: var(--muted);
  font-size: 12px;
}

.axis-line,
.grid-line {
  stroke: rgba(31, 41, 51, 0.12);
  stroke-width: 1;
}

.baseline-line {
  stroke: var(--amber);
  fill: none;
  stroke-width: 3;
}

.scenario-line {
  stroke: var(--teal);
  fill: none;
  stroke-width: 3;
}

.baseline-fill {
  fill: rgba(217, 119, 6, 0.16);
}

.scenario-fill {
  fill: rgba(15, 118, 110, 0.16);
}

.baseline-fail-fill {
  fill: rgba(217, 119, 6, 0.34);
}

.scenario-fail-fill {
  fill: rgba(15, 118, 110, 0.34);
}

.baseline-rug,
.scenario-rug {
  stroke-width: 1;
  opacity: 0.22;
}

.baseline-rug {
  stroke: var(--amber);
}

.scenario-rug {
  stroke: var(--teal);
}

.reveal {
  opacity: 0;
  transform: translateY(12px);
  animation: rise 650ms ease forwards;
}

.studio-layout > :nth-child(2) {
  animation-delay: 90ms;
}

.analysis-grid > :nth-child(2) {
  animation-delay: 160ms;
}

.controls-band {
  animation-delay: 280ms;
}

.context-row > :nth-child(1) {
  animation-delay: 340ms;
}

.insight-grid > :nth-child(1) {
  animation-delay: 400ms;
}

.insight-grid > :nth-child(2) {
  animation-delay: 460ms;
}

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

@media (max-width: 1200px) {
  .studio-layout,
  .analysis-grid,
  .insight-stack,
  .context-row,
  .insight-grid,
  .hero {
    grid-template-columns: 1fr;
  }

  .hero-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-self: stretch;
    align-content: start;
  }

  .rail-panel {
    position: static;
  }

  .decision-panel {
    position: static;
  }

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

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

@media (max-width: 720px) {
  .app-shell {
    padding: 16px 14px 32px;
  }

  .panel,
  .hero,
  .rail-panel,
  .panel-main,
  .decision-panel,
  .controls-band,
  .context-row > .panel,
  .insight-grid > .panel,
  .analysis-grid > .panel {
    border-radius: 20px;
  }

  .hero-metrics,
  .controls-grid-band,
  .context-grid,
  .score-summary {
    grid-template-columns: 1fr;
  }

  .student-list {
    max-height: none;
  }

  .cohort-modal-overlay {
    padding: 12px;
  }

  .cohort-modal {
    width: 94vw;
    height: 90vh;
  }
}
