/* (Your provided CSS - unchanged except a few small helpers added below) */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background: #f8f9fa;
    color: #333;
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

header {
    text-align: center;
    background: #007bff;
    color: #fff;
    padding: 2rem 1rem;
}

header h1 {
    margin: 0;
    font-size: 2.5rem;
}

header p {
    margin: 0.5rem 0 0 0;
    font-size: 1.2rem;
    opacity: 0.9;
}

main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

section {
    background: #fff;
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.section-title {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
    color: #007bff;
}

/* Upload Area Styles */
.upload-area {
    display: block; /* label behaves like block */
    border: 2px dashed #007bff;
    border-radius: 12px;
    padding: 3rem 2rem;
    text-align: center;
    background: #f8f9ff;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    outline: none;
}

.upload-area:hover,
.upload-area:focus {
    border-color: #0056b3;
    background: #e3f2fd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.upload-area.dragover {
    border-color: #28a745;
    background: #e8f5e8;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* keep file input accessible but off-screen (NOT display:none) */
.file-input-offscreen {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

/* #fileInput styles are handled via .file-input-offscreen class */

/* Button Styles */
.btn-primary, .btn-secondary {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    margin: 0.25rem;
}

.btn-primary {
    background: #007bff;
    color: white;
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #545b62;
}

/* Preview Section */
.preview-section {
    display: none;
    margin-top: 2rem;
}

.preview-section.show {
    display: block;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin: 1rem 0;
}

.image-item {
    position: relative;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    background: #f8f9fa;
}

.image-item img {
    width: 100%;
    height: 150px;
    object-fit: cover;
}

.image-item .file-info {
    padding: 0.5rem;
    font-size: 0.8rem;
    color: #666;
    text-align: center;
}

/* Progress Section */
.progress-section {
    display: none;
    text-align: center;
}

.progress-section.show {
    display: block;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: #007bff;
    transition: width 0.3s ease;
    width: 0%;
}

/* Download Section */
.download-section {
    display: none;
    text-align: center;
}

.download-section.show {
    display: block;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

/* How to Use Section */
.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-top: 2rem;
}

.step {
    text-align: center;
}

.step-number {
    width: 60px;
    height: 60px;
    background: #007bff;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin: 0 auto 1rem auto;
}

footer {
    background: #f1f1f1;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 2rem;
    color: #666;
}

footer a {
    color: #007bff;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 { font-size: 2rem; }
    section { padding: 1.5rem; }
    .upload-area { padding: 2rem 1rem; }
    .image-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
}

.note-box {
  text-align: center;
  margin: 2rem auto;
  padding: 1rem 1.5rem;
  max-width: 800px;
  border: 2px solid #007bff;
  border-radius: 8px;
  background: #e9f5ff;
  font-size: 1rem;
  font-weight: 500;
  color: #0056b3;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.note-box p {
  margin: 0;
}

#faq {
  margin-top: 3rem;
}

#faq h2 {
  text-align: center;
  color: #007bff;
  margin-bottom: 2rem;
}

.faq-question {
  width: 100%;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  padding: 1rem;
  font-size: 1rem;
  font-weight: bold;
  text-align: left;
  cursor: pointer;
  transition: background 0.3s ease;
  color: #007bff;
}

.faq-question:hover {
  background: #e9f5ff;
}

.faq-answer {
  display: none;
  padding: 1rem;
  border-left: 3px solid #007bff;
  margin-top: 0.5rem;
  background: #fff;
  border-radius: 4px;
}

.faq-item.active .faq-answer {
  display: block;
}
.faq-item {
  margin-bottom: 1rem;
}

/* Related Tools Section */
.related-tools {
  margin-top: 3rem;
  padding: 1.5rem;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.related-tools h2 {
  margin-bottom: 1rem;
  font-size: 1.3rem;
  color: #007bff;
}

.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.tool-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s, box-shadow 0.2s;
}

.tool-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.tool-card .icon {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

/* Small helpers for generated content */
.image-item .actions {
  display:flex;
  gap:6px;
  justify-content:center;
  padding:0.5rem;
}

.download-link {
  display:inline-block;
  padding:0.4rem 0.6rem;
  border-radius:6px;
  background:#007bff;
  color:#fff;
  text-decoration:none;
  font-size:0.9rem;
  margin:4px;
}

.download-link:hover { background:#0056b3; }

#zipOverlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.5rem;
  text-align: center;
  flex-direction: column;
}
#zipOverlay.show {
  display: flex;
}
.loader {
  border: 6px solid #f3f3f3;
  border-top: 6px solid #007bff;
  border-radius: 50%;
  width: 60px;
  height: 60px;
  animation: spin 1s linear infinite;
  margin-bottom: 1rem;
}
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}
/* === Fix for cropped action buttons in image preview cards === */

.image-item {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  border: 2px solid #dee2e6;
  border-radius: 10px;
  padding: 10px;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.2s ease;
}

.image-item:hover {
  transform: translateY(-3px);
}

.image-item img {
  width: auto;
  max-width: 100%;
  max-height: 160px;
  border-radius: 6px;
  object-fit: contain;
  margin: 8px 0;
}

.image-item .file-info {
  font-size: 0.85rem;
  color: #555;
  margin-bottom: 8px;
}

.image-item .actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 8px;
}

.image-item button {
  flex: 1 1 30%;
  min-width: 90px;
  white-space: nowrap;
}

/* Ensure grid has space for controls */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.2rem;
}
