:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface-2: #242836;
  --border: #2e3348;
  --text: #e8eaef;
  --muted: #8b92a8;
  --gold: #ffd700;
  --gold-dim: #c9a800;
  --accent: #5b8def;
  --danger: #f07178;
  --success: #7fd992;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #161922 0%, var(--bg) 100%);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 1.5rem;
  background: var(--gold);
  color: #111;
  border-radius: 10px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
}

.tagline {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.api-config {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 260px;
}

.api-config label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.api-config input {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.api-config .hint {
  font-size: 0.75rem;
  color: var(--muted);
}

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.75rem 2rem;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.tab:hover {
  color: var(--text);
  background: var(--surface);
}

.tab.active {
  background: var(--surface-2);
  color: var(--gold);
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  padding: 1.5rem 2rem 2rem;
  max-width: 1400px;
  margin: 0 auto;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

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

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

.intro {
  margin: -0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.875rem;
}

.field {
  margin-bottom: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.85rem;
  font-weight: 500;
}

.muted-label {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8em;
}

.field-hint {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.field input[type="text"],
.field input[type="url"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  cursor: pointer;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

@media (max-width: 600px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: 1fr;
  }
}

.image-source {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}

.image-source legend {
  padding: 0 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.source-toggle {
  display: flex;
  gap: 1.25rem;
  margin-bottom: 0.75rem;
  font-size: 0.875rem;
}

.source-toggle label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
}

.file-drop {
  text-align: center;
  padding: 1rem;
  border-radius: 8px;
  background: var(--surface-2);
}

.file-drop p {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.file-drop input[type="file"] {
  font-size: 0.85rem;
  color: var(--muted);
}

.checkbox-field label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
}

.checkbox-field input[type="checkbox"] {
  margin-top: 0.2rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--gold);
}

.upload-preview {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.upload-preview img {
  max-width: 100%;
  max-height: 160px;
  border-radius: 8px;
  object-fit: contain;
  flex: 1 1 120px;
}

#gif-urls {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.1s, opacity 0.15s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--gold);
  color: #111;
}

.btn.primary:hover:not(:disabled) {
  background: var(--gold-dim);
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.secondary:hover:not(:disabled) {
  border-color: var(--gold-dim);
}

.btn-sm {
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.promo-id-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.promo-id-row input {
  flex: 1;
  min-width: 0;
}

.result-panel h2 {
  margin-bottom: 0.75rem;
}

.status {
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.status.idle {
  background: var(--surface-2);
  color: var(--muted);
}

.status.loading {
  background: #2a3040;
  color: var(--accent);
}

.status.ok {
  background: rgba(127, 217, 146, 0.12);
  color: var(--success);
}

.status.error {
  background: rgba(240, 113, 120, 0.12);
  color: var(--danger);
}

.preview {
  min-height: 280px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.preview.empty p {
  color: var(--muted);
  font-size: 0.9rem;
}

.preview img {
  max-width: 100%;
  max-height: 420px;
  object-fit: contain;
}

.actions {
  margin-top: 1rem;
}

.actions.hidden,
.json-out.hidden {
  display: none;
}

.json-out {
  margin-top: 1rem;
  padding: 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.8rem;
  overflow: auto;
  max-height: 320px;
  color: var(--success);
}

.challenge-list {
  list-style: none;
  padding: 0;
  margin: 0;
  width: 100%;
  text-align: left;
}

.challenge-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}

.challenge-list a {
  color: var(--accent);
  word-break: break-all;
}

.footer {
  padding: 1rem 2rem 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}
