:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #67707d;
  --line: #d9e0e7;
  --blue: #1f6feb;
  --green: #167d4c;
  --red: #b42318;
  --amber: #b76e00;
  --violet: #6750a4;
}

* {
  box-sizing: border-box;
}

.workflow-controls { margin: 20px 0; flex-wrap: wrap; }
#workflowSection { margin-bottom: 28px; }
#workflowSection h2, #workflowSection h3, #workflowSection p { margin-bottom: 12px; }
#workflowSection .metrics { margin: 20px 0; }
#workflowSection pre { white-space: pre-wrap; overflow-wrap: anywhere; }
#workflowError { color: var(--red); }
button:disabled { opacity: 0.55; cursor: not-allowed; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #111820;
  color: #f8fafc;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: #f5b84b;
  color: #111820;
  border-radius: 8px;
  font-weight: 800;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  font-size: 20px;
}

.brand p,
.eyebrow,
.panel-head span,
.metrics span {
  color: var(--muted);
}

.sidebar .brand p {
  color: #a7b1bf;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 8px;
}

.nav {
  color: #dce5ee;
  background: transparent;
  text-align: left;
  padding: 10px 12px;
  border-radius: 6px;
  user-select: none;
}

.nav.active,
.nav:hover {
  background: #223040;
}

.status {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #cbd5df;
  font-size: 13px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #41d17d;
}

.workspace {
  padding: 28px;
  display: grid;
  gap: 20px;
  align-content: start;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 12px;
  font-weight: 700;
}

h2 {
  margin-top: 4px;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
  max-width: 780px;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

select {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: white;
  color: var(--ink);
  padding: 0 12px;
  min-width: 250px;
  font: inherit;
}

.primary,
.secondary {
  min-height: 42px;
  border-radius: 7px;
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
}

.primary {
  background: var(--blue);
  color: white;
}

.secondary {
  margin-top: 14px;
  background: #111820;
  color: white;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 12px;
}

.case-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.case-strip article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  display: grid;
  gap: 8px;
}

.case-strip article:nth-child(1) {
  border-left: 5px solid var(--blue);
}

.case-strip article:nth-child(2) {
  border-left: 5px solid var(--red);
}

.case-strip article:nth-child(3) {
  border-left: 5px solid var(--green);
}

.case-strip span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.case-strip strong {
  font-size: 18px;
  line-height: 1.25;
}

.metrics article,
.panel,
.adapter {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metrics article {
  padding: 16px;
  display: grid;
  gap: 6px;
}

.metrics strong {
  font-size: 24px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
}

.run-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1.15fr) minmax(300px, 0.85fr);
  gap: 16px;
}

.panel {
  padding: 18px;
  min-height: 260px;
}

.demo-flow-panel {
  min-height: auto;
}

.demo-flow {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.demo-flow article {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  background: #fbfcfd;
}

.demo-flow span {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #111820;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 10px;
}

.demo-flow strong {
  display: block;
  margin-bottom: 5px;
}

.demo-flow p {
  color: #333b45;
  line-height: 1.45;
}

.simulator-panel {
  min-height: auto;
}

.simulator-form {
  display: grid;
  grid-template-columns: minmax(180px, 0.7fr) repeat(3, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: start;
}

.simulator-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.simulator-form button {
  align-self: end;
}

.sim-actions {
  align-self: end;
  display: grid;
  gap: 8px;
}

.compact {
  min-height: 38px;
  margin-top: 0;
  padding: 0 12px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  font: inherit;
  text-transform: none;
}

input {
  min-height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 94px;
  padding: 10px 12px;
  resize: vertical;
  line-height: 1.35;
}

.simulation-result {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.before-after,
.sim-decision {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 14px;
  background: #fbfcfd;
}

.before {
  border-left: 5px solid var(--red);
}

.after {
  border-left: 5px solid var(--green);
}

.before-after span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.before-after p,
.sim-decision p {
  line-height: 1.45;
}

.sim-decision {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.sim-decision small,
.live-note {
  color: var(--muted);
}

.sim-decision code {
  color: var(--violet);
  overflow-wrap: anywhere;
}

.timeline-panel {
  grid-row: span 2;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  font-size: 17px;
}

.panel-link {
  color: var(--blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
  text-transform: uppercase;
}

.panel-link:hover {
  text-decoration: underline;
}

.timeline {
  list-style: none;
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
}

.timeline li {
  border-left: 3px solid var(--blue);
  padding: 4px 0 4px 12px;
}

.timeline time {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.timeline strong,
.agent strong,
.mismatch strong {
  display: block;
  margin-bottom: 4px;
}

.agent-list,
.mismatch-list,
.trace-list,
.event-list,
.adapter-strip {
  display: grid;
  gap: 10px;
}

.agent,
.mismatch,
.trace-step,
.event {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 12px;
}

.agent small {
  color: var(--green);
  font-weight: 700;
}

.mismatch {
  border-left: 4px solid var(--red);
}

.trace-step {
  display: grid;
  grid-template-columns: 34px minmax(120px, 0.8fr) minmax(170px, 1fr);
  gap: 8px 12px;
  align-items: start;
  background: #fbfcfd;
}

.trace-step p,
.trace-step small,
.event p,
.event small {
  grid-column: 2 / -1;
}

.trace-index {
  grid-row: span 3;
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #111820;
  color: #f8fafc;
  font-size: 12px;
  font-weight: 800;
}

.trace-step code {
  color: var(--violet);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.trace-step small,
.event small {
  color: var(--muted);
}

.decision {
  border-top: 4px solid var(--amber);
}

.report {
  grid-column: 1 / -1;
  min-height: 220px;
}

.decision p {
  color: #323a45;
  line-height: 1.5;
}

pre {
  white-space: pre-wrap;
  color: var(--green);
  font-size: 12px;
  max-height: 260px;
  overflow: auto;
  line-height: 1.5;
}

.structured-panel pre {
  color: #26303a;
}

.observability-panel {
  min-height: 180px;
}

.event {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 4px 10px;
}

.event-level {
  grid-row: span 3;
  align-self: start;
  border-radius: 999px;
  padding: 5px 8px;
  text-align: center;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.event-info .event-level {
  background: #e8f1ff;
  color: #174ea6;
}

.event-warning .event-level {
  background: #fff4d6;
  color: #8a5200;
}

.adapter-strip {
  grid-template-columns: repeat(2, minmax(240px, 1fr));
}

#replaySection,
#agentRunSection,
#observabilitySection,
#adapters,
#architectureSection {
  scroll-margin-top: 24px;
}

.tabs {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
}

.tool-list {
  display: grid;
  gap: 10px;
}

.tool {
  display: grid;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 10px 12px;
}

.tool code {
  color: var(--violet);
  font-weight: 800;
}

.architecture-panel {
  grid-column: 1 / -1;
  grid-row: 1;
}

.architecture-preview {
  display: flex;
  justify-content: center;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f3f6fa;
}

.architecture-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 540px;
  object-fit: contain;
}

.tools-panel {
  grid-column: 1 / -1;
  min-height: 0;
}

.tools-panel summary {
  cursor: pointer;
  font-weight: 700;
}

.tools-panel summary span {
  margin-left: 12px;
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.tools-panel[open] .tool-list {
  margin-top: 16px;
}

.tools-panel .tool-list {
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.adapter {
  padding: 16px;
}

.adapter h4 {
  margin-bottom: 10px;
}

.adapter p {
  color: #333b45;
  line-height: 1.45;
}

@media (max-width: 920px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    height: auto;
  }

  .topbar,
  .grid,
  .run-grid,
  .tabs,
  .simulator-form {
    grid-template-columns: 1fr;
    display: grid;
  }

  .actions {
    display: grid;
    width: 100%;
  }

  select {
    min-width: 0;
    width: 100%;
  }

  .case-strip,
  .metrics,
  .demo-flow,
  .simulation-result,
  .adapter-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 18px;
  }

  .case-strip,
  .metrics,
  .demo-flow,
  .simulation-result,
  .adapter-strip {
    grid-template-columns: 1fr;
  }

  .primary,
  .secondary {
    width: 100%;
  }

  .architecture {
    grid-template-columns: 1fr;
  }

  .trace-step,
  .event {
    grid-template-columns: 1fr;
  }

  .trace-index,
  .event-level,
  .trace-step p,
  .trace-step small,
  .event p,
  .event small {
    grid-column: auto;
  }
}
