body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 900px;
  margin: 2rem auto;
  padding: 0 1rem;
  line-height: 1.5;
}
h1 {
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
  color: #064971; /* Logo color - dark teal */
  font-weight: 700;
  line-height: 1.3;
}

/* Header h1 styling */
.header-text h1 {
  color: #064971; /* Logo color - dark teal */
  font-weight: 700;
  font-size: 1.6rem;
  margin-bottom: 0.5rem;
}

/* Section headings (h2) */
h2 {
  color: #064971; /* Logo color - dark teal */
  font-weight: 700;
  font-size: 1.4rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}

/* First h2 in a section shouldn't have top margin */
section > h2:first-child {
  margin-top: 0;
}

/* Subsection headings (h3) */
h3 {
  color: #086d6c; /* Logo color - medium teal */
  font-weight: 600;
  font-size: 1.2rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(8, 109, 108, 0.2); /* Light teal border */
  line-height: 1.4;
}

/* First h3 in a container shouldn't have top margin */
section > h3:first-of-type,
.card > h3:first-of-type {
  margin-top: 0;
}
.card {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
}
label {
  display: block;
  margin-top: 0.6rem;
  font-weight: 600;
}
/* Form input styling */
input[type="number"], 
input[type="file"], 
select {
  margin-top: 0.25rem;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid #d1d5db;
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: inherit;
  background: #ffffff;
  color: #111827;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
}

/* Excel settings inputs - make them smaller */
#maxRows,
#maxCols,
#cellSize {
  width: auto;
  max-width: 180px;
  min-width: 120px;
}

/* Palette size input - make it smaller */
#paletteK {
  width: auto;
  max-width: 150px;
  min-width: 100px;
}

input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: #0b8f68;
  box-shadow: 0 0 0 3px rgba(11, 143, 104, 0.1);
}

input[type="number"]:hover,
select:hover {
  border-color: #9ca3af;
}

input[type="number"]:disabled,
select:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

/* Select dropdown styling */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.5rem;
  cursor: pointer;
  width: auto;
  max-width: 300px;
  min-width: 200px;
}

/* Checkbox styling */
input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: 0.5rem;
  margin-top: 0;
  cursor: pointer;
  accent-color: #0b8f68;
  flex-shrink: 0;
  vertical-align: middle;
}

  /* Checkbox label styling - make labels with checkboxes display as flex */
  /* Note: Using a class-based approach would be more compatible, but :has() is well-supported now */
  @supports selector(:has(*)) {
    label:has(input[type="checkbox"]) {
      display: flex;
      align-items: center;
      margin-top: 0.5rem;
      cursor: pointer;
      font-weight: 500;
    }
  }
  
  /* Fallback for browsers that don't support :has() */
  label > input[type="checkbox"] {
    margin-top: 0.25rem;
  }
  
  /* Ensure checkbox labels look good even without :has() support */
  label[style*="margin-top"] input[type="checkbox"] {
    margin-top: 0;
  }

/* Drag and drop zone */
.drop-zone {
  border: 2px dashed #9ca3af;
  border-radius: 8px;
  padding: 2rem;
  margin-top: 0.25rem;
  text-align: center;
  background: #f9fafb;
  transition: all 0.2s ease;
  cursor: pointer;
}

.drop-zone:hover {
  border-color: #0b8f68;
  background: #f0fdf4;
}

.drop-zone.drag-over {
  border-color: #0b8f68;
  background: #dcfce7;
  border-style: solid;
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.drop-zone-icon {
  color: #6b7280;
  margin-bottom: 0.5rem;
}

.drop-zone:hover .drop-zone-icon,
.drop-zone.drag-over .drop-zone-icon {
  color: #0b8f68;
}

.drop-zone-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #374151;
}

.drop-zone-text-small {
  margin: 0;
  font-size: 0.9rem;
  color: #6b7280;
}

.drop-zone-button {
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: #064971;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  display: inline-block;
  transition: background 0.2s ease;
}

.drop-zone-button:hover {
  background: #086d6c;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  margin-top: 0.5rem;
}
.row > div {
  flex: 1 1 200px;
}
button {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  background: #064971;
  color: white;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover:not(:disabled) {
  background: #086d6c;
}

button:disabled {
  background: #9ca3af;
  cursor: not-allowed;
}
#status {
  margin-top: 0.75rem;
  font-size: 0.9rem;
  color: #374151;
}
#status.error {
  color: #b91c1c;
}

/* Error message styling */
.error-message {
  color: #b91c1c;
  font-size: 0.9rem;
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 4px;
  display: block;
}

#downloadError {
  margin-top: 0.75rem;
  font-weight: 600;
}
#estimate {
  margin-top: 0.25rem;
  font-size: 0.8rem;
  color: #6b7280;
}
#preview-container {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.small-text {
  font-size: 0.8rem;
  color: #6b7280;
}

/* Original image + crop box */
#imageContainer {
  position: relative;
  display: inline-block;
  width: 600px;
  max-width: 100%;
  min-height: 200px;
  border: 1px solid #ddd;
  background: #fafafa;
  box-sizing: border-box;
  overflow: hidden;
  touch-action: none; /* Prevent scrolling while drawing crop box on mobile */
}
#sourceImage {
  display: none;
  max-width: 600px;
  width: 100%;
  height: auto;
  cursor: crosshair;
}
#cropBox {
  position: absolute;
  border: 2px dashed red;
  pointer-events: none;
  display: none;
  box-sizing: border-box;
}

/* Progress bar */
#progressWrapper {
  margin-top: 0.75rem;
  display: none;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #374151;
}
.progress-bar-container {
  flex: 1;
  height: 10px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: #064971;
  transition: width 0.1s linear;
}
#paletteOptions {
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
}
#palettePreview {
  margin-top: 0.25rem;
  min-height: 20px;
}

/* Excel-style pixel preview */
#pixelPreviewCanvas {
  border: 1px solid #ddd;
  display: block;
  width: 600px;          /* upscale width */
  max-width: 100%;
  height: auto;
  image-rendering: pixelated; /* keep blocky look when zoomed */
  background: #f9fafb;
}

.header-logo-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.site-logo {
  width: 100px;     /* adjust based on your design */
  height: 100px;
  object-fit: contain;
}

.header-text {
  display: flex;
  flex-direction: column;
}

.privacy-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 1.5rem;
}

.privacy-container h1 {
  margin-bottom: 0.5rem;
}

.privacy-container h2 {
  color: #064971;
  margin-top: 1.8rem;
  margin-bottom: 0.4rem;
}

.privacy-meta {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.privacy-container p {
  line-height: 1.6;
  margin-bottom: 0.7rem;
}

.privacy-container ul {
  padding-left: 1.4rem;
  margin-bottom: 0.8rem;
}

.privacy-container li {
  margin-bottom: 0.3rem;
}
.terms-container {
  max-width: 800px;
  margin: 2rem auto;
  padding: 1.5rem;
}

.terms-container h1 {
  margin-bottom: 0.5rem;
}

.terms-container h2 {
  color: #064971;
  margin-top: 1.8rem;
  margin-bottom: 0.4rem;
}

.terms-meta {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.terms-container p {
  line-height: 1.6;
  margin-bottom: 0.7rem;
}

.terms-container ul {
  padding-left: 1.4rem;
  margin-bottom: 0.8rem;
}

.terms-container li {
  margin-bottom: 0.3rem;
}

.seo-section,
.faq-section {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem 2rem;
}

.seo-section h2,
.faq-section h2 {
    margin-bottom: 0.75rem;
    color: #064971;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #064971;
}

.seo-section h3 {
    margin-top: 1.5rem;
    margin-bottom: 0.4rem;
    color: #086d6c;
    border-bottom: 1px solid rgba(8, 109, 108, 0.2);
}

.faq-item {
    margin-bottom: 1.3rem;
}

.faq-item h3 {
    margin-bottom: 0.3rem;
}

/* Mobile Responsiveness */

/* Tablet and smaller screens */
@media (max-width: 768px) {
  body {
    padding: 0 0.75rem;
    margin: 1rem auto;
  }
  
  h1 {
    font-size: 1.4rem;
  }
  
  h2 {
    font-size: 1.3rem;
    color: #064971;
  }
  
  /* Keep underlines for SEO and FAQ sections on tablets */
  .seo-section h2,
  .faq-section h2 {
    border-bottom: 2px solid #064971;
    padding-bottom: 0.5rem;
  }
  
  .header-logo-title {
    flex-direction: column;
    text-align: center;
    gap: 12px;
  }
  
  .site-logo {
    width: 80px;
    height: 80px;
  }
  
  .header-text h1 {
    font-size: 1.3rem;
    color: #064971;
  }
  
  .subheading {
    font-size: 0.9rem;
  }
  
  /* Make inputs full width on tablets */
  #maxRows,
  #maxCols,
  #cellSize,
  #paletteK,
  select {
    width: 100%;
    max-width: 100%;
  }
  
  /* Stack row items on tablets */
  .row {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .row > div {
    width: 100%;
    flex: 1 1 auto;
  }
  
  #imageContainer {
    width: 100%;
    max-width: 100%;
  }
  
  #pixelPreviewCanvas {
    width: 100%;
    max-width: 100%;
  }
}

/* Mobile phones */
@media (max-width: 480px) {
  body {
    padding: 0 0.5rem;
    margin: 0.75rem auto;
    font-size: 0.95rem;
  }
  
  h1 {
    font-size: 1.2rem;
    margin-bottom: 0.4rem;
    color: #064971;
  }
  
  h2 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
    color: #064971;
  }
  
  /* Keep underlines for SEO and FAQ sections on mobile */
  .seo-section h2,
  .faq-section h2 {
    border-bottom: 2px solid #064971;
    padding-bottom: 0.4rem;
  }
  
  h3 {
    font-size: 1rem;
    color: #086d6c;
    border-bottom: 1px solid rgba(8, 109, 108, 0.2);
    padding-bottom: 0.3rem;
  }
  
  .card {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
  }
  
  /* Header adjustments for mobile */
  .header-logo-title {
    gap: 10px;
  }
  
  .site-logo {
    width: 60px;
    height: 60px;
  }
  
  .header-text h1 {
    font-size: 1.1rem;
    line-height: 1.3;
    color: #064971;
  }
  
  .subheading {
    font-size: 0.85rem;
    line-height: 1.4;
  }
  
  /* Form inputs - full width on mobile */
  input[type="number"],
  input[type="file"],
  select {
    width: 100%;
    max-width: 100%;
    padding: 0.75rem 1rem;
    font-size: 16px; /* Prevents zoom on iOS */
    min-height: 44px; /* Better touch target */
  }
  
  #maxRows,
  #maxCols,
  #cellSize,
  #paletteK {
    width: 100%;
    max-width: 100%;
    min-width: 100%;
  }
  
  select {
    padding-right: 2.5rem;
  }
  
  /* Labels */
  label {
    font-size: 0.95rem;
    margin-top: 0.75rem;
  }
  
  /* Buttons - larger touch targets */
  button {
    width: 100%;
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    min-height: 44px; /* Minimum touch target size */
    margin-top: 1rem;
  }
  
  .drop-zone-button {
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    min-height: 44px;
  }
  
  /* Drop zone */
  .drop-zone {
    padding: 1.5rem 1rem;
  }
  
  .drop-zone-icon {
    width: 40px;
    height: 40px;
  }
  
  .drop-zone-text {
    font-size: 0.95rem;
  }
  
  .drop-zone-text-small {
    font-size: 0.85rem;
  }
  
  /* Small text */
  .small-text {
    font-size: 0.75rem;
  }
  
  /* Checkboxes - larger for better touch targets on mobile */
  input[type="checkbox"] {
    width: 22px;
    height: 22px;
    min-width: 22px;
    min-height: 22px;
  }
  
  /* Checkbox labels - better touch targets */
  @supports selector(:has(*)) {
    label:has(input[type="checkbox"]) {
      min-height: 44px;
      padding: 0.5rem 0;
    }
  }
  
  /* Row layout - always stack on mobile */
  .row {
    flex-direction: column;
    gap: 0.75rem;
  }
  
  .row > div {
    width: 100%;
    flex: 1 1 auto;
  }
  
  /* Image container */
  #imageContainer {
    width: 100%;
    max-width: 100%;
    min-height: 150px;
  }
  
  #sourceImage {
    max-width: 100%;
  }
  
  /* Canvas preview */
  #pixelPreviewCanvas {
    width: 100%;
    max-width: 100%;
  }
  
  /* Error messages */
  .error-message {
    font-size: 0.85rem;
    padding: 0.625rem;
  }
  
  /* Progress bar */
  #progressWrapper {
    font-size: 0.8rem;
    gap: 0.5rem;
  }
  
  .progress-bar-container {
    height: 12px;
  }
  
  /* Preview container */
  #preview-container {
    gap: 1rem;
  }
  
  /* Section descriptions */
  .section-desc {
    font-size: 0.9rem;
    line-height: 1.5;
  }
  
  .hint-text {
    font-size: 0.85rem;
  }
  
  /* SEO and FAQ sections */
  .seo-section,
  .faq-section {
    padding: 0 1rem 1.5rem;
  }
  
  .privacy-container,
  .terms-container {
    padding: 1rem;
    margin: 1rem auto;
  }
  
  .privacy-container h1,
  .terms-container h1 {
    font-size: 1.3rem;
    color: #064971;
  }
  
  .privacy-container h2,
  .terms-container h2 {
    font-size: 1.1rem;
    color: #064971;
  }
}