:root {
  color-scheme: light;
  --ink: #1d2730;
  --muted: #66727e;
  --line: #d7dde1;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --blue: #23384f;
  --teal: #2f8f83;
  --gold: #c58c24;
  --coral: #cf5c45;
  --soft-blue: #e8f0f5;
  --soft-teal: #e5f4ef;
  --soft-gold: #fbf1d8;
  --soft-coral: #fbe8e1;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--paper);
}

button,
input,
textarea {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px) 18px;
  border-bottom: 1px solid var(--line);
  background: #fffdfa;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 2.4rem, 2.6rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.topbar__meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 10px;
  min-width: min(410px, 100%);
}

.topbar__meta div {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 12px;
  border-radius: 8px;
}

.topbar__meta span {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
}

.topbar__meta small {
  color: var(--muted);
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  align-items: start;
  gap: 26px;
  padding: 24px clamp(18px, 4vw, 48px) 42px;
}

.input-pane,
.output-pane {
  min-width: 0;
}

.input-pane {
  position: sticky;
  top: 16px;
  display: grid;
  gap: 10px;
}

label {
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 800;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 11px 12px;
  line-height: 1.45;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
button:focus-visible {
  outline: 3px solid rgba(47, 143, 131, 0.24);
  outline-offset: 2px;
}

.button-row,
.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: white;
  padding: 9px 13px;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  filter: brightness(1.08);
}

button.secondary {
  border-color: var(--teal);
  background: var(--teal);
}

button.ghost {
  border-color: var(--line);
  background: transparent;
  color: var(--ink);
}

.status {
  min-height: 22px;
  color: var(--muted);
  font-size: 0.9rem;
}

.output-pane {
  display: grid;
  gap: 18px;
}

.summary-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--teal);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.summary-band span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.canvas-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.split-block {
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
  gap: 18px;
}

.map-board {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto minmax(140px, 1fr) auto minmax(140px, 1fr) auto minmax(140px, 1fr);
  gap: 10px;
  align-items: center;
}

.map-lane {
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-blue);
  padding: 12px;
}

.map-lane:nth-of-type(3) {
  background: var(--soft-teal);
}

.map-lane:nth-of-type(5) {
  background: var(--soft-gold);
}

.map-lane:nth-of-type(7) {
  background: var(--soft-coral);
}

.map-lane strong {
  display: block;
  margin-bottom: 10px;
}

.map-arrow {
  color: var(--gold);
  font-size: 1.25rem;
  font-weight: 900;
}

.chip,
.flag,
.ok,
.role {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin: 3px 4px 3px 0;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 0.78rem;
  line-height: 1.2;
}

.chip {
  background: white;
  border: 1px solid var(--line);
}

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

.flag {
  background: var(--soft-coral);
  color: #8a3224;
}

.ok {
  background: var(--soft-teal);
  color: #176d63;
}

.role {
  background: var(--soft-blue);
  color: var(--blue);
  font-weight: 800;
}

.role--predictor {
  background: var(--soft-teal);
  color: #176d63;
}

.role--outcome {
  background: var(--soft-coral);
  color: #8a3224;
}

.role--control,
.role--mediator,
.role--moderator {
  background: var(--soft-gold);
  color: #805713;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}

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

.gap-list {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-left: 18px;
}

.gap-list li {
  line-height: 1.45;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.prompt-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdfa;
}

.prompt-card p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

#exportPreview {
  min-height: 280px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.87rem;
}

@media (max-width: 1040px) {
  .topbar {
    align-items: start;
    flex-direction: column;
  }

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

  .input-pane {
    position: static;
  }
}

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

  .layout {
    gap: 18px;
    padding: 16px 14px 30px;
  }

  .topbar__meta,
  .split-block,
  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .summary-band {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row button,
  .export-actions button {
    flex: 1 1 150px;
  }

  .map-board {
    grid-template-columns: 1fr;
  }

  .map-arrow {
    transform: rotate(90deg);
    justify-self: center;
  }
}
