:root {
  --ink: #17212b;
  --muted: #5f6f7f;
  --line: #d7dee8;
  --bg: #f6f8fb;
  --panel: #ffffff;
  --green: #19795c;
  --blue: #1d5f99;
  --amber: #a86500;
  --red: #b42318;
  --teal: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.status-strip .toggle {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #b6e0d2;
  color: var(--green);
  background: #eefbf6;
  border-radius: 999px;
  padding: 6px 9px 6px 6px;
  font-size: 12px;
  font-weight: 700;
}

.status-strip .toggle span {
  position: relative;
  width: 28px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--green);
}

.status-strip .toggle span::after {
  content: "";
  position: absolute;
  top: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
}

.status-strip .toggle:not(.active) {
  border-color: var(--line);
  color: var(--muted);
  background: #fff;
}

.status-strip .toggle:not(.active) span {
  background: #95a3b1;
}

.status-strip .toggle:not(.active) span::after {
  right: auto;
  left: 2px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  min-height: calc(100vh - 82px);
}

.mission-panel {
  padding: 22px;
  background: #fbfcfd;
  border-right: 1px solid var(--line);
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 10px 14px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
  min-width: 128px;
}

button:focus,
textarea:focus {
  outline: 3px solid #b8d8f2;
  outline-offset: 2px;
}

label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  line-height: 1.45;
}

.scenario-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.scenario-picker button {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--blue);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 900;
  text-align: left;
}

.scenario-picker button.active,
.scenario-picker button:hover {
  border-color: #7db5df;
  background: #edf7ff;
}

.diagram {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.diagram div {
  position: relative;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-weight: 800;
}

.diagram div:not(:last-child)::after {
  content: "flow";
  position: absolute;
  right: 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.output-links {
  margin-top: 18px;
  padding: 12px;
  border: 1px solid #f4c978;
  border-radius: 8px;
  background: #fff8e8;
}

.output-links p {
  margin: 0 0 8px;
  color: #6f4d00;
  font-size: 13px;
  font-weight: 700;
}

.ask-panel {
  margin-top: 18px;
  padding: 0 12px 12px;
  overflow: hidden;
  border: 1px solid #b6e0d2;
  border-radius: 8px;
  background: #fff;
}

.ask-banner {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 -12px 14px;
  padding: 9px 12px;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 900;
}

.ask-banner span {
  display: grid;
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 999px;
  background: #fff;
  color: var(--green);
  font-weight: 900;
}

.ask-panel textarea {
  min-height: 78px;
}

.ask-panel pre {
  min-height: 120px;
  max-height: 220px;
  margin-top: 10px;
  overflow: auto;
}

code,
pre {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

code {
  overflow-wrap: anywhere;
}

.workspace {
  padding: 22px;
  overflow: auto;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.metric-card {
  padding: 14px;
  color: inherit;
  text-align: left;
  min-width: 0;
}

.metric-card:hover {
  border-color: #9dc6e7;
  background: #f7fbff;
}

.metric {
  display: block;
  color: var(--blue);
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
}

.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.phase-bar {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.phase-bar button {
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
  min-width: 0;
  padding: 8px 10px;
}

.phase-bar button.active {
  border-color: #8cc5b5;
  color: var(--green);
  background: #eefbf6;
}

.phase-bar button.inspected {
  box-shadow: inset 0 0 0 2px #1d5f9933;
}

.phase-detail {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #c7d8ea;
  border-radius: 8px;
  background: #f4f9fd;
}

.phase-detail strong {
  display: block;
  margin-bottom: 4px;
}

.phase-detail p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

.panel {
  padding: 16px;
  margin-bottom: 14px;
}

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

.panel-heading span {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.panel-heading span[data-tone="working"] {
  border-color: #f4c978;
  color: #6f4d00;
  background: #fff8e8;
}

.panel-heading span[data-tone="ok"] {
  border-color: #b6e0d2;
  color: var(--green);
  background: #eefbf6;
}

.panel-heading span[data-tone="error"] {
  border-color: #f0b8b2;
  color: var(--red);
  background: #fff3f2;
}

.foundry-panel pre {
  max-height: 280px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
}

.pulse {
  animation: panel-pulse 900ms ease-out 3;
}

@keyframes panel-pulse {
  0% {
    border-color: #1d5f99;
    background: #e8f5ff;
    box-shadow: 0 0 0 0 #1d5f9955;
  }

  45% {
    border-color: #1d5f99;
    background: #fff7d6;
    box-shadow: 0 0 0 9px #1d5f9900;
  }

  100% {
    border-color: var(--line);
    background: var(--panel);
    box-shadow: none;
  }
}

.panel h2 {
  margin-bottom: 12px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
}

.agent,
.fit {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.reveal {
  animation: reveal-card 180ms ease-out both;
}

@keyframes reveal-card {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

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

.agent strong,
.fit strong {
  display: block;
  margin-bottom: 6px;
}

.agent p,
.fit p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.agent p:last-child,
.fit p:last-child {
  margin-bottom: 0;
}

.card-label {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.fit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}

.action-item {
  border: 1px solid #c7d8ea;
  border-radius: 8px;
  padding: 12px;
  background: #f7fbff;
}

.action-reveal {
  animation: action-reveal 620ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

@keyframes action-reveal {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.985);
    border-color: #9dc6e7;
    background: #eef8ff;
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    border-color: #c7d8ea;
    background: #f7fbff;
  }
}

.action-item strong {
  display: block;
  margin-bottom: 8px;
  color: var(--blue);
}

.action-item p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.action-item p:last-child {
  margin-bottom: 0;
}

.badge {
  display: inline-block;
  margin-bottom: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #e8f1f8;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
}

ul {
  margin: 0;
  padding-left: 18px;
}

li {
  margin-bottom: 9px;
}

.gates li {
  color: var(--red);
  font-weight: 700;
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.4;
}

pre {
  min-height: 180px;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  color: #24313d;
  line-height: 1.45;
}

@media (max-width: 900px) {
  .topbar,
  .layout,
  .split {
    display: block;
  }

  .mission-panel {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metrics,
  .phase-bar {
    grid-template-columns: 1fr;
  }

  .status-strip {
    justify-content: flex-start;
    margin-top: 12px;
  }
}
