:root {
  color-scheme: light;
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef4f6;
  --ink: #17232a;
  --muted: #63717a;
  --line: #d6dfdf;
  --green: #146c43;
  --green-strong: #0f5132;
  --green-soft: #dff2e8;
  --blue: #255e85;
  --blue-soft: #e3eff8;
  --amber: #966116;
  --amber-soft: #fff2d8;
  --red: #9b3944;
  --red-soft: #f8e0e4;
  --shadow: 0 18px 44px rgba(23, 35, 42, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(37, 94, 133, 0.10), transparent 280px),
    var(--bg);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

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

h1 {
  font-size: 1.05rem;
}

h2 {
  font-size: clamp(1.2rem, 2vw, 1.72rem);
  line-height: 1.18;
  overflow-wrap: anywhere;
}

h3 {
  font-size: 0.98rem;
}

.muted,
.brand p {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 2rem);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.brand,
.top-actions,
.builder-head,
.sidebar-head,
.snippet-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.brand {
  min-width: 0;
}

.mark {
  width: 2.5rem;
  height: 2.5rem;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.button {
  min-height: 2.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.55rem 0.82rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.button svg {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.button.primary {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.button.primary:hover {
  background: var(--green-strong);
}

.button.secondary {
  background: var(--blue-soft);
  color: var(--blue);
  border-color: #bfd6e8;
}

.button.ghost {
  background: transparent;
}

.button.compact {
  min-height: 2.15rem;
  padding: 0.42rem 0.62rem;
}

.button:disabled {
  opacity: 0.55;
  cursor: progress;
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 2.5vw, 2rem);
}

.config-band {
  display: grid;
  grid-template-columns: minmax(18rem, 1.4fr) repeat(4, minmax(8rem, 0.75fr)) auto;
  gap: 0.8rem;
  align-items: end;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
}

label {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  min-height: 2.45rem;
  padding: 0.52rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 4rem;
  resize: vertical;
  line-height: 1.35;
}

.status-stack {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.45rem;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  white-space: nowrap;
}

.status.ok {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b8dfc8;
}

.status.warn {
  color: var(--amber);
  background: var(--amber-soft);
  border-color: #e7c88d;
}

.status.bad {
  color: var(--red);
  background: var(--red-soft);
  border-color: #e1b5bc;
}

.status.pending,
.status.subtle {
  color: var(--blue);
  background: var(--blue-soft);
  border-color: #bfd6e8;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.metric {
  min-height: 5rem;
  display: grid;
  align-content: center;
  gap: 0.35rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  font-size: 1.5rem;
  line-height: 1;
}

.outcome-band {
  display: grid;
  grid-template-columns: minmax(15rem, 1.1fr) minmax(18rem, 1.4fr) minmax(14rem, 0.9fr);
  gap: 1rem;
  align-items: stretch;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.outcome-copy {
  display: grid;
  align-content: center;
  gap: 0.45rem;
}

.eyebrow {
  color: var(--green);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.outcome-steps {
  display: grid;
  gap: 0.5rem;
}

.step {
  display: grid;
  grid-template-columns: 1.75rem 1fr;
  gap: 0.6rem;
  align-items: start;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.step-index {
  width: 1.75rem;
  height: 1.75rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 800;
}

.step strong,
.step span {
  display: block;
  overflow-wrap: anywhere;
}

.step span {
  color: var(--muted);
  font-size: 0.86rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(18rem, 0.32fr) minmax(0, 1fr);
  gap: 1rem;
}

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

.sidebar {
  padding: 1rem;
  align-self: start;
  position: sticky;
  top: 5rem;
}

.sidebar-head {
  justify-content: space-between;
  margin-bottom: 0.85rem;
}

.detail {
  min-width: 0;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}

.tabbar {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.tab {
  min-height: 2.2rem;
  flex: 0 0 auto;
  padding: 0.35rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.tab.active {
  color: var(--green);
  background: var(--green-soft);
  border-color: #b8dfc8;
}

.tab-panel {
  display: none;
  padding: 1rem;
}

.tab-panel.active {
  display: block;
}

.split-grid,
.graph-grid,
.snippet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.graph-grid .wide,
.snippet-grid .wide {
  grid-column: 1 / -1;
}

.builder-head {
  justify-content: space-between;
  margin-bottom: 1rem;
}

.boundary-box {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.fact-list,
.compact-list,
.map-list,
.trace-list,
.convergence-list {
  display: grid;
  gap: 0.55rem;
}

.fact {
  display: grid;
  grid-template-columns: minmax(7rem, 0.32fr) minmax(0, 1fr);
  gap: 0.65rem;
  padding: 0.65rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.fact b {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.fact span,
.fact code {
  overflow-wrap: anywhere;
  min-width: 0;
}

.row,
.trace-row,
.question {
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.65rem;
  align-items: start;
}

.row code {
  color: var(--blue);
  overflow-wrap: anywhere;
}

.kind {
  min-width: 4.8rem;
  text-align: center;
  padding: 0.22rem 0.45rem;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 0.76rem;
  font-weight: 800;
}

.row .position {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
}

.empty {
  color: var(--muted);
}

.question {
  display: grid;
  gap: 0.45rem;
}

.question header {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
}

.question h4 {
  margin: 0;
  font-size: 0.95rem;
}

.question p {
  color: var(--muted);
  font-size: 0.88rem;
}

.snippet {
  min-width: 0;
}

.snippet-head {
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

pre {
  max-height: 25rem;
  margin: 0;
  overflow: auto;
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101b22;
  color: #ecf4f7;
  font-size: 0.82rem;
  line-height: 1.45;
}

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

.trace-row {
  display: grid;
  grid-template-columns: 5rem 4rem minmax(0, 1fr) 4rem;
  gap: 0.55rem;
  align-items: start;
  font-size: 0.86rem;
}

.trace-row code {
  overflow-wrap: anywhere;
}

@media (max-width: 1180px) {
  .config-band,
  .outcome-band,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

@media (max-width: 760px) {
  .topbar,
  .detail-head,
  .top-actions,
  .builder-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    width: 100%;
  }

  .button {
    width: 100%;
  }

  .metrics,
  .split-grid,
  .graph-grid,
  .snippet-grid {
    grid-template-columns: 1fr;
  }

  .fact,
  .row,
  .trace-row {
    grid-template-columns: 1fr;
  }
}
