/* ==========================================================================
   Bulk Image to WebP Converter - Stylesheet
   White/light SaaS-style interface, blue primary accent, fully responsive.
   ========================================================================== */

:root {
  --bg: #f7f9fc;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #5b6b84;
  --text-faint: #93a3b8;
  --border: #e3e9f1;
  --border-strong: #cdd7e4;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: #eaf1ff;
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  --success: #16a34a;
  --success-soft: #eafaf0;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #b45309;
  --warning-soft: #fff7e8;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 40px rgba(30, 58, 138, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --max-width: 1120px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
}

button {
  font-family: inherit;
}

a {
  color: var(--primary);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  text-decoration: none;
}

.skip-link:focus {
  left: 0;
  color: #fff;
}

/* ----------------------------------------------------------------
   Layout helpers
   ---------------------------------------------------------------- */
.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* ----------------------------------------------------------------
   Buttons & controls
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.18s ease, border-color 0.18s ease,
    color 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}

.btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, #2f74f7 0%, var(--primary-hover) 100%);
  box-shadow: 0 8px 20px rgba(37, 99, 235, 0.35);
}

.btn-outline {
  background: var(--surface);
  color: var(--primary);
  border-color: var(--border-strong);
}

.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  background: var(--primary-soft);
}

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

.btn-ghost:hover:not(:disabled) {
  color: var(--danger);
  background: var(--danger-soft);
}

.btn-convert {
  display: flex;
  width: min(100%, 480px);
  margin: 22px auto 0;
  padding: 15px 24px;
  font-size: 16px;
  border-radius: var(--radius-md);
}

.btn-zip {
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
}

.icon-btn:hover:not(:disabled) {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-soft);
}

.icon-btn:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ----------------------------------------------------------------
   Notices
   ---------------------------------------------------------------- */
.notice {
  max-width: 640px;
  margin: 14px auto 0;
  padding: 12px 16px;
  font-size: 14px;
  border-radius: var(--radius-sm);
}

.notice-error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid #f8c9c9;
}

/* ----------------------------------------------------------------
   Header
   ---------------------------------------------------------------- */
.site-header {
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  color: #fff;
  background: var(--primary-gradient);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.brand-name {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.header-badges li {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  white-space: nowrap;
}

/* ----------------------------------------------------------------
   Hero
   ---------------------------------------------------------------- */
.hero {
  text-align: center;
  padding: 52px 0 8px;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4.5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.15;
}

.hero-desc {
  max-width: 640px;
  margin: 0 auto;
  font-size: clamp(1rem, 1.6vw, 1.13rem);
  color: var(--text-muted);
}

.trust-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
}

.trust-list li {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}

.trust-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  color: #fff;
  background: var(--success);
  border-radius: 50%;
}

/* ----------------------------------------------------------------
   Privacy banner
   ---------------------------------------------------------------- */
.privacy-banner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 26px auto 0;
  max-width: 640px;
  padding: 16px 18px;
  background: var(--primary-soft);
  border: 1px solid #d4e2ff;
  border-radius: var(--radius-md);
}

.privacy-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  color: var(--primary);
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.privacy-title {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-hover);
}

.privacy-text {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------
   Dropzone
   ---------------------------------------------------------------- */
.upload-section {
  margin-top: 34px;
}

.dropzone {
  max-width: 640px;
  margin: 0 auto;
  padding: 46px 24px;
  text-align: center;
  background: var(--surface);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone:focus-visible {
  outline: none;
}

.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: var(--shadow-lg);
  transform: scale(1.015);
}

.dz-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 76px;
  height: 76px;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 22px;
  margin-bottom: 16px;
  transition: transform 0.2s ease;
}

.dropzone.dragover .dz-icon {
  transform: translateY(-4px);
}

.dz-title {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.dz-or {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-faint);
}

.dz-hint {
  margin: 16px 0 0;
  font-size: 13px;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------
   Sections & headings
   ---------------------------------------------------------------- */
.gallery-section {
  margin-top: 44px;
}

.settings-section {
  margin-top: 40px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.section-head h2,
.settings-panel h2,
.progress-section h2,
.results-bar h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.section-count {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.section-actions {
  display: flex;
  gap: 10px;
}

/* ----------------------------------------------------------------
   Image grid & cards
   ---------------------------------------------------------------- */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
}

.image-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
}

.image-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.image-card.is-completed {
  border-color: #bfe3cc;
}

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(-45deg, #eef2f7 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef2f7 75%),
    linear-gradient(-45deg, transparent 75%, #eef2f7 75%);
  background-size: 18px 18px;
  background-position: 0 0, 0 9px, 9px -9px, -9px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
}

.card-thumb {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  filter: drop-shadow(0 1px 2px rgba(15, 23, 42, 0.12));
}

.card-thumb.is-empty {
  width: 42px;
  height: 42px;
  opacity: 0.35;
  filter: none;
}

.remove-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  box-shadow: var(--shadow-sm);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--border);
}

.card-name {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-word;
}

.card-details {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}

.card-status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 7px;
  margin: 2px 0 0;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 650;
  border-radius: 999px;
  max-width: 100%;
  text-align: left;
}

.status-text {
  min-width: 0;
}

.card-error {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--danger);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-ready {
  color: var(--text-muted);
  background: #eef2f7;
}

.status-ready .status-dot {
  background: var(--text-faint);
}

.status-waiting {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-waiting .status-dot {
  background: #eab308;
}

.status-converting {
  color: var(--primary);
  background: var(--primary-soft);
}

.status-converting .status-dot {
  background: var(--primary);
  animation: pulse 1s ease-in-out infinite;
}

.status-completed {
  color: var(--success);
  background: var(--success-soft);
}

.status-completed .status-dot {
  background: var(--success);
}

.status-failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-failed .status-dot {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ---- results inside a card ---- */
.card-results {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-strong);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.compare-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13px;
}

.compare-label {
  color: var(--text-muted);
}

.compare-label em {
  font-style: normal;
  font-size: 11.5px;
  color: var(--text-faint);
}

.compare-value {
  font-weight: 650;
  text-align: right;
  white-space: nowrap;
}

.compare-value.positive {
  color: var(--success);
}

.compare-value.negative {
  color: var(--danger);
}

.download-one {
  margin-top: 10px;
  width: 100%;
  padding: 9px 14px;
  font-size: 13.5px;
}

/* ----------------------------------------------------------------
   Settings panel
   ---------------------------------------------------------------- */
.settings-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px;
}

.settings-panel h2 {
  margin-bottom: 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 20px 0 12px;
}

.setting-label {
  min-width: 0;
}

.setting-title {
  display: block;
  font-size: 15px;
  font-weight: 650;
}

.setting-hint {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-muted);
}

.setting-value {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 4px 10px;
}

.setting-divider {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---- switch toggle ---- */
.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  width: 48px;
  height: 27px;
  border-radius: 999px;
  background: var(--border-strong);
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.25);
  transition: transform 0.2s ease;
}

.switch:checked {
  background: var(--primary);
}

.switch:checked::after {
  transform: translateX(21px);
}

.switch:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

/* ---- quality slider ---- */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  margin: 4px 0 0;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.12);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--primary);
  box-shadow: 0 1px 4px rgba(37, 99, 235, 0.35);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: transparent;
}

input[type="range"]::-moz-range-progress {
  height: 8px;
  border-radius: 999px;
  background: var(--primary);
}

input[type="range"]:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
}

/* ---- resize controls ---- */
.resize-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin-top: 4px;
}

.resize-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.resize-field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.resize-field input[type="number"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.resize-field input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.ratio-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  align-self: start;
  padding-top: 8px;
  cursor: pointer;
}

.ratio-field input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

.ratio-hint {
  grid-column: 1 / -1;
}

/* ----------------------------------------------------------------
   Progress
   ---------------------------------------------------------------- */
.progress-section {
  margin-top: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 22px 24px;
}

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

.progress-header h2 {
  font-size: 18px;
}

.progress-pct {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--primary-gradient);
  transition: width 0.25s ease;
}

.progress-meta {
  margin: 10px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* ----------------------------------------------------------------
   Results bar
   ---------------------------------------------------------------- */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  margin-top: 26px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--success);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
}

.results-bar h2 {
  font-size: 20px;
}

.results-message {
  margin: 4px 0 0;
  font-size: 14px;
  color: var(--text-muted);
}

.zip-status {
  flex-basis: 100%;
  margin: 0;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
}

/* ----------------------------------------------------------------
   Footer
   ---------------------------------------------------------------- */
.site-footer {
  margin-top: 60px;
  padding: 26px 0 34px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.footer-brand {
  margin: 0 0 3px;
  font-size: 15px;
  font-weight: 700;
}

.footer-text {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

.noscript {
  max-width: var(--max-width);
  margin: 20px auto;
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  text-align: center;
  font-weight: 600;
}

/* ----------------------------------------------------------------
   Responsive
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
  .hero {
    padding-top: 36px;
  }

  .section-head {
    flex-direction: column;
    align-items: flex-start;
  }

  .section-head h2 {
    font-size: 20px;
  }

  .results-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .btn-zip {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .container {
    padding: 0 14px;
  }

  .header-inner {
    padding: 10px 14px;
    flex-direction: column;
    gap: 8px;
  }

  .header-badges li {
    font-size: 12px;
    padding: 6px 10px;
  }

  .brand-name {
    font-size: 17px;
  }

  .hero {
    padding-top: 30px;
  }

  .dropzone {
    padding: 34px 16px;
  }

  .dz-icon {
    width: 62px;
    height: 62px;
    border-radius: 18px;
  }

  .dz-title {
    font-size: 17px;
  }

  .image-grid {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    padding: 18px;
  }

  .resize-controls {
    grid-template-columns: 1fr;
  }

  .ratio-hint {
    grid-column: auto;
  }

  .section-actions {
    width: 100%;
  }

  .section-actions .btn {
    flex: 1;
  }

  .progress-section,
  .results-bar {
    padding: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}