:root {
  --primary: #4361ee;
  --primary-light: #4895ef;
  --primary-dark: #3a0ca3;
  --secondary: #f72585;
  --success: #4cc9f0;
  --dark: #141414;
  --light: #f8f9fa;
  --gray: #8d99ae;
  --gray-dark: #2b2d42;
  --light-bg: #edf2f4;
  --dark-bg: #1a1a1a;
  --card-bg: rgba(255, 255, 255, 0.95);
  --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  --radius: 12px;
  --transition: all 0.3s ease;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background: linear-gradient(135deg, var(--light-bg) 0%, #e6e6e6 100%);
  color: var(--dark);
  min-height: 100vh;
  padding: 20px;
  line-height: 1.6;
}

@media (prefers-color-scheme: dark) {
  body {
    background: linear-gradient(135deg, var(--dark-bg) 0%, #121212 100%);
    color: var(--light);
  }

  .card {
    background: rgba(30, 30, 30, 0.85);
  }
}

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  text-align: center;
  padding: 40px 20px;
  max-width: 800px;
  margin: 0 auto;
}

.logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}

.logo-icon {
  background: var(--primary);
  color: white;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 20px;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 16px;
  background: linear-gradient(45deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.2;
}

.subtitle {
  font-size: 1.25rem;
  margin-bottom: 20px;
  color: var(--gray-dark);
}

@media (prefers-color-scheme: dark) {
  .subtitle {
    color: var(--light);
  }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 30px;
  margin-bottom: 30px;
}

/* New Layout for Upload and Options */
.main-content-wrapper {
  display: flex;
  gap: 30px;
  /* Space between cards */
  align-items: flex-start;
  /* Align tops of cards */
  margin-bottom: 30px;
  /* Space before result section */
}

.upload-card {
  flex: 1;
  /* Allows it to grow */
  min-width: 300px;
  /* Minimum width before wrapping */
  max-width: 400px;
  /* Max width for upload card to not be too wide */
  position: sticky;
  /* Make it sticky for better UX on scroll */
  top: 20px;
  /* Stick to top with some offset */
  align-self: flex-start;
  /* Ensure it sticks to the start of the cross axis */
}

.options-card {
  flex: 2;
  /* Allows it to grow more than upload card */
  min-width: 400px;
  /* Minimum width before wrapping */
}

@media (max-width: 992px) {

  /* Adjust breakpoint for stacking */
  .main-content-wrapper {
    flex-direction: column;
  }

  .upload-card,
  .options-card {
    max-width: 100%;
    /* Take full width */
    position: static;
    /* Remove sticky on small screens */
  }
}

.upload-area {
  border: 3px dashed var(--primary);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  /* Flexbox for centering content */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  /* Ensure a minimum height for the upload area */
}

.upload-area:hover,
.upload-area.drag-over {
  background: rgba(67, 97, 238, 0.05);
  border-color: var(--success);
}

/* Content inside upload area (icon, text, hint) */
#uploadContent {
  display: block;
  /* Initially visible */
}

#uploadContent.hidden {
  display: none;
}

.upload-icon {
  font-size: 60px;
  margin-bottom: 20px;
  color: var(--primary);
}

.upload-text {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 10px;
}

.upload-hint {
  color: var(--gray);
  max-width: 80%;
  margin: 0 auto;
}

/* Image preview inside upload area */
#uploadedImagePreview {
  max-width: 100%;
  max-height: 200px;
  /* Limit height for thumbnail */
  object-fit: contain;
  /* Ensure the image fits without cropping */
  border-radius: var(--radius);
  display: none;
  /* Hidden by default */
  margin-bottom: 15px;
  /* Space above clear button */
}

#fileInput {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.process-section {
  margin-top: 30px;
  text-align: center;
  /* Center the process button */
}

h2 {
  font-size: 1.8rem;
  margin-bottom: 24px;
  position: relative;
  padding-bottom: 12px;
}

h2:after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
}

.section-description {
  font-size: 1rem;
  color: var(--gray);
  margin-bottom: 20px;
}

@media (prefers-color-scheme: dark) {
  .section-description {
    color: var(--light);
  }
}

.options-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-bottom: 30px;
}

.option-card {
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(0, 0, 0, 0.05);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  /* Distribute space */
  align-items: center;
}

@media (prefers-color-scheme: dark) {
  .option-card {
    background: rgba(40, 40, 40, 0.7);
    border-color: rgba(255, 255, 255, 0.05);
  }
}

.option-card:hover,
.option-card.active {
  border-color: var(--primary);
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.option-icon {
  font-size: 36px;
  margin-bottom: 15px;
  color: var(--primary);
}

.option-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.option-desc {
  font-size: 0.9rem;
  color: var(--gray);
  flex-grow: 1;
  /* Allow description to take available space */
  margin-bottom: 15px;
  /* Space before checkbox */
}

.checkbox-container {
  margin-top: auto;
  /* Push checkbox to bottom */
  display: inline-block;
  position: relative;
  cursor: pointer;
  /* Ensure label is clickable */
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.checkmark {
  position: relative;
  display: inline-block;
  height: 22px;
  width: 22px;
  background-color: white;
  border: 2px solid var(--primary);
  border-radius: 4px;
  transition: var(--transition);
}

@media (prefers-color-scheme: dark) {
  .checkmark {
    background-color: #333;
  }
}

.checkbox-container input:checked~.checkmark {
  background-color: var(--primary);
  border-color: var(--primary);
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
  left: 6px;
  top: 2px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.checkbox-container input:checked~.checkmark:after {
  display: block;
}

.image-preview-container {
  display: flex;
  gap: 30px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 30px 0;
}

.preview-box {
  flex: 1;
  min-width: 300px;
  max-width: 500px;
  overflow: hidden;
}

.preview-label {
  font-weight: 600;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.preview-area {
  border-radius: var(--radius);
  overflow: hidden;
  background: #f0f0f0;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  min-height: 150px;
  /* Placeholder height */
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray);
  font-style: italic;
}

@media (prefers-color-scheme: dark) {
  .preview-area {
    background: #252525;
  }
}

.preview-area img,
.preview-area canvas {
  display: block;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  /* Ensure image fits within bounds */
}

#originalImage {
  display: none;
  /* Hidden until an image is loaded */
}

.action-buttons {
  display: flex;
  gap: 15px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 30px;
}

.btn {
  padding: 14px 32px;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-3px);
  box-shadow: 0 7px 14px rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: transparent;
  border: 2px solid var(--gray);
  color: var(--gray);
}

.btn-secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-3px);
}

.btn-success {
  background: var(--success);
  color: var(--dark);
}

.btn-success:hover {
  background: #39b7d9;
  transform: translateY(-3px);
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.section-hidden {
  display: none;
}

footer {
  text-align: center;
  padding: 30px 0;
  margin-top: 50px;
  color: var(--gray);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

/* Info Ribbon */
.info-ribbon {
  background: linear-gradient(45deg, var(--primary), var(--primary-light));
  color: white;
  text-align: center;
  padding: 10px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  font-weight: 500;
}

/* FAQ Specific Styles */
.faq-section {
  margin-top: 60px;
  padding: 30px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.faq-section h2 {
  margin-bottom: 30px;
  text-align: center;
}

.faq-item {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

@media (prefers-color-scheme: dark) {
  .faq-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  }
}

.faq-item:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.faq-item .question {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--primary-dark);
  cursor: pointer;
  padding-right: 20px;
  /* Space for potential arrow icon */
  position: relative;
  transition: color 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  .faq-item .question {
    color: var(--primary-light);
  }
}

.faq-item .question:hover {
  color: var(--primary);
}

.faq-item .answer {
  margin-top: 10px;
  color: var(--dark);
  line-height: 1.7;
  padding-left: 10px;
}

@media (prefers-color-scheme: dark) {
  .faq-item .answer {
    color: var(--light);
  }
}

.faq-item .answer ul {
  margin-top: 10px;
  margin-left: 20px;
  list-style-type: disc;
}

.faq-item .answer li {
  margin-bottom: 5px;
}