:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #f1f5f9;
  --accent: #f59e0b;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --success: #10b981;
  --error: #ef4444;
  --border-radius: 12px;
  --transition: all 0.3s ease;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 800px;
  margin: 0 auto;
  padding: 2rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

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

.user-info .credits-badge {
  display: inline-block;
  background: var(--primary);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

.user-info .credits-badge.low {
  background: var(--error);
}

.user-info .credits-badge.admin {
  background: var(--accent);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.tagline {
  color: var(--text-muted);
  font-size: 1.1rem;
}

/* Main */
main {
  flex: 1;
  position: relative;
}

/* Steps */
.step {
  display: none;
  animation: fadeIn 0.4s ease;
}

.step.active {
  display: block;
}

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

.step-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: 50%;
  font-weight: 600;
  font-size: 1rem;
}

.step-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
}

.step-description {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

/* Upload Area */
.upload-area {
  border: 2px dashed var(--surface-light);
  border-radius: var(--border-radius);
  padding: 3rem 2rem;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  background: var(--surface);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.1);
}

.upload-icon {
  color: var(--primary);
  margin-bottom: 1rem;
}

.upload-area p {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.upload-or {
  display: block;
  color: var(--text-muted);
  margin: 0.75rem 0;
  font-size: 0.9rem;
}

.upload-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 1rem !important;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  text-decoration: none;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
}

.btn-secondary:hover {
  background: #475569;
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
}

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

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.1rem;
}

/* Image Container */
.image-container {
  position: relative;
  background: var(--surface);
  border-radius: var(--border-radius);
  overflow: visible;
  margin-bottom: 1.5rem;
  display: block;
  width: fit-content;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

#uploaded-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  width: auto;
  height: auto;
}

#person-labels {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.person-marker {
  position: absolute;
  transform: translate(-50%, -100%);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: var(--transition);
}

.person-marker:hover {
  transform: translate(-50%, -100%) scale(1.1);
}

.person-label {
  background: rgba(99, 102, 241, 0.95);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 16px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.person-arrow {
  color: rgba(99, 102, 241, 0.95);
  font-size: 1.2rem;
  line-height: 1;
  margin-top: -2px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.person-marker:hover .person-label {
  background: var(--primary-light);
}

.person-marker:hover .person-arrow {
  color: var(--primary-light);
}

.person-marker.selected .person-label {
  background: var(--accent);
}

.person-marker.selected .person-arrow {
  color: var(--accent);
}

/* Selection Arrow */
.selection-arrow {
  position: absolute;
  color: var(--accent);
  animation: bounce 1s infinite;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

.selection-arrow.hidden {
  display: none;
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Selected Info */
.selected-info {
  text-align: center;
  margin-bottom: 1.5rem;
  min-height: 2rem;
}

#selected-label {
  background: var(--accent);
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: 500;
}

/* Celebrity Input */
.celebrity-input-group {
  margin-bottom: 2rem;
}

#celebrity-input {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  border: 2px solid var(--surface-light);
  border-radius: var(--border-radius);
  background: var(--surface);
  color: var(--text);
  transition: var(--transition);
}

#celebrity-input:focus {
  outline: none;
  border-color: var(--primary);
}

#celebrity-input::placeholder {
  color: var(--text-muted);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.suggestion-chip {
  background: var(--surface-light);
  border: none;
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
}

.suggestion-chip:hover {
  background: var(--primary);
}

/* Result */
.result-container {
  margin-bottom: 2rem;
}

.result-comparison {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.result-image-wrapper {
  flex: 1;
  min-width: 250px;
  max-width: 350px;
  position: relative;
}

.result-label {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}

.result-image-wrapper img {
  width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.result-arrow {
  font-size: 2rem;
  color: var(--primary);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
}

.result-actions.hidden {
  display: none;
}

/* Loading */
.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.9);
  z-index: 100;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
}

.loading-overlay.active {
  display: flex;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

/* Error Toast */
.error-toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--error);
  color: white;
  padding: 1rem 2rem;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 200;
  animation: slideUp 0.3s ease;
}

.error-toast.hidden {
  display: none;
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

#error-close {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 600px) {
  .container {
    padding: 1rem;
  }

  header h1 {
    font-size: 2rem;
  }

  .upload-area {
    padding: 2rem 1rem;
  }

  .result-comparison {
    flex-direction: column;
  }

  .result-arrow {
    transform: rotate(90deg);
  }

  .result-image-wrapper {
    max-width: 100%;
  }
}
