:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --panel: #ffffff;
  --ink: #17211f;
  --muted: #64706c;
  --line: #d8dfdc;
  --green: #1f7a4d;
  --green-soft: #e7f4ec;
  --blue: #1c5f8f;
  --blue-soft: #e7f0f8;
  --amber: #a46412;
  --amber-soft: #fff3dd;
  --red: #a73737;
  --red-soft: #fbe8e6;
  --shadow: 0 12px 36px rgba(23, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: linear-gradient(180deg, #f7f8f7 0%, var(--bg) 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 92px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: 42px;
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 15px;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0;
}

.status-pill,
.verdict {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--green);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.dot.running {
  background: var(--amber);
}

.dot.error {
  background: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: 280px minmax(0, 1.2fr) minmax(340px, 0.9fr);
  gap: 16px;
  align-items: stretch;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 54px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.experiment-list {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.real-config {
  display: none;
  gap: 10px;
  padding: 0 14px 14px;
}

.real-config.visible {
  display: grid;
}

.real-config label {
  display: grid;
  gap: 5px;
}

.real-config label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.real-config input,
.real-config textarea {
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  font-size: 12px;
}

.real-config textarea {
  min-height: 92px;
  line-height: 1.45;
  resize: vertical;
}

.live-only {
  display: none;
}

.real-config.live .live-only {
  display: grid;
}

.real-config input:focus,
.real-config textarea:focus {
  border-color: rgba(31, 122, 77, 0.7);
  outline: none;
}

.experiment-button {
  width: 100%;
  min-height: 86px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    transform 160ms ease;
}

.experiment-button:hover,
.experiment-button.active {
  border-color: rgba(31, 122, 77, 0.55);
  background: var(--green-soft);
}

.experiment-button:active {
  transform: translateY(1px);
}

.experiment-button strong {
  display: block;
  margin-bottom: 7px;
  font-size: 14px;
}

.experiment-button span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  cursor: pointer;
}

.request-panel,
.output-panel {
  min-height: 520px;
}

.request-grid {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.layer,
.result-card {
  min-height: 104px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.layer span,
.result-card span {
  display: block;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.layer p,
.result-card p,
.finding {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.58;
}

.fixed {
  border-left: 5px solid var(--green);
}

.convex {
  border-left: 5px solid var(--blue);
}

.policy {
  border-left: 5px solid var(--amber);
}

.user {
  border-left: 5px solid var(--ink);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--amber-soft);
  color: var(--amber);
  font-size: 12px;
  font-weight: 700;
}

.chip.empty {
  background: #eef1ef;
  color: var(--muted);
}

.output-panel {
  display: flex;
  flex-direction: column;
}

.result-card {
  margin: 14px;
  background: var(--green-soft);
}

.trace-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 0 14px 14px;
}

.tool-trace {
  display: grid;
  gap: 10px;
}

.tool-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.tool-item.ok {
  border-color: rgba(31, 122, 77, 0.38);
  background: var(--green-soft);
}

.tool-item.blocked {
  border-color: rgba(167, 55, 55, 0.35);
  background: var(--red-soft);
}

.tool-item strong {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 13px;
}

.tool-item code {
  display: block;
  overflow-x: auto;
  color: var(--muted);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.finding {
  min-height: 120px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.raw-panel {
  margin-top: 16px;
}

.transform-panel {
  margin-top: 16px;
}

.transform-flow {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr) minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
}

.transform-column {
  min-width: 0;
}

.transform-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 30px;
  margin-bottom: 10px;
}

.transform-title span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--ink);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.source-json,
.mapping-row,
.layer-map-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.source-json {
  min-height: 480px;
  max-height: 620px;
  padding: 14px;
}

.mapping-rules,
.layer-map {
  display: grid;
  gap: 10px;
}

.mapping-row,
.layer-map-row {
  padding: 12px;
}

.mapping-path {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.mapping-path code {
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.mapping-path span {
  color: var(--muted);
  font-weight: 800;
}

.mapping-path strong {
  color: var(--ink);
  font-size: 13px;
}

.mapping-row p {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.mapping-row pre,
.layer-map-row pre {
  max-height: 120px;
  padding: 0;
  color: #20312d;
  background: transparent;
}

.guardrail-note {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(167, 55, 55, 0.25);
  border-radius: 8px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.layer-map-row {
  border-left: 5px solid var(--line);
}

.layer-map-row.platform_instruction {
  border-left-color: var(--green);
}

.layer-map-row.agent_profile {
  border-left-color: var(--blue);
}

.layer-map-row.tool_policy {
  border-left-color: var(--amber);
}

.layer-map-row.conversation_context {
  border-left-color: #6f5aa8;
}

.layer-map-row.user_message {
  border-left-color: var(--ink);
}

.layer-map-row strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.layer-map-row span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

pre {
  overflow: auto;
  max-height: 360px;
  margin: 0;
  padding: 16px;
  color: #20312d;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .output-panel {
    grid-column: 1 / -1;
  }

  .transform-flow {
    grid-template-columns: 1fr;
  }

  .source-json {
    min-height: 260px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 30px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .request-panel,
  .output-panel {
    min-height: auto;
  }
}
