:root {
  color-scheme: light;
  --ink: #1e2522;
  --muted: #68716d;
  --line: #dce1dd;
  --paper: #f4f5f1;
  --white: #fcfdfb;
  --green: #1f6047;
  --green-dark: #174737;
  --lime: #d9f26b;
  --amber: #f0ae4e;
  --red: #bd493c;
  --radius: 18px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 90% 0, rgb(217 242 107 / 18%), transparent 28rem),
    var(--paper);
  color: var(--ink);
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
  padding: 0 3vw;
  border-bottom: 1px solid var(--line);
  background: rgb(244 245 241 / 92%);
  backdrop-filter: blur(18px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  background: var(--green);
  color: var(--lime);
  font-family: Georgia, serif;
  font-size: 22px;
}

.brand strong, .brand small { display: block; }
.brand small { color: var(--muted); font-size: 11px; letter-spacing: .06em; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  border-radius: 999px;
  background: #e8ebe6;
}

.tab {
  padding: 9px 17px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
}
.tab.active { background: var(--white); color: var(--ink); box-shadow: 0 1px 4px #26332b12; }

.health {
  justify-self: end;
  color: var(--muted);
  font-size: 12px;
}
.health span {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--amber);
}
.health.ready span { background: #34a26e; }
.health.warning span { background: var(--red); }

main { width: min(1480px, 94vw); margin: 0 auto; }
.view { display: none; padding: 64px 0 80px; }
.view.active { display: block; }

.hero-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 8vw;
  align-items: end;
  margin-bottom: 36px;
}

h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(40px, 5.4vw, 76px);
  font-weight: 400;
  line-height: .98;
  letter-spacing: -.045em;
}
h2 { margin-bottom: 12px; font-size: 21px; }
.eyebrow {
  margin-bottom: 18px;
  color: var(--green);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.hero-note { max-width: 42ch; margin-bottom: 4px; color: var(--muted); line-height: 1.6; }

.question-panel, .graph-panel, .rubric-card, .experiment-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: 0 15px 60px rgb(40 56 48 / 5%);
}

.question-panel { padding: 28px; }
.question-panel > label:first-child {
  display: block;
  margin-bottom: 12px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: clamp(24px, 2.3vw, 35px);
  line-height: 1.3;
}
textarea::placeholder { color: #adb4b0; }

.question-footer, .run-actions, .section-heading, .card-title-row {
  display: flex;
  align-items: center;
}
.question-footer {
  justify-content: space-between;
  gap: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.select-label { flex: 1; color: var(--muted); font-size: 12px; }
.select-label select { display: block; width: min(600px, 100%); margin-top: 6px; }

input, select {
  min-height: 40px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--white);
  color: var(--ink);
}

.toggle { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.toggle input { position: absolute; opacity: 0; }
.toggle span {
  position: relative;
  width: 38px;
  height: 22px;
  border-radius: 99px;
  background: #cdd3ce;
  transition: .2s;
}
.toggle span::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  content: "";
  transition: .2s;
}
.toggle input:checked + span { background: var(--green); }
.toggle input:checked + span::after { transform: translateX(16px); }

.run-actions { flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.mode-option { position: relative; }
.mode-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 0;
  z-index: 10;
  width: max-content;
  max-width: min(320px, calc(100vw - 48px));
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--ink);
  box-shadow: 0 12px 32px rgb(30 37 34 / 18%);
  color: var(--white);
  font-size: 12px;
  font-weight: 450;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  text-wrap: pretty;
  transform: translateY(4px);
  transition:
    opacity 140ms ease,
    transform 140ms ease;
}
.mode-tooltip::after {
  position: absolute;
  top: 100%;
  left: 22px;
  border: 6px solid transparent;
  border-top-color: var(--ink);
  content: "";
}
.mode-option:hover .mode-tooltip,
.mode-option:focus-within .mode-tooltip {
  opacity: 1;
  transform: translateY(0);
}
.button {
  min-height: 44px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 680;
}
.button:disabled { cursor: wait; opacity: .55; }
.button.primary { margin-left: auto; background: var(--green); color: white; }
.button.primary:hover { background: var(--green-dark); }
.button.secondary { border-color: var(--line); background: #f7f8f5; color: var(--ink); }
.button.small-button { min-height: 34px; padding: 7px 10px; font-size: 12px; }

.status-line { min-height: 20px; margin: 15px 0 -8px; color: var(--muted); font-size: 13px; }
.results-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 15px;
  margin-top: 22px;
}
.result-card, .answer-card {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
}
.result-card > header, .answer-card > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.result-card header div, .answer-card header { gap: 9px; }
.condition-index, .answer-card header span {
  display: inline-grid;
  width: 27px;
  height: 27px;
  place-items: center;
  border-radius: 50%;
  background: #e8eee9;
  color: var(--green);
  font-size: 12px;
  font-weight: 800;
}
.run-state { color: var(--muted); font-size: 11px; }
pre.answer, .answer-card pre {
  min-height: 300px;
  max-height: 640px;
  margin: 0;
  padding: 22px;
  overflow: auto;
  white-space: pre-wrap;
  color: #303733;
  font: 14px/1.65 Inter, sans-serif;
}
.metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.metric { padding: 5px 8px; border-radius: 7px; background: #f0f2ee; color: var(--muted); font-size: 11px; }
.card-actions { display: flex; gap: 8px; padding: 0 18px 16px; }

.graph-panel { margin-top: 26px; padding: 26px; }
.section-heading { justify-content: space-between; gap: 20px; margin-bottom: 25px; }
.section-heading h1 { font-size: clamp(38px, 4vw, 60px); }
.section-heading .eyebrow { margin-bottom: 8px; }
.icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
}
.graph-layout { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; }
.graph-canvas { min-height: 540px; overflow: hidden; border-radius: 13px; background: #f2f4ef; }
.graph-canvas-state { display: grid; place-items: center; padding: 24px; }
.graph-state { max-width: 360px; color: var(--muted); text-align: center; }
.graph-canvas svg { width: 100%; height: 540px; }
.graph-node { cursor: pointer; }
.graph-node text { pointer-events: none; font: 11px Inter, sans-serif; fill: var(--ink); }
.graph-link { stroke: #aeb7b1; stroke-width: 1.2; }
.node-detail { padding: 20px; overflow: auto; border: 1px solid var(--line); border-radius: 13px; }
.node-detail p { color: var(--muted); line-height: 1.55; }
.source-link { display: block; margin-top: 10px; color: var(--green); word-break: break-all; }

.evaluation-heading { align-items: end; }
.compact-field { margin-left: auto; color: var(--muted); font-size: 12px; }
.compact-field input { display: block; margin-top: 5px; }
.blind-notice { margin-bottom: 22px; padding: 13px 16px; border-left: 3px solid var(--lime); background: #eef4d9; color: #4c594c; }
.empty-state { padding: 80px 20px; text-align: center; color: var(--muted); }
.evaluation-question { margin: 24px 0; }
.evaluation-question span { color: var(--green); font-size: 11px; font-weight: 750; text-transform: uppercase; }
.evaluation-question p { max-width: 960px; margin-top: 8px; font: 26px/1.3 Georgia, serif; }
.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.answer-card pre { min-height: 400px; }
.rubric-card { margin-top: 18px; padding: 20px; }
.rubric-row { display: grid; grid-template-columns: 1fr 80px 80px; gap: 12px; align-items: center; padding: 7px 0; }
.rubric-header { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
.rubric-row select { width: 70px; }
.winner-row { display: grid; grid-template-columns: 180px 1fr auto; gap: 14px; align-items: end; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.winner-row label { color: var(--muted); font-size: 12px; }
.winner-row input, .winner-row select { display: block; width: 100%; margin-top: 5px; }
.reveal { margin-top: 20px; padding: 22px; border-radius: var(--radius); background: #e5f0e8; }
.reveal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }

.experiment-grid { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(0, 2fr); gap: 18px; }
.experiment-card { padding: 24px; }
.experiment-card > p { color: var(--muted); line-height: 1.6; }
.experiment-card label { display: block; margin: 14px 0; color: var(--muted); font-size: 12px; }
.experiment-card input { display: block; width: 100%; margin-top: 6px; }
.experiment-card .button { width: 100%; margin: 8px 0 0; }
.experiment-card .small { margin: 12px 0 0; font-size: 11px; }
.card-title-row { justify-content: space-between; }
.experiment-list { display: grid; gap: 10px; }
.experiment-item { padding: 15px; border: 1px solid var(--line); border-radius: 12px; }
.experiment-item header { display: flex; justify-content: space-between; gap: 12px; }
.experiment-item p { margin: 8px 0; color: var(--muted); font-size: 12px; }
.progress { height: 5px; overflow: hidden; border-radius: 99px; background: #e5e8e3; }
.progress span { display: block; height: 100%; background: var(--green); }
.experiment-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }

.hidden { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .mode-tooltip { transition: none; }
}

@media (max-width: 900px) {
  .topbar {
    position: relative;
    grid-template-columns: 1fr;
    min-height: 68px;
    backdrop-filter: none;
  }
  .tabs { position: fixed; right: 12px; bottom: 12px; left: 12px; z-index: 30; justify-content: center; box-shadow: 0 8px 30px #1e252233; }
  .health { display: none; }
  .hero-grid, .results-grid, .answers-grid, .experiment-grid, .graph-layout { grid-template-columns: 1fr; }
  .hero-note { margin-top: 20px; }
  .view { padding-top: 36px; }
  .question-footer, .evaluation-heading { align-items: flex-start; flex-direction: column; }
  .button.primary { margin-left: 0; }
  .winner-row { grid-template-columns: 1fr; }
}
