:root {
  --bg: #f5f1e8;
  --paper: rgba(255, 252, 246, 0.92);
  --paper-strong: rgba(255, 252, 246, 0.98);
  --stroke: rgba(39, 42, 50, 0.14);
  --ink: #1c2230;
  --muted: #5f6775;
  --accent: #4169e1;
  --accent-deep: #000080;
  --accent-cool: #4169e1;
  --pre-fill: rgba(255, 240, 245, 0.86);
  --post-fill: rgba(240, 255, 240, 0.86);
  --basin-fill: rgba(65, 105, 225, 0.14);
  --pre-ink: #8b0000;
  --post-ink: #006400;
  --basin-ink: #000080;
  --rcp-ink: #ff0000;
  --traj-ink: rgba(128, 128, 128, 0.72);
  --shadow: 0 18px 40px rgba(28, 34, 48, 0.08);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --font-sans: "Avenir Next", "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top right, rgba(212, 91, 51, 0.18), transparent 30%),
    radial-gradient(circle at bottom left, rgba(15, 108, 116, 0.16), transparent 28%),
    linear-gradient(180deg, #f7f2ea 0%, #efe8db 100%);
  color: var(--ink);
  font-family: var(--font-sans);
}

body {
  padding: 28px;
}

.page-shell {
  max-width: 1560px;
  margin: 0 auto;
  display: grid;
  gap: 20px;
}

.page-shell > * {
  min-width: 0;
}

.hero {
  display: block;
}

.hero-copy,
.card,
.hero-question {
  background: var(--paper);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-copy {
  padding: 34px 36px;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(23rem, 0.88fr);
  column-gap: clamp(28px, 4vw, 80px);
  row-gap: 18px;
  align-items: center;
}

.hero-copy > * {
  min-width: 0;
}

.hero-intro {
  display: grid;
  gap: 14px;
  min-width: 0;
}

.hero-intro .eyebrow {
  margin: 0;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--accent-deep);
  font-weight: 700;
}

.hero h1,
.card h2,
.hero-question h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.hero h1 {
  font-size: clamp(2.05rem, 2.8vw, 3.25rem);
  line-height: 1.04;
  max-width: none;
  white-space: normal;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.hero-text {
  margin: 0;
  max-width: 34ch;
  justify-self: end;
  padding-left: clamp(18px, 2vw, 28px);
  border-left: 1px solid rgba(39, 42, 50, 0.14);
  line-height: 1.74;
  color: var(--muted);
  font-size: 1.02rem;
  text-wrap: pretty;
}

.prompt-row-card {
  padding: 20px;
}

.toolbar {
  padding: 16px 18px;
  display: grid;
  grid-template-columns: minmax(170px, 220px) auto minmax(420px, 1fr) minmax(150px, 180px);
  gap: 22px;
  align-items: start;
}

.toolbar-group {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
}

.toolbar-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}

.toolbar-label-placeholder {
  visibility: hidden;
}

.playback-stack {
  grid-template-rows: auto auto;
}

.toolbar select {
  min-height: 42px;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--paper-strong);
  padding: 0 14px;
  font: inherit;
  color: var(--ink);
}

.playback-group {
  display: grid;
  grid-template-columns: repeat(3, auto);
  align-items: center;
  gap: 12px;
}

.primary-btn,
.ghost-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease;
}

.primary-btn {
  border: 0;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-deep) 100%);
  color: white;
}

.ghost-btn {
  border: 1px solid var(--stroke);
  background: var(--paper-strong);
  color: var(--ink);
}

.primary-btn:hover,
.ghost-btn:hover {
  transform: translateY(-1px);
}

.slider-group {
  align-items: center;
}

#step-slider {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  height: 12px;
  border-radius: 999px;
  border: 1px solid rgba(65, 105, 225, 0.18);
  background: linear-gradient(90deg, rgba(255, 240, 245, 0.95) 0%, rgba(240, 255, 240, 0.95) 100%);
  outline: none;
}

#step-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

#step-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  background: var(--accent);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  cursor: pointer;
}

.step-readout,
.sentence-mode {
  color: var(--muted);
  font-size: 0.93rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 0.82fr);
  gap: 20px;
  align-items: stretch;
}

.viz-column,
.detail-column {
  display: grid;
  gap: 20px;
  align-content: stretch;
}

.card {
  padding: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.card-header > * {
  min-width: 0;
}

.compact-header {
  margin-bottom: 14px;
}

.legend-pills,
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 700;
}

.pre-pill {
  background: var(--pre-fill);
  color: var(--pre-ink);
}

.post-pill {
  background: var(--post-fill);
  color: var(--post-ink);
}

.basin-pill {
  background: var(--basin-fill);
  color: var(--basin-ink);
}

.status-badge.is-pre {
  background: var(--pre-fill);
  color: var(--pre-ink);
}

.status-badge.is-post {
  background: var(--post-fill);
  color: var(--post-ink);
}

.status-badge.is-basin {
  background: var(--basin-fill);
  color: var(--basin-ink);
}

.status-badge.is-rcp {
  background: rgba(255, 0, 0, 0.12);
  color: var(--rcp-ink);
}

.plot-frame {
  min-height: 620px;
  flex: 1 1 auto;
}

.prompt-text {
  margin: 0;
  line-height: 1.72;
  color: var(--muted);
  min-width: 0;
}

.hero-question .card-header {
  margin-bottom: 0;
}

.question-panel {
  height: 100%;
  max-height: clamp(220px, 34vh, 360px);
  min-width: 0;
  overflow: auto;
  padding: 22px 26px;
}

.hero-prompt-text {
  inline-size: 100%;
  display: grid;
  gap: 14px;
  font-family: var(--font-serif);
  font-size: 1.05rem;
  max-height: none;
  overflow: visible;
  line-height: 1.76;
  color: rgba(28, 34, 48, 0.82);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-wrap: pretty;
  hyphens: auto;
}

.prompt-paragraph {
  margin: 0;
  text-align: justify;
  text-align-last: left;
}

.prompt-paragraph.is-final {
  padding-top: 12px;
  border-top: 1px solid rgba(65, 105, 225, 0.14);
  font-weight: 700;
  color: var(--ink);
}

.prompt-answer {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding-top: 10px;
  border-top: 1px dashed rgba(65, 105, 225, 0.18);
  color: var(--ink);
}

.prompt-answer-label {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  font-weight: 700;
}

.prompt-answer-value {
  font-size: 1.18rem;
  font-weight: 800;
  color: rgba(188, 30, 30, 0.96);
}

.sentence-panel {
  padding: 18px;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(212, 91, 51, 0.08), rgba(15, 108, 116, 0.06)),
    var(--paper-strong);
  border: 1px solid rgba(212, 91, 51, 0.12);
  min-width: 0;
}

.sentence-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.sentence-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-deep);
  font-weight: 700;
}

.thinking-trace {
  min-height: 14rem;
  max-height: 28rem;
  overflow: auto;
  font-family: var(--font-serif);
  font-size: 1.06rem;
  line-height: 1.72;
  color: var(--ink);
  scroll-behavior: smooth;
}

.chart-card,
.step-card {
  height: 100%;
}

.chart-card,
.step-card {
  min-height: 0;
}

.chart-card,
.step-card {
  display: flex;
  flex-direction: column;
}

.step-card {
  overflow: hidden;
}

.step-card .sentence-panel {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.step-card .thinking-trace {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}

.trace-sentence {
  display: inline;
  transition: color 180ms ease, background 180ms ease;
}

.trace-sentence.is-past {
  color: rgba(28, 34, 48, 0.44);
}

.trace-sentence.is-current {
  font-weight: 800;
  color: var(--ink);
  background: rgba(65, 105, 225, 0.10);
  border-radius: 6px;
  padding: 0.04rem 0.18rem;
}

.trace-sentence.is-future {
  color: rgba(28, 34, 48, 0.22);
}

.trace-number-hot {
  color: rgba(188, 30, 30, 0.96);
  font-weight: 850;
}

.trace-number-soft {
  color: rgba(188, 30, 30, 0.92);
  font-weight: 840;
}

.trace-number-rcp {
  color: rgba(188, 30, 30, 0.94);
  font-weight: 840;
}

.trace-number-hot,
.trace-number-soft,
.trace-number-rcp {
  display: inline-block;
  padding: 0.01em 0.16em;
  margin: 0 0.015em;
  border-radius: 0.32em;
  background: rgba(198, 40, 40, 0.16);
  box-shadow:
    inset 0 0 0 1px rgba(198, 40, 40, 0.22),
    0 1px 2px rgba(198, 40, 40, 0.08);
  text-shadow: 0 0 0.01px currentColor;
  opacity: 1;
}

.trace-sentence.is-past .trace-number-soft,
.trace-sentence.is-past .trace-number-rcp {
  color: rgba(188, 30, 30, 0.98);
  font-weight: 860;
  background: rgba(198, 40, 40, 0.18);
  box-shadow:
    inset 0 0 0 1px rgba(198, 40, 40, 0.26),
    0 1px 2px rgba(198, 40, 40, 0.10);
}

@media (max-width: 1180px) {
  .workspace,
  .toolbar,
  .hero-copy {
    grid-template-columns: 1fr;
  }

  .hero-text {
    padding-left: 0;
    border-left: 0;
    border-top: 1px solid rgba(39, 42, 50, 0.14);
    padding-top: 18px;
  }
}

@media (max-width: 720px) {
  body {
    padding: 16px;
  }

  .hero-copy,
  .card,
  .hero-question {
    padding: 18px;
  }

  .plot-frame {
    min-height: 420px;
  }

  .thinking-trace {
    font-size: 1.04rem;
  }
}
