:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --surface: #ffffff;
  --ink: #191917;
  --muted: #687385;
  --line: #d7dde7;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --focus: #2563eb;
  --danger: #b42318;
  --ok: #16803c;
  --amber: #b7791f;
  --blue: #1d4ed8;
}

* {
  box-sizing: border-box;
}

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

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

button,
a.button {
  min-height: 2.5rem;
  border: 1px solid var(--ink);
  border-radius: 6px;
  padding: 0.55rem 0.85rem;
  background: var(--ink);
  color: #ffffff;
  text-decoration: none;
  cursor: pointer;
}

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

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

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.submit-band,
.jobs-band {
  padding: 24px 0;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 2rem + 1vw, 3rem);
  line-height: 1;
}

h2 {
  font-size: 1.35rem;
}

.identity,
.form-message,
.empty-state {
  color: var(--muted);
  font-size: 0.95rem;
}

.form-message[data-kind="error"] {
  color: var(--danger);
}

.form-message[data-kind="success"] {
  color: var(--ok);
}

.identity[data-kind="error"] {
  color: var(--danger);
}

.identity[data-kind="success"] {
  color: var(--ok);
}

.job-form {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(260px, 0.7fr);
  gap: 1rem;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.mode-group {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
  grid-column: 1 / -1;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-group legend,
.field > span {
  display: block;
  margin-bottom: 0.45rem;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
}

.mode-group label {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcff;
}

.mode-group input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.7rem 0.75rem;
  background: #ffffff;
  color: var(--ink);
}

.field textarea {
  min-height: 8rem;
  resize: vertical;
}

.field input[type="range"] {
  padding: 0;
  accent-color: var(--accent);
}

.span-2 {
  grid-column: 1 / -1;
}

[hidden] {
  display: none !important;
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.75rem;
}

.job-list {
  display: grid;
  gap: 0.75rem;
}

.admin-panel {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.75rem;
}

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

.job-summary {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
}

.thumb,
.placeholder {
  width: 64px;
  height: 48px;
  border-radius: 6px;
  background: #e9edf4;
  object-fit: cover;
}

.placeholder {
  display: grid;
  place-items: center;
  padding: 0.25rem;
  color: var(--muted);
  font-size: 0.7rem;
  text-align: center;
}

.job-meta {
  min-width: 0;
}

.job-progress {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  font-style: italic;
}

.job-line,
.job-subline {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.job-line {
  margin-bottom: 0.35rem;
}

.mode-badge,
.variation-pill,
.status-pill {
  flex: none;
  border-radius: 999px;
  padding: 0.2rem 0.5rem;
  font-size: 0.78rem;
  font-weight: 700;
}

.mode-badge {
  background: #e6f3f1;
  color: var(--accent-dark);
}

.variation-pill {
  background: #eef2ff;
  color: #4338ca;
}

.prompt-snippet {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.job-subline {
  color: var(--muted);
  font-size: 0.9rem;
  flex-wrap: wrap;
}

.status-pill {
  background: #e5e7eb;
  color: #374151;
}

.status-running {
  background: #dbeafe;
  color: var(--blue);
}

.status-done {
  background: #dcfce7;
  color: var(--ok);
}

.status-failed {
  background: #fee2e2;
  color: var(--danger);
}

.status-cancelled {
  background: #eceff5;
  color: var(--muted);
}

.status-paused {
  background: #fef3c7;
  color: var(--amber);
}

.job-row.job-status-running .status-pill {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

.job-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.button.secondary,
button.secondary {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.button.ghost,
button.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--accent-dark);
}

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

.icon-button {
  width: 2.5rem;
  padding-inline: 0;
  text-align: center;
}

.user-email,
.priority-label,
.runtime-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.job-detail {
  display: grid;
  gap: 0.8rem;
  padding: 0 0.75rem 0.9rem 5.75rem;
}

.full-prompt {
  white-space: pre-wrap;
}

.job-error {
  margin: 0;
  max-height: 12rem;
  overflow: auto;
  border-radius: 6px;
  padding: 0.75rem;
  background: #fff1f2;
  color: var(--danger);
}

.preview-wrap {
  max-width: 720px;
}

.artifact-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.artifact-card {
  display: grid;
  gap: 0.55rem;
}

.artifact-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.artifact-label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 600;
}

.preview-large {
  display: block;
  width: min(100%, 720px);
  max-height: 420px;
  border-radius: 8px;
  object-fit: contain;
  background: #111111;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 16px;
  }

  .section-head,
  .form-actions {
    align-items: start;
    flex-direction: column;
  }

  .job-form,
  .mode-group,
  .job-summary {
    grid-template-columns: 1fr;
  }

  .job-summary {
    align-items: start;
  }

  .thumb,
  .placeholder {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .job-actions {
    justify-content: start;
    flex-wrap: wrap;
  }

  .job-detail {
    padding: 0 0.75rem 0.9rem;
  }
}
