:root {
  --ink: #1a2233;
  --muted: #64748b;
  --bg: #f4f6fb;
  --card: #ffffff;
  --accent: #2454ff;
  --accent-dark: #163bd6;
  --border: #e3e7f1;
  --ok: #17a568;
  --warn: #d97706;
  --err: #dc2626;
  --shadow-sm: 0 1px 2px rgba(17, 24, 39, .04), 0 1px 3px rgba(17, 24, 39, .06);
  --shadow-md: 0 4px 10px rgba(17, 24, 39, .05), 0 2px 4px rgba(17, 24, 39, .04);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink);
  background: linear-gradient(180deg, #eef1fb 0%, var(--bg) 220px);
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px; background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; box-shadow: var(--shadow-sm);
}
.brand { display: flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; transition: opacity .15s; }
.brand:hover { opacity: .8; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 11px; background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: 14px;
  box-shadow: 0 3px 8px rgba(36, 84, 255, .3);
}
.brand h1 { font-size: 18px; margin: 0; letter-spacing: -.01em; }
.brand p { font-size: 12px; color: var(--muted); margin: 2px 0 0; }
.ghost-link { color: var(--accent); text-decoration: none; font-size: 14px; font-weight: 600; transition: color .15s; }
.ghost-link:hover { color: var(--accent-dark); }

.topbar-right { display: flex; align-items: center; gap: 18px; }
.user-chip { font-size: 13px; color: var(--muted); }
.user-chip strong { color: var(--ink); }

main { max-width: 880px; margin: 0 auto; padding: 32px 20px 80px; display: flex; flex-direction: column; gap: 24px; }

.panel {
  background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 26px;
  box-shadow: var(--shadow-md);
}
.panel h2 { font-size: 16px; margin: 0 0 6px; letter-spacing: -.01em; }
.hint { color: var(--muted); font-size: 13px; margin: 0 0 16px; }

.results-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.results-heading h2 { margin: 0; }

.btn-ghost {
  background: transparent; border: 1px solid var(--border); color: var(--ink);
  font: inherit; font-size: 13px; font-weight: 600; padding: 7px 14px; border-radius: 8px;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.btn-ghost:hover { background: var(--bg); border-color: #c7d0e6; }

.dropzone {
  border: 2px dashed var(--border); border-radius: 12px; padding: 40px 20px; text-align: center;
  cursor: pointer; color: var(--muted); transition: border-color .15s, background .15s;
}
.dropzone::before {
  content: "⬆"; display: block; width: 44px; height: 44px; margin: 0 auto 12px; line-height: 44px;
  border-radius: 999px; background: var(--bg); color: var(--accent); font-size: 18px;
}
.dropzone:hover { border-color: #c7d0e6; }
.dropzone.drag-active { border-color: var(--accent); background: #eef2ff; color: var(--ink); }
.dropzone strong { color: var(--ink); }

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.file-row {
  display: flex; align-items: center; gap: 10px; font-size: 13px; background: var(--bg);
  border-radius: 8px; padding: 8px 12px;
}
.file-row span:first-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { color: var(--muted); }
.remove-file { border: none; background: none; color: var(--err); cursor: pointer; font-size: 14px; }

.keep-toggle {
  display: block; margin-top: 18px; font-size: 13px; color: var(--ink); line-height: 1.5; cursor: pointer;
}
.keep-toggle input { margin-right: 8px; }
.hint-inline { display: block; color: var(--muted); font-size: 12px; margin-left: 24px; }

.btn-primary {
  margin-top: 18px; background: var(--accent); color: #fff; border: none; border-radius: 10px;
  padding: 12px 22px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 2px 6px rgba(36, 84, 255, .25); transition: background .15s, transform .1s, box-shadow .15s;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); box-shadow: 0 4px 10px rgba(36, 84, 255, .32); }
.btn-primary:active:not(:disabled) { transform: translateY(1px); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-primary:focus-visible { outline: 2px solid var(--accent-dark); outline-offset: 2px; }

.jobs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.jobs-table th { text-align: left; color: var(--muted); font-weight: 600; padding: 8px 6px; border-bottom: 1px solid var(--border); }
.jobs-table td { padding: 10px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.jobs-table a { color: var(--accent); text-decoration: none; font-weight: 600; }
.empty-row { color: var(--muted); text-align: center; padding: 20px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-queued { background: #eef2ff; color: #4338ca; }
.badge-processing { background: #fffbeb; color: var(--warn); }
.badge-done { background: #ecfdf5; color: var(--ok); }
.badge-failed { background: #fef2f2; color: var(--err); }

/* ---- progress bars ----------------------------------------------------- */
.progress-track {
  width: 100%; min-width: 90px; height: 8px; border-radius: 999px; background: var(--bg);
  overflow: hidden; border: 1px solid var(--border);
}
.progress-fill {
  height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease;
}
.progress-fill[data-status="queued"] { background: #a5b4fc; }
.progress-fill[data-status="processing"] {
  background: repeating-linear-gradient(45deg, var(--warn), var(--warn) 10px, #fcd34d 10px, #fcd34d 20px);
  background-size: 28px 28px; animation: progress-stripes 1s linear infinite;
}
.progress-fill[data-status="done"] { background: var(--ok); }
.progress-fill[data-status="failed"] { background: var(--err); }
@keyframes progress-stripes { from { background-position: 0 0; } to { background-position: 28px 0; } }

.batch-progress { margin-bottom: 18px; }
.batch-progress-label { margin: 8px 0 0; font-size: 13px; color: var(--muted); }

/* ---- download buttons ---------------------------------------------------- */
a.dl-btn {
  display: inline-block; background: var(--accent); color: #fff; text-decoration: none;
  font-size: 12px; font-weight: 600; padding: 6px 14px; border-radius: 8px; transition: background .15s, transform .1s;
}
a.dl-btn:hover { background: var(--accent-dark); }
a.dl-btn:active { transform: translateY(1px); }
a.dl-btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
a.dl-btn-ghost:hover { background: var(--bg); }

/* ---- single-file conversion card ---------------------------------------- */
.single-job-card {
  max-width: 440px; margin: 0 auto; padding: 28px 24px; text-align: center;
  border: 1px solid var(--border); border-radius: 12px; background: var(--bg);
}
.single-job-filename { font-weight: 600; margin: 0 0 16px; word-break: break-word; }
.single-job-track { height: 10px; }
.single-job-status { margin: 14px 0 0; }
.single-job-summary { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.single-job-error { color: var(--err); font-size: 13px; margin: 10px 0 0; }
.single-job-result { margin-top: 6px; }

footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 20px; }
footer a { color: var(--muted); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--border); transition: color .15s, border-color .15s; }
footer a:hover { color: var(--accent); border-color: var(--accent); }

/* ---- auth page ------------------------------------------------------------ */
.auth-body {
  display: flex; flex-direction: column; min-height: 100vh; margin: 0;
  background: radial-gradient(circle at 15% 10%, #eef2ff 0%, var(--bg) 45%), radial-gradient(circle at 85% 90%, #f3e8ff 0%, var(--bg) 45%);
}
.auth-main { margin: auto; padding: 20px; width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 4px; }
.auth-card { text-align: center; box-shadow: 0 12px 28px rgba(26, 34, 51, .09), var(--shadow-sm); }
.auth-brand { justify-content: center; margin-bottom: 20px; }
.auth-card h2 { font-size: 17px; margin: 0 0 20px; font-weight: 700; letter-spacing: -.01em; }
.auth-error { background: #fef2f2; color: var(--err); font-size: 13px; padding: 10px 12px; border-radius: 8px; margin: 0 0 16px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.auth-form label { font-size: 13px; color: var(--ink); font-weight: 600; display: flex; flex-direction: column; gap: 6px; }
.auth-form input {
  font: inherit; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; font-weight: 400;
  transition: border-color .15s, box-shadow .15s;
}
.auth-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(36, 84, 255, .12); }
.auth-submit { width: 100%; margin-top: 4px; }
.auth-footer { text-align: center; }
.auth-footer p { margin: 0; }

/* ---- responsive ----------------------------------------------------------- */
@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding: 16px 20px; }
  .topbar-right { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 10px; }

  main { padding: 20px 14px 60px; gap: 18px; }
  .panel { padding: 18px; border-radius: 12px; }
  .dropzone { padding: 24px 14px; }

  .jobs-table thead { display: none; }
  .jobs-table, .jobs-table tbody, .jobs-table tr, .jobs-table td { display: block; width: 100%; }
  .jobs-table tr {
    border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; padding: 10px 12px; background: var(--card);
  }
  .jobs-table td {
    border-bottom: none; padding: 6px 0; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  }
  .jobs-table td[data-label]::before {
    content: attr(data-label); font-weight: 600; color: var(--muted); font-size: 12px; flex-shrink: 0;
  }
  .jobs-table .progress-cell { flex-direction: column; align-items: stretch; }
  .jobs-table .progress-cell::before { margin-bottom: 4px; }

  .single-job-card { padding: 22px 16px; }
}
