:root {
  --bg: #f7f2e8;
  --ink: #14110f;
  --muted: #625b55;
  --card: rgba(255, 252, 248, 0.9);
  --line: rgba(20, 17, 15, 0.12);
  --accent: #ab3428;
  --accent-2: #22577a;
  --accent-3: #588157;
  --mono: "IBM Plex Mono", monospace;
  --sans: "IBM Plex Sans", sans-serif;
  --display: "Bebas Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(171, 52, 40, 0.08), transparent 30%),
    radial-gradient(circle at bottom right, rgba(34, 87, 122, 0.08), transparent 35%),
    linear-gradient(180deg, #fcf8f1, var(--bg));
  min-height: 100vh;
  position: relative;
}

.ambient {
  position: fixed;
  inset: auto;
  pointer-events: none;
  border-radius: 999px;
  filter: blur(30px);
  opacity: 0.35;
}

.ambient-a {
  width: 18rem;
  height: 18rem;
  background: rgba(171, 52, 40, 0.2);
  top: 4rem;
  right: 3rem;
}

.ambient-b {
  width: 22rem;
  height: 22rem;
  background: rgba(34, 87, 122, 0.16);
  left: -4rem;
  bottom: 6rem;
}

.hero,
.layout {
  position: relative;
  z-index: 1;
}

.hero {
  padding: 3.5rem 1.25rem 1rem;
  max-width: 84rem;
  margin: 0 auto;
}

.eyebrow,
.label,
.small,
button,
textarea,
pre,
th {
  font-family: var(--mono);
}

.eyebrow {
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.78rem;
}

.hero h1 {
  font-family: var(--display);
  font-size: clamp(4rem, 12vw, 8rem);
  line-height: 0.9;
  margin: 0.3rem 0 0.5rem;
}

.lede {
  max-width: 52rem;
  font-size: 1.08rem;
  color: var(--muted);
}

.hero-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.hero-strip > div,
.panel {
  border: 1px solid var(--line);
  background: var(--card);
  box-shadow: 0 20px 50px rgba(20, 17, 15, 0.08);
  backdrop-filter: blur(6px);
}

.hero-strip > div {
  border-radius: 1rem;
  padding: 0.9rem 1rem;
}

.hero-strip strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.02rem;
}

.layout {
  max-width: 84rem;
  margin: 0 auto;
  padding: 1rem 1.25rem 3rem;
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 1rem;
}

.panel {
  border-radius: 1.2rem;
  padding: 1rem;
}

.controls-panel {
  grid-row: span 2;
}

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

h2 {
  margin-top: 0;
  margin-bottom: 0.4rem;
}

.panel-copy {
  color: var(--muted);
  margin-top: 0;
}

.button-row,
.snapshot-actions,
.button-grid,
.preset-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button-grid,
.preset-strip {
  margin-top: 0.45rem;
}

.preset-strip button {
  min-width: 10rem;
}

#mind-buttons button {
  min-width: 8.5rem;
}

button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff8ef;
  padding: 0.72rem 1rem;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, border-color 120ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 17, 15, 0.24);
}

button.primary,
button.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.control-group {
  margin-top: 1rem;
}

.mind-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 0.45rem;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin: 1rem 0;
}

.editor-block {
  margin-top: 1rem;
}

.editor-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
  margin-bottom: 0.7rem;
}

.editor-copy {
  color: var(--muted);
  margin: 0.3rem 0 0;
  font-size: 0.92rem;
}

#snapshot-box {
  width: 100%;
  border-radius: 1rem;
  border: 1px solid var(--line);
  padding: 0.9rem;
  resize: vertical;
  background: rgba(255, 255, 255, 0.74);
}

#snapshot-box {
  min-height: 11rem;
}

#cli-export-box {
  width: 100%;
  min-height: 10rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  padding: 0.9rem;
  resize: vertical;
  background: rgba(255, 255, 255, 0.74);
}

.command-box {
  margin: 0.75rem 0 0;
  border-radius: 1rem;
  border: 1px solid var(--line);
  padding: 0.9rem;
  background: rgba(255, 248, 239, 0.82);
  white-space: pre-wrap;
}

.program-list {
  display: grid;
  gap: 0.9rem;
}

.program-card {
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.74);
  padding: 0.9rem;
}

.program-header,
.program-footer,
.row-actions,
.operand-fields {
  display: flex;
  gap: 0.6rem;
}

.program-header,
.program-footer {
  align-items: center;
  justify-content: space-between;
}

.program-title {
  display: block;
  margin-top: 0.2rem;
}

.field-row {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.8rem;
}

.field-label {
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.field-row input,
.field-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  background: #fffdf8;
  padding: 0.68rem 0.8rem;
  font-family: var(--mono);
}

.op-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 1rem;
}

.op-row {
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 0.75rem;
  background: rgba(255, 248, 239, 0.82);
}

.op-kind {
  margin-top: 0;
}

.operand-fields {
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.operand-row {
  flex: 1 1 9rem;
  margin-top: 0;
}

.operand-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.45rem 0.75rem;
  background: rgba(20, 17, 15, 0.06);
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.row-actions {
  flex-wrap: wrap;
  margin-top: 0.7rem;
}

.micro-btn:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

.advanced-json {
  margin-top: 0.9rem;
}

.advanced-json summary {
  cursor: pointer;
  font-family: var(--mono);
  color: var(--muted);
}

#script-box {
  width: 100%;
  min-height: 11rem;
  margin-top: 0.75rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  padding: 0.9rem;
  resize: vertical;
  background: rgba(255, 255, 255, 0.68);
}

.beats {
  display: grid;
  gap: 0.7rem;
}

.beat-card {
  border-left: 4px solid var(--accent-3);
  border-radius: 0.8rem;
  padding: 0.8rem 0.9rem;
  background: rgba(255, 255, 255, 0.72);
}

.beat-card strong {
  display: block;
  margin-bottom: 0.2rem;
}

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

.table-note {
  color: var(--muted);
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

tr.running td:first-child {
  color: var(--accent-2);
}

tr.cancelled td:first-child {
  color: var(--accent);
}

#trace-log {
  margin: 0;
  min-height: 14rem;
  max-height: 24rem;
  overflow: auto;
  padding: 1rem;
  border-radius: 1rem;
  background: #111318;
  color: #d5f6ff;
  line-height: 1.5;
}

.small {
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    grid-row: auto;
  }

  .editor-header {
    flex-direction: column;
  }

  .program-header,
  .program-footer {
    flex-direction: column;
    align-items: stretch;
  }
}
