:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d7dee8;
  --blue: #2563eb;
  --green: #17803d;
  --orange: #b45309;
  --red: #b42318;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text);
  padding: 9px 13px;
  cursor: pointer;
}

button:active {
  transform: translateY(1px);
}

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

.danger {
  border-color: #fecaca;
  background: #fff1f2;
  color: var(--red);
}

.shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.hidden {
  display: none !important;
}

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

.login {
  width: min(420px, 100%);
  margin: 12vh auto 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.1;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

.eyebrow {
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.muted {
  color: var(--muted);
  margin-top: 4px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 14px;
  align-items: start;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.between {
  justify-content: space-between;
}

.stack,
.composer {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

textarea {
  min-height: 170px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.65fr);
  gap: 10px;
}

.check {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: center;
  font-weight: 600;
}

.inline-check {
  align-self: end;
  min-height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px 12px;
}

.check input {
  width: 18px;
  height: 18px;
}

.git-import {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(120px, 0.65fr);
  gap: 10px;
}

.git-import .muted {
  grid-column: 1 / -1;
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.status {
  max-width: 52%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.status.ok {
  border-color: #bbf7d0;
  color: var(--green);
}

.status.warn {
  border-color: #fed7aa;
  color: var(--orange);
}

.jobs {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.job {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 74px;
  text-align: left;
  background: #fbfdff;
}

.job.selected {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.job.running {
  border-color: #86efac;
}

.job.failed,
.job.interrupted {
  border-color: #fecaca;
}

.job-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.job small,
.job span {
  color: var(--muted);
}

.chat-panel,
.log-panel {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.task-chat {
  display: grid;
  gap: 10px;
  max-height: 42vh;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
}

.chat-event {
  display: grid;
  gap: 6px;
  max-width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
}

.chat-event.codex {
  border-color: #bfdbfe;
}

.chat-event.human {
  justify-self: end;
  border-color: #bbf7d0;
  background: #f0fdf4;
}

.chat-event.system {
  border-color: #e5e7eb;
  background: #f9fafb;
}

.chat-event.question,
.chat-event.blocked {
  border-color: #fed7aa;
  background: #fff7ed;
}

.chat-event-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.chat-event-head strong {
  color: var(--text);
}

.chat-event p {
  white-space: pre-wrap;
  word-break: break-word;
}

.hitl-actions {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(3, minmax(110px, auto));
  gap: 10px;
  align-items: center;
}

.terminal-head {
  align-items: flex-start;
}

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

.compact-check {
  display: grid;
  grid-template-columns: 18px auto;
  align-items: center;
  width: auto;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 9px 11px;
  color: var(--muted);
  font-weight: 600;
}

.compact-check input {
  width: 16px;
  height: 16px;
}

pre {
  width: 100%;
  min-height: 260px;
  max-height: 58vh;
  overflow: auto;
  margin: 14px 0 0;
  border-radius: 8px;
  background: #101828;
  color: #ecfdf5;
  padding: 14px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.artifacts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.artifact {
  display: grid;
  gap: 5px;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  color: var(--text);
  padding: 12px;
  text-decoration: none;
}

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

.error {
  min-height: 20px;
  color: var(--red);
}

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

  .topbar {
    align-items: stretch;
  }

  .status {
    max-width: none;
    text-align: left;
  }

  .grid,
  .topbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .panel {
    padding: 13px;
  }

  .actions button {
    flex: 1 1 160px;
  }

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

  .git-import {
    grid-template-columns: 1fr;
  }

  .hitl-actions {
    grid-template-columns: 1fr;
  }

  .terminal-head {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .terminal-actions {
    justify-content: stretch;
  }

  .terminal-actions button,
  .compact-check {
    flex: 1 1 150px;
  }

  pre {
    max-height: 46vh;
  }
}
