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

:root {
  --clr-bg: #f5f7fa;
  --clr-surface: #ffffff;
  --clr-primary: #4f46e5;
  --clr-primary-hover: #4338ca;
  --clr-primary-light: #eef2ff;
  --clr-danger: #ef4444;
  --clr-danger-hover: #dc2626;
  --clr-success: #16a34a;
  --clr-text: #1e293b;
  --clr-text-muted: #64748b;
  --clr-border: #e2e8f0;
  --clr-drop-border: #a5b4fc;
  --clr-drop-bg: #eef2ff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08);
}

html {
  font-size: 16px;
}

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

.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

/* --- Header --- */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--clr-text-muted);
  margin-top: 0.25rem;
  font-size: 0.95rem;
}

/* --- Drop Zone --- */
.drop-zone {
  border: 2px dashed var(--clr-border);
  border-radius: var(--radius);
  background: var(--clr-surface);
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
  position: relative;
}

.drop-zone:hover,
.drop-zone:focus-visible {
  border-color: var(--clr-drop-border);
  background: var(--clr-drop-bg);
  outline: none;
}

.drop-zone.drag-over {
  border-color: var(--clr-primary);
  background: var(--clr-drop-bg);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.15);
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--clr-primary);
  margin-bottom: 1rem;
}

.drop-text {
  font-size: 1.1rem;
  font-weight: 600;
}

.drop-hint {
  color: var(--clr-text-muted);
  font-size: 0.875rem;
  margin-top: 0.25rem;
}

.drop-formats {
  display: inline-block;
  margin-top: 0.75rem;
  font-size: 0.75rem;
  color: var(--clr-text-muted);
  background: var(--clr-bg);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
}

/* --- Settings --- */
.settings {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.setting-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
}

.setting-group label {
  font-weight: 600;
  white-space: nowrap;
}

.setting-group input[type="number"] {
  width: 80px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  font-size: 0.875rem;
  text-align: center;
}

.setting-group input[type="range"] {
  width: 100px;
  accent-color: var(--clr-primary);
}

.setting-group select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: var(--clr-surface);
}

.unit {
  color: var(--clr-text-muted);
  font-size: 0.8rem;
  min-width: 2ch;
}

/* --- Progress --- */
.progress-section {
  margin-top: 1.5rem;
}

.progress-bar-track {
  height: 8px;
  background: var(--clr-border);
  border-radius: 999px;
  overflow: hidden;
}

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

.progress-text {
  text-align: center;
  font-size: 0.8rem;
  color: var(--clr-text-muted);
  margin-top: 0.5rem;
}

/* --- Actions --- */
.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.6rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
}

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

.btn-primary {
  background: var(--clr-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--clr-primary-hover);
}

.btn-secondary {
  background: var(--clr-border);
  color: var(--clr-text);
}

.btn-secondary:hover {
  background: #cbd5e1;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-danger {
  background: none;
  color: var(--clr-danger);
  border: 1px solid var(--clr-danger);
}

.btn-danger:hover {
  background: var(--clr-danger);
  color: #fff;
}

.btn-download {
  background: none;
  color: var(--clr-primary);
  border: 1px solid var(--clr-primary);
}

.btn-download:hover {
  background: var(--clr-primary);
  color: #fff;
}

/* --- Results Table --- */
.results {
  margin-top: 1.25rem;
  background: var(--clr-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.results table {
  width: 100%;
  border-collapse: collapse;
}

.results thead {
  background: var(--clr-bg);
}

.results th,
.results td {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--clr-border);
}

.results th {
  font-weight: 600;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
}

.th-thumb {
  width: 56px;
}

.th-size {
  width: 90px;
  text-align: right;
}

.th-actions {
  width: 130px;
  text-align: right;
}

.results td.col-size {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.results td.col-actions {
  text-align: right;
}

.results td.col-actions .btn + .btn {
  margin-left: 0.35rem;
}

.thumb {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 6px;
  background: var(--clr-bg);
}

.saved-positive {
  color: var(--clr-success);
  font-weight: 600;
}

.saved-negative {
  color: var(--clr-danger);
  font-weight: 600;
}

.filename {
  word-break: break-all;
}

/* --- Summary --- */
.summary {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--clr-text-muted);
  text-align: center;
  border-top: 1px solid var(--clr-border);
}

/* --- Utility --- */
.hidden {
  display: none !important;
}

/* --- Responsive --- */
@media (max-width: 640px) {
  .container {
    padding: 1.25rem 0.75rem 3rem;
  }

  header h1 {
    font-size: 1.35rem;
  }

  .drop-zone {
    padding: 2rem 1rem;
  }

  .drop-icon {
    width: 36px;
    height: 36px;
  }

  .settings {
    flex-direction: column;
  }

  .results th,
  .results td {
    padding: 0.5rem 0.6rem;
    font-size: 0.78rem;
  }

  .th-thumb {
    width: 40px;
  }

  .thumb {
    width: 36px;
    height: 36px;
  }

  /* Hide "Original" column on very small screens to save space */
  .results th:nth-child(3),
  .results td:nth-child(3) {
    display: none;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
    text-align: center;
  }
}
