:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #151b23;
  --panel-2: #1f2630;
  --line: #303947;
  --text: #e7edf5;
  --muted: #9facbd;
  --soft: #c9d4e2;
  --teal: #28c4a4;
  --blue: #78a9ff;
  --amber: #f1bd5c;
  --red: #ff7b72;
  --green: #6bd889;
  --ink: #080b10;
  --focus: #d9f99d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.45;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid var(--teal);
  border-radius: 6px;
  background: var(--teal);
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: var(--line);
}

button.warn {
  border-color: var(--amber);
  background: var(--amber);
}

button.danger {
  border-color: var(--red);
  background: transparent;
  color: var(--red);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--soft);
  font-size: 0.88rem;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f141b;
  color: var(--text);
  padding: 10px 11px;
}

textarea {
  resize: vertical;
}

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

li + li {
  margin-top: 8px;
}

pre {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #0a0e14;
  color: var(--soft);
  white-space: pre-wrap;
  word-break: break-word;
}

.shell {
  min-height: 100vh;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(420px, 0.95fr);
  gap: 24px;
  align-items: end;
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: #111720;
}

.topbar h1,
.project-strip h2,
.section-head h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  max-width: 760px;
  font-size: 2rem;
  line-height: 1.12;
}

.kicker {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.runtime {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.runtime span {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--panel);
  color: var(--soft);
  font-size: 0.8rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(440px, 1fr) minmax(300px, 380px);
  gap: 16px;
  padding: 16px;
}

.left-rail,
.center-pane,
.right-rail {
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.project-create,
.action-panel,
.output-panel,
.right-rail section,
.project-strip {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.stack {
  display: grid;
  gap: 12px;
}

.stage-nav {
  display: grid;
  gap: 8px;
}

.stage-button {
  min-height: 48px;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  border-color: var(--line);
  background: var(--panel);
  color: var(--text);
}

.stage-button.active {
  border-color: var(--blue);
  background: var(--panel-2);
}

.stage-index {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #0f141b;
  color: var(--blue);
  font-weight: 800;
}

.project-strip {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.status-cluster,
.button-row,
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.badge,
.pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 0.78rem;
  font-weight: 700;
}

.badge.neutral {
  color: var(--blue);
}

.badge.pending {
  color: var(--amber);
}

.badge.approved {
  color: var(--green);
}

.badge.memory {
  color: var(--teal);
}

.pill {
  color: var(--soft);
  background: #0f141b;
}

.section-head {
  margin-bottom: 14px;
}

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

.full {
  grid-column: 1 / -1;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: #0f141b;
}

.result-stack {
  display: grid;
  gap: 12px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #111720;
}

.result-card h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.key-value {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(160px, 1fr);
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(48, 57, 71, 0.75);
}

.key-value:last-child {
  border-bottom: 0;
}

.key-value dt {
  color: var(--muted);
}

.key-value dd {
  margin: 0;
  min-width: 0;
  word-break: break-word;
}

.copy-item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #0f141b;
}

.copy-item p {
  margin: 0;
  color: var(--soft);
}

.copy-item button {
  justify-self: start;
  min-height: 34px;
  padding: 0 12px;
}

.boundary-grid {
  display: grid;
  gap: 16px;
}

.boundary-grid h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  max-width: min(520px, calc(100vw - 32px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel-2);
  color: var(--text);
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

#toast.visible {
  opacity: 1;
}

@media (max-width: 1200px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

  .runtime {
    justify-content: flex-start;
  }
}

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

  .topbar h1 {
    font-size: 1.45rem;
  }

  .workspace {
    padding: 10px;
  }

  .form-grid,
  .key-value {
    grid-template-columns: 1fr;
  }

  .project-strip {
    display: grid;
  }
}
