:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #16202e;
  --muted: #68758a;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #eaf1ff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1420;
    --surface: #151e2d;
    --border: #253148;
    --text: #e8edf5;
    --muted: #94a3b8;
    --accent: #5b8cff;
    --accent-dark: #3f74f5;
    --accent-soft: #1b2942;
    --success: #4ade80;
    --success-soft: #16301f;
    --danger: #f87171;
    --danger-soft: #3a1b1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* {
  box-sizing: border-box;
}

/* Author `display` rules beat the UA rule for [hidden], so restate it. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ---- header ---- */

.site-header {
  padding: 48px 0 28px;
  text-align: center;
}

.logo {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo span {
  color: var(--accent);
}

.tagline {
  margin: 8px 0 0;
  color: var(--muted);
}

/* ---- dropzone ---- */

.dropzone {
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 44px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

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

.dropzone.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.005);
}

.dz-icon {
  width: 40px;
  height: 40px;
  color: var(--accent);
}

.dz-title {
  margin: 10px 0 2px;
  font-size: 18px;
  font-weight: 600;
}

.dz-sub {
  margin: 0;
  color: var(--muted);
}

.dz-sub .link {
  color: var(--accent);
  text-decoration: underline;
}

.dz-meta {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---- options ---- */

.options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-top: 20px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.option {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.option label {
  font-size: 13px;
  font-weight: 600;
}

.option small {
  font-size: 12px;
  color: var(--muted);
}

.option output {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.option select,
.option input[type="number"] {
  width: 100%;
  padding: 7px 9px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.option input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.option-check {
  justify-content: center;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ---- summary ---- */

.summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-top: 20px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.summary-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.stat-saved .stat-value {
  color: var(--success);
}

.summary-actions {
  display: flex;
  gap: 8px;
}

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 16px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-dark);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

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

.btn-small {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-download {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

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

/* ---- errors ---- */

.global-error {
  margin: 16px 0 0;
  padding: 10px 14px;
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 8px;
  color: var(--danger);
  font-size: 14px;
}

/* ---- file list ---- */

.file-list {
  list-style: none;
  margin: 16px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.file-row {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 72px auto;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.thumb {
  width: 44px;
  height: 44px;
  border-radius: 6px;
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.file-main {
  min-width: 0;
}

.file-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.file-name {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-badge {
  flex-shrink: 0;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.file-row[data-state="done"] .file-badge {
  background: var(--success-soft);
  color: var(--success);
}

.file-row[data-state="error"] .file-badge {
  background: var(--danger-soft);
  color: var(--danger);
}

.bar {
  height: 4px;
  margin: 7px 0 5px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

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

.file-row[data-state="working"] .bar-fill {
  width: 65%;
  animation: pulse 1.1s ease-in-out infinite;
}

.file-row[data-state="done"] .bar-fill {
  background: var(--success);
}

.file-row[data-state="error"] .bar-fill {
  width: 100%;
  background: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.45;
  }
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .file-row[data-state="working"] .bar-fill {
    animation: none;
    opacity: 0.7;
  }
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.file-row[data-state="error"] .meta-note {
  color: var(--danger);
}

.file-saved {
  text-align: right;
  font-size: 15px;
  font-weight: 700;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.file-actions {
  min-width: 0;
}

@media (max-width: 600px) {
  .site-header {
    padding: 28px 0 20px;
  }

  .file-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 10px 12px;
  }

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

  .file-saved {
    grid-column: 3;
  }

  .file-actions {
    grid-column: 2 / -1;
  }

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

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

/* ---- footer ---- */

.site-footer {
  margin: 36px 0 48px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.site-footer p {
  max-width: 620px;
  margin: 0 auto;
}
