:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1c2024;
  --muted: #60646c;
  --primary: #2f5bea;
  --primary-hover: #2449c4;
  --danger: #c62a2f;
  --danger-bg: #fdecec;
  --success: #18794e;
  --success-bg: #e6f6ee;
  --info-bg: #e9efff;
  --radius: 10px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

a {
  color: var(--primary);
}

h1 {
  font-size: 1.4rem;
  margin: 0 0 0.25rem;
}

h2 {
  font-size: 1.1rem;
  margin: 0 0 0.75rem;
}

.muted,
.hint,
.run-meta {
  color: var(--muted);
}

.hint {
  font-size: 0.85rem;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.user-name {
  font-size: 0.9rem;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.flash-alert {
  background: var(--danger-bg);
  color: var(--danger);
}

.flash-notice {
  background: var(--info-bg);
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 1rem 0 0.35rem;
}

input[type="text"],
input[type="email"],
select,
textarea {
  width: 100%;
  font: inherit;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
}

textarea {
  resize: vertical;
}

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

.button {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.button:hover {
  background: var(--bg);
}

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

.button-primary:hover {
  background: var(--primary-hover);
}

.button-ghost {
  border-color: transparent;
  font-weight: 500;
  padding: 0.35rem 0.6rem;
}

.button-block {
  width: 100%;
}

.button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.run-form .button,
.developer-sign-in .button {
  margin-top: 1rem;
}

.run-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.run-list li + li {
  border-top: 1px solid var(--border);
}

.run-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas: "title status" "meta status";
  align-items: center;
  column-gap: 1rem;
  padding: 0.8rem 1rem;
  color: inherit;
  text-decoration: none;
}

.run-row:hover {
  background: var(--bg);
}

.run-title {
  grid-area: title;
  font-weight: 600;
}

.run-row .run-meta {
  grid-area: meta;
  font-size: 0.85rem;
}

.run-row .status {
  grid-area: status;
}

.status {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.status-queued,
.status-working {
  background: var(--info-bg);
  color: var(--primary);
}

.status-completed {
  background: var(--success-bg);
  color: var(--success);
}

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

.back-link {
  text-decoration: none;
  font-size: 0.9rem;
}

.run-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.prompt {
  margin-top: 1rem;
}

.prompt summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
}

.prompt-body {
  margin-top: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border-radius: 8px;
}

.error-message {
  color: var(--danger);
  white-space: pre-wrap;
}

.working {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.progress {
  border-left: 3px solid var(--border);
  padding-left: 1rem;
  color: var(--muted);
}

.markdown > :first-child {
  margin-top: 0;
}

.markdown pre {
  background: #f1f3f5;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
}

.markdown code {
  font-family: var(--mono);
  font-size: 0.88em;
}

.markdown :not(pre) > code {
  background: #f1f3f5;
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
}

.markdown table {
  border-collapse: collapse;
  margin: 1rem 0;
}

.markdown th,
.markdown td {
  border: 1px solid var(--border);
  padding: 0.35rem 0.6rem;
  text-align: left;
}

.sign-in-page {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
}

.sign-in {
  width: 100%;
  max-width: 400px;
  padding: 1rem;
}

.sign-in-card h1 {
  font-size: 1.6rem;
}

.sign-in-card form {
  margin-top: 1.25rem;
}

.developer-sign-in {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.developer-sign-in h2 {
  font-size: 0.95rem;
  margin: 0;
}
