:root {
  --burgundy-950: #310912;
  --burgundy-900: #4b0d1b;
  --burgundy-800: #681527;
  --burgundy-700: #84223a;
  --gold-500: #f4c430;
  --gold-300: #ffdf72;
  --gold-100: #fff3c8;
  --green-700: #1d5b4d;
  --teal-500: #2e8c84;
  --paper: #fffaf0;
  --paper-deep: #f7e7bf;
  --ink: #26151a;
  --muted: #725d63;
  --line: rgba(104, 21, 39, 0.18);
  --shadow: 0 24px 60px rgba(49, 9, 18, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 0%, rgba(244, 196, 48, 0.34), transparent 25rem),
    radial-gradient(circle at 0% 28%, rgba(104, 21, 39, 0.16), transparent 28rem),
    linear-gradient(180deg, #fff7de 0%, #f4dfb8 46%, #fff8e5 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
}

img {
  max-width: 100%;
}

.brain-app {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.journal-header {
  overflow: hidden;
  border: 1px solid rgba(255, 223, 114, 0.25);
  border-radius: 10px;
  color: #fff7df;
  background:
    linear-gradient(135deg, rgba(49, 9, 18, 0.98), rgba(104, 21, 39, 0.94)),
    var(--burgundy-950);
  box-shadow: var(--shadow);
}

.journal-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 223, 114, 0.18);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
  text-decoration: none;
}

.brand img {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  object-fit: contain;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  color: var(--gold-300);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
}

.brand small {
  color: rgba(255, 247, 223, 0.72);
  font-size: 0.82rem;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav-links a {
  padding: 9px 12px;
  border: 1px solid rgba(255, 223, 114, 0.16);
  border-radius: 999px;
  color: rgba(255, 247, 223, 0.86);
  text-decoration: none;
  font-size: 0.9rem;
}

.nav-links a:hover {
  background: rgba(255, 223, 114, 0.12);
}

.hero-grid {
  display: block;
  padding: clamp(22px, 5vw, 60px);
}

.overline,
.panel-kicker {
  margin: 0 0 9px;
  color: var(--gold-300);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  max-width: 980px;
  margin-bottom: 14px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.4rem, 6vw, 5.7rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 3vw, 2.6rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.04rem;
  line-height: 1.2;
}

.subtitle {
  max-width: 820px;
  color: rgba(255, 247, 223, 0.82);
  font-size: clamp(1rem, 1.4vw, 1.24rem);
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 26px;
}

.primary-link,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  text-decoration: none;
  font-weight: 700;
}

.primary-link {
  color: var(--burgundy-950);
  background: var(--gold-500);
}

.secondary-link {
  border: 1px solid rgba(255, 223, 114, 0.34);
  color: #fff7df;
  background: rgba(255, 223, 114, 0.08);
}

.paper-panel,
.finding-card,
.chart-shell,
.pipeline-canvas,
.pipeline-detail,
.data-table-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: 0 12px 34px rgba(49, 9, 18, 0.08);
}

.finding-card span,
.pipeline-detail span {
  display: block;
  color: var(--muted);
  font-size: 0.84rem;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.research-index {
  position: sticky;
  top: 14px;
  align-self: start;
  padding: 16px;
  border-radius: 10px;
  color: #fff7df;
  background: linear-gradient(180deg, var(--burgundy-800), var(--burgundy-950));
  box-shadow: var(--shadow);
}

.research-index h2 {
  margin-bottom: 14px;
  color: var(--gold-300);
  font-size: 1.35rem;
}

.section-button,
.chart-mode,
.pipeline-step {
  cursor: pointer;
}

.section-button {
  display: block;
  width: 100%;
  min-height: 42px;
  margin-top: 8px;
  border: 1px solid rgba(255, 223, 114, 0.2);
  border-radius: 8px;
  color: rgba(255, 247, 223, 0.82);
  background: rgba(255, 247, 223, 0.06);
  text-align: left;
  padding: 0 12px;
}

.section-button.is-active {
  color: var(--burgundy-950);
  background: var(--gold-500);
}

.paper-panel {
  min-height: 310px;
  padding: clamp(20px, 4vw, 42px);
}

.panel-heading {
  max-width: 920px;
}

.paper-panel .panel-kicker,
.section-intro .panel-kicker {
  color: var(--burgundy-700);
}

#sectionText {
  max-width: 1020px;
  color: #3a252a;
  font-size: clamp(1rem, 1.15vw, 1.18rem);
  line-height: 1.75;
}

.keyword-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 22px;
}

.keyword-cloud span {
  padding: 8px 10px;
  border: 1px solid rgba(104, 21, 39, 0.16);
  border-radius: 999px;
  color: var(--burgundy-800);
  background: var(--gold-100);
  font-size: 0.86rem;
}

.section-block {
  margin-top: 16px;
  padding: clamp(18px, 3vw, 30px);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.46);
}

.section-intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 560px);
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

.section-intro p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.evidence-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 14px;
}

.chart-shell {
  min-width: 0;
  padding: 18px;
}

.chart-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chart-mode {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid rgba(104, 21, 39, 0.2);
  border-radius: 999px;
  color: var(--burgundy-800);
  background: rgba(255, 243, 200, 0.52);
}

.chart-mode.is-active {
  color: var(--gold-100);
  background: var(--burgundy-800);
}

.chart-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 380px);
  gap: 18px;
  align-items: start;
}

.chart-title-row p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.45;
}

.evidence-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 10px;
}

.chart-axis {
  stroke: rgba(49, 9, 18, 0.28);
  stroke-width: 1;
}

.chart-label,
.chart-value,
.chart-unit {
  fill: var(--ink);
  font-size: 16px;
}

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

.bar-bg {
  fill: rgba(104, 21, 39, 0.08);
}

.bar-primary {
  fill: var(--burgundy-800);
}

.bar-secondary {
  fill: var(--gold-500);
}

.bar-teal {
  fill: var(--teal-500);
}

.data-bar {
  transform-box: fill-box;
  transform-origin: left center;
  animation: bar-grow 0.48s ease-out both;
}

.finding-stack {
  display: grid;
  gap: 10px;
}

.finding-card {
  padding: 16px;
}

.finding-card strong {
  display: block;
  margin: 8px 0;
  color: var(--burgundy-800);
  font-size: 1.24rem;
}

.finding-card p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.pipeline-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 410px);
  gap: 14px;
}

.pipeline-canvas {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  align-items: center;
  min-height: 260px;
  padding: 22px;
  overflow: hidden;
}

.pipeline-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.pipeline-links path {
  fill: none;
  stroke: rgba(104, 21, 39, 0.16);
  stroke-width: 6;
  stroke-linecap: round;
}

.pipeline-step {
  position: relative;
  z-index: 1;
  min-height: 142px;
  padding: 15px;
  border: 1px solid rgba(104, 21, 39, 0.18);
  border-radius: 10px;
  color: var(--ink);
  background: rgba(255, 243, 200, 0.9);
  text-align: left;
}

.pipeline-step.is-active {
  color: #fff7df;
  background: linear-gradient(160deg, var(--burgundy-800), var(--burgundy-950));
}

.pipeline-step span {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 14px;
  border-radius: 50%;
  color: var(--burgundy-950);
  background: var(--gold-500);
  font-weight: 800;
}

.pipeline-step strong,
.pipeline-step small {
  display: block;
}

.pipeline-step strong {
  margin-bottom: 6px;
}

.pipeline-step small {
  color: inherit;
  opacity: 0.72;
}

.pipeline-detail {
  padding: 20px;
}

.pipeline-detail h3 {
  color: var(--burgundy-800);
  font-size: 1.45rem;
}

.pipeline-detail p,
.pipeline-detail li {
  color: var(--muted);
  line-height: 1.56;
}

.pipeline-detail ul {
  padding-left: 20px;
  margin-bottom: 0;
}

.table-grid {
  display: grid;
  gap: 14px;
}

.data-table-card {
  overflow: hidden;
}

.data-table-card h3 {
  margin: 0;
  padding: 16px 18px;
  color: #fff7df;
  background: var(--burgundy-800);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper);
}

th,
td {
  padding: 12px;
  border: 1px solid rgba(104, 21, 39, 0.14);
  text-align: left;
  vertical-align: top;
  line-height: 1.4;
}

th {
  color: var(--burgundy-900);
  background: var(--gold-100);
}

td {
  color: #38242a;
}

.metric-list {
  display: inline-grid;
  gap: 4px;
  line-height: 1.35;
}

.observation-cell {
  text-align: center;
  vertical-align: middle;
}

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 10px;
  color: rgba(255, 247, 223, 0.82);
  background: var(--burgundy-950);
}

.app-footer p {
  margin: 0;
}

.app-footer a {
  color: var(--gold-300);
  font-weight: 800;
}

@media (max-width: 1120px) {
  .evidence-layout,
  .pipeline-grid,
  .content-grid {
    grid-template-columns: 1fr;
  }

  .research-index {
    position: static;
  }

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

  .pipeline-links {
    display: none;
  }
}

@media (max-width: 820px) {
  .brain-app {
    width: min(100% - 20px, 1480px);
    padding-top: 10px;
  }

  .journal-nav,
  .section-intro,
  .chart-title-row {
    display: block;
  }

  .nav-links {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .hero-grid {
    padding: 20px;
  }

  .section-intro p,
  .chart-title-row p {
    margin-top: 8px;
  }

  .pipeline-canvas {
    grid-template-columns: 1fr;
  }

  .pipeline-step {
    min-height: 112px;
  }

  .data-table-card {
    overflow-x: auto;
  }

  table {
    min-width: 780px;
  }
}

@media (max-width: 520px) {
  h1 {
    font-size: 2.15rem;
  }

  .hero-actions a,
  .nav-links a {
    width: 100%;
  }

  .chart-mode {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}

@keyframes bar-grow {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}
