/* ===== Base ===== */
::selection { background: #4f46e5; color: #fff; }
body { background-image: radial-gradient(circle at 20% 0%, rgba(99,102,241,0.08), transparent 40%), radial-gradient(circle at 80% 100%, rgba(99,102,241,0.06), transparent 40%); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0f172a; }
::-webkit-scrollbar-thumb { background: #334155; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #475569; }

/* ===== Card ===== */
.card {
  background: linear-gradient(180deg, rgba(30,41,59,0.6), rgba(15,23,42,0.6));
  border: 1px solid rgb(51 65 85 / 0.7);
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.card-title {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.95rem; font-weight: 700; color: #f1f5f9;
  margin-bottom: 0.25rem;
}
.card-subtitle { font-size: 0.78rem; color: #94a3b8; line-height: 1.4; }

.code-inline {
  background: rgba(99,102,241,0.12); color: #a5b4fc;
  padding: 0.05rem 0.4rem; border-radius: 0.3rem; font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
}

/* ===== Forms ===== */
.field-label { display: block; font-size: 0.75rem; font-weight: 600; color: #cbd5e1; margin-bottom: 0.35rem; }

.input-base {
  width: 100%;
  background: #0b1220;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 0.6rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.875rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input-base::placeholder { color: #475569; }
.input-base:focus { border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99,102,241,0.2); }

select.input-base { appearance: none; background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3e%3cpath d='M6 9l6 6 6-6'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 0.7rem center; background-size: 1.1em; padding-right: 2.2rem; }

.checkbox-base {
  width: 1rem; height: 1rem; border-radius: 0.3rem;
  accent-color: #6366f1; cursor: pointer;
}

.icon-btn {
  width: 2rem; height: 2rem; display: flex; align-items: center; justify-content: center;
  color: #94a3b8; border-radius: 0.4rem; transition: background .15s, color .15s;
  background: transparent; border: none; cursor: pointer;
}
.icon-btn:hover { background: #1e293b; color: #e2e8f0; }

.badge-slate {
  font-size: 0.7rem; font-weight: 600; padding: 0.2rem 0.6rem; border-radius: 999px;
  background: #1e293b; color: #94a3b8; border: 1px solid #334155; white-space: nowrap;
}
.badge-slate.badge-green { background: rgba(34,197,94,0.1); color: #4ade80; border-color: rgba(34,197,94,0.3); }
.badge-slate.badge-amber { background: rgba(245,158,11,0.1); color: #fbbf24; border-color: rgba(245,158,11,0.3); }
.badge-slate.badge-red { background: rgba(239,68,68,0.1); color: #f87171; border-color: rgba(239,68,68,0.3); }
.badge-slate.badge-indigo { background: rgba(99,102,241,0.15); color: #a5b4fc; border-color: rgba(99,102,241,0.35); }

/* ===== Buttons ===== */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  color: #fff; font-weight: 600; font-size: 0.85rem;
  padding: 0.65rem 1rem; border-radius: 0.65rem; border: none; cursor: pointer;
  transition: transform .1s, box-shadow .15s, filter .15s;
  box-shadow: 0 4px 14px rgba(79,70,229,0.35);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  background: #1e293b; color: #e2e8f0; font-weight: 600; font-size: 0.85rem;
  padding: 0.65rem 1rem; border-radius: 0.65rem; border: 1px solid #334155; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-secondary:hover:not(:disabled) { background: #334155; border-color: #475569; }

.generate-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.65rem;
  background: linear-gradient(135deg, #818cf8, #4f46e5 50%, #3730a3);
  color: #fff; font-weight: 800; font-size: 0.95rem; letter-spacing: 0.01em;
  padding: 1rem; border-radius: 0.9rem; border: none; cursor: pointer;
  box-shadow: 0 8px 24px rgba(79,70,229,0.4);
  transition: transform .12s, filter .15s;
}
.generate-btn:hover:not(:disabled) { filter: brightness(1.1); }
.generate-btn:active:not(:disabled) { transform: translateY(1px); }
.generate-btn:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.3); }

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed #334155; border-radius: 0.85rem;
  padding: 1.75rem 1rem; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; cursor: pointer; transition: border-color .15s, background .15s;
  background: rgba(15,23,42,0.4);
}
.dropzone:hover, .dropzone.dragover {
  border-color: #6366f1; background: rgba(99,102,241,0.07);
}

/* ===== Gallery thumbs ===== */
.ref-thumb {
  position: relative; aspect-ratio: 1/1; border-radius: 0.6rem; overflow: hidden;
  border: 1px solid #334155; background: #0b1220;
}
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-thumb .thumb-status {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 0.6rem; font-weight: 600; text-align: center;
  padding: 0.15rem 0.2rem; backdrop-filter: blur(2px);
}
.thumb-status.st-ready { background: rgba(34,197,94,0.75); color: #fff; }
.thumb-status.st-uploading { background: rgba(245,158,11,0.75); color: #fff; }
.thumb-status.st-error { background: rgba(239,68,68,0.8); color: #fff; }
.ref-thumb .thumb-remove {
  position: absolute; top: 3px; right: 3px; width: 1.3rem; height: 1.3rem; border-radius: 999px;
  background: rgba(15,23,42,0.85); color: #f87171; display: flex; align-items: center; justify-content: center;
  font-size: 0.65rem; cursor: pointer; border: 1px solid rgba(255,255,255,0.1);
}
.ref-thumb .thumb-remove:hover { background: #ef4444; color: #fff; }
.ref-thumb .thumb-spinner {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(15,23,42,0.5);
}

/* ===== Viewer ===== */
.viewer {
  position: relative; width: 100%; aspect-ratio: 16/9;
  background: #000; border-radius: 0.85rem; overflow: hidden;
  border: 1px solid #1e293b;
}

/* ===== Loader ===== */
.loader-ring {
  width: 48px; height: 48px; border-radius: 50%;
  border: 4px solid rgba(99,102,241,0.2); border-top-color: #818cf8;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Console ===== */
.console {
  background: #05070d; border: 1px solid #1e293b; border-radius: 0.65rem;
  padding: 0.75rem; height: 220px; overflow-y: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 0.72rem; line-height: 1.6;
}
.console-line { display: flex; gap: 0.5rem; margin-bottom: 0.2rem; }
.console-time { color: #475569; flex-shrink: 0; }
.console-msg { word-break: break-word; }
.console-line.ok .console-msg { color: #4ade80; }
.console-line.info .console-msg { color: #93c5fd; }
.console-line.warn .console-msg { color: #fbbf24; }
.console-line.error .console-msg { color: #f87171; }
.console-line.step .console-msg { color: #c4b5fd; font-weight: 600; }

/* ===== History ===== */
.history-thumb {
  position: relative; aspect-ratio: 16/9; border-radius: 0.6rem; overflow: hidden;
  border: 1px solid #334155; cursor: pointer; background: #0b1220;
}
.history-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.history-thumb:hover img { transform: scale(1.05); }
.history-thumb .history-date {
  position: absolute; bottom: 0; left: 0; right: 0; font-size: 0.6rem;
  background: rgba(0,0,0,0.6); color: #cbd5e1; padding: 0.15rem 0.3rem; text-align: center;
}

@media (min-width: 1024px) {
  .history-thumb, .ref-thumb { aspect-ratio: 1/1; }
  #history-gallery .history-thumb { aspect-ratio: 16/9; }
}
