:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242d;
  --border: #2a2f3a;
  --text: #e6e8ee;
  --text-dim: #9aa1b1;
  --accent: #ffb86b;
  --accent-2: #7ad0ff;
  --ok: #6fd28a;
  --err: #ff7a7a;
  --warn: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.rate-pill {
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

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

.ghost-btn {
  padding: 6px 12px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  width: auto;
}
.ghost-btn:hover { background: var(--surface-2); }

.link-btn {
  background: none;
  border: none;
  color: var(--accent-2);
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  width: auto;
}

.api-banner {
  padding: 10px 28px;
  background: rgba(255, 209, 102, 0.12);
  border-bottom: 1px solid rgba(255, 209, 102, 0.3);
  color: var(--warn);
  font-size: 13px;
}

.hidden { display: none !important; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  width: min(480px, 90vw);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

.modal-actions button:not(.ghost-btn) {
  width: auto;
  padding: 10px 20px;
}

.modal .hint a { color: var(--accent-2); }

main {
  display: grid;
  grid-template-columns: minmax(320px, 420px) 1fr;
  gap: 24px;
  padding: 24px 28px;
  max-width: 1400px;
  margin: 0 auto;
}

h2 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
}

.submit-card, .jobs-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

form label {
  display: block;
  margin-bottom: 14px;
}

form label > span {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

input[type="text"], textarea, input[type="file"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}

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

input[type="file"] { padding: 8px; }

.row {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}

.photo-preview {
  width: 120px;
  height: 120px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  background-size: cover;
  background-position: center;
}

button {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #1a1208;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: filter 0.15s, transform 0.05s;
}

button:hover { filter: brightness(1.05); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.hint {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
}

.jobs-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.empty-state {
  padding: 40px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

.job {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}

.job-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 10px;
}

.job-title {
  font-weight: 600;
  font-size: 14px;
}

.job-meta {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-queued { background: rgba(154, 161, 177, 0.15); color: var(--text-dim); }
.status-analyzing, .status-generating, .status-running { background: rgba(122, 208, 255, 0.15); color: var(--accent-2); }
.status-done { background: rgba(111, 210, 138, 0.15); color: var(--ok); }
.status-error { background: rgba(255, 122, 122, 0.15); color: var(--err); }
.status-partial { background: rgba(255, 209, 102, 0.15); color: var(--warn); }

.variations {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.variation {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.variation img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.variation-link {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.var-actions {
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  z-index: 2;
}

.var-btn {
  width: 26px;
  height: 26px;
  padding: 0;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.2s;
}

.var-btn:hover {
  background: var(--accent);
  color: #1a1208;
}

.rerun-btn:active { transform: rotate(180deg); }
.download-btn:active { transform: translateY(2px); }

.job-head-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.remove-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.remove-btn:hover { color: var(--err); border-color: var(--err); }

.variation-label {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.variation-status {
  font-size: 11px;
  color: var(--text-dim);
  text-align: center;
}

.variation.status-running .variation-status::after {
  content: "";
  display: inline-block;
  margin-left: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.error-text {
  font-size: 11px;
  color: var(--err);
  margin-top: 6px;
  word-break: break-word;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; }
}
