:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #22c55e;
  --error: #ef4444;
  --warn: #f59e0b;
}

* {
  box-sizing: border-box;
}

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

header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 600;
}

header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  max-width: 920px;
  margin: 0 auto;
  padding: 1.5rem;
}

.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.tab {
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
}

.tab:hover {
  color: var(--text);
  border-color: var(--muted);
}

.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
}

.panel.active {
  display: block;
}

.panel h2 {
  margin: 0 0 1rem;
  font-size: 1.1rem;
}

.form-grid {
  display: grid;
  gap: 0.85rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  color: var(--muted);
}

label.required span::after {
  content: " *";
  color: var(--error);
}

input[type="text"],
input[type="url"],
textarea,
select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

textarea {
  min-height: 100px;
  resize: vertical;
  font-family: "Consolas", "Cascadia Code", monospace;
  font-size: 0.85rem;
}

.check-row {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  color: var(--text);
}

.check-row input {
  width: auto;
}

.mode-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.mode-row label {
  flex-direction: row;
  align-items: center;
  color: var(--text);
}

.actions {
  margin-top: 1.25rem;
}

button.primary {
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  cursor: pointer;
}

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

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

.job-status {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.job-status.hidden {
  display: none;
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.pending,
.status-badge.processing {
  background: rgba(245, 158, 11, 0.2);
  color: var(--warn);
}

.status-badge.done {
  background: rgba(34, 197, 94, 0.2);
  color: var(--success);
}

.status-badge.failed {
  background: rgba(239, 68, 68, 0.2);
  color: var(--error);
}

.output-block {
  margin-top: 0.75rem;
}

.output-block h3 {
  margin: 0.75rem 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

pre.log {
  margin: 0;
  padding: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: auto;
  max-height: 420px;
  font-size: 0.8rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 0.5rem;
}

.job-tracker {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.job-tracker.hidden {
  display: none;
}

.job-tracker h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
}

.api-links {
  margin: 0.5rem 0 1rem;
  padding-left: 1.25rem;
}

.api-links a {
  color: var(--accent);
}

.api-example {
  max-height: 200px;
}

.job-links {
  margin: 0.5rem 0;
}

.link-btn {
  margin-right: 0.5rem;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  border-radius: 4px;
  cursor: pointer;
}

.link-btn:hover {
  border-color: var(--accent);
}

code {
  font-family: "Consolas", "Cascadia Code", monospace;
  font-size: 0.88em;
}

.sources-fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.sources-fieldset legend {
  padding: 0 0.35rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.field-hint {
  margin: -0.35rem 0 0;
}
