/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --black: #0a0a0a;
  --white: #ffffff;
  --gray-100: #f5f5f5;
  --gray-200: #e8e8e8;
  --gray-400: #999;
  --gray-600: #555;
  --gray-800: #222;
  --accent: #0a0a0a;
  --success: #1a7a3c;
  --error: #c0392b;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.13);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--gray-100);
  color: var(--black);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
header {
  background: var(--black);
  color: var(--white);
  padding: 16px 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.header-inner {
  max-width: 860px;
  margin: 0 auto;
}
.logo-area {
  display: flex;
  align-items: center;
  gap: 14px;
}
.logo-icon {
  width: 42px;
  height: 42px;
  background: var(--white);
  color: var(--black);
  font-weight: 900;
  font-size: 22px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -1px;
}
h1 {
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1.2;
}
.subtitle {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.55);
  margin-top: 2px;
}

/* ── Main ────────────────────────────────────────────────────────────────────── */
main {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 32px auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Card ────────────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* ── Drop zone ───────────────────────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--gray-200);
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  outline: none;
}
.drop-zone:hover,
.drop-zone:focus,
.drop-zone.drag-over {
  border-color: var(--black);
  background: var(--gray-100);
}
.drop-icon {
  color: var(--gray-400);
  margin-bottom: 12px;
}
.drop-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.drop-subtitle {
  font-size: 0.85rem;
  color: var(--gray-600);
  margin-bottom: 12px;
}
.drop-info {
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 12px;
}

/* ── Options ─────────────────────────────────────────────────────────────────── */
.options-row {
  display: flex;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.option-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.option-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.select, .input-number {
  height: 40px;
  padding: 0 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: 6px;
  font-size: 0.95rem;
  font-family: var(--font);
  background: var(--white);
  color: var(--black);
  outline: none;
  transition: border-color 0.2s;
  min-width: 140px;
}
.select:focus, .input-number:focus {
  border-color: var(--black);
}
.input-number { min-width: 100px; }

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 22px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  border: none;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--black);
  color: var(--white);
}
.btn-primary:hover { background: var(--gray-800); box-shadow: var(--shadow); }
.btn-primary:disabled { background: var(--gray-400); cursor: not-allowed; }
.btn-outline {
  background: transparent;
  color: var(--black);
  border: 1.5px solid var(--gray-200);
}
.btn-outline:hover { border-color: var(--black); }
.btn-link {
  background: none;
  border: none;
  color: var(--gray-600);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  font-family: var(--font);
  text-decoration: underline;
}
.btn-link:hover { color: var(--black); }

/* ── Section header ──────────────────────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.section-header h2 {
  font-size: 1rem;
  font-weight: 700;
}
.results-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── File list ───────────────────────────────────────────────────────────────── */
.file-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
  margin-bottom: 16px;
}
.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--gray-100);
  border-radius: 6px;
  font-size: 0.88rem;
}
.file-item-thumb {
  width: 40px;
  height: 40px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  background: var(--gray-200);
}
.file-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.file-item-size {
  color: var(--gray-600);
  font-size: 0.8rem;
  white-space: nowrap;
}
.file-item-remove {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.15s;
}
.file-item-remove:hover { color: var(--error); }

.compress-row {
  display: flex;
  justify-content: flex-end;
}

/* ── Progress ─────────────────────────────────────────────────────────────────── */
#progress-section h2 { margin-bottom: 16px; font-size: 1rem; }
.progress-bar-wrap {
  background: var(--gray-200);
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar {
  height: 100%;
  background: var(--black);
  border-radius: 999px;
  transition: width 0.3s ease;
  width: 0%;
}
.progress-label {
  font-size: 0.85rem;
  color: var(--gray-600);
}

/* ── Results ─────────────────────────────────────────────────────────────────── */
.results-stats {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--gray-100);
  border-radius: 8px;
}
.stat-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  font-weight: 600;
}
.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
}
.stat-value.success { color: var(--success); }

.results-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 520px;
  overflow-y: auto;
}
.result-item {
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  overflow: hidden;
}
.result-item.error-item {
  border-color: #f5c6c2;
  background: #fff8f8;
}
.result-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--gray-100);
}
.result-filename {
  flex: 1;
  font-weight: 600;
  font-size: 0.88rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.badge {
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-success { background: #d4edda; color: var(--success); }
.badge-error { background: #f8d7da; color: var(--error); }

.result-body {
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.preview-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preview-label {
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-600);
  font-weight: 600;
}
.preview-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 4px;
  background: var(--gray-200);
}
.preview-size {
  font-size: 0.82rem;
  font-weight: 600;
}
.preview-size.saved { color: var(--success); }

.result-download {
  padding: 0 14px 12px;
  display: flex;
  justify-content: flex-end;
}

.error-msg {
  padding: 12px 14px;
  font-size: 0.85rem;
  color: var(--error);
}

/* ── Footer ─────────────────────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px;
  font-size: 0.78rem;
  color: var(--gray-400);
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  main { margin: 16px auto; }
  .card { padding: 16px; }
  .result-body { grid-template-columns: 1fr; }
  .results-actions { flex-direction: column; }
  .options-row { flex-direction: column; }
}
