:root {
  color-scheme: light;
  --ink: #1d2b22;
  --ink-soft: #435247;
  --paper: #f2e2bd;
  --paper-hi: #fff8df;
  --paper-dim: #d8c79f;
  --terminal: #17352c;
  --terminal-hi: #21483b;
  --grass: #83ad58;
  --water: #39a7c2;
  --cyan: #67d9e7;
  --warning: #ee6a3a;
  --sun: #f4c64f;
  --success: #2f7d4a;
  --danger: #b64332;
  --line: rgba(29, 43, 34, 0.19);
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --body: "Avenir Next", "Trebuchet MS", sans-serif;
  --mono: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  font-family: var(--body);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
}

button,
textarea,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.35);
  opacity: 0.48;
}

[hidden] {
  display: none !important;
}

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.skip-link {
  background: var(--sun);
  color: var(--ink);
  font-weight: 800;
  left: 16px;
  padding: 10px 14px;
  position: fixed;
  top: -80px;
  z-index: 100;
}

.skip-link:focus {
  top: 12px;
}

.app-shell {
  background:
    radial-gradient(circle at 9% 12%, rgba(255, 248, 223, 0.9) 0 1px, transparent 2px) 0 0 / 19px 19px,
    var(--paper);
  display: grid;
  gap: 10px;
  grid-template-rows: 62px 54px minmax(0, 1fr);
  height: 100dvh;
  min-height: 640px;
  padding: 10px 14px 14px;
  position: relative;
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  min-width: 0;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  background: var(--terminal);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(29, 43, 34, 0.25);
  display: grid;
  gap: 2px;
  grid-template-columns: repeat(3, 8px);
  height: 38px;
  padding: 5px;
  transform: rotate(-2deg);
  width: 38px;
}

.brand-mark i {
  background: var(--grass);
  display: block;
}

.brand-mark i:nth-child(2) {
  background: var(--water);
  transform: translateY(5px);
}

.brand-mark i:nth-child(3) {
  background: var(--sun);
  transform: translateY(10px);
}

.eyebrow {
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.13em;
  margin: 0 0 2px;
  text-transform: uppercase;
}

.brand-lockup h1 {
  font-family: var(--display);
  font-size: clamp(22px, 2vw, 30px);
  letter-spacing: -0.035em;
  line-height: 0.95;
  margin: 0;
}

.brand-lockup h1 span {
  color: var(--success);
  font-family: var(--body);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-left: 6px;
  text-transform: uppercase;
}

.mission-meta {
  align-items: center;
  background: rgba(255, 248, 223, 0.7);
  border: 1px solid var(--line);
  display: flex;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  gap: 8px;
  padding: 8px 11px;
}

.live-dot {
  background: var(--warning);
  border: 2px solid var(--paper-hi);
  border-radius: 50%;
  box-shadow: 0 0 0 1px var(--ink);
  height: 8px;
  width: 8px;
}

.app-shell[data-mode]:not([data-mode="welcome"]) .live-dot {
  animation: live-pulse 1.8s ease-in-out infinite;
  background: var(--success);
}

.meta-divider {
  background: var(--line);
  height: 12px;
  width: 1px;
}

.stage-rail {
  background: var(--paper-hi);
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(29, 43, 34, 0.18);
  min-width: 0;
  overflow: hidden;
}

.stage-rail ol {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: 100%;
  list-style: none;
  margin: 0;
  padding: 0;
}

.stage-rail li {
  align-items: center;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 0 8px;
  grid-template-columns: 27px 1fr;
  grid-template-rows: 1fr 1fr;
  min-width: 0;
  opacity: 0.45;
  padding: 6px 12px;
  position: relative;
  transition: background 180ms ease, opacity 180ms ease;
}

.stage-rail li:last-child {
  border-right: 0;
}

.stage-rail li span {
  align-items: center;
  background: var(--paper-dim);
  border: 1px solid var(--ink);
  border-radius: 50%;
  display: flex;
  font-family: var(--mono);
  font-size: 11px;
  grid-row: 1 / 3;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.stage-rail li b {
  align-self: end;
  font-size: 11px;
  line-height: 1.1;
}

.stage-rail li small {
  align-self: start;
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.1;
}

.stage-rail li.is-active {
  background: var(--sun);
  opacity: 1;
}

.stage-rail li.is-active span {
  background: var(--ink);
  color: var(--paper-hi);
}

.stage-rail li.is-complete {
  background: rgba(131, 173, 88, 0.17);
  opacity: 0.82;
}

.stage-rail li.is-complete span {
  background: var(--success);
  color: white;
}

.workspace {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1.7fr) minmax(382px, 0.72fr);
  min-height: 0;
}

.scene-card,
.workbench {
  border: 2px solid var(--ink);
  box-shadow: 5px 5px 0 rgba(29, 43, 34, 0.24);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.scene-card {
  background: #b8d7c1;
  border-radius: 18px 5px 18px 5px;
}

#farm-canvas {
  display: block;
  height: 100%;
  width: 100%;
}

.scene-grain {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");
  inset: 0;
  mix-blend-mode: multiply;
  opacity: 0.35;
  pointer-events: none;
  position: absolute;
}

.mission-card {
  background: var(--paper-hi);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(29, 43, 34, 0.25);
  left: 14px;
  max-width: 335px;
  padding: 13px 15px 12px;
  position: absolute;
  top: 14px;
}

.mission-card::after {
  background: var(--warning);
  content: "";
  height: 8px;
  left: -2px;
  position: absolute;
  top: -2px;
  width: 76px;
}

.card-kicker {
  color: var(--danger);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.11em;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.mission-card h2 {
  font-family: var(--display);
  font-size: clamp(20px, 2.1vw, 29px);
  letter-spacing: -0.035em;
  line-height: 1;
  margin: 0 0 5px;
}

.mission-card > p:not(.card-kicker) {
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.4;
  margin: 0;
}

.world-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.world-facts span {
  align-items: center;
  background: #f1d9b1;
  border: 1px solid rgba(29, 43, 34, 0.35);
  display: inline-flex;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  gap: 5px;
  padding: 4px 6px;
  text-transform: uppercase;
}

.fact-icon {
  background: var(--warning);
  border: 1px solid var(--ink);
  border-radius: 50%;
  height: 7px;
  width: 7px;
}

.fact-icon.dry {
  background: #b98952;
}

.world-facts .is-good {
  background: #d8edbd;
}

.world-facts .is-good .fact-icon {
  background: var(--success);
}

.world-callout,
.bert-tag {
  align-items: center;
  background: var(--paper-hi);
  border: 1px solid var(--ink);
  box-shadow: 2px 2px 0 rgba(29, 43, 34, 0.25);
  display: flex;
  font-size: 9px;
  gap: 7px;
  padding: 5px 7px;
  pointer-events: none;
  position: absolute;
  transition: opacity 180ms ease, transform 180ms ease;
}

.world-callout {
  left: 56%;
  top: 43%;
}

.world-callout > span {
  align-items: center;
  background: var(--warning);
  border: 1px solid var(--ink);
  color: white;
  display: flex;
  font-size: 11px;
  font-weight: 900;
  height: 20px;
  justify-content: center;
  width: 20px;
}

.world-callout div,
.bert-tag {
  line-height: 1.05;
}

.world-callout b,
.world-callout small,
.bert-tag b,
.bert-tag small {
  display: block;
}

.world-callout small,
.bert-tag small {
  color: var(--ink-soft);
  margin-top: 2px;
}

.bert-tag {
  left: 30%;
  top: 69%;
}

.bert-tag > span {
  background: var(--sun);
  border: 1px solid var(--ink);
  height: 11px;
  width: 11px;
}

.bert-speech {
  align-items: center;
  background: var(--paper-hi);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 rgba(29, 43, 34, 0.28);
  display: grid;
  gap: 9px;
  grid-template-columns: 32px minmax(0, 1fr);
  max-width: 236px;
  min-width: 190px;
  padding: 8px 10px 8px 8px;
  pointer-events: none;
  position: absolute;
  z-index: 7;
}

.bert-speech::after {
  background: var(--paper-hi);
  border-bottom: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
  bottom: -8px;
  content: "";
  height: 13px;
  left: 24px;
  position: absolute;
  transform: rotate(45deg);
  width: 13px;
}

.bert-cue {
  align-items: center;
  background: var(--sun);
  border: 1px solid var(--ink);
  display: flex;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 900;
  height: 31px;
  justify-content: center;
  min-width: 31px;
}

.bert-speech[data-tone="question"] .bert-cue,
.bert-speech[data-tone="warning"] .bert-cue {
  background: var(--warning);
  color: white;
}

.bert-speech[data-tone="working"] .bert-cue {
  background: var(--cyan);
}

.bert-speech p {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.28;
  margin: 0;
}

.agent-boundary-note {
  background: var(--sun);
  border: 2px solid var(--ink);
  bottom: 58px;
  box-shadow: 4px 4px 0 var(--ink);
  left: 12px;
  max-width: min(330px, calc(100% - 24px));
  padding: 9px 11px;
  position: absolute;
  transform: rotate(-0.35deg);
  z-index: 6;
}

.agent-boundary-note strong {
  display: block;
  font-family: var(--display);
  font-size: 16px;
  line-height: 1.05;
  margin: 2px 0 3px;
}

.agent-boundary-note > p:last-child {
  font-size: 12px;
  line-height: 1.3;
  margin: 0;
}

.scene-caption {
  align-items: center;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  left: 10px;
  position: absolute;
  right: 10px;
}

.scene-caption p {
  background: rgba(23, 53, 44, 0.93);
  border: 1px solid var(--paper-hi);
  box-shadow: 2px 2px 0 rgba(29, 43, 34, 0.25);
  color: var(--paper-hi);
  margin: 0;
  padding: 7px 10px;
}

.scene-caption p span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.1em;
  margin-right: 8px;
}

.scene-caption p b {
  font-size: 10px;
}

.icon-button,
.text-button {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
  padding: 6px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.scene-caption .icon-button {
  background: rgba(255, 248, 223, 0.9);
  border: 1px solid var(--ink);
  text-decoration: none;
}

.start-layer {
  align-items: center;
  background: rgba(23, 53, 44, 0.52);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: absolute;
  transition: opacity 300ms ease, visibility 300ms ease;
  z-index: 10;
}

.app-shell:not([data-mode="welcome"]) .start-layer {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.start-card {
  background: var(--paper-hi);
  border: 3px solid var(--ink);
  box-shadow: 7px 7px 0 var(--sun);
  max-width: 455px;
  padding: 23px 26px 21px;
  position: relative;
  transform: rotate(-0.5deg);
}

.start-number {
  color: var(--warning);
  font-family: var(--display);
  font-size: 54px;
  font-weight: 800;
  left: -80px;
  line-height: 0.8;
  margin: 0;
  position: absolute;
  text-shadow: 2px 2px 0 var(--ink);
  top: 8px;
}

.start-number span {
  color: var(--paper-hi);
  font-family: var(--mono);
  font-size: 10px;
  text-align: right;
  text-shadow: none;
}

.start-number #start-mission-number {
  color: var(--warning);
  font-family: var(--display);
  font-size: inherit;
  text-shadow: 2px 2px 0 var(--ink);
}

.start-card h2 {
  font-family: var(--display);
  font-size: clamp(31px, 4vw, 47px);
  letter-spacing: -0.045em;
  line-height: 0.94;
  margin: 7px 0 12px;
}

.start-card > p:not(.eyebrow, .start-number) {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.55;
  margin: 0 0 17px;
}

.start-card > small {
  color: var(--ink-soft);
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  margin-top: 11px;
  text-align: center;
  text-transform: uppercase;
}

.mission-roster {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  list-style: none;
  margin: 0 0 14px;
  padding: 0;
}

.mission-roster button {
  align-content: center;
  background: #f7e9bd;
  border: 2px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  gap: 2px;
  min-height: 58px;
  padding: 5px;
  text-align: left;
  width: 100%;
}

.mission-roster button:focus-visible,
.mission-roster [data-state="selected"] button {
  box-shadow: 3px 3px 0 var(--cyan);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.mission-roster button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.8);
  opacity: 0.56;
}

.mission-roster span,
.mission-roster small {
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.mission-roster b {
  font-family: var(--display);
  font-size: 13px;
  line-height: 1;
}

.workbench {
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px) 0 0 / 100% 22px,
    var(--terminal);
  border-radius: 5px 18px 5px 18px;
  color: var(--paper-hi);
  display: grid;
  gap: 7px;
  grid-template-rows: auto auto auto minmax(138px, 1fr) minmax(104px, 0.75fr) auto auto;
  padding: 12px;
}

.workbench-header {
  align-items: center;
  border-bottom: 1px solid rgba(255, 248, 223, 0.18);
  display: flex;
  justify-content: space-between;
  padding: 0 1px 8px;
}

.terminal-eyebrow {
  color: var(--cyan);
}

.workbench h2,
.workbench h3 {
  margin: 0;
}

.workbench-header h2 {
  font-family: var(--display);
  font-size: 24px;
  letter-spacing: -0.025em;
}

.compiler-badge {
  background: rgba(255, 248, 223, 0.08);
  border: 1px solid rgba(255, 248, 223, 0.32);
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  padding: 5px 7px;
  text-transform: uppercase;
}

.compiler-badge.is-good {
  background: rgba(103, 217, 231, 0.15);
  border-color: var(--cyan);
  color: var(--cyan);
}

.compiler-badge.is-bad {
  background: rgba(238, 106, 58, 0.15);
  border-color: var(--warning);
  color: #ff9a70;
}

.lesson-prompt {
  align-items: center;
  background: var(--paper);
  border: 1px solid var(--ink);
  color: var(--ink);
  display: grid;
  gap: 9px;
  grid-template-columns: minmax(112px, 0.8fr) 1.2fr;
  padding: 7px 9px;
}

.lesson-step {
  color: var(--danger);
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  text-transform: uppercase;
}

.lesson-prompt h3 {
  font-family: var(--display);
  font-size: 15px;
  line-height: 1;
}

.lesson-prompt p {
  border-left: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 9px;
  line-height: 1.35;
  margin: 0;
  padding-left: 9px;
}

.language-card {
  background: rgba(255, 248, 223, 0.06);
  border: 1px solid rgba(255, 248, 223, 0.16);
  padding: 6px 8px;
}

.language-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 5px;
}

.language-heading > span {
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 7px;
  letter-spacing: 0.08em;
}

.language-heading button {
  background: transparent;
  border: 0;
  color: var(--cyan);
  cursor: pointer;
  font-size: 8px;
  font-weight: 800;
  padding: 2px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.language-card ol {
  display: grid;
  gap: 4px;
  grid-template-columns: repeat(4, 1fr);
  list-style: none;
  margin: 0;
  padding: 0;
}

.language-card li {
  border-left: 2px solid rgba(103, 217, 231, 0.45);
  min-width: 0;
  padding: 3px 3px 3px 5px;
  transition: background 140ms ease, opacity 140ms ease;
}

.language-card li.is-active {
  background: rgba(244, 198, 79, 0.15);
  border-left-color: var(--sun);
  box-shadow: inset 0 0 0 1px rgba(244, 198, 79, 0.28);
}

.language-card li.is-complete {
  background: rgba(47, 125, 74, 0.16);
  border-left-color: #93d16b;
}

.language-card li.is-complete code::after {
  color: #93d16b;
  content: " ✓";
}

.language-card li.is-locked {
  opacity: 0.42;
}

.language-card li.is-hinted span {
  color: var(--paper-hi);
  font-family: var(--mono);
}

.language-card code {
  color: var(--cyan);
  display: block;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
}

.language-card li span {
  color: var(--paper-dim);
  display: block;
  font-size: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-card.is-revealed li span {
  color: var(--paper-hi);
  font-family: var(--mono);
  font-size: 6.5px;
}

.editor-shell,
.trace-shell {
  background: #10271f;
  border: 1px solid rgba(255, 248, 223, 0.22);
  min-height: 0;
  overflow: hidden;
}

.editor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.editor-toolbar,
.trace-heading {
  align-items: center;
  background: rgba(255, 248, 223, 0.06);
  border-bottom: 1px solid rgba(255, 248, 223, 0.12);
  display: flex;
  justify-content: space-between;
  min-height: 27px;
  padding: 5px 8px;
}

.editor-toolbar span,
.trace-heading span,
.trace-heading h3 {
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 700;
}

.editor-toolbar i {
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  height: 6px;
  margin-right: 5px;
  width: 6px;
}

.editor-area {
  display: grid;
  grid-template-columns: 32px 1fr;
  min-height: 0;
}

.line-numbers {
  border-right: 1px solid rgba(255, 248, 223, 0.09);
  color: rgba(255, 248, 223, 0.33);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.75;
  padding: 8px 8px 8px 0;
  text-align: right;
  user-select: none;
}

#program-editor {
  background: transparent;
  border: 0;
  color: #e8f4d3;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.75;
  min-height: 0;
  outline: 0;
  overflow: auto;
  padding: 8px 10px;
  resize: none;
  tab-size: 2;
  white-space: pre;
}

#program-editor::placeholder {
  color: rgba(255, 248, 223, 0.3);
}

#program-editor:focus {
  box-shadow: inset 3px 0 0 var(--sun);
}

.editor-help {
  border-top: 1px solid rgba(255, 248, 223, 0.09);
  color: rgba(255, 248, 223, 0.43);
  font-size: 7px;
  margin: 0;
  padding: 4px 8px;
}

.trace-shell {
  display: grid;
  grid-template-rows: auto 1fr;
}

.trace-output {
  overflow-anchor: none;
  min-height: 0;
  overflow: auto;
  padding: 6px 8px;
}

.empty-trace {
  align-items: center;
  color: rgba(255, 248, 223, 0.38);
  display: flex;
  font-family: var(--mono);
  font-size: 8px;
  gap: 7px;
  min-height: 42px;
}

.empty-trace span {
  color: var(--cyan);
  font-size: 16px;
}

.empty-trace p {
  margin: 0;
}

.trace-item {
  align-items: start;
  border-bottom: 1px solid rgba(255, 248, 223, 0.08);
  display: grid;
  gap: 6px;
  grid-template-columns: 17px 1fr auto;
  padding: 5px 1px;
}

.trace-item:last-child {
  border-bottom: 0;
}

.trace-index {
  align-items: center;
  background: rgba(103, 217, 231, 0.12);
  border: 1px solid rgba(103, 217, 231, 0.5);
  color: var(--cyan);
  display: flex;
  font-family: var(--mono);
  font-size: 7px;
  height: 17px;
  justify-content: center;
  width: 17px;
}

.trace-item b,
.trace-item small {
  display: block;
}

.trace-item b {
  color: var(--paper-hi);
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.25;
}

.trace-item small {
  color: rgba(255, 248, 223, 0.48);
  font-size: 7px;
  line-height: 1.3;
  margin-top: 2px;
}

.trace-state {
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 6.5px;
  padding-top: 2px;
  text-transform: uppercase;
}

.trace-item.is-running {
  background: rgba(103, 217, 231, 0.07);
}

.trace-item.is-running .trace-index {
  animation: trace-pulse 800ms ease-in-out infinite alternate;
  background: var(--cyan);
  color: var(--ink);
}

.trace-item.is-pass .trace-index {
  background: var(--success);
  border-color: #93d16b;
  color: white;
}

.trace-item.is-learned .trace-index {
  background: rgba(47, 125, 74, 0.72);
  border-color: #93d16b;
  color: white;
}

.trace-item.is-learned .trace-state {
  color: #93d16b;
}

.trace-item.is-fail {
  background: rgba(238, 106, 58, 0.09);
}

.trace-item.is-no-change {
  background: rgba(244, 198, 79, 0.08);
}

.trace-item.is-coach-focus {
  background: rgba(244, 198, 79, 0.11);
  box-shadow: inset 3px 0 0 var(--sun);
}

.trace-item.is-fail .trace-index,
.trace-item.is-error .trace-index {
  background: var(--warning);
  border-color: #ff9a70;
  color: white;
}

.trace-item.is-no-change .trace-index {
  background: rgba(244, 198, 79, 0.18);
  border-color: var(--sun);
  color: var(--sun);
}

.trace-item.is-error button {
  background: none;
  border: 0;
  color: #ffbd98;
  cursor: pointer;
  font-size: 7px;
  padding: 0;
  text-decoration: underline;
}

.coach-note {
  background: #f4c64f;
  border: 1px solid var(--ink);
  color: var(--ink);
  display: grid;
  font-size: 8px;
  gap: 7px;
  grid-template-columns: 20px 1fr;
  line-height: 1.35;
  margin-top: 2px;
  padding: 5px 7px;
}

.coach-note > span {
  align-items: center;
  background: var(--ink);
  color: var(--sun);
  display: flex;
  font-family: var(--display);
  font-weight: 900;
  height: 20px;
  justify-content: center;
}

.coach-note strong,
.coach-note code {
  font-family: var(--mono);
}

.action-row {
  display: grid;
  gap: 7px;
  grid-template-columns: 1fr 1.15fr;
}

.primary-button,
.secondary-button {
  align-items: center;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.26);
  cursor: pointer;
  display: inline-flex;
  font-size: 10px;
  font-weight: 900;
  justify-content: space-between;
  min-height: 36px;
  padding: 8px 10px;
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover {
  box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.26);
  transform: translate(2px, 2px);
}

.primary-button {
  background: var(--sun);
  color: var(--ink);
}

.secondary-button {
  background: var(--paper-hi);
  color: var(--ink);
}

.primary-button kbd,
.secondary-button kbd {
  background: rgba(29, 43, 34, 0.1);
  border: 1px solid rgba(29, 43, 34, 0.35);
  font-family: var(--mono);
  font-size: 7px;
  padding: 2px 4px;
}

.safety-note {
  color: rgba(255, 248, 223, 0.48);
  font-family: var(--mono);
  font-size: 7px;
  margin: 0;
  text-align: center;
  text-transform: uppercase;
}

.safety-note span {
  color: var(--cyan);
}

.app-shell[data-mode="proof"]::after {
  animation: proof-vignette 360ms ease-out both;
  background:
    radial-gradient(circle at 50% 46%, rgba(23, 53, 44, 0.12), rgba(23, 53, 44, 0.68)),
    rgba(29, 43, 34, 0.16);
  content: "";
  inset: 0;
  pointer-events: none;
  position: fixed;
  z-index: 25;
}

.receipt-panel {
  animation: receipt-rise 480ms cubic-bezier(0.16, 1, 0.3, 1) both;
  background:
    linear-gradient(135deg, rgba(244, 198, 79, 0.12), transparent 32%),
    var(--paper-hi);
  border: 3px solid var(--ink);
  box-shadow: 10px 10px 0 var(--success);
  display: grid;
  gap: 14px;
  left: 50%;
  max-height: calc(100dvh - 36px);
  max-width: calc(100vw - 48px);
  overflow-y: auto;
  padding: 17px 18px 15px;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1180px;
  z-index: 30;
}

.debrief-header {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 82px minmax(290px, 0.92fr) minmax(340px, 1.08fr);
}

.receipt-stamp {
  border: 3px solid var(--success);
  color: var(--success);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 900;
  padding: 10px 7px;
  text-align: center;
  transform: rotate(-4deg);
}

.receipt-stamp span {
  display: block;
  font-size: 24px;
  line-height: 1;
}

.receipt-heading h2 {
  font-family: var(--display);
  font-size: 30px;
  letter-spacing: -0.035em;
  line-height: 0.96;
  margin: 1px 0 7px;
}

.receipt-heading > p:last-child {
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.35;
  margin: 0;
}

.debrief-takeaway {
  background: var(--sun);
  border: 2px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  padding: 11px 13px;
  transform: rotate(0.35deg);
}

.debrief-takeaway strong {
  display: block;
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.05;
  margin: 3px 0 4px;
}

.debrief-takeaway > p:last-child {
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
}

.learning-recap {
  background:
    repeating-linear-gradient(0deg, transparent 0 25px, rgba(57, 167, 194, 0.13) 26px 27px),
    rgba(242, 226, 189, 0.45);
  border: 2px solid var(--ink);
  padding: 11px 12px 12px;
}

.recap-heading {
  align-items: end;
  display: grid;
  gap: 18px;
  grid-template-columns: auto minmax(260px, 1fr);
  margin-bottom: 9px;
}

.recap-heading h3 {
  font-family: var(--display);
  font-size: 20px;
  letter-spacing: -0.025em;
  line-height: 1;
  margin: 1px 0 0;
}

.recap-heading > p {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
  text-align: right;
}

.recap-phases {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.recap-phases li {
  --phase-color: var(--cyan);
  background: rgba(255, 248, 223, 0.92);
  border: 1px solid var(--ink);
  border-top: 4px solid var(--phase-color);
  display: grid;
  gap: 7px;
  grid-template-columns: 27px minmax(0, 1fr);
  min-height: 124px;
  padding: 8px;
}

.recap-phases li:nth-child(2) {
  --phase-color: var(--sun);
}

.recap-phases li:nth-child(3) {
  --phase-color: var(--warning);
}

.recap-phases li:nth-child(4) {
  --phase-color: var(--success);
}

.recap-number {
  align-items: center;
  background: var(--phase-color);
  border: 1px solid var(--ink);
  display: flex;
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 900;
  height: 27px;
  justify-content: center;
  width: 27px;
}

.recap-phases strong {
  align-items: baseline;
  display: flex;
  font-family: var(--mono);
  font-size: 11px;
  justify-content: space-between;
  text-transform: uppercase;
}

.recap-phases strong small {
  color: var(--ink-soft);
  font-size: 8px;
  letter-spacing: 0.07em;
}

.recap-phases code {
  background: var(--terminal);
  color: var(--cyan);
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  line-height: 1.2;
  margin: 5px 0;
  overflow-wrap: anywhere;
  padding: 4px 5px;
}

.recap-phases p {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.35;
  margin: 0;
}

.lesson-alert {
  align-items: center;
  background:
    repeating-linear-gradient(-45deg, rgba(182, 67, 50, 0.09) 0 7px, transparent 7px 14px),
    #f6d99b;
  border: 2px solid var(--danger);
  display: grid;
  gap: 11px;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  padding: 8px 10px;
}

.lesson-alert-mark {
  align-items: center;
  background: var(--danger);
  border: 2px solid var(--ink);
  color: white;
  display: flex;
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 900;
  height: 36px;
  justify-content: center;
  width: 36px;
}

.lesson-alert strong {
  font-family: var(--display);
  font-size: 16px;
  line-height: 1;
}

.lesson-alert div > p:last-child {
  color: var(--ink-soft);
  font-size: 10px;
  margin: 2px 0 0;
}

.lesson-alert > button {
  background: var(--danger);
  border: 2px solid var(--ink);
  color: white;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 8px;
  min-height: 44px;
  padding: 7px 8px;
  text-transform: uppercase;
}

.receipt-footer {
  align-items: end;
  border-top: 1px dashed var(--ink);
  display: grid;
  gap: 14px;
  grid-template-columns: minmax(0, 1fr) auto;
  padding-top: 11px;
}

.receipt-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin: 0;
}

.receipt-grid div {
  border-left: 2px solid var(--success);
  min-width: 0;
  padding-left: 7px;
}

.receipt-grid dt {
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 7px;
  font-weight: 800;
  text-transform: uppercase;
}

.receipt-grid dd {
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 700;
  margin: 2px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.receipt-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  justify-content: flex-end;
}

.receipt-actions .primary-button,
.receipt-actions .secondary-button {
  min-height: 31px;
  white-space: nowrap;
}

.receipt-actions .text-button {
  color: var(--ink-soft);
}

.feedback-body {
  background:
    linear-gradient(90deg, transparent 0 48px, rgba(238, 106, 58, 0.18) 49px 50px, transparent 51px),
    repeating-linear-gradient(0deg, var(--paper-hi) 0 27px, #b6d1c8 28px 29px);
  min-height: 100dvh;
  overflow: auto;
}

.feedback-page {
  margin: 0 auto;
  max-width: 800px;
  padding: 32px 22px 48px;
}

.back-link {
  color: var(--ink);
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 14px;
  text-underline-offset: 3px;
}

.feedback-card {
  background: var(--paper-hi);
  border: 3px solid var(--ink);
  box-shadow: 8px 8px 0 var(--terminal);
  padding: clamp(22px, 5vw, 48px);
}

.feedback-card header h1 {
  font-family: var(--display);
  font-size: clamp(36px, 7vw, 66px);
  letter-spacing: -0.05em;
  line-height: 0.93;
  margin: 6px 0 12px;
}

.feedback-card header > p:last-child {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
  max-width: 570px;
}

.feedback-session {
  align-items: center;
  background: var(--terminal);
  color: var(--paper-hi);
  display: grid;
  gap: 4px 14px;
  grid-template-columns: auto 1fr;
  margin: 24px 0;
  padding: 13px 15px;
}

.feedback-session span {
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 8px;
  font-weight: 800;
  grid-row: 1 / 3;
  text-transform: uppercase;
}

.feedback-session strong {
  font-family: var(--mono);
  font-size: 13px;
}

.feedback-session small {
  color: var(--paper-dim);
  font-size: 8px;
}

.feedback-card form {
  display: grid;
  gap: 11px;
}

.feedback-card fieldset {
  border: 1px solid var(--line);
  margin: 0 0 5px;
  padding: 14px;
}

.feedback-card legend,
.field-label {
  font-family: var(--display);
  font-size: 17px;
  font-weight: 800;
}

.rating-row {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(5, 1fr);
  margin-top: 8px;
}

.rating-row label {
  cursor: pointer;
  display: grid;
  text-align: center;
}

.rating-row input {
  clip: rect(0 0 0 0);
  position: absolute;
}

.rating-row span {
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--ink);
  display: flex;
  font-family: var(--mono);
  font-weight: 900;
  height: 38px;
  justify-content: center;
}

.rating-row input:checked + span {
  background: var(--sun);
  box-shadow: 3px 3px 0 var(--ink);
}

.rating-row input:focus-visible + span {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
}

.rating-row small {
  color: var(--ink-soft);
  font-size: 7px;
  margin-top: 4px;
}

.feedback-card textarea {
  background: #fffdf5;
  border: 2px solid var(--ink);
  border-radius: 0;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.5;
  padding: 10px;
  resize: vertical;
}

.consent-row {
  align-items: center;
  display: flex;
  font-size: 10px;
  gap: 8px;
  margin: 4px 0;
}

.consent-row input {
  accent-color: var(--success);
  height: 17px;
  width: 17px;
}

.feedback-card form > .primary-button {
  justify-self: start;
  min-width: 230px;
}

.feedback-confirmation {
  align-items: center;
  background: #d8edbd;
  border: 2px solid var(--success);
  display: grid;
  gap: 10px;
  grid-template-columns: 32px 1fr auto;
  margin-top: 20px;
  padding: 12px;
}

.feedback-confirmation > span {
  align-items: center;
  background: var(--success);
  color: white;
  display: flex;
  font-weight: 900;
  height: 32px;
  justify-content: center;
  width: 32px;
}

.feedback-confirmation strong,
.feedback-confirmation p {
  display: block;
  margin: 0;
}

.feedback-confirmation p {
  color: var(--ink-soft);
  font-size: 8px;
  margin-top: 3px;
}

.feedback-footer {
  font-family: var(--mono);
  font-size: 8px;
  margin: 22px 0 0;
  text-align: center;
  text-transform: uppercase;
}

/* Voxel Field Rig — the interface is built from the same material logic as the farm. */
:root {
  --u: 4px;
  --ink: #14221b;
  --ink-soft: #3d5145;
  --paper: #ead49a;
  --paper-hi: #fff2c7;
  --paper-dim: #cdb77e;
  --shell: #091510;
  --frame: #20372d;
  --frame-hi: #52705f;
  --frame-lo: #06100c;
  --terminal: #10251d;
  --terminal-hi: #193429;
  --grass: #6ea54d;
  --water: #4fc2d6;
  --cyan: #70dce4;
  --warning: #e56845;
  --sun: #f4bf42;
  --success: #438e52;
  --danger: #b94435;
  --line: rgba(20, 34, 27, 0.3);
  --display: Copperplate, "Rockwell Extra Bold", "Iowan Old Style", Georgia, serif;
  --body: "Avenir Next Condensed", "Trebuchet MS", sans-serif;
  --mono: "SFMono-Regular", Menlo, Monaco, Consolas, monospace;
  --voxel-depth:
    inset 2px 2px 0 var(--frame-hi),
    inset -3px -3px 0 var(--frame-lo),
    5px 5px 0 #050a08;
}

body {
  background: var(--shell);
}

.app-shell {
  --state-accent: var(--water);
  background:
    linear-gradient(rgba(112, 220, 228, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(112, 220, 228, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(circle at 50% -25%, #29483a 0, var(--shell) 52%);
  gap: 12px;
  grid-template-rows: 64px 58px minmax(0, 1fr);
  padding: 10px 12px 14px;
}

.app-shell[data-mode="failure"] {
  --state-accent: var(--warning);
}

.app-shell[data-mode="repair"],
.app-shell[data-mode="repair-ready"] {
  --state-accent: var(--sun);
}

.app-shell[data-mode="proof"] {
  --state-accent: #69b85f;
}

.topbar {
  background: var(--frame);
  border: 3px solid var(--frame-lo);
  box-shadow:
    inset 2px 2px 0 var(--frame-hi),
    inset -3px -3px 0 var(--frame-lo),
    5px 5px 0 #050a08;
  color: var(--paper-hi);
  padding: 7px 11px;
  position: relative;
}

.topbar::after {
  background: var(--state-accent);
  bottom: -3px;
  content: "";
  height: 3px;
  left: 72px;
  position: absolute;
  transition: background 180ms ease;
  width: clamp(64px, 12vw, 180px);
}

.topbar .eyebrow {
  color: #9ebead;
}

.brand-lockup {
  gap: 14px;
}

.brand-mark {
  background: #0a1a14;
  border: 3px solid #050c09;
  box-shadow: inset 2px 2px 0 #416555, 3px 3px 0 #050a08;
  height: 42px;
  padding: 6px;
  transform: none;
  width: 42px;
}

.brand-lockup h1 {
  font-size: clamp(21px, 1.85vw, 28px);
  letter-spacing: 0.015em;
  text-shadow: 2px 2px 0 #07100c;
}

.brand-lockup h1 span {
  color: var(--sun);
  font-size: 9px;
  text-shadow: none;
}

.mission-meta {
  background: #0a1913;
  border: 2px solid #4f6a5c;
  box-shadow: inset 2px 2px 0 #183329, inset -2px -2px 0 #050b08;
  color: var(--paper-hi);
  font-size: 10px;
  min-height: 36px;
  padding: 8px 12px;
}

.meta-divider {
  background: #4f6a5c;
}

.stage-rail {
  background: #172b22;
  border: 3px solid #050c09;
  box-shadow: inset 2px 2px 0 #536e5e, inset -3px -3px 0 #07110d, 5px 5px 0 #050a08;
  min-height: 58px;
}

.stage-rail li {
  background: #e5cf91;
  border-right: 3px solid #14221b;
  box-shadow: inset 2px 2px 0 #fff0bd, inset -3px -3px 0 #a68f5d;
  gap: 0 9px;
  opacity: 0.72;
  padding: 6px 11px;
}

.stage-rail li span {
  background: #cab57d;
  border: 2px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 1px 1px 0 #fff1bd, inset -2px -2px 0 #88774f;
  font-weight: 900;
  height: 28px;
  width: 28px;
}

.stage-rail li b {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.stage-rail li small {
  font-size: 10px;
}

.stage-rail li.is-active {
  background: var(--sun);
  box-shadow: inset 3px 3px 0 #ad792b, inset -2px -2px 0 #ffe17b;
  opacity: 1;
}

.stage-rail li.is-active span {
  background: var(--ink);
  box-shadow: inset 2px 2px 0 #4f6458;
}

.stage-rail li.is-complete {
  background: #72a956;
  box-shadow: inset 2px 2px 0 #a6d275, inset -3px -3px 0 #396b3c;
  opacity: 1;
}

.workspace {
  gap: 14px;
  grid-template-columns: minmax(0, 1.8fr) minmax(420px, 0.88fr);
}

.scene-card,
.workbench {
  border: 4px solid #07110d;
  border-radius: 0;
  box-shadow: var(--voxel-depth);
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.scene-card {
  background: #87b29a;
}

.scene-card::before {
  box-shadow:
    inset 0 0 0 2px var(--state-accent),
    inset 7px 7px 0 rgba(255, 255, 255, 0.12),
    inset -7px -7px 0 rgba(5, 15, 11, 0.24);
  content: "";
  inset: 0;
  pointer-events: none;
  position: absolute;
  transition: box-shadow 180ms ease;
  z-index: 8;
}

#farm-canvas {
  image-rendering: pixelated;
}

.scene-grain {
  background-image:
    linear-gradient(rgba(20, 34, 27, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 34, 27, 0.08) 1px, transparent 1px),
    url("data:image/svg+xml,%3Csvg viewBox='0 0 120 120' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.06'/%3E%3C/svg%3E");
  background-size: 24px 24px, 24px 24px, auto;
  opacity: 0.22;
}

.mission-card {
  background: var(--paper-hi);
  border: 3px solid var(--ink);
  box-shadow: inset 3px 3px 0 #fff9dc, inset -4px -4px 0 #c5aa70, 5px 5px 0 rgba(7, 17, 13, 0.55);
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  left: 16px;
  max-width: 350px;
  padding: 15px 16px 14px;
  top: 16px;
}

.mission-card::after {
  background: var(--warning);
  height: 7px;
  width: 92px;
}

.card-kicker {
  font-size: 10px;
}

.mission-card h2 {
  font-size: clamp(21px, 2vw, 28px);
  letter-spacing: 0;
}

.mission-card > p:not(.card-kicker) {
  font-size: 12px;
  line-height: 1.35;
}

.world-facts {
  gap: 7px;
  margin-top: 11px;
}

.world-facts span {
  background: #e1c381;
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 #f9e3a8, inset -2px -2px 0 #a48750;
  font-size: 9px;
  min-height: 28px;
  padding: 5px 8px;
}

.world-callout,
.bert-tag {
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 #fff9dd, 3px 3px 0 rgba(7, 17, 13, 0.48);
  font-size: 10px;
  padding: 6px 8px;
}

.bert-tag {
  min-width: 94px;
}

.bert-tag > span {
  box-shadow: inset 2px 2px 0 #ffe17b, inset -2px -2px 0 #a96f24;
  height: 14px;
  width: 14px;
}

.bert-speech {
  border: 3px solid var(--ink);
  box-shadow: inset 2px 2px 0 #fff9dd, 5px 5px 0 rgba(7, 17, 13, 0.52);
  max-width: 252px;
  min-width: 208px;
  padding: 10px;
}

.bert-speech::after {
  border: 0;
  bottom: -13px;
  clip-path: polygon(0 0, 100% 0, 100% 4px, 9px 4px, 9px 9px, 5px 9px, 5px 13px, 0 13px);
  height: 13px;
  left: 25px;
  transform: none;
  width: 15px;
}

.bert-cue {
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.45), inset -2px -2px 0 rgba(20, 34, 27, 0.35);
  height: 34px;
  min-width: 34px;
}

.bert-speech p {
  font-size: 13px;
}

.agent-boundary-note {
  border: 3px solid var(--ink);
  box-shadow: inset 3px 3px 0 #ffe681, inset -3px -3px 0 #a57429, 5px 5px 0 #07110d;
  padding: 11px 13px;
  transform: none;
}

.agent-boundary-note strong {
  font-size: 17px;
}

.scene-caption {
  bottom: 8px;
  gap: 8px;
  left: 8px;
  right: 8px;
  z-index: 9;
}

.scene-caption p {
  background: rgba(9, 21, 16, 0.95);
  border: 2px solid #537163;
  box-shadow: inset 2px 2px 0 #203d31, inset -2px -2px 0 #030906;
  flex: 1;
  min-height: 38px;
  padding: 9px 11px;
}

.scene-caption p span {
  font-size: 9px;
}

.scene-caption p b {
  font-size: 12px;
}

.scene-caption .icon-button {
  background: var(--paper-hi);
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 white, inset -2px -2px 0 #b89d66;
  min-height: 44px;
  padding-inline: 11px;
}

.start-layer {
  background:
    linear-gradient(rgba(112, 220, 228, 0.09) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(112, 220, 228, 0.09) 1px, transparent 1px) 0 0 / 24px 24px,
    rgba(6, 16, 12, 0.34);
}

.start-card {
  border: 4px solid var(--ink);
  box-shadow: inset 3px 3px 0 #fff9dc, inset -4px -4px 0 #c0a46c, 9px 9px 0 var(--sun);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
  max-width: 490px;
  padding: 26px 29px 24px;
  transform: none;
}

.start-card h2 {
  font-size: clamp(31px, 3.5vw, 45px);
  letter-spacing: 0;
}

.start-card > p:not(.eyebrow, .start-number) {
  font-size: 14px;
}

.workbench {
  background:
    linear-gradient(rgba(112, 220, 228, 0.035) 1px, transparent 1px) 0 0 / 100% 24px,
    linear-gradient(90deg, transparent 0 95%, rgba(112, 220, 228, 0.05) 95%) 0 0 / 28px 100%,
    var(--terminal);
  gap: 8px;
  grid-template-rows: auto auto auto minmax(145px, 1fr) minmax(120px, 0.75fr) auto auto;
  padding: 13px;
}

.workbench::before {
  box-shadow: inset 0 0 0 2px rgba(112, 220, 228, 0.18);
  content: "";
  inset: 4px;
  pointer-events: none;
  position: absolute;
}

.workbench-header {
  background: #0a1a14;
  border: 2px solid #3f5e50;
  box-shadow: inset 2px 2px 0 #1e3d31, inset -2px -2px 0 #040a07;
  min-height: 54px;
  padding: 8px 10px;
}

.workbench-header h2 {
  font-size: 24px;
  letter-spacing: 0.015em;
}

.compiler-badge {
  border: 2px solid #536e5f;
  box-shadow: inset 2px 2px 0 #1b392e, inset -2px -2px 0 #040b08;
  font-size: 9px;
  min-height: 28px;
  padding: 7px 9px;
}

.lesson-prompt {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: inset 2px 2px 0 #fff1bc, inset -3px -3px 0 #aa915a;
  gap: 10px;
  padding: 9px 11px;
}

.lesson-step {
  font-size: 9px;
}

.lesson-prompt h3 {
  font-size: 17px;
  letter-spacing: 0;
}

.lesson-prompt p {
  font-size: 12px;
}

.language-card {
  background: #0a1c15;
  border: 2px solid #3d5c4e;
  box-shadow: inset 2px 2px 0 #1b3b2f, inset -2px -2px 0 #040a07;
  padding: 8px 9px;
}

.language-heading {
  margin-bottom: 7px;
}

.language-heading > span {
  font-size: 9px;
}

.language-heading button {
  align-items: center;
  display: inline-flex;
  font-size: 10px;
  justify-content: center;
  min-height: 44px;
  padding: 8px 6px;
}

.language-card ol {
  gap: 6px;
}

.language-card li {
  background: #122b21;
  border: 2px solid #365346;
  box-shadow: inset 2px 2px 0 #1e4436, inset -2px -2px 0 #07110d;
  min-height: 44px;
  padding: 6px 7px;
}

.language-card li.is-active {
  background: #6f5426;
  border-color: var(--sun);
  box-shadow: inset 3px 3px 0 #3d2e18, inset -2px -2px 0 #a77a2d;
}

.language-card li.is-complete {
  background: #244d31;
  border-color: #77bd67;
  box-shadow: inset 2px 2px 0 #386c42, inset -2px -2px 0 #10291a;
}

.language-card li.is-locked {
  background: #0d2119;
  color: #93aa9c;
  opacity: 1;
}

.language-card code {
  font-size: 10px;
}

.language-card li span,
.language-card.is-revealed li span {
  font-size: 10px;
  line-height: 1.25;
}

.editor-shell,
.trace-shell {
  background: #071a13;
  border: 3px solid #345246;
  box-shadow: inset 3px 3px 0 #030a07, inset -2px -2px 0 #203d32;
}

.editor-toolbar,
.trace-heading {
  background: #10291f;
  border-bottom: 2px solid #365348;
  min-height: 32px;
  padding: 7px 9px;
}

.editor-toolbar span,
.trace-heading span,
.trace-heading h3 {
  font-size: 9px;
}

.line-numbers {
  font-size: 12px;
  line-height: 1.72;
  padding-top: 10px;
}

#program-editor {
  background:
    repeating-linear-gradient(0deg, rgba(112, 220, 228, 0.025) 0 23px, rgba(112, 220, 228, 0.065) 23px 24px),
    #071a13;
  box-sizing: border-box;
  font-size: 13px;
  height: 100%;
  line-height: 1.72;
  max-height: 100%;
  padding: 10px 11px;
}

#program-editor:focus {
  box-shadow: inset 0 0 0 2px rgba(112, 220, 228, 0.42), inset 0 0 24px rgba(79, 194, 214, 0.08);
}

.editor-help {
  font-size: 12px;
  line-height: 1.35;
  min-height: 38px;
  padding: 8px 9px;
}

.trace-output {
  background: repeating-linear-gradient(0deg, transparent 0 27px, rgba(112, 220, 228, 0.035) 27px 28px);
}

.empty-trace p,
.trace-item b,
.trace-item small,
.coach-note {
  font-size: 12px;
}

.trace-item small {
  line-height: 1.35;
  min-height: 0;
}

.trace-state {
  font-size: 9px;
}

.trace-item {
  min-height: 38px;
  padding: 7px 8px;
}

.trace-index {
  border-radius: 0;
  min-height: 24px;
  min-width: 24px;
}

.action-row {
  gap: 9px;
}

.primary-button,
.secondary-button {
  border: 3px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.48), inset -3px -3px 0 rgba(20, 34, 27, 0.32), 0 4px 0 #050b08;
  font-size: 12px;
  min-height: 46px;
  padding: 10px 13px;
  text-transform: uppercase;
}

.primary-button {
  background: var(--sun);
}

.secondary-button {
  background: #d8d1ad;
}

.primary-button:not(:disabled):hover,
.secondary-button:not(:disabled):hover {
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.56), inset -3px -3px 0 rgba(20, 34, 27, 0.32), 0 6px 0 #050b08;
  transform: translateY(-2px);
}

.primary-button:not(:disabled):active,
.secondary-button:not(:disabled):active {
  box-shadow: inset 3px 3px 0 rgba(20, 34, 27, 0.32), inset -2px -2px 0 rgba(255, 255, 255, 0.35), 0 1px 0 #050b08;
  transform: translateY(3px);
}

.safety-note {
  color: #9eb5a8;
  font-size: 10px;
}

.receipt-panel {
  background:
    linear-gradient(rgba(20, 34, 27, 0.045) 1px, transparent 1px) 0 0 / 24px 24px,
    var(--paper-hi);
  border: 5px solid #326f43;
  border-radius: 0;
  box-shadow: inset 4px 4px 0 #8fd070, inset -5px -5px 0 #173c29, 10px 10px 0 #050a08;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

.receipt-stamp,
.debrief-takeaway,
.learning-recap,
.lesson-alert {
  border-radius: 0;
}

.receipt-stamp {
  box-shadow: inset 2px 2px 0 #9eda80, inset -3px -3px 0 #1d5934;
}

.debrief-takeaway {
  border: 3px solid var(--ink);
  box-shadow: inset 2px 2px 0 #fff0b5, inset -3px -3px 0 #aa8a4d;
}

.learning-recap {
  border: 3px solid var(--ink);
  box-shadow: inset 3px 3px 0 #fff9dc, inset -3px -3px 0 #c0a46c;
}

.recap-phases li {
  border: 2px solid var(--ink);
  border-radius: 0;
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.4), inset -3px -3px 0 rgba(20, 34, 27, 0.2);
}

.recap-number {
  border: 2px solid var(--ink);
  border-radius: 0;
}

.lesson-alert {
  border: 3px solid var(--ink);
  box-shadow: inset 3px 3px 0 #ff9b71, inset -3px -3px 0 #923424;
}

.receipt-grid dt {
  font-size: 9px;
}

.receipt-grid dd {
  font-size: 10px;
  line-height: 1.15;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.receipt-actions .primary-button,
.receipt-actions .secondary-button,
.receipt-actions .text-button {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
  padding-block: 9px;
}

.receipt-actions .text-button {
  background: #d8d1ad;
  border: 2px solid var(--ink);
  box-shadow: inset 2px 2px 0 #f7efcf, inset -2px -2px 0 #9d906d, 0 3px 0 #050b08;
  color: var(--ink);
  font-size: 10px;
  padding-inline: 11px;
  text-decoration: none;
  text-transform: uppercase;
}

.feedback-body {
  background:
    linear-gradient(rgba(112, 220, 228, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgba(112, 220, 228, 0.035) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--shell);
}

.feedback-page .back-link {
  align-items: center;
  background: #10291f;
  border: 2px solid #67d9e7;
  box-shadow: inset 2px 2px 0 #24493b, 3px 3px 0 #050b08;
  color: #9cf2f0;
  display: inline-flex;
  font-size: 12px;
  justify-content: center;
  min-height: 44px;
  padding: 9px 12px;
}

.feedback-card {
  border: 4px solid #07110d;
  border-radius: 0;
  box-shadow: var(--voxel-depth);
  clip-path: polygon(0 0, calc(100% - 14px) 0, 100% 14px, 100% 100%, 14px 100%, 0 calc(100% - 14px));
}

.feedback-session,
.feedback-card fieldset,
.feedback-card textarea,
.rating-row span,
.feedback-confirmation {
  border-radius: 0;
}

@keyframes live-pulse {
  0%, 100% { box-shadow: 0 0 0 1px var(--ink), 0 0 0 2px rgba(47, 125, 74, 0); }
  50% { box-shadow: 0 0 0 1px var(--ink), 0 0 0 6px rgba(47, 125, 74, 0.2); }
}

@keyframes trace-pulse {
  to { box-shadow: 0 0 0 4px rgba(103, 217, 231, 0.12); }
}

@keyframes receipt-rise {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 35px)); }
  to { opacity: 1; transform: translate(-50%, -50%); }
}

@keyframes proof-vignette {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 1180px) {
  .app-shell {
    padding-inline: 10px;
  }

  .workspace {
    grid-template-columns: minmax(0, 1.55fr) minmax(360px, 0.75fr);
  }

  .stage-rail li {
    padding-inline: 7px;
  }

  .stage-rail li small {
    display: none;
  }

  .receipt-panel {
    max-width: calc(100vw - 30px);
    width: 1120px;
  }

  .debrief-header {
    grid-template-columns: 72px minmax(260px, 0.9fr) minmax(300px, 1.1fr);
  }
}

@media (max-height: 760px) {
  .app-shell {
    gap: 7px;
    grid-template-rows: 53px 48px minmax(0, 1fr);
    padding-block: 7px 10px;
  }

  .workbench {
    gap: 5px;
    grid-template-rows: auto auto auto minmax(120px, 1fr) minmax(91px, 0.65fr) auto auto;
    padding: 9px;
  }

  .mission-card {
    padding-block: 10px;
  }

  .mission-card h2 {
    font-size: 22px;
  }

  .world-facts {
    margin-top: 6px;
  }

  .receipt-panel {
    gap: 9px;
    max-height: calc(100dvh - 18px);
    padding: 11px 12px 10px;
  }

  .receipt-heading h2 {
    font-size: 25px;
  }

  .debrief-takeaway {
    padding-block: 8px;
  }

  .learning-recap {
    padding-block: 8px 9px;
  }

  .recap-phases li {
    min-height: 112px;
    padding-block: 6px;
  }

  .receipt-footer {
    padding-top: 8px;
  }
}

@media (max-width: 880px) {
  body {
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
  }

  .mission-meta {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(440px, 58vh) auto;
  }

  .workbench {
    min-height: 650px;
  }

  .receipt-panel {
    max-height: calc(100dvh - 22px);
    max-width: calc(100vw - 30px);
    width: 760px;
  }

  .debrief-header {
    align-items: start;
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .debrief-takeaway {
    grid-column: 1 / 3;
  }

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

  .receipt-footer {
    grid-template-columns: 1fr;
  }

  .receipt-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 600px) {
  .brand-lockup h1 span,
  .stage-rail li small,
  .stage-rail li b,
  .start-number {
    display: none;
  }

  .stage-rail li {
    display: flex;
    justify-content: center;
  }

  .mission-card {
    max-width: calc(100% - 28px);
  }

  .world-callout,
  .bert-tag {
    transform: scale(0.85);
    transform-origin: top left;
  }

  .feedback-card {
    padding: 20px;
  }

  .receipt-panel {
    width: calc(100vw - 22px);
  }

  .debrief-header {
    grid-template-columns: 55px minmax(0, 1fr);
  }

  .receipt-stamp {
    font-size: 11px;
  }

  .receipt-stamp span {
    font-size: 18px;
  }

  .receipt-heading h2 {
    font-size: 22px;
  }

  .recap-heading {
    align-items: start;
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .recap-heading > p {
    text-align: left;
  }

  .recap-phases {
    grid-template-columns: 1fr;
  }

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

  .rating-row small {
    display: none;
  }

  .feedback-confirmation {
    grid-template-columns: 30px 1fr;
  }

  .feedback-confirmation button {
    grid-column: 1 / 3;
  }
}

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

.app-shell[data-test-mode="true"] *,
.app-shell[data-test-mode="true"] *::before,
.app-shell[data-test-mode="true"] *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  scroll-behavior: auto !important;
  transition-duration: 0.01ms !important;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: minmax(0, 1.55fr) minmax(400px, 0.82fr);
  }

  .stage-rail li {
    padding-inline: 7px;
  }
}

@media (max-height: 760px) {
  .app-shell {
    gap: 8px;
    grid-template-rows: 54px 50px minmax(0, 1fr);
    padding-block: 7px 10px;
  }

  .topbar {
    padding-block: 4px;
  }

  .brand-mark {
    height: 36px;
    width: 36px;
  }

  .stage-rail {
    min-height: 50px;
  }

  .stage-rail li span {
    height: 26px;
    width: 26px;
  }

  .workbench {
    gap: 5px;
    grid-template-rows: auto auto auto minmax(120px, 1fr) minmax(94px, 0.62fr) auto auto;
    padding: 9px;
  }

  .workbench-header {
    min-height: 44px;
    padding-block: 5px;
  }

  .lesson-prompt {
    padding-block: 6px;
  }

  .language-card {
    padding-block: 6px;
  }

  .language-card li {
    min-height: 38px;
    padding-block: 4px;
  }

  .primary-button,
  .secondary-button {
    min-height: 44px;
    padding-block: 8px;
  }
}

@media (min-width: 881px) and (max-width: 1350px),
  (min-width: 881px) and (max-height: 760px) {
  .app-shell[data-program-lines="4"] .workbench {
    gap: 4px;
    grid-template-rows: auto auto auto minmax(132px, 1fr) minmax(94px, 0.62fr) auto auto;
  }

  .app-shell[data-program-lines="4"] .editor-shell {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-shell[data-program-lines="4"] .editor-help {
    display: none;
  }

  .app-shell[data-program-lines="4"] #program-editor {
    padding-block: 8px;
  }

  .app-shell[data-program-lines="4"] .lesson-prompt,
  .app-shell[data-program-lines="4"] .language-card {
    padding-block: 4px;
  }

  .app-shell[data-mode="failure"] .workbench {
    grid-template-rows: auto auto auto minmax(132px, 0.9fr) minmax(150px, 1fr) auto auto;
  }

  .app-shell[data-mode="failure"] .language-card {
    align-items: center;
    display: grid;
    gap: 6px;
    grid-template-columns: 96px minmax(0, 1fr);
    padding-block: 4px;
  }

  .app-shell[data-mode="failure"] .language-heading {
    margin: 0;
  }

  .app-shell[data-mode="failure"] .language-heading > span {
    display: none;
  }

  .app-shell[data-mode="failure"] .language-heading button {
    width: 100%;
  }

  .app-shell[data-mode="failure"] .language-card ol {
    gap: 4px;
  }

  .app-shell[data-mode="failure"] .language-card li {
    min-height: 38px;
    padding: 4px 5px;
  }

  .app-shell[data-mode="failure"] .trace-item {
    min-height: 0;
    padding: 4px 6px;
  }

  .app-shell[data-mode="failure"] .trace-item b,
  .app-shell[data-mode="failure"] .trace-item small,
  .app-shell[data-mode="failure"] .coach-note {
    font-size: 10px;
    line-height: 1.2;
  }

  .app-shell[data-mode="failure"] .coach-note {
    padding: 4px 6px;
  }

  .app-shell[data-mode="failure"] .coach-note > div {
    min-width: 0;
  }

  .app-shell[data-mode="failure"] .coach-note code {
    overflow-wrap: anywhere;
    white-space: normal;
  }
}

@media (max-width: 880px) {
  .workspace {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(470px, 60vh) auto;
  }

  .workbench {
    min-height: 680px;
  }
}

@media (max-width: 600px) {
  .app-shell {
    padding-inline: 7px;
  }

  .brand-lockup h1 {
    font-size: 19px;
  }

  .stage-rail li {
    align-content: center;
    display: grid;
    gap: 2px;
    grid-template-columns: 1fr;
    grid-template-rows: 24px auto;
    justify-items: center;
    padding: 3px 2px;
  }

  .stage-rail li span {
    grid-row: 1;
    height: 23px;
    width: 23px;
  }

  .stage-rail li b {
    display: block;
    font-size: 9px;
    line-height: 1;
  }

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

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

  .primary-button,
  .secondary-button {
    font-size: 10px;
    min-height: 44px;
    padding-inline: 8px;
  }

  .mission-card {
    left: 10px;
    max-width: calc(100% - 20px);
    top: 10px;
  }

  .scene-caption p b {
    font-size: 10px;
  }

  .rating-row {
    gap: 4px;
  }

  .rating-row label,
  .rating-row span {
    min-height: 44px;
  }

  .rating-row span {
    height: 44px;
  }

  .rating-row small {
    display: block;
    font-size: 9px;
    line-height: 1.1;
    margin-top: 5px;
  }

  .consent-row {
    font-size: 12px;
    min-height: 44px;
    padding-block: 8px;
  }

  .consent-row input {
    height: 20px;
    min-width: 20px;
    width: 20px;
  }
}

/* Keep the plain-English field language readable without horizontal panning. */
#program-editor {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

@media (min-width: 881px) and (max-width: 1350px),
  (min-width: 881px) and (max-height: 760px) {
  .app-shell[data-mode="failure"] .workbench {
    gap: 3px;
  }

  .app-shell[data-mode="failure"] .editor-area,
  .app-shell[data-mode="repair"] .editor-area,
  .app-shell[data-mode="repair-ready"] .editor-area {
    grid-template-columns: 1fr;
  }

  .app-shell[data-mode="failure"] .line-numbers,
  .app-shell[data-mode="repair"] .line-numbers,
  .app-shell[data-mode="repair-ready"] .line-numbers,
  .app-shell[data-mode="failure"] .editor-help,
  .app-shell[data-mode="repair"] .editor-help,
  .app-shell[data-mode="repair-ready"] .editor-help {
    display: none;
  }

  .app-shell[data-mode="failure"] #program-editor,
  .app-shell[data-mode="repair"] #program-editor,
  .app-shell[data-mode="repair-ready"] #program-editor {
    font-size: 12px;
    line-height: 1.35;
    padding-block: 6px;
  }
}

@media (max-width: 600px) {
  .editor-area {
    grid-template-columns: 1fr;
  }

  .line-numbers {
    display: none;
  }

  #program-editor {
    overflow-x: hidden;
  }
}

/* Guided learner input layer */
.evidence-layer {
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  position: absolute;
  z-index: 6;
}

.evidence-bubble {
  --evidence-accent: #d89b35;
  align-items: center;
  background: #fff5d7;
  border: 3px solid var(--evidence-accent);
  box-shadow: inset 2px 2px 0 #fffdf0, 4px 4px 0 rgba(7, 17, 13, 0.48);
  color: var(--ink);
  display: flex;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 900;
  gap: 7px;
  line-height: 1.2;
  max-width: 158px;
  min-height: 42px;
  padding: 7px 9px;
  pointer-events: none;
  position: absolute;
  text-transform: uppercase;
}

.evidence-bubble::after {
  background: var(--evidence-accent);
  bottom: -8px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  content: "";
  height: 8px;
  left: 16px;
  position: absolute;
  width: 13px;
}

.evidence-bubble[data-tone="green"] {
  --evidence-accent: #58a45d;
}

.evidence-bubble[data-tone="blue"] {
  --evidence-accent: #3e9fbd;
}

.evidence-marker {
  color: var(--evidence-accent);
  font-size: 12px;
}

.workbench-header-actions {
  align-items: center;
  display: flex;
  gap: 7px;
}

.workbench-reset {
  background: #173a2d;
  border: 2px solid #6d8b7d;
  box-shadow: inset 2px 2px 0 #275442, inset -2px -2px 0 #07110d;
  color: var(--paper-hi);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  min-height: 44px;
  padding: 7px 9px;
  text-transform: uppercase;
}

.workbench-reset:hover:not(:disabled),
.workbench-reset:focus-visible {
  border-color: var(--cyan);
  color: var(--cyan);
  outline: 0;
}

.workbench-reset:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.persistent-goal-panel {
  align-items: stretch;
  grid-template-columns: minmax(120px, 0.8fr) minmax(0, 1.2fr);
}

.mission-goal-lockup,
.phase-hint {
  min-width: 0;
}

.goal-label {
  color: var(--danger);
  display: block;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.06em;
  margin-bottom: 3px;
  text-transform: uppercase;
}

.mission-goal-lockup strong {
  display: block;
  font-family: var(--display);
  font-size: 14px;
  line-height: 1.08;
}

.phase-hint {
  border-left: 2px solid var(--line);
  padding-left: 10px;
}

.persistent-goal-panel .phase-hint p {
  border: 0;
  margin-top: 3px;
  padding: 0;
}

.language-heading > div {
  min-width: 0;
}

.language-heading > div > span,
.language-heading > div > strong {
  display: block;
}

.language-heading > div > span {
  color: var(--paper-dim);
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.08em;
}

.language-heading > div > strong {
  color: var(--paper-hi);
  font-family: var(--display);
  font-size: 13px;
  line-height: 1.1;
  margin-top: 2px;
}

.guided-line-builder ol {
  align-items: stretch;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.guided-line-builder li,
.guided-line-builder li.is-active,
.guided-line-builder li.is-complete,
.guided-line-builder li.is-locked {
  align-items: start;
  display: grid;
  gap: 5px;
  grid-template-columns: 22px minmax(0, 1fr);
  min-height: 48px;
  padding: 5px 6px;
}

.builder-line-number {
  align-items: center;
  background: #07140f;
  border: 1px solid #527064;
  color: var(--paper-dim) !important;
  display: flex !important;
  font-family: var(--mono);
  font-size: 8px !important;
  font-weight: 900;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.builder-line-copy {
  min-width: 0;
}

.guided-line-builder .builder-line-copy code {
  color: var(--cyan);
  font-size: 8px;
  text-transform: uppercase;
}

.builder-sentence {
  color: var(--paper-hi);
  font-size: 9px;
  line-height: 1.2;
  margin: 2px 0 0;
}

.builder-blank {
  background: rgba(244, 198, 79, 0.16);
  border: 1px dashed var(--sun);
  color: var(--sun);
  cursor: pointer;
  display: inline;
  font: inherit;
  font-weight: 900;
  margin: 1px 2px;
  min-height: 28px;
  padding: 3px 5px;
  text-align: left;
}

.builder-blank[data-open="false"] {
  background: rgba(103, 217, 231, 0.15);
  border-color: var(--cyan);
  color: var(--cyan);
}

.builder-blank:focus-visible {
  outline: 2px solid var(--paper-hi);
  outline-offset: 2px;
}

.builder-choices {
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 7px;
}

.builder-choice {
  --choice-accent: #889b92;
  background: #132c22;
  border: 2px solid var(--choice-accent);
  box-shadow: inset 2px 2px 0 rgba(255, 255, 255, 0.08), inset -2px -2px 0 #06110c;
  color: var(--paper-hi);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  line-height: 1.15;
  min-height: 44px;
  padding: 7px 8px;
}

.builder-choice[data-evidence-tone="amber"] {
  --choice-accent: #d89b35;
}

.builder-choice[data-evidence-tone="green"] {
  --choice-accent: #58a45d;
}

.builder-choice[data-evidence-tone="blue"] {
  --choice-accent: #3e9fbd;
}

.builder-choice:hover:not(:disabled),
.builder-choice:focus-visible,
.builder-choice[aria-pressed="true"] {
  background: #234c3b;
  box-shadow: inset 0 0 0 2px var(--choice-accent);
  outline: 0;
}

.builder-choice:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.builder-reaction {
  background: rgba(244, 198, 79, 0.12);
  border-left: 3px solid var(--sun);
  color: var(--paper-hi);
  font-size: 9px;
  line-height: 1.25;
  margin: 6px 0 0;
  padding: 5px 7px;
}

/* This support text is part of the persistent phase guidance. */
.editor-help,
.app-shell[data-program-lines="4"] .editor-help,
.app-shell[data-mode="failure"] .editor-help,
.app-shell[data-mode="repair"] .editor-help,
.app-shell[data-mode="repair-ready"] .editor-help {
  display: block !important;
}

/* Four complete commands must fit even in the input event's first paint. */
#program-editor {
  font-size: 11px;
  height: auto;
  line-height: 1.25;
  max-height: none;
  padding-block: 4px;
}

.line-numbers {
  font-size: 11px;
  line-height: 1.25;
  padding-top: 4px;
}

@media (max-width: 1180px), (max-height: 760px) {
  .workbench-header h2 {
    font-size: 20px;
  }

  .workbench-reset {
    padding-inline: 7px;
  }

  .mission-goal-lockup strong {
    font-size: 10px;
  }

  .persistent-goal-panel .phase-hint p {
    font-size: 8px;
    line-height: 1.15;
  }

  .persistent-goal-panel .phase-hint h3 {
    font-size: 14px;
  }

  .persistent-goal-panel {
    gap: 5px;
    padding: 4px 7px;
  }

  .language-card.guided-line-builder {
    padding: 5px 7px;
  }

  .guided-line-builder .language-heading {
    margin-bottom: 3px;
  }

  .guided-line-builder .language-heading button {
    min-height: 30px;
    padding-block: 4px;
  }

  .guided-line-builder li,
  .guided-line-builder li.is-active,
  .guided-line-builder li.is-complete,
  .guided-line-builder li.is-locked {
    gap: 3px;
    min-height: 42px;
    padding: 3px;
  }

  .builder-sentence {
    font-size: 7px;
    line-height: 1.05;
  }

  .builder-choice {
    font-size: 8px;
  }

  .guided-line-builder .builder-line-copy code {
    font-size: 7px;
  }

  .builder-line-number {
    font-size: 7px !important;
    height: 18px;
    width: 18px;
  }

  .builder-blank {
    min-height: 22px;
    padding: 2px 4px;
  }

  .builder-choices {
    margin-top: 4px;
  }
}

@media (min-width: 881px) and (max-width: 1350px),
  (min-width: 881px) and (max-height: 760px) {
  .app-shell[data-program-lines="4"] .workbench {
    grid-template-rows: auto auto auto minmax(132px, 1fr) minmax(82px, 0.55fr) auto auto;
  }

  .app-shell[data-program-lines="4"][data-mode="failure"] .workbench {
    grid-template-rows: auto auto auto minmax(124px, 0.9fr) minmax(104px, 0.7fr) auto auto;
  }

  .app-shell[data-mode="failure"] .trace-shell,
  .app-shell[data-mode="repair"] .trace-shell,
  .app-shell[data-mode="repair-ready"] .trace-shell {
    min-height: 104px;
  }

  .app-shell[data-mode="failure"] .language-card.guided-line-builder,
  .app-shell[data-mode="repair"] .language-card.guided-line-builder,
  .app-shell[data-mode="repair-ready"] .language-card.guided-line-builder {
    display: block;
    padding: 5px 7px;
  }

  .app-shell[data-mode="failure"] .guided-line-builder .language-heading,
  .app-shell[data-mode="repair"] .guided-line-builder .language-heading,
  .app-shell[data-mode="repair-ready"] .guided-line-builder .language-heading {
    margin-bottom: 3px;
  }

  .app-shell[data-mode="failure"] .guided-line-builder .language-heading button,
  .app-shell[data-mode="repair"] .guided-line-builder .language-heading button,
  .app-shell[data-mode="repair-ready"] .guided-line-builder .language-heading button {
    width: auto;
  }

  .app-shell[data-program-lines="4"] .editor-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .app-shell[data-program-lines="4"] .editor-help {
    font-size: 7px;
    line-height: 1.15;
    min-height: 18px;
    padding: 3px 7px;
  }

  .app-shell[data-program-lines="4"] #program-editor {
    font-size: 11px;
    height: auto;
    line-height: 1.4;
    max-height: none;
    padding-block: 5px;
  }

  .app-shell[data-program-lines="4"][data-mode="failure"] #program-editor,
  .app-shell[data-program-lines="4"][data-mode="repair"] #program-editor,
  .app-shell[data-program-lines="4"][data-mode="repair-ready"] #program-editor {
    padding-block: 3px;
  }

  .app-shell[data-program-lines="4"] .line-numbers {
    font-size: 11px;
    line-height: 1.4;
    padding-top: 5px;
  }
}

@media (max-width: 600px) {
  .persistent-goal-panel {
    grid-template-columns: 1fr;
  }

  .phase-hint {
    border-left: 0;
    border-top: 2px solid var(--line);
    margin-top: 7px;
    padding: 7px 0 0;
  }

  .mission-goal-lockup strong {
    font-size: 12px;
  }

  .persistent-goal-panel .phase-hint h3 {
    font-size: 16px;
  }

  .persistent-goal-panel .phase-hint p {
    font-size: 10px;
  }

  .guided-line-builder ol {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .builder-choices {
    grid-template-columns: 1fr;
  }

  .builder-choice {
    font-size: 10px;
  }

  .builder-sentence {
    font-size: 9px;
    line-height: 1.2;
  }

  .evidence-bubble {
    font-size: 9px;
    max-width: 124px;
    min-height: 40px;
    padding: 6px 7px;
  }

  .workbench-header-actions {
    gap: 4px;
  }

  .compiler-badge {
    display: none;
  }
}
