* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --border: #2a2a2a;
  --text: #e0e0e0;
  --text-dim: #888;
  --primary: #6366f1;
  --primary-hover: #5558e6;
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --radius: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

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

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

.nav-links { display: flex; gap: 1.5rem; }
.nav-link { color: var(--text-dim); text-decoration: none; transition: color 0.2s; }
.nav-link:hover { color: var(--text); }
.nav-cost { color: var(--text-dim); font-size: 0.75rem; padding: 0.25rem 0.5rem; background: var(--bg); border-radius: var(--radius); }

.container { max-width: 960px; margin: 0 auto; padding: 2rem; }

.hero { text-align: center; margin-bottom: 3rem; }
.hero h1 { font-size: 2rem; margin-bottom: 0.5rem; }
.hero p { color: var(--text-dim); margin-bottom: 1.5rem; }

.url-form { display: flex; gap: 0.75rem; max-width: 700px; margin: 0 auto; flex-wrap: wrap; }
.mode-select {
  padding: 0.75rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.875rem; cursor: pointer;
}
.url-input {
  flex: 1; padding: 0.75rem 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 1rem;
}
.url-input:focus { outline: none; border-color: var(--primary); }

.btn {
  padding: 0.75rem 1.5rem; border: none; border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  text-decoration: none; display: inline-block; transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: var(--primary); color: white; }
.btn-secondary { background: var(--border); color: var(--text); }
.btn-warning { background: var(--warning); color: black; }
.btn-danger { background: var(--danger); color: white; }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  padding: 0.75rem; text-align: left;
  border-bottom: 1px solid var(--border);
}
.table th { color: var(--text-dim); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table td a { color: var(--primary); text-decoration: none; }
.table .actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.badge {
  display: inline-block; padding: 0.2rem 0.6rem; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; text-transform: uppercase;
}
.badge-queued { background: var(--border); color: var(--text-dim); }
.badge-scraping, .badge-rebuilding, .badge-publishing { background: #1e3a5f; color: #60a5fa; }
.badge-done { background: #14532d; color: #4ade80; }
.badge-failed { background: #450a0a; color: #f87171; }
.badge-cancelled { background: #3b3b3b; color: #a0a0a0; }

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

.input {
  width: 100%; padding: 0.75rem 1rem; background: var(--bg);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-size: 0.9rem; margin-bottom: 0.75rem;
}
.input:focus { outline: none; border-color: var(--primary); }

label { display: block; font-size: 0.85rem; color: var(--text-dim); margin-bottom: 0.25rem; }

.log-container {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; max-height: 500px; overflow-y: auto;
}
.log-output {
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem;
  white-space: pre-wrap; word-break: break-all; color: var(--text-dim);
}

.job-header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.job-header h1 { font-size: 1.25rem; word-break: break-all; }
.job-meta { margin-bottom: 1.5rem; }
.job-meta p { margin-bottom: 0.25rem; font-size: 0.9rem; }
.job-actions { margin-bottom: 1.5rem; display: flex; gap: 0.5rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }

.back-link { color: var(--text-dim); text-decoration: none; font-size: 0.85rem; }
.back-link:hover { color: var(--text); }
.empty-state { color: var(--text-dim); text-align: center; padding: 3rem 1rem; }
.loading { color: var(--text-dim); text-align: center; }
.error { color: var(--danger); }

.alert { padding: 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.alert-success { background: #14532d; color: #4ade80; }
.alert-error { background: #450a0a; color: #f87171; }

.settings-form { display: flex; flex-direction: column; gap: 0.5rem; }
.settings-form .btn { align-self: flex-start; }

.submit-form { max-width: 700px; margin: 0 auto; }
.prompt-toggle { margin-top: 0.75rem; }
.prompt-toggle summary {
  cursor: pointer; color: var(--text-dim); font-size: 0.85rem;
  padding: 0.5rem 0; user-select: none;
}
.prompt-toggle summary:hover { color: var(--text); }
.prompt-section { margin-top: 0.5rem; }
.prompt-input {
  font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.8rem;
  line-height: 1.5; resize: vertical; min-height: 120px;
}
.hint { font-size: 0.8rem; color: var(--text-dim); margin-bottom: 0.75rem; }

/* JSON Editor */
.editor-section { margin-bottom: 2rem; }
.editor-hint { color: var(--text-dim); margin-bottom: 1rem; font-size: 0.9rem; }
.editor-actions { display: flex; gap: 0.75rem; align-items: center; }
.json-editor {
  width: 100%; padding: 1rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 0.8rem; line-height: 1.5; resize: vertical;
  tab-size: 2; white-space: pre; overflow-x: auto;
}
.json-editor:focus { outline: none; border-color: var(--primary); }
.save-status { font-size: 0.85rem; margin-left: 0.5rem; }
.save-status--ok { color: #22c55e; }
.save-status--error { color: #ef4444; }
/* Image Picker */
.image-pickers { display: flex; gap: 2rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.image-picker { flex: 1; min-width: 280px; }
.image-picker__label { font-size: 0.95rem; margin-bottom: 0.75rem; color: var(--text); }
.image-picker__grid {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  max-height: 280px; overflow-y: auto;
  padding: 0.5rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.image-picker__item {
  position: relative; width: 90px; height: 90px; border-radius: 6px;
  border: 2px solid var(--border); cursor: pointer;
  overflow: hidden; transition: border-color 0.15s;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.image-picker__item:hover { border-color: var(--text-dim); }
.image-picker__item--selected { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.image-picker__item--suggested { border-color: rgba(99, 102, 241, 0.35); }
.image-picker__item img { width: 100%; height: 100%; object-fit: contain; }
.image-picker__none {
  font-size: 0.75rem; color: var(--text-dim);
  flex-shrink: 0;
}
.image-picker__check {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--primary); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: bold;
}
.image-picker__badge {
  position: absolute; bottom: 2px; left: 2px;
  padding: 1px 4px; border-radius: 3px;
  background: rgba(99, 102, 241, 0.8); color: white;
  font-size: 0.55rem; text-transform: uppercase;
  white-space: nowrap;
}
.image-picker__size {
  position: absolute; top: 2px; left: 2px;
  padding: 1px 4px; border-radius: 3px;
  background: rgba(0, 0, 0, 0.6); color: #ccc;
  font-size: 0.55rem;
}

.badge-extracted { background: #f59e0b; color: #000; }
.badge-render_queued { background: #6366f1; }
.badge-rendering { background: #6366f1; }
.badge-scraping { background: #8b5cf6; }
.badge-extracting { background: #8b5cf6; }
