:root {
  --bg: #f3f5f9;
  --card: #ffffff;
  --border: #e3e8f0;
  --text: #1c2333;
  --muted: #6b7487;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --amber: #d97706;
  --amber-soft: #fffbeb;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", sans-serif;
  background:
    radial-gradient(1200px 500px at 80% -10%, #e0e7ff 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 32px 16px 40px;
}

.header {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 860px;
  width: 100%;
  margin-bottom: 24px;
}

.logo {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 30px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}

.header h1 {
  margin: 0;
  font-size: 24px;
  letter-spacing: 0.5px;
}

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

.main {
  width: 100%;
  max-width: 860px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Dropzone ---------- */

.dropzone {
  background: var(--card);
  border: 2px dashed #c7d0e0;
  border-radius: var(--radius);
  padding: 48px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.1s ease;
  box-shadow: var(--shadow);
  outline: none;
}

.dropzone:hover,
.dropzone:focus-visible {
  border-color: var(--accent);
  background: #fafbff;
}

.dropzone.drag {
  border-color: var(--accent);
  border-style: solid;
  background: var(--accent-soft);
  transform: scale(1.01);
}

.dz-icon {
  font-size: 40px;
  line-height: 1;
  margin-bottom: 12px;
  color: var(--accent);
}

.dz-main {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

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

/* ---------- Options ---------- */

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

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.chip:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.chip input {
  accent-color: var(--accent);
  margin: 0;
}

/* ---------- File list ---------- */

.filelist {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.list-header h2 {
  margin: 0;
  font-size: 15px;
}

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

.btn {
  border: none;
  border-radius: 9px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: filter 0.15s ease, background 0.15s ease;
}

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

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

.btn.primary:hover:not(:disabled) {
  filter: brightness(1.08);
}

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

.btn.ghost:hover {
  background: #f6f8fb;
  color: var(--text);
}

.files {
  list-style: none;
  margin: 0;
  padding: 0;
}

.file-row {
  border-bottom: 1px solid var(--border);
}

.file-row:last-child {
  border-bottom: none;
}

.file-row-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
}

.file-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

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

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

.file-meta {
  margin-top: 3px;
  font-size: 12px;
  color: var(--muted);
}

.file-status {
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.file-status.working { color: var(--amber); }
.file-status.done { color: var(--green); }
.file-status.error { color: var(--red); }

.spinner {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.file-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.icon-btn:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

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

.dl-btn {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}

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

/* Preview */
.preview {
  padding: 0 18px 14px 72px;
}

.preview:empty {
  display: none;
}

.preview summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  user-select: none;
}

.preview pre {
  margin: 10px 0 0;
  padding: 12px 14px;
  background: #f7f8fb;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: "SF Mono", Menlo, Consolas, "PingFang TC", monospace;
  max-height: 260px;
  overflow: auto;
}

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

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

.footer {
  margin-top: 28px;
  max-width: 860px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.8;
}

@media (max-width: 560px) {
  .file-row-inner {
    flex-wrap: wrap;
  }
  .file-actions {
    width: 100%;
    justify-content: flex-end;
  }
  .preview {
    padding-left: 18px;
  }
}
