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

:root {
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --primary-dark: #5b21b6;
  --bg: #0f0b1a;
  --bg-card: #1a1425;
  --bg-card-hover: #231d30;
  --surface: #2d2540;
  --text: #f0edf5;
  --text-muted: #9b8fb8;
  --border: #3d3455;
  --success: #10b981;
  --warning: #f59e0b;
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: -40%;
  left: -20%;
  width: 80%;
  height: 80%;
  background: radial-gradient(ellipse, rgba(124, 58, 237, 0.12) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: -30%;
  right: -20%;
  width: 70%;
  height: 70%;
  background: radial-gradient(ellipse, rgba(236, 72, 153, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.header {
  text-align: center;
  padding: 40px 24px 20px;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon { font-size: 28px; }

.logo-text {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light), #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.tagline {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 300;
}

/* Main */
.main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 20px 24px;
}

/* Views */
.view {
  display: none;
  width: 100%;
  max-width: 600px;
  animation: fadeIn 0.35s ease;
}

.view.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Section Header */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-header h2 {
  font-size: 18px;
  font-weight: 600;
}

/* Agent Grid */
.agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  min-height: 80px;
}

.agent-grid-loading,
.agent-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  padding: 24px;
}

.agent-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.agent-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: translateY(-2px);
}

.agent-card.processing {
  opacity: 0.6;
  cursor: default;
}

.agent-card-thumb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 8px;
  display: block;
  border: 2px solid var(--border);
}

.agent-card:hover .agent-card-thumb {
  border-color: var(--primary);
}

.agent-card-placeholder {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--surface);
  margin: 0 auto 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: var(--text-muted);
}

.agent-card-name {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-card-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
}

.agent-card-status {
  display: inline-block;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: 4px;
  font-weight: 500;
}

.status-ready {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}

.status-processing {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 8px 0 20px;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.divider span {
  color: var(--text-muted);
  font-size: 13px;
  white-space: nowrap;
}

/* Upload Section */
.upload-section {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.drop-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 24px 16px;
  transition: all 0.2s;
  cursor: pointer;
  flex: 0 0 200px;
  min-height: 180px;
  overflow: hidden;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(124, 58, 237, 0.08);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.upload-icon { color: var(--text-muted); }

.drop-text {
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

.drop-or {
  color: var(--text-muted);
  font-size: 11px;
}

.preview-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.preview-overlay.hidden { display: none; }

.preview-overlay img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 6px;
  object-fit: contain;
}

.btn-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-remove:hover { background: rgba(220, 38, 38, 0.8); }

.upload-options {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prompt-section label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.prompt-section textarea {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  resize: vertical;
  transition: border-color 0.2s;
}

.prompt-section textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.prompt-section textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-sm { padding: 6px 14px; font-size: 12px; }

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover { background: var(--primary-dark); }

.btn-icon {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 16px;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--primary);
}

.btn-generate {
  width: 100%;
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), #ec4899);
  color: white;
  border-radius: var(--radius-sm);
}

.btn-generate:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.3);
}

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

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

.btn-secondary:hover { background: var(--bg-card-hover); }

/* Step Card */
.step-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
}

.step-card h2 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.step-desc {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
  line-height: 1.5;
}

/* Generating */
.generating-card { padding: 48px 32px; }

.generating-visual {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.generating-thumb {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  position: relative;
  z-index: 2;
  border: 3px solid var(--primary);
}

.pulse-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 2px solid var(--primary);
  opacity: 0;
  animation: pulse 2s ease-out infinite;
}

.pulse-ring.delay-1 { animation-delay: 0.5s; }
.pulse-ring.delay-2 { animation-delay: 1s; }

@keyframes pulse {
  0% { transform: scale(0.8); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

.progress-bar {
  width: 100%;
  height: 4px;
  background: var(--surface);
  border-radius: 2px;
  margin: 20px 0 12px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), #ec4899);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.generating-tip {
  color: var(--text-muted);
  font-size: 12px;
}

/* Fullscreen Agent View */
.fullscreen-agent {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: #000;
  display: flex;
  flex-direction: column;
}

.fullscreen-agent.hidden {
  display: none;
}

.back-btn {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.back-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.agent-iframe {
  width: 100%;
  height: 100%;
  border: none;
  flex: 1;
}

/* Responsive */
@media (max-width: 600px) {
  .header { padding: 28px 16px 14px; }
  .main { padding: 12px 16px; }
  .upload-section {
    flex-direction: column;
  }
  .drop-zone { flex: unset; width: 100%; }
  .agent-grid { grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); }
}
