/* ==========================================================================
   PurifyAI - Modern Dark Glassmorphic Design System
   ========================================================================== */

:root {
  --bg-primary: #07090e;
  --bg-secondary: #0d121d;
  --bg-tertiary: #131a29;
  
  --surface-glass: rgba(16, 23, 38, 0.75);
  --surface-glass-hover: rgba(22, 32, 53, 0.85);
  --surface-border: rgba(255, 255, 255, 0.09);
  --surface-border-focus: rgba(99, 102, 241, 0.5);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.35);
  
  --success: #10b981;
  --success-glow: rgba(16, 185, 129, 0.3);
  
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 10px 25px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 45px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 35px var(--primary-glow);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
}

/* Ambient Ambient Gradient Orbs */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
  animation: floatOrb 20s infinite alternate ease-in-out;
}

.glow-1 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, #4f46e5 0%, transparent 70%);
  top: -100px;
  left: -100px;
}

.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, #0891b2 0%, transparent 70%);
  bottom: -150px;
  right: -100px;
  animation-duration: 25s;
}

.glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, #7c3aed 0%, transparent 70%);
  top: 40%;
  left: 55%;
  opacity: 0.25;
  animation-duration: 18s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(40px, 30px) scale(1.08); }
  100% { transform: translate(-30px, 50px) scale(0.95); }
}

.container {
  width: 100%;
  max-width: 1380px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Header Navigation
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  background: rgba(7, 9, 14, 0.82);
  border-bottom: 1px solid var(--surface-border);
  height: 72px;
  display: flex;
  align-items: center;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-title .highlight {
  background: linear-gradient(135deg, #818cf8, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  margin-left: 6px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
}

.nav-status {
  display: none;
}

@media (min-width: 860px) {
  .nav-status {
    display: flex;
    align-items: center;
  }
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  border-radius: 100px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  background-color: var(--success);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--success);
  animation: pulseDot 2s infinite ease-in-out;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ==========================================================================
   Buttons and Form Controls
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  color: #fff;
  box-shadow: 0 4px 18px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #7174f8 0%, #5850ec 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 22px var(--primary-glow);
}

.btn-primary-outline {
  background: rgba(99, 102, 241, 0.12);
  color: #a5b4fc;
  border-color: rgba(99, 102, 241, 0.4);
}

.btn-primary-outline:hover {
  background: rgba(99, 102, 241, 0.22);
  color: #fff;
  border-color: #6366f1;
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 4px 16px var(--success-glow);
}

.btn-success:hover {
  background: linear-gradient(135deg, #18c48c 0%, #08a374 100%);
  transform: translateY(-1px);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border-color: var(--surface-border);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.82rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 13px 28px;
  font-size: 1.05rem;
  border-radius: var(--radius-md);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--surface-border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  border-color: rgba(255, 255, 255, 0.2);
}

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

.pulse-glow {
  position: relative;
}

.pulse-glow::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: inherit;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  z-index: -1;
  opacity: 0.35;
  filter: blur(8px);
  animation: glowPulse 2.5s infinite alternate ease-in-out;
}

@keyframes glowPulse {
  0% { opacity: 0.2; transform: scale(0.98); }
  100% { opacity: 0.6; transform: scale(1.02); }
}

/* ==========================================================================
   Cards & Surfaces
   ========================================================================== */

.card {
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   Hero & Upload Section
   ========================================================================== */

.main-content {
  padding-top: 36px;
  padding-bottom: 72px;
}

.upload-section {
  padding: 48px 40px;
  text-align: center;
  max-width: 980px;
  margin: 0 auto;
}

.section-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #a5b4fc;
  margin-bottom: 20px;
}

.hero-title {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.gradient-text {
  background: linear-gradient(135deg, #818cf8 0%, #22d3ee 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-desc {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto 36px;
  line-height: 1.6;
}

/* Mode Switcher Tabs */
.mode-tabs {
  display: inline-flex;
  background: rgba(13, 18, 29, 0.9);
  border: 1px solid var(--surface-border);
  padding: 6px;
  border-radius: 100px;
  gap: 8px;
  margin-bottom: 32px;
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  border-radius: 100px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-tab:hover {
  color: var(--text-main);
}

.mode-tab.active {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.tab-chip {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.12);
}

/* Dropzone */
.dropzone {
  position: relative;
  border: 2px dashed rgba(255, 255, 255, 0.16);
  border-radius: var(--radius-lg);
  padding: 56px 28px;
  background: rgba(13, 18, 29, 0.55);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.dropzone:hover, .dropzone.drag-active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.06);
  box-shadow: inset 0 0 30px rgba(99, 102, 241, 0.1), 0 0 30px rgba(99, 102, 241, 0.15);
  transform: translateY(-2px);
}

.file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.dropzone-icon-ring {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.1);
  border: 1px solid rgba(99, 102, 241, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  color: #818cf8;
  transition: transform 0.3s ease;
}

.dropzone:hover .dropzone-icon-ring {
  transform: scale(1.1);
  background: rgba(99, 102, 241, 0.2);
}

.dropzone-heading {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.dropzone-sub {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.link-btn {
  background: none;
  border: none;
  color: #818cf8;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.dropzone-specs {
  display: inline-flex;
  gap: 10px;
  font-size: 0.8rem;
  color: var(--text-dim);
}

/* Samples Showcase */
.samples-showcase {
  margin-top: 40px;
  padding-top: 32px;
  border-top: 1px solid var(--surface-border);
}

.samples-header {
  margin-bottom: 18px;
}

.samples-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.samples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.sample-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border);
  padding: 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
}

.sample-card:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(99, 102, 241, 0.4);
  transform: translateY(-2px);
}

.sample-thumb-wrapper {
  position: relative;
  width: 90px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  background: #000;
}

.sample-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sample-badge {
  position: absolute;
  bottom: 3px;
  right: 3px;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

.badge-photo {
  background: rgba(16, 185, 129, 0.85);
  color: #fff;
}

.badge-video {
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
}

.sample-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sample-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sample-desc {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================================================
   Image Studio Workspace
   ========================================================================== */

.studio-workspace {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.studio-toolbar {
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.group-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
}

.tool-btn-group {
  display: flex;
  background: rgba(0, 0, 0, 0.3);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--surface-border);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  color: var(--text-main);
}

.tool-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}

.btn-ai-detect {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(6, 182, 212, 0.25));
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #c7d2fe;
}

.btn-ai-detect:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.45), rgba(6, 182, 212, 0.45));
  color: #fff;
}

.toolbar-divider {
  width: 1px;
  height: 28px;
  background: var(--surface-border);
}

.toolbar-spacer {
  flex: 1;
}

/* Custom Sliders */
.slider-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-slider {
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  width: 90px;
}

.range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #6366f1;
  cursor: pointer;
  box-shadow: 0 0 10px var(--primary);
  transition: transform 0.1s ease;
}

.range-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.range-sm {
  width: 70px;
}

.brush-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(99, 102, 241, 0.4);
  border: 2px solid #6366f1;
  display: inline-block;
}

.custom-select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--surface-border);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

.custom-select:focus {
  border-color: var(--primary);
}

/* Preset Chips Bar */
.preset-chips-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding: 6px 4px;
}

.preset-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  white-space: nowrap;
}

.chip {
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.chip:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

/* Canvas Viewport */
.canvas-viewport {
  position: relative;
  min-height: 520px;
  max-height: 72vh;
  background: #090c14;
  background-image: 
    radial-gradient(rgba(255, 255, 255, 0.07) 1px, transparent 1px);
  background-size: 20px 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--surface-border);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.canvas-wrapper {
  position: relative;
  display: inline-block;
  transform-origin: center center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  border-radius: 4px;
  overflow: hidden;
}

#image-canvas {
  display: block;
  max-width: 100%;
}

#mask-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.65;
}

.selection-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Selection Boxes on Canvas */
.watermark-box {
  position: absolute;
  border: 2px dashed #00f2fe;
  background: rgba(0, 242, 254, 0.22);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.4);
  cursor: move;
  box-sizing: border-box;
}

.watermark-box.active {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.28);
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.6);
}

.box-label {
  position: absolute;
  top: -24px;
  left: 0;
  background: rgba(13, 18, 29, 0.9);
  border: 1px solid #00f2fe;
  color: #00f2fe;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
}

.box-delete-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.resize-handle {
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  border: 2px solid #00f2fe;
  border-radius: 50%;
}

.handle-tl { top: -5px; left: -5px; cursor: nwse-resize; }
.handle-tr { top: -5px; right: -5px; cursor: nesw-resize; }
.handle-bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
.handle-br { bottom: -5px; right: -5px; cursor: nwse-resize; }

.canvas-cursor-ring {
  position: absolute;
  pointer-events: none;
  border: 2px solid #6366f1;
  background: rgba(99, 102, 241, 0.2);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  z-index: 50;
}

/* Studio Bottom Bar */
.studio-bottom-bar {
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.media-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.meta-item.filename {
  font-weight: 700;
  color: var(--text-main);
}

.meta-item.tag {
  background: rgba(255, 255, 255, 0.06);
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.78rem;
  color: #a5b4fc;
}

/* ==========================================================================
   Before / After Split Comparison Slider
   ========================================================================== */

.result-section {
  padding: 24px;
  margin-top: 12px;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.result-title {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--text-main);
}

.result-subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.result-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.comparison-container {
  position: relative;
  width: 100%;
  max-width: 1000px;
  height: 540px;
  margin: 0 auto;
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--surface-border);
}

.comparison-before-wrapper,
.comparison-after-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.comp-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #05070a;
  display: block;
}

.comp-badge {
  position: absolute;
  top: 16px;
  padding: 5px 12px;
  border-radius: 100px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  backdrop-filter: blur(8px);
}

.badge-before {
  left: 16px;
  background: rgba(239, 68, 68, 0.85);
  color: #fff;
}

.badge-after {
  right: 16px;
  background: rgba(16, 185, 129, 0.85);
  color: #fff;
}

.comparison-after-wrapper {
  clip-path: polygon(50% 0, 100% 0, 100% 100%, 50% 100%);
}

.comparison-slider-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 40px;
  transform: translateX(-50%);
  cursor: ew-resize;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
}

.handle-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.8);
}

.handle-thumb {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: #0f172a;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 2;
}

/* ==========================================================================
   Video Studio Workspace
   ========================================================================== */

.video-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

@media (min-width: 960px) {
  .video-grid {
    grid-template-columns: 1.55fr 1fr;
  }
}

.video-player-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.video-viewport-wrapper {
  position: relative;
  width: 100%;
  min-height: 380px;
  max-height: 68vh;
  background: #05070a;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 16px 16px;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.video-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 64vh;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
  border-radius: var(--radius-sm);
  overflow: hidden;
  user-select: none;
}

.video-element {
  display: block;
  max-width: 100%;
  max-height: 64vh;
  width: auto;
  height: auto;
  object-fit: contain;
}

.video-overlay-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.video-box-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

.video-controls-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius-sm);
}

.btn-play {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
}

.timeline-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.video-range-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  outline: none;
}

.video-range-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #06b6d4;
  box-shadow: 0 0 10px #06b6d4;
}

.time-readout {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.mono {
  font-family: var(--font-mono);
}

.video-settings-card {
  padding: 24px;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.settings-title {
  font-size: 1.2rem;
  font-weight: 700;
}

.badge-pill {
  padding: 4px 10px;
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #a5b4fc;
  font-size: 0.72rem;
  font-weight: 700;
  border-radius: 100px;
  text-transform: uppercase;
}

.tip-box {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: #67e8f9;
  margin-bottom: 20px;
}

.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.video-preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.video-preset-btn {
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.video-preset-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.4);
  color: #fff;
}

.coords-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.coord-input-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.coord-label {
  font-size: 0.72rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
}

.coord-input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--surface-border);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-main);
  outline: none;
}

.coord-input:focus {
  border-color: var(--primary);
}

.algo-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.radio-card:hover {
  background: rgba(255, 255, 255, 0.06);
}

.radio-card input[type="radio"]:checked ~ .radio-content .radio-title {
  color: #818cf8;
}

.radio-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.radio-desc {
  display: block;
  font-size: 0.78rem;
  color: var(--text-dim);
}

.switch-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
}

.switch-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
}

.switch-desc {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* iOS Style Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider.round {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.2);
  transition: .3s;
  border-radius: 34px;
}

.slider.round:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider.round {
  background-color: #10b981;
}

input:checked + .slider.round:before {
  transform: translateX(20px);
}

/* Video Progress Card */
.video-progress-card {
  padding: 24px;
  margin-top: 16px;
  border-color: rgba(99, 102, 241, 0.4);
}

.progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.progress-title-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
}

.spinner-ring {
  width: 28px;
  height: 28px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: #6366f1;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.progress-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.progress-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #06b6d4, #10b981);
  border-radius: 100px;
  transition: width 0.3s ease;
  box-shadow: 0 0 15px rgba(6, 182, 212, 0.6);
}

.progress-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.metric-item.highlight {
  font-size: 1.1rem;
  font-weight: 800;
  color: #22d3ee;
}

/* Video Result Card */
.video-result-card {
  padding: 24px;
  margin-top: 16px;
}

.video-compare-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 20px;
}

@media (min-width: 800px) {
  .video-compare-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.compare-video-box {
  position: relative;
  background: #000;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--surface-border);
}

.video-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 5;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
}

.compare-video {
  width: 100%;
  display: block;
  aspect-ratio: 16 / 9;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(10px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  width: 100%;
  max-width: 480px;
  padding: 24px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--surface-border);
  font-size: 0.9rem;
}

.shortcut-key {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.8rem;
  color: #a5b4fc;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  background: rgba(16, 23, 38, 0.95);
  border: 1px solid var(--surface-border);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-success { border-color: rgba(16, 185, 129, 0.5); }
.toast-error { border-color: rgba(239, 68, 68, 0.5); }
.toast-info { border-color: rgba(99, 102, 241, 0.5); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Helper Utilities */
.hidden {
  display: none !important;
}
