:root {
  --bg-dark: #090d16;
  --panel-bg: rgba(18, 24, 38, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --accent-primary: #6366f1;
  --accent-glow: #818cf8;
  --accent-pink: #ec4899;
  --accent-green: #10b981;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --radius-lg: 16px;
  --radius-md: 10px;
  --transition-fast: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 15% 15%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 85% 85%, rgba(236, 72, 153, 0.12) 0px, transparent 50%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
}

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

.logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-tag {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-glow);
  border: 1px solid rgba(99, 102, 241, 0.3);
}

.brand-text p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 30px;
  font-size: 0.82rem;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: var(--accent-green);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 320px 1.1fr;
  gap: 24px;
  flex: 1;
}

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

/* Panel Design */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 14px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-main);
}

.panel-title i {
  color: var(--accent-glow);
  width: 20px;
  height: 20px;
}

.panel-title h2 {
  font-size: 1.1rem;
  font-weight: 700;
}

.step-badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* Camera Stage */
.camera-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #04060a;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.video-container {
  width: 100%;
  height: 100%;
  position: relative;
}

video#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror camera */
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: #0b0f19;
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

.camera-placeholder i {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

.scanner-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: none;
}

.video-container.active .scanner-overlay {
  display: block;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-glow), transparent);
  box-shadow: 0 0 15px var(--accent-glow);
  animation: scan 3s linear infinite;
}

@keyframes scan {
  0% { top: 0; }
  50% { top: 100%; }
  100% { top: 0; }
}

.face-guide {
  position: absolute;
  top: 45%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 52%;
  height: 65%;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.2);
}

/* Captured Preview */
.captured-preview {
  position: absolute;
  inset: 0;
  background: #000;
}

.captured-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: rgba(16, 185, 129, 0.85);
  backdrop-filter: blur(8px);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.hidden-canvas, .hidden-input, .hidden {
  display: none !important;
}

/* Controls Bar */
.controls-bar {
  display: flex;
  gap: 12px;
  margin-top: auto;
}

.btn-group {
  display: flex;
  gap: 10px;
  width: 100%;
}

/* Buttons */
.btn {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
  text-decoration: none;
}

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

.btn i {
  width: 18px;
  height: 18px;
}

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

.btn-primary:hover:not(:disabled) {
  background: #4f46e5;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.4);
}

.btn-accent {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-pink));
  color: white;
  flex: 1;
}

.btn-accent:hover:not(:disabled) {
  opacity: 0.95;
  box-shadow: 0 4px 20px rgba(236, 72, 153, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--panel-border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-muted);
}

.btn-outline:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.25);
  color: var(--text-main);
}

.btn-glow {
  background: linear-gradient(135deg, #4f46e5, #9333ea, #ec4899);
  background-size: 200% 200%;
  animation: glowShift 4s ease infinite;
  color: white;
  width: 100%;
  padding: 14px;
  font-size: 1rem;
  box-shadow: 0 0 20px rgba(147, 51, 234, 0.4);
}

@keyframes glowShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.btn-glow:hover:not(:disabled) {
  transform: scale(1.02);
  box-shadow: 0 0 30px rgba(236, 72, 153, 0.6);
}

.btn-success {
  background: var(--accent-green);
  color: white;
  flex: 1;
}

.btn-success:hover {
  background: #059669;
  box-shadow: 0 4px 16px rgba(16, 185, 129, 0.4);
}

/* Jewelry Card */
.jewelry-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.jewelry-image-box {
  position: relative;
  width: 100%;
  height: 200px;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0.08) 0%, transparent 70%);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow: hidden;
}

.jewelry-image-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.5));
  transition: var(--transition-fast);
}

.jewelry-card:hover .jewelry-image-box img {
  transform: scale(1.06);
}

.jewelry-info h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.jewelry-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 12px;
}

.jewelry-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 0.72rem;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.tag i {
  width: 12px;
  height: 12px;
}

.action-trigger-area {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint-text {
  font-size: 0.76rem;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.hint-text i {
  width: 14px;
  height: 14px;
}

/* Result Stage */
.result-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #04060a;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
}

.result-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.placeholder-icon {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.placeholder-icon i {
  width: 28px;
  height: 28px;
}

.result-placeholder h3 {
  color: var(--text-main);
  font-size: 1rem;
}

.result-placeholder p {
  font-size: 0.82rem;
  max-width: 260px;
  line-height: 1.4;
}

/* Loading */
.result-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}

.spinner-ring {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--accent-glow);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

.result-loading h3 {
  font-size: 1rem;
  font-weight: 700;
}

.result-loading p {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 280px;
}

/* Result View */
.result-view {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
}

.image-wrapper {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-meta {
  position: absolute;
  bottom: 12px;
  left: 12px;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(8px);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.76rem;
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--accent-green);
}

.meta-item.time-meta {
  color: var(--accent-glow);
  border-left: 1px solid rgba(255, 255, 255, 0.1);
  padding-left: 10px;
}


.meta-item i {
  width: 14px;
  height: 14px;
}

.result-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 16px 0 0;
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Comprehensive Responsive Media Queries */
@media (max-width: 1024px) {
  .workspace-grid {
    grid-template-columns: 1fr 1fr;
  }
  .jewelry-panel {
    grid-column: span 2;
  }
}

@media (max-width: 768px) {
  .app-container {
    padding: 12px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .jewelry-panel {
    grid-column: span 1;
  }

  .brand-text h1 {
    font-size: 1.2rem;
  }

  .controls-bar {
    flex-direction: column;
  }

  .btn-group {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    padding: 12px 14px;
  }

  .result-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 12px;
    border-radius: 12px;
  }

  .meta-item.time-meta {
    border-left: none;
    padding-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 4px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .logo-icon {
    width: 36px;
    height: 36px;
  }

  .panel {
    padding: 14px;
  }

  .jewelry-image-box {
    height: 160px;
  }
}


/* Compact Floating Jewelry Selector Overlay */
.jewelry-thumb-selector {
  position: absolute;
  bottom: 12px;
  right: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(11, 15, 25, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 5px;
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 5;
}

.thumb-chip {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.thumb-chip img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.thumb-chip:hover {
  transform: scale(1.12);
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(99, 102, 241, 0.5);
}

.thumb-chip.active {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--accent-glow);
  box-shadow: 0 0 14px rgba(99, 102, 241, 0.6);
  transform: scale(1.1);
}


/* Footer */
.app-footer {
  text-align: center;
  padding: 16px 0 0;
  margin-top: auto;
  font-size: 0.78rem;
  color: var(--text-muted);
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
