:root {
  --orange: #f59e0b;
  --orange-deep: #ea580c;
  --orange-soft: #fbbf24;
  --bg: #fff7ed;
  --text: #1f2937;
  --muted: #6b7280;
  --muted-light: #9ca3af;
  --border: #e5e7eb;
  --card: #ffffff;
  --shadow: 0 10px 25px rgba(0, 0, 0, 0.06);
  --shadow-orange: 0 10px 25px rgba(251, 146, 60, 0.22);
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 60%);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: #dc2626; font-size: 13px; margin: 10px 0 0; }
.hint { color: var(--muted-light); font-size: 12px; margin: 6px 0 0; }

/* ---------- 登录 ---------- */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 10%, rgba(251, 191, 36, 0.35), transparent 40%),
    radial-gradient(circle at 85% 5%, rgba(251, 146, 60, 0.28), transparent 42%),
    linear-gradient(180deg, #fff7ed 0%, #ffffff 100%);
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border-radius: 24px;
  padding: 32px 24px 26px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-logo {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 24px;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24 0%, #fb923c 100%);
  box-shadow: var(--shadow-orange);
}

.login-card h1 { margin: 0 0 6px; font-size: 22px; }
.login-card p { margin: 0 0 22px; font-size: 13px; }

.login-card input {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0 14px;
  font-size: 16px;
  outline: none;
  margin-bottom: 12px;
  background: #fff;
}

.login-card input:focus {
  border-color: var(--orange-soft);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18);
}

/* ---------- 主框架 ---------- */
.app-shell { max-width: 480px; margin: 0 auto; min-height: 100vh; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  background: linear-gradient(135deg, #fbbf24 0%, #fb923c 100%);
  color: #fff;
  box-shadow: 0 6px 20px rgba(251, 146, 60, 0.2);
}

.app-title { font-size: 20px; font-weight: 700; letter-spacing: 0.3px; }
.app-subtitle { font-size: 12px; opacity: 0.9; margin-top: 2px; }

.app-header .btn-ghost {
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.38);
  color: #fff;
}

.app-main { padding: 18px 16px 32px; }
.view { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.view-title { margin: 8px 0 16px; font-size: 22px; }

.back-link {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  margin: 2px 0 10px;
  cursor: pointer;
}

/* ---------- 首页入口 ---------- */
.entry-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 18px;
  margin-bottom: 14px;
  background: #fff;
  border: 1px solid rgba(251, 191, 36, 0.18);
  border-radius: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.entry-card:active { transform: scale(0.98); }
.entry-card-secondary { background: linear-gradient(135deg, #fff7ed 0%, #ffffff 100%); }

.entry-icon {
  width: 46px;
  height: 46px;
  flex: 0 0 46px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24 0%, #fb923c 100%);
}

.entry-body { flex: 1; min-width: 0; }
.entry-body strong { display: block; font-size: 17px; margin-bottom: 3px; }
.entry-body small { display: block; color: var(--muted); font-size: 12px; line-height: 1.45; }
.entry-arrow { color: var(--orange); font-size: 18px; font-weight: 700; }

/* ---------- 表单 ---------- */
.segmented {
  display: flex;
  padding: 4px;
  background: #f3f4f6;
  border-radius: 14px;
  margin-bottom: 16px;
}

.segmented button {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.active {
  background: #fff;
  color: var(--orange-deep);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
}

.form-card {
  background: #fff;
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(251, 191, 36, 0.12);
}

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 7px; }

.field input,
.field select {
  width: 100%;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 0 13px;
  font-size: 16px;
  color: var(--text);
  background: #fff;
  outline: none;
  appearance: none;
}

.field input:focus,
.field select:focus {
  border-color: var(--orange-soft);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.16);
}

.advanced { margin: 4px 0 16px; }
.advanced summary {
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  padding: 6px 0;
  list-style: none;
}
.advanced summary::-webkit-details-marker { display: none; }
.advanced summary::before { content: "＋ "; color: var(--orange); font-weight: 700; }
.advanced[open] summary::before { content: "－ "; }
.advanced-fields { padding-top: 8px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

.btn:active { transform: scale(0.98); }
.btn-block { width: 100%; height: 50px; }

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, #fbbf24 0%, #fb923c 50%, #f59e0b 100%);
  box-shadow: var(--shadow-orange);
}

.btn-secondary {
  color: var(--orange-deep);
  background: linear-gradient(135deg, #fff7ed 0%, #fef3c7 100%);
  border: 1px solid rgba(251, 146, 60, 0.22);
}

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

.btn-small { height: 34px; padding: 0 14px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: 0.55; pointer-events: none; }

/* ---------- 结果 ---------- */
.status-card {
  background: #fff;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}

.status-row { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  background: #f3f4f6;
  color: var(--muted);
}

.progress {
  height: 5px;
  background: #f3f4f6;
  border-radius: 99px;
  overflow: hidden;
  margin-top: 12px;
}

.progress-bar {
  height: 100%;
  width: 12%;
  border-radius: 99px;
  background: linear-gradient(90deg, #fbbf24, #fb923c);
  transition: width 0.4s ease;
}

.result-images { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }

.result-images.horizontal {
  flex-direction: row;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  gap: 12px;
  padding: 2px 2px 8px;
  margin: 0 -2px;
  scrollbar-width: none;
}

.result-images.horizontal::-webkit-scrollbar { display: none; }

.result-images.horizontal .image-card {
  flex: 0 0 86%;
  max-width: 380px;
  scroll-snap-align: center;
}

.result-images.horizontal .image-card.full img {
  max-height: 56vh;
}

.carousel-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 4px 0 10px;
}

.carousel-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(251, 146, 60, 0.25);
  background: #fff;
  color: var(--orange-deep);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(251, 146, 60, 0.12);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.carousel-btn:disabled {
  opacity: 0.35;
  cursor: default;
  box-shadow: none;
}

.carousel-count {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.image-card {
  background: #fff;
  border-radius: 18px;
  padding: 10px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(251, 191, 36, 0.12);
}

.image-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  padding: 2px 4px 9px;
}

.image-label strong { color: var(--text); font-size: 14px; }
.image-open-hint { color: var(--orange); font-size: 11px; font-weight: 600; }
.image-link { display: block; cursor: zoom-in; }
.image-link:active { opacity: 0.92; }
.image-card img { display: block; width: 100%; border-radius: 12px; }
.image-card.full img { max-height: 62vh; object-fit: contain; background: #fff7ed; }
.image-download { color: var(--orange); font-size: 13px; font-weight: 600; text-decoration: none; }

#result { padding-bottom: 104px; }

.result-actions {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: row;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid rgba(251, 191, 36, 0.2);
  box-shadow: 0 -8px 24px rgba(251, 146, 60, 0.08);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.result-actions .btn {
  flex: 1;
  width: auto;
  height: 46px;
  border-radius: 14px;
}

.save-hint {
  text-align: center;
  color: var(--muted-light);
  font-size: 12px;
  margin: 10px 0 0;
}

/* ---------- 历史 ---------- */
.history-list { display: flex; flex-direction: column; gap: 12px; }

.history-item {
  background: #fff;
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(251, 191, 36, 0.12);
}

.history-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.history-title { font-size: 15px; font-weight: 700; }
.history-time { font-size: 11px; color: var(--muted-light); margin-top: 3px; }
.history-input { font-size: 13px; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.history-actions { display: flex; gap: 8px; margin-top: 12px; }
.history-actions .btn { flex: 1; height: 36px; font-size: 13px; border-radius: 11px; }

.history-thumb {
  width: 54px;
  height: 72px;
  border-radius: 10px;
  object-fit: cover;
  background: #fff7ed;
  border: 1px solid rgba(251, 191, 36, 0.2);
}

.status-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: var(--muted);
  white-space: nowrap;
}
.status-pill.done { background: #ecfdf5; color: #059669; }
.status-pill.failed { background: #fef2f2; color: #dc2626; }
.status-pill.running { background: #fffbeb; color: #d97706; }

.empty {
  text-align: center;
  color: var(--muted-light);
  font-size: 13px;
  padding: 40px 0;
}

@media (min-width: 520px) {
  .app-main { padding: 22px 22px 40px; }
}
