/* ── 基础样式 ─────────────────────────────────────────────────────────── */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Helvetica, Arial, sans-serif;
  background: #f5f7fb;
  color: #1f2937;
}

h1 { margin: 0; font-size: 22px; }
h2 { margin: 0; font-size: 16px; }
.muted { color: #6b7280; margin: 0; }
.hint { font-size: 12px; }
.link { color: #2563eb; text-decoration: none; font-size: 14px; }
.link:hover { text-decoration: underline; }
.link.active { color: #111827; font-weight: 700; }

/* ── 顶部导航 ─────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
  padding: 14px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}
.topbar .brand { margin: 0; font-size: 17px; }
.topnav { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }

/* ── 页面容器 ─────────────────────────────────────────────────────────── */
.container { max-width: 960px; margin: 0 auto; padding: 24px; }
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card { max-width: 380px; }

/* ── 表单控件 ─────────────────────────────────────────────────────────── */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
input[type=text], input[type=password], select, textarea {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .15);
}
button {
  background: #2563eb;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button:hover:not(:disabled) { background: #1d4ed8; }
button:disabled { background: #93c5fd; cursor: not-allowed; }

.error {
  background: #fee2e2;
  color: #991b1b;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}

/* ── 上传页：拖拽区与预览 ─────────────────────────────────────────────── */
.drop-zone {
  border: 2px dashed #c7d2fe;
  border-radius: 12px;
  background: #f8faff;
  padding: 30px 20px;
  text-align: center;
  color: #374151;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  user-select: none;
}
.drop-zone:hover,
.drop-zone.drag-over { border-color: #2563eb; background: #eff6ff; }
.drop-icon { font-size: 32px; line-height: 1.2; }
.drop-title { font-weight: 600; margin-top: 6px; }
.drop-hint { color: #6b7280; font-size: 13px; margin-top: 4px; }

.preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.preview:empty { display: none; }
.thumb {
  position: relative;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #374151;
  user-select: none;
}
.thumb img {
  width: 100%;
  height: 110px;
  object-fit: contain;
  border-radius: 6px;
  background: #f3f4f6;
}
.thumb span {
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.thumb small { font-size: 11px; }
.thumb-del {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, .15);
  z-index: 2;
}
.thumb-del:hover { background: #dc2626; }

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
}
.options-row > label { flex: 1 1 160px; }
.options-row .option-check {
  flex: 0 0 auto;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  cursor: pointer;
}
.options-row .option-check input { margin: 0; }

/* ── 结果页 ───────────────────────────────────────────────────────────── */
.error-list { display: flex; flex-direction: column; gap: 6px; }
.error-item {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
}
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.result-card {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.result-thumb { display: block; }
.result-thumb img {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: contain;
  image-rendering: pixelated;
  border-radius: 8px;
  background: #f3f4f6;
}
.result-thumb:hover img { outline: 2px solid #2563eb; outline-offset: -2px; }
.result-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.result-meta { font-size: 12px; color: #6b7280; }
.download-bar { display: flex; gap: 8px; margin-top: auto; }
.btn-dl {
  flex: 1;
  text-align: center;
  padding: 7px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  background: #2563eb;
  color: #fff;
}
.btn-dl:hover { background: #1d4ed8; }
.btn-dl-thumb { background: #059669; }
.btn-dl-thumb:hover { background: #047857; }

/* ── 错误页 ───────────────────────────────────────────────────────────── */
.error-page { align-items: flex-start; }
.error-page h1 { font-size: 44px; margin: 0; color: #111827; }

.actions { margin-top: 4px; }
.actions a {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  background: #e5e7eb;
  color: #111827;
  text-decoration: none;
}
.actions a:hover { background: #d1d5db; }

/* ── 转换中的遮罩 ─────────────────────────────────────────────────────── */
.busy-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, .55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.busy-overlay[hidden] { display: none; }
.busy-box {
  background: #fff;
  border-radius: 12px;
  padding: 28px 40px;
  text-align: center;
  box-shadow: 0 16px 48px rgba(15, 23, 42, .25);
}
.busy-title { font-weight: 600; margin-top: 4px; }
.busy-hint { color: #6b7280; font-size: 13px; margin-top: 4px; }
.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 12px;
  border: 4px solid #dbeafe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 600px) {
  .container { padding: 16px; }
  .card { padding: 20px; }
  .topbar { padding: 12px 16px; }
  .options-row > label { flex: 1 1 100%; }
  .options-row .option-check { flex: 1 1 100%; padding-bottom: 0; }
}
