:root {
  color-scheme: light;
  --bg: #edf1f2;
  --surface: #ffffff;
  --surface-soft: #f7f9f9;
  --line: #d7e0df;
  --text: #111c1f;
  --muted: #647174;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --blue: #2563eb;
  --amber: #b45309;
  --success: #15803d;
}

* {
  box-sizing: border-box;
}

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

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

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  padding: 0 16px;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.ghost {
  min-height: 34px;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--muted);
  padding: 0 12px;
}

button.ghost:hover {
  border-color: #a9c9c5;
  color: var(--accent-strong);
}

.app-shell {
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin-top: 6px;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  padding: 0 12px;
}

.status.ready {
  border-color: #8bc7bf;
  color: var(--success);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(300px, 360px) minmax(420px, 1fr) minmax(260px, 320px);
  gap: 16px;
  align-items: start;
}

.panel {
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.dropzone {
  display: grid;
  place-items: center;
  min-height: 190px;
  border: 1px dashed #9fb8b4;
  border-radius: 8px;
  background: #f2faf8;
  cursor: pointer;
  padding: 22px;
  text-align: center;
}

.dropzone.dragging {
  border-color: var(--accent);
  background: #e4f5f2;
}

.dropzone input {
  display: none;
}

.drop-title {
  display: block;
  color: var(--accent-strong);
  font-size: 18px;
  font-weight: 800;
}

.drop-meta {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.field-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

label span {
  display: block;
  margin-bottom: 8px;
  color: #344346;
  font-size: 13px;
  font-weight: 800;
}

select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
}

select {
  height: 42px;
  padding: 0 10px;
}

textarea {
  min-height: 220px;
  padding: 12px;
  resize: vertical;
  line-height: 1.55;
}

select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, .14);
}

.rule-box,
.task-card,
.node-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.rule-box {
  margin: 16px 0;
}

.rule-box strong,
.node-card strong {
  display: block;
  font-size: 15px;
}

.rule-box p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.task-card {
  min-height: 112px;
}

.task-empty,
.empty {
  display: block;
  color: var(--muted);
  text-align: center;
  padding: 24px 12px;
}

.task-title {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

.task-meta {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.pipeline {
  display: grid;
  gap: 10px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.pipeline li {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  display: flex;
  align-items: center;
  padding: 0 12px;
  font-size: 14px;
}

.pipeline li.done {
  border-color: #9bd3b0;
  color: var(--success);
  background: #f0fdf4;
}

.pipeline li.reserved {
  border-color: #f3cc8f;
  color: var(--amber);
  background: #fff7ed;
}

.segments {
  display: grid;
  gap: 14px;
  max-height: 560px;
  overflow: auto;
  padding-right: 4px;
}

.segment-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  overflow: hidden;
}

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

.segment-head strong {
  font-size: 15px;
}

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

.segment-actions button {
  min-height: 32px;
  font-size: 12px;
  padding: 0 10px;
}

.segment-card textarea {
  min-height: 250px;
  border: 0;
  border-radius: 0;
  background: #fbfcfc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.generation-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

.node-card span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.node-card.active {
  border-color: #91b9ff;
  background: #eff6ff;
}

.history {
  margin-top: 8px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.history-list {
  display: grid;
  gap: 8px;
  max-height: 250px;
  overflow: auto;
}

.history-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  padding: 10px;
  text-align: left;
  color: var(--text);
}

.history-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.history-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

  .output-panel,
  .generation-panel {
    min-height: 480px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-row {
    justify-content: flex-start;
  }

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

  .panel {
    min-height: auto;
    padding: 16px;
  }
}
