/* ─────────── 基础 ─────────── */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[v-cloak] { display: none; }

:root {
  --accent: #6366f1;
  --accent-light: #eef2ff;
  --accent-hover: #5558e8;
  --bg: #f5f7fa;
  --bg-card: #ffffff;
  --bg-hover: #f0f1f3;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;
  --border: #e5e7eb;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --status-pending: #94a3b8;
  --status-inProgress: #3b82f6;
  --status-testing: #f59e0b;
  --status-completed: #22c55e;
  --danger: #ef4444;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior: contain;
  min-height: 100vh;
}

/* ─────────── token 缺失页 ─────────── */
.token-missing {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 24px;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
}
.token-card {
  background: #fff; border-radius: 16px; padding: 28px 24px;
  max-width: 360px; width: 100%; text-align: center;
}
.token-card h2 { font-size: 20px; margin-bottom: 12px; }
.token-card p { color: var(--text-secondary); font-size: 14px; margin-bottom: 12px; line-height: 1.6; }
.token-card code {
  background: #f0f1f3; padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 13px;
}
.token-example {
  display: block; padding: 10px; margin: 8px 0 12px;
  background: var(--accent-light); color: var(--accent);
  border-radius: 8px; word-break: break-all; font-size: 12px;
}
.token-card .hint { color: var(--text-tertiary); font-size: 12px; }

/* ─────────── 顶部栏 ─────────── */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.topbar .title {
  flex: 1; font-size: 17px; font-weight: 600; text-align: center;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.topbar .back-btn, .topbar .refresh-btn {
  width: 36px; height: 36px; border: none; background: transparent;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-primary); border-radius: 8px;
  cursor: pointer; transition: background 0.15s;
}
.topbar .back-btn:active, .topbar .refresh-btn:active { background: var(--bg-hover); }
.topbar .refresh-btn.loading svg { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ─────────── 内容区 ─────────── */
.content {
  padding: 16px 16px calc(80px + var(--safe-bottom));
  min-height: calc(100vh - 60px);
}

/* ─────────── 加载/错误 ─────────── */
.loading-screen, .error-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 60vh; gap: 16px; color: var(--text-secondary);
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite;
}

/* ─────────── 统计栏 ─────────── */
.stat-bar {
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--bg-card); border-radius: 12px;
  padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.stat-item { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat-item .num { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-item .lbl { font-size: 12px; color: var(--text-secondary); }

/* ─────────── 搜索框 ─────────── */
.search-bar { margin-bottom: 12px; }
.search-input {
  width: 100%; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-card); font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--accent); }

/* ─────────── 项目列表 ─────────── */
.project-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.project-card {
  background: var(--bg-card); border-radius: 12px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); cursor: pointer;
  transition: transform 0.1s, box-shadow 0.15s;
}
.project-card:active { transform: scale(0.98); }
.proj-name { font-size: 15px; font-weight: 600; margin-bottom: 6px; }
.proj-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.meta-pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: var(--bg-hover); color: var(--text-secondary); font-size: 11px;
}
.meta-pill.pending { background: #fef3c7; color: #b45309; }

.empty {
  list-style: none; text-align: center; padding: 40px 16px;
  color: var(--text-tertiary); font-size: 14px;
}

/* ─────────── 浮动加号按钮 ─────────── */
.fab {
  position: fixed; right: 20px;
  bottom: calc(20px + var(--safe-bottom));
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--accent); color: #fff; border: none;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(99,102,241,0.4); cursor: pointer;
  z-index: 40; transition: transform 0.1s;
}
.fab:active { transform: scale(0.92); }

/* ─────────── 项目详情：Tabs ─────────── */
.detail-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--bg-hover); border-radius: 10px;
  margin-bottom: 16px;
}
.detail-tabs button {
  flex: 1; padding: 10px 12px; border: none; background: transparent;
  color: var(--text-secondary); font-size: 14px; font-weight: 500;
  border-radius: 7px; cursor: pointer; transition: all 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.detail-tabs button.active {
  background: var(--accent); color: #fff; font-weight: 600;
  box-shadow: 0 2px 6px rgba(99,102,241,0.35);
}
.tab-count {
  display: inline-block; min-width: 20px; padding: 0 6px;
  background: rgba(255,255,255,0.25); color: inherit;
  border-radius: 10px; font-size: 11px;
}
.detail-tabs button:not(.active) .tab-count { background: rgba(0,0,0,0.06); }

/* ─────────── Prompt 卡片 ─────────── */
.prompt-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.prompt-card {
  background: var(--bg-card); border-radius: 12px; padding: 14px 16px;
  box-shadow: var(--shadow-sm); position: relative;
}
.prompt-card::before {
  content: ''; position: absolute; left: 0; top: 12px; bottom: 12px;
  width: 3px; border-radius: 0 2px 2px 0;
}
.prompt-card.st-pending::before { background: var(--status-pending); }
.prompt-card.st-inProgress::before { background: var(--status-inProgress); }
.prompt-card.st-testing::before { background: var(--status-testing); }
.prompt-card.st-completed::before { background: var(--status-completed); }

.prompt-content {
  font-size: 14px; line-height: 1.5; color: var(--text-primary);
  white-space: pre-wrap; word-wrap: break-word;
  margin-bottom: 8px;
}
.prompt-images {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px; margin: 8px 0;
}
.prompt-images img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  border-radius: 6px; cursor: zoom-in;
}

.prompt-actions {
  display: flex; align-items: center; gap: 8px;
  padding-top: 8px; border-top: 1px solid var(--border);
}
.status-pill {
  padding: 4px 10px; border-radius: 10px; border: none;
  background: var(--bg-hover); color: var(--text-secondary);
  font-size: 12px; font-weight: 500; cursor: pointer;
}
.status-pill.st-pending { background: #f1f5f9; color: #64748b; }
.status-pill.st-inProgress { background: #dbeafe; color: #1e40af; }
.status-pill.st-testing { background: #fef3c7; color: #b45309; }
.status-pill.st-completed { background: #dcfce7; color: #166534; }
.icon-btn {
  margin-left: auto; width: 28px; height: 28px; border-radius: 6px; border: none;
  background: var(--bg-hover); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn + .icon-btn { margin-left: 4px; }
.icon-btn-danger:active { background: #fee2e2; color: var(--danger); }
.icon-btn:active { background: var(--accent-light); color: var(--accent); }

/* ─────────── 弹窗 ─────────── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  /* iOS Safari 工具栏可见时，100vh 比可视区域高，导致 modal 底部被工具栏挡住。
     用 100dvh（动态视口高度）让遮罩贴合实际可见区域。旧浏览器 fallback 到 100vh。 */
  height: 100vh;
  height: 100dvh;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 100; animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 16px 16px 0 0;
  width: 100%; max-width: 600px; padding: 20px;
  padding-bottom: calc(20px + var(--safe-bottom));
  max-height: 90vh; overflow-y: auto;
  animation: slideUp 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.modal-bottom {}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 17px; font-weight: 600; }
.btn-modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--bg-hover); border: none; color: var(--text-secondary);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.confirm-text { color: var(--text-secondary); margin-bottom: 16px; line-height: 1.6; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 13px; font-weight: 500;
  color: var(--text-secondary); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 12px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #fff; color: var(--text-primary); outline: none;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--accent);
}
.form-textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

.form-actions {
  display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap;
}
.form-actions > .btn { flex: 1; min-width: 80px; }
.form-actions > label.btn { flex: 0 0 auto; min-width: auto; padding: 10px 16px; }

.btn {
  padding: 10px 16px; font-size: 14px; font-weight: 500;
  border: none; border-radius: 8px; cursor: pointer;
  text-align: center; display: inline-block;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary:active:not(:disabled) { background: var(--accent-hover); }
.btn-secondary {
  background: var(--bg-hover); color: var(--text-primary);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-cancel { background: var(--bg-hover); color: var(--text-secondary); }
.btn-danger { background: var(--danger); color: #fff; }

/* 上传图片预览 */
.upload-preview { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px; }
.upload-item { position: relative; }
.upload-item img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; }
.upload-remove {
  position: absolute; top: -6px; right: -6px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff; border: 2px solid #fff;
  font-size: 14px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ─────────── Toast ─────────── */
.toast {
  position: fixed; top: calc(var(--safe-top) + 60px); left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.85); color: #fff;
  padding: 10px 18px; border-radius: 22px; font-size: 14px;
  z-index: 200; max-width: 80%;
  animation: toastIn 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}
.toast-success { background: var(--status-completed); }
.toast-error { background: var(--danger); }

/* ─────────── 图片预览 ─────────── */
.image-preview {
  position: fixed; inset: 0; background: rgba(0,0,0,0.92);
  display: flex; align-items: center; justify-content: center;
  z-index: 300; padding: 20px;
}
.image-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
