:root {
  color-scheme: dark;
  --bg-dark: #050811;
  --bg-panel: rgba(13, 19, 33, 0.88);
  --bg-card: rgba(20, 28, 48, 0.75);
  --border-neon: rgba(6, 182, 212, 0.35);
  --border-purple: rgba(168, 85, 247, 0.35);
  --cyan-neon: #06b6d4;
  --cyan-bright: #22d3ee;
  --purple-neon: #a855f7;
  --pink-neon: #ec4899;
  --green-neon: #10b981;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --radius-lg: 20px;
  --radius-md: 12px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Outfit', -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Glow */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(150px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.2;
}

.glow-cyan { top: -100px; left: -100px; width: 500px; height: 500px; background: var(--cyan-neon); }
.glow-purple { bottom: -100px; right: -100px; width: 500px; height: 500px; background: var(--purple-neon); }

/* Layout */
.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 24px 60px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border-neon);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  font-size: 34px;
  filter: drop-shadow(0 0 15px var(--cyan-neon));
}

.brand-title {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ffffff, var(--cyan-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  font-size: 11px;
  font-weight: 700;
  color: var(--cyan-neon);
  font-family: 'Fira Code', monospace;
  letter-spacing: 0.5px;
}

/* GPU Ticker */
.gpu-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid var(--border-neon);
  padding: 8px 16px;
  border-radius: var(--radius-md);
}

.gpu-indicator {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green-neon);
  box-shadow: 0 0 12px var(--green-neon);
  animation: pulseGpu 1.5s infinite;
}

@keyframes pulseGpu {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.gpu-stat-group {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  font-family: 'Fira Code', monospace;
}

.gpu-name {
  font-weight: 800;
  color: #ffffff;
}

.gpu-metric strong {
  color: var(--cyan-bright);
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 360px 1fr 340px;
  gap: 20px;
}

/* Panels */
.panel {
  background: var(--bg-panel);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.panel-num {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--cyan-neon);
  color: #000;
  font-weight: 900;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 0.5px;
}

.panel-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed rgba(6, 182, 212, 0.35);
  background: rgba(6, 182, 212, 0.04);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--cyan-neon);
  background: rgba(6, 182, 212, 0.12);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.2);
}

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

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

/* Faces Grid */
.faces-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 4px;
}

.face-card {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 2px solid transparent;
  aspect-ratio: 1;
  background: #000;
  cursor: pointer;
  transition: all 0.2s ease;
}

.face-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-card:hover {
  transform: scale(1.03);
  border-color: var(--cyan-bright);
}

.face-card.selected {
  border-color: var(--cyan-neon);
  box-shadow: 0 0 20px var(--cyan-neon);
}

.face-card.selected::after {
  content: "ACTIVE ✓";
  position: absolute;
  top: 6px;
  left: 6px;
  background: var(--cyan-neon);
  color: #000;
  font-size: 9px;
  font-weight: 900;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-delete-face {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(239, 68, 68, 0.85);
  border: none;
  color: #fff;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.face-card:hover .btn-delete-face {
  opacity: 1;
}

/* Target Area */
.target-card {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.target-card h3 {
  font-size: 14px;
  font-weight: 800;
}

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

.target-preview-wrap {
  width: 100%;
  max-height: 260px;
  overflow: hidden;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: center;
  background: #000;
}

.target-preview-wrap img, .target-preview-wrap video {
  max-width: 100%;
  max-height: 260px;
  object-fit: contain;
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-item label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.form-select {
  background: rgba(11, 15, 25, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

.form-select:focus {
  border-color: var(--cyan-neon);
}

.form-range {
  width: 100%;
  accent-color: var(--cyan-neon);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s ease;
}

.btn-upload {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid var(--cyan-neon);
  color: var(--cyan-neon);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-upload:hover {
  background: var(--cyan-neon);
  color: #000;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-neon);
  color: var(--cyan-neon);
  padding: 8px 14px;
  font-size: 12px;
}

.btn-render {
  background: linear-gradient(135deg, var(--cyan-neon), var(--purple-neon));
  color: #ffffff;
  padding: 16px;
  font-size: 16px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 25px rgba(6, 182, 212, 0.4);
}

.btn-render:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 35px rgba(6, 182, 212, 0.6);
}

.btn-refresh {
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
}

/* Progress */
.render-progress-card {
  background: var(--bg-card);
  border: 1px solid var(--cyan-neon);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: fadeIn 0.3s ease;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
}

.progress-title { color: var(--cyan-bright); }
.progress-percent { font-family: 'Fira Code', monospace; color: #ffffff; }

.progress-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--cyan-neon), var(--pink-neon));
  transition: width 0.3s ease;
}

/* Output Gallery */
.gallery-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 600px;
  overflow-y: auto;
  padding-right: 4px;
}

.gallery-item {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.gallery-item img, .gallery-item video {
  width: 100%;
  border-radius: 8px;
  object-fit: cover;
  max-height: 180px;
}

.gallery-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gallery-link {
  color: var(--cyan-neon);
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.gallery-link:hover { text-decoration: underline; }

/* Footer */
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding-top: 10px;
}

.hidden { display: none !important; }

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

@media (max-width: 1024px) {
  .workspace-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
}
