* { box-sizing: border-box; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  margin: 0;
  background: #f4f5f7;
  color: #1f2328;
}

/* 登录页 */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.login-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.08);
  width: 320px;
  text-align: center;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .subtitle { color: #6b7280; font-size: 13px; margin: 0 0 20px; }
.login-card input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}
.login-card button {
  width: 100%;
  padding: 10px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.login-card button:hover { background: #1d4ed8; }
.error-msg { color: #dc2626; font-size: 13px; margin-top: 12px; }

/* 主页面 */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
}
header h1 { font-size: 18px; margin: 0; }
.link-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: 13px;
  text-decoration: underline;
}

main {
  max-width: 720px;
  margin: 24px auto;
  padding: 0 16px;
}

.upload-card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 8px rgba(0, 0, 0, 0.06);
}

.file-drop {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  border: 2px dashed #d0d5dd;
  border-radius: 10px;
  color: #6b7280;
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 20px;
}
.file-drop.dragover { border-color: #2563eb; background: #eff6ff; }

/* 暂存文件列表 */
#pendingList { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.pending-item {
  display: flex; align-items: center; gap: 10px;
  background: #f9fafb; border: 1px solid #e5e7eb;
  border-radius: 8px; padding: 6px 10px;
}
.pending-thumb {
  flex-shrink: 0; width: 48px; height: 48px;
  border-radius: 6px; overflow: hidden;
  background: #e5e7eb; display: flex; align-items: center; justify-content: center;
}
.pending-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pending-thumb-icon { font-size: 11px; font-weight: 700; color: #6b7280; }
.pending-name { flex: 1; font-size: 13px; color: #374151; word-break: break-all; }
.pending-remove {
  flex-shrink: 0; width: 24px; height: 24px;
  background: none; border: none; cursor: pointer;
  color: #9ca3af; font-size: 14px; border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
}
.pending-remove:hover { background: #fee2e2; color: #dc2626; }

.options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.options label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: #374151;
}
.options select {
  padding: 8px 10px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 13px;
}

.upload-card > button[type="submit"] {
  padding: 10px 20px;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
}
.upload-card > button[type="submit"]:hover:not(:disabled) { background: #1d4ed8; }
.upload-card > button[type="submit"]:disabled { background: #93c5fd; cursor: not-allowed; }

#jobList { margin-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.job-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.05);
}
.job-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; word-break: break-all; }
.job-status { font-size: 13px; color: #6b7280; }
.job-error .job-status { color: #dc2626; }
.job-result { display: block; max-width: 100%; max-height: 400px; margin-top: 12px; border-radius: 8px; }
.job-thumb { display: block; max-width: 100%; max-height: 200px; margin-top: 10px; border-radius: 8px; opacity: 0.75; }
.download-link {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  color: #2563eb;
  text-decoration: none;
}
.download-link:hover { text-decoration: underline; }

.compare {
  position: relative;
  width: 100%;
  max-width: 600px;
  aspect-ratio: 1 / 1; /* 真实图片加载后会被覆盖成正确比例 */
  margin-top: 12px;
  border-radius: 8px;
  overflow: hidden;
  background: #1f2328;
}
.compare-caption {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  font-size: 11px;
  color: #fff;
  background: rgba(0, 0, 0, 0.5);
  padding: 3px 8px;
  border-radius: 999px;
  pointer-events: none;
}
.compare-before,
.compare-after {
  position: absolute;
  inset: 0;
  background-size: contain;
  background-position: center;
  background-repeat: no-repeat;
}
.compare-after { clip-path: inset(0 50% 0 0); }
.compare-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}
.compare-handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transform: translateX(-1px);
}
.compare-handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 28px;
  height: 28px;
  background: #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.35);
}

/* 3D preview button */
.preview3d-btn {
  display: inline-block;
  margin-top: 8px;
  margin-left: 10px;
  padding: 5px 13px;
  background: #374151;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
}
.preview3d-btn:hover { background: #1f2937; }

/* 3D preview modal */
.preview3d-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
}
.preview3d-modal {
  width: min(92vw, 960px);
  height: min(88vh, 680px);
  background: #16213e;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6);
}
.preview3d-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 16px;
  color: #e5e7eb;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.preview3d-close {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.preview3d-close:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.preview3d-body {
  flex: 1;
  min-height: 0;
  position: relative;
  background: #16213e;
}
.preview3d-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  font-size: 14px;
}
.preview3d-canvas {
  display: none;
  position: absolute;
  inset: 0;
}
.preview3d-hint {
  flex-shrink: 0;
  padding: 7px 16px;
  color: rgba(255, 255, 255, 0.3);
  font-size: 11px;
  text-align: center;
}
