* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --radius: 16px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.05);
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 20px 16px;
  min-height: 100vh;
  line-height: 1.5;
}

.page {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.card-header h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}

.card-header h2 span {
  font-weight: 400;
  font-size: 16px;
  color: var(--muted);
}

/* ---------- Header ---------- */
.header-card {
  text-align: center;
  padding: 32px 24px;
}

.header-content h1 {
  font-size: 32px;
  font-weight: 800;
  margin: 0 0 8px;
  letter-spacing: -0.03em;
}

.header-content p {
  font-size: 16px;
  color: var(--muted);
  margin: 0;
}

/* ---------- Upload / Dropzone ---------- */
.upload-card {
  text-align: center;
  padding: 32px 24px;
}

.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 48px 24px;
  cursor: pointer;
  transition: all 0.2s ease;
  background: #fafafa;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-2px);
}

.dropzone-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
  opacity: 0.6;
}

.dropzone h3 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--text);
}

.dropzone-hint {
  font-size: 14px;
  color: var(--muted);
  margin: 0;
}

.dropzone input {
  display: none;
}

/* ---------- Controls ---------- */
.controls-card {
  display: none;
}

.controls-card.visible {
  display: block;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.control-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quality-label {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.quality-label span {
  font-weight: 800;
  color: var(--primary);
}

input[type="range"] {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--border);
  outline: none;
  appearance: none;
  cursor: pointer;
  margin-left: 8px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  background: var(--primary);
  border-radius: 50%;
  cursor: pointer;
  border: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 10px;
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn:active {
  transform: scale(0.97);
}

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

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  box-shadow: 0 4px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:not(:disabled):hover {
  background: var(--primary-hover);
  box-shadow: 0 6px 8px rgba(37, 99, 235, 0.3);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: #f9fafb;
  border-color: var(--muted);
}

.btn.small {
  padding: 8px 14px;
  font-size: 13px;
}

.skip-notice {
  font-size: 13px;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fde68a;
  border-radius: 8px;
  padding: 10px 14px;
  margin: 0;
}

/* ---------- Gallery ---------- */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

/* ---------- Image Card ---------- */
.image-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.image-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.image-card img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  background: #f3f4f6;
  display: block;
}

.image-card .card-info {
  padding: 12px 14px;
}

.image-card .name {
  font-weight: 600;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.image-card .size {
  font-size: 12px;
  color: var(--muted);
}

.image-card .remove-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.image-card:hover .remove-btn {
  opacity: 1;
}

.image-card .remove-btn:hover {
  background: rgba(0, 0, 0, 0.75);
}

.download-link {
  margin-top: 10px;
  padding: 8px 12px;
  background: #eff6ff;
  color: var(--primary);
  border-radius: 8px;
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
  border: 1px solid #bfdbfe;
  width: 100%;
}

.download-link:hover {
  background: #dbeafe;
}

/* ---------- Actions ---------- */
.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body {
    padding: 16px 12px;
  }

  .page {
    gap: 14px;
  }

  .card {
    padding: 20px;
    border-radius: 14px;
  }

  .header-card {
    padding: 28px 20px;
  }

  .header-content h1 {
    font-size: 26px;
  }

  .upload-card {
    padding: 24px 16px;
  }

  .dropzone {
    padding: 36px 16px;
  }

  .controls-card {
    padding: 20px;
  }

  .control-group {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .quality-label {
    margin-left: 0;
    text-align: left;
  }

  input[type="range"] {
    margin-left: 0;
    width: 100%;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
  }

  .image-card img {
    height: 120px;
  }

  .header-actions {
    flex-direction: column;
  }

  .header-actions .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 16px;
  }

  .header-content h1 {
    font-size: 24px;
  }

  .dropzone {
    padding: 30px 16px;
  }

  .dropzone-icon {
    font-size: 40px;
  }

  .dropzone h3 {
    font-size: 18px;
  }

  .gallery {
    grid-template-columns: repeat(2, 1fr);
  }

  .image-card img {
    height: 110px;
  }
}