:root {
  --bg-space: #07090e;
  --bg-surface: rgba(16, 22, 34, 0.85);
  --bg-surface-border: rgba(255, 255, 255, 0.09);
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --text-main: #f8fafc;
  --text-dim: #94a3b8;
  --danger-color: #ef4444;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-code: 'JetBrains Mono', monospace;
}

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

body {
  background-color: var(--bg-space);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Ambient Sphere Lights */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(150px);
  pointer-events: none;
  z-index: 0;
}
.glow-primary {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.16) 0%, rgba(0,0,0,0) 70%);
  top: -120px;
  left: 15%;
}
.glow-secondary {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.13) 0%, rgba(0,0,0,0) 70%);
  top: 35%;
  right: 8%;
}

/* Navigation Bar */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(7, 9, 14, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--bg-surface-border);
}
.nav-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-logo-img {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 0 16px rgba(59, 130, 246, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.brand-logo-img:hover {
  transform: scale(1.08);
  box-shadow: 0 0 22px rgba(59, 130, 246, 0.7);
}
.brand-title {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.badge-pro {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.25), rgba(6, 182, 212, 0.25));
  color: #38bdf8;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(56, 189, 248, 0.4);
  margin-left: 4px;
}
.nav-badges {
  display: flex;
  gap: 12px;
}
.pill-badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.pill-green {
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.25);
}
.pill-green .dot {
  width: 6px;
  height: 6px;
  background: #34d399;
  border-radius: 50%;
  box-shadow: 0 0 8px #34d399;
}
.pill-purple {
  background: rgba(168, 85, 247, 0.12);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.25);
}

/* Main Layout */
.app-main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 36px 24px;
  position: relative;
  z-index: 1;
}

.stage {
  display: none;
}
.stage.active {
  display: block;
  animation: slideFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideFadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* STAGE 1: Hero & Upload */
.hero-header {
  text-align: center;
  max-width: 800px;
  margin: 0 auto 36px;
}
.tag-pill {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  color: #60a5fa;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}
.hero-heading {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 800;
  letter-spacing: -1.2px;
  line-height: 1.15;
  margin-bottom: 16px;
}
.gradient-text {
  background: linear-gradient(135deg, #60a5fa 0%, #38bdf8 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.hero-description {
  color: var(--text-dim);
  font-size: 1.15rem;
  line-height: 1.6;
}

.drop-zone {
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg-surface);
  border: 2px dashed rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-lg);
  padding: 50px 32px;
  text-align: center;
  transition: all 0.25s ease;
  cursor: pointer;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(22, 30, 48, 0.95);
  transform: translateY(-2px);
  box-shadow: 0 28px 56px var(--primary-glow);
}
.drop-icon-pulse {
  width: 88px;
  height: 88px;
  margin: 0 auto 20px;
  background: rgba(59, 130, 246, 0.1);
  color: #60a5fa;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(59, 130, 246, 0.2);
}
.drop-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.drop-subtitle {
  color: var(--text-dim);
  font-size: 1rem;
  margin-bottom: 14px;
}
.btn-text-action {
  background: none;
  border: none;
  color: #60a5fa;
  font-weight: 700;
  text-decoration: underline;
  cursor: pointer;
  font-size: inherit;
}
.drop-meta {
  display: inline-block;
  font-size: 0.8rem;
  color: #64748b;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 28px;
}

.demo-samples {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.demo-label {
  font-size: 0.85rem;
  color: var(--text-dim);
}
.sample-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}
.sample-btn {
  background: rgba(255, 255, 255, 0.06);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}
.sample-btn:hover {
  background: rgba(59, 130, 246, 0.22);
  border-color: var(--primary);
  color: white;
  transform: translateY(-1px);
}

/* STAGE 2: Studio Toolbar */
.studio-toolbar {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(16px);
}
.toolbar-section {
  display: flex;
  align-items: center;
  gap: 8px;
}
.toolbar-sep {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.1);
}
.toolbar-fill {
  flex: 1;
}

.action-tool {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.action-tool:hover {
  background: rgba(255, 255, 255, 0.1);
}
.action-tool.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  box-shadow: 0 0 14px var(--primary-glow);
}

.brush-controls {
  gap: 10px;
}
.ctrl-label {
  font-size: 0.85rem;
  color: var(--text-dim);
  white-space: nowrap;
}
.size-range {
  accent-color: var(--primary);
  cursor: pointer;
  width: 90px;
}
.preset-chips {
  display: flex;
  gap: 4px;
}
.preset-chip {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  font-size: 0.75rem;
  font-weight: 700;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
}
.preset-chip.active, .preset-chip:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--primary);
  color: white;
}

.btn-tool-accent {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}
.btn-tool-accent:hover {
  background: rgba(16, 185, 129, 0.25);
  border-color: #34d399;
}

.icon-tool-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-dim);
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.icon-tool-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: white;
}
.icon-tool-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.icon-tool-btn.danger:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--danger-color);
  color: #f87171;
}

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-dim);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
}
.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.06);
  color: white;
}

.btn-gradient-action {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: white;
  border: none;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 0.92rem;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 0 18px var(--primary-glow);
  transition: all 0.2s ease;
}
.btn-gradient-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 26px rgba(59, 130, 246, 0.65);
}

/* Canvas Viewport */
.studio-viewport {
  position: relative;
  width: 100%;
  height: 68vh;
  min-height: 500px;
  background: #04060a;
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-lg);
  overflow-x: scroll; /* ALWAYS visible horizontal scrollbar for Left/Right scrolling */
  overflow-y: scroll; /* ALWAYS visible vertical scrollbar for Up/Down scrolling */
  box-shadow: inset 0 2px 24px rgba(0, 0, 0, 0.8);
}

/* Always Visible, Prominent Vertical & Horizontal Scrollbars */
.studio-viewport::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
.studio-viewport::-webkit-scrollbar-track {
  background: #0b1120;
  border-left: 1px solid #1e293b;
  border-top: 1px solid #1e293b;
}
.studio-viewport::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3b82f6, #2563eb);
  border-radius: 7px;
  border: 2px solid #0b1120;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.6);
}
.studio-viewport::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #60a5fa, #3b82f6);
}
.studio-viewport::-webkit-scrollbar-corner {
  background: #0b1120;
}

.canvas-spacer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  visibility: hidden;
}
.canvas-stack {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  cursor: crosshair;
  user-select: none;
}
.canvas-stack canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
}
#layer-image {
  z-index: 1;
}
#layer-mask {
  z-index: 2;
  opacity: 0.68;
}
#layer-temp {
  z-index: 3;
  pointer-events: none;
}

/* Brush Cursor Circle */
.brush-ring {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.9);
  background: rgba(239, 68, 68, 0.35);
  border-radius: 50%;
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: none;
  z-index: 50;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}

.floating-vp-controls {
  position: absolute;
  bottom: 20px;
  right: 20px;
  background: rgba(16, 22, 34, 0.85);
  border: 1px solid var(--bg-surface-border);
  backdrop-filter: blur(10px);

/* Video Scrubber Bar */
.video-scrubber-bar {
  position: absolute;
  bottom: 20px;
  left: 20px;
  right: 220px;
  background: rgba(11, 16, 26, 0.92);
  border: 1px solid var(--bg-surface-border);
  backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 60;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
}
.btn-vid-control {
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  color: white;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.btn-vid-control:hover {
  transform: scale(1.1);
}
.vid-time-display {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 42px;
}
.vid-slider {
  flex: 1;
  accent-color: #3b82f6;
  cursor: pointer;
}
.btn-vid-step {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--bg-surface-border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.btn-vid-step:hover {
  background: rgba(255, 255, 255, 0.16);
  color: white;
}
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  z-index: 20;
}
.vp-control-btn {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 28px;
  height: 28px;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
}
.vp-control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}
.vp-zoom-badge {
  font-size: 0.8rem;
  font-family: var(--font-code);
  color: var(--text-dim);
  padding: 0 6px;
}
.floating-helper {
  position: absolute;
  bottom: 20px;
  left: 20px;
  background: rgba(16, 22, 34, 0.8);
  border: 1px solid var(--bg-surface-border);
  backdrop-filter: blur(10px);
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  color: var(--text-dim);
  z-index: 20;
}

/* STAGE 3: Result & Comparison Split Slider */
.result-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}
.result-heading {
  font-family: var(--font-display);
  font-size: 1.85rem;
  font-weight: 800;
  margin-bottom: 4px;
}
.result-subheading {
  color: var(--text-dim);
  font-size: 0.95rem;
}
.result-btn-group {
  display: flex;
  gap: 12px;
}
.btn-secondary-flat {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.btn-secondary-flat:hover {
  background: rgba(16, 185, 129, 0.25);
}

.slider-comparison-box {
  background: #04060a;
  border: 1px solid var(--bg-surface-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 520px;
}
.comparison-stage {
  position: relative;
  overflow: hidden;
  max-width: 100%;
  max-height: 75vh;
  border-radius: var(--radius-md);
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.7);
  user-select: none;
}
.comp-frame {
  display: block;
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
}
.comp-after-frame {
  width: 100%;
}
.comp-before-layer {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 50%;
  overflow: hidden;
  border-right: 2px solid white;
}
.comp-before-layer .comp-before-frame {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: auto;
  max-width: none;
}
.slider-divider-handle {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  width: 40px;
  transform: translateX(-50%);
  cursor: ew-resize;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
}
.divider-line {
  width: 2px;
  flex: 1;
  background: white;
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}
.divider-thumb {
  width: 38px;
  height: 38px;
  background: white;
  border-radius: 50%;
  color: #07090e;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.6);
}
.badge-tag {
  position: absolute;
  bottom: 16px;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.8);
  color: white;
  backdrop-filter: blur(4px);
  z-index: 5;
}
.tag-left { left: 16px; }
.tag-right { right: 16px; }

/* Inpainting Modal */
.ai-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(4, 6, 10, 0.85);
  backdrop-filter: blur(10px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.ai-modal-overlay.active {
  display: flex;
}
.ai-modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  padding: 36px;
  border-radius: var(--radius-lg);
  text-align: center;
  max-width: 420px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}
.pulsing-loader {
  margin-bottom: 20px;
}
.pulse-ring {
  width: 52px;
  height: 52px;
  margin: 0 auto;
  border: 4px solid rgba(59, 130, 246, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spinRing 0.8s linear infinite;
}
@keyframes spinRing {
  to { transform: rotate(360deg); }
}
.modal-main-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.modal-sub-title {
  color: var(--text-dim);
  font-size: 0.9rem;
  margin-bottom: 20px;
}
.modal-track {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}
.modal-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent-cyan));
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Feature Grid */
.value-prop-section {
  max-width: 1280px;
  margin: 0 auto;
  padding: 48px 24px 60px;
}
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}
.prop-card {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-border);
  padding: 24px;
  border-radius: var(--radius-md);
  transition: all 0.2s ease;
}
.prop-card:hover {
  border-color: rgba(59, 130, 246, 0.35);
  transform: translateY(-2px);
}
.prop-icon {
  font-size: 1.8rem;
  margin-bottom: 12px;
}
.prop-card h4 {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin-bottom: 8px;
  font-weight: 700;
}
.prop-card p {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.5;
}

/* Footer */
.app-footer {
  border-top: 1px solid var(--bg-surface-border);
  padding: 24px 0;
  text-align: center;
  font-size: 0.85rem;
  color: #64748b;
}

@media (max-width: 768px) {
  .hero-heading { font-size: 2.2rem; }
  .studio-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-section { flex-wrap: wrap; }
  .toolbar-fill { display: none; }
}
