* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", Arial, sans-serif; color: #1f2330; background: #f5f6fa; }

.topbar { display: flex; align-items: center; gap: 24px; padding: 12px 24px; background: #ffffff; border-bottom: 1px solid #e6e8ef; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; font-size: 18px; color: #2d3748; }
.steps { display: flex; gap: 12px; }
.step { padding: 4px 10px; border-radius: 999px; background: #eef0f6; color: #5a6378; font-size: 13px; }
.step.active { background: #4f46e5; color: #fff; }
.actions { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.auto-switch { font-size: 13px; color: #5a6378; display: inline-flex; gap: 6px; align-items: center; }

main { padding: 20px; }
.page { display: none; }
.page.active { display: block; }

.card { background: #fff; border: 1px solid #e6e8ef; border-radius: 14px; padding: 24px; max-width: 920px; margin: 0 auto; }
.card h2 { margin: 0 0 4px; }
.hint { color: #6b7280; margin: 0 0 16px; }
.muted { color: #9aa1b2; font-size: 12px; }

.dropzone { border: 2px dashed #c8cee0; border-radius: 12px; padding: 28px; text-align: center; cursor: pointer; background: #fafbff; transition: .15s; }
.dropzone:hover, .dropzone.drag { border-color: #4f46e5; background: #f1f0ff; }
.dz-icon { font-size: 28px; margin-bottom: 8px; color: #4f46e5; }

.url-input { margin-top: 18px; }
.url-input label { font-size: 13px; color: #4b5563; display: block; margin-bottom: 6px; }
.url-input textarea { width: 100%; padding: 10px 12px; border: 1px solid #d6dae6; border-radius: 8px; font-family: monospace; font-size: 13px; resize: vertical; }

.file-list { list-style: none; padding: 0; margin: 16px 0 0; max-height: 240px; overflow: auto; border: 1px solid #eef0f6; border-radius: 8px; }
.file-list li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid #f0f2f8; font-size: 13px; }
.file-list li:last-child { border-bottom: none; }
.file-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .badge { padding: 2px 8px; border-radius: 4px; background: #eef0f6; color: #5a6378; font-size: 11px; }
.file-list .badge.url { background: #ecfdf5; color: #047857; }
.file-list .badge.local { background: #eff6ff; color: #1d4ed8; }
.file-list .state { font-size: 12px; }
.file-list .state.ok { color: #059669; }
.file-list .state.err { color: #dc2626; }
.file-list .state.pending { color: #9aa1b2; }
.file-list button.del { border: none; background: transparent; color: #b91c1c; cursor: pointer; }

.footer-row { display: flex; align-items: center; gap: 16px; margin-top: 18px; }
.status { color: #6b7280; font-size: 13px; }

button { font: inherit; cursor: pointer; }
.primary { background: #4f46e5; color: #fff; border: none; padding: 10px 18px; border-radius: 8px; font-weight: 600; }
.primary:disabled { background: #b7b9c9; cursor: not-allowed; }
.ghost { background: transparent; color: #4b5563; border: 1px solid #d6dae6; padding: 8px 14px; border-radius: 8px; }
.ghost:hover { background: #f3f4f6; }

.bar { display: flex; align-items: center; gap: 12px; padding: 8px 16px; background: #fff; border: 1px solid #e6e8ef; border-radius: 12px; margin-bottom: 16px; }
.bar .spacer { flex: 1; }

/* === 网格：每行 5 个，块宽为浏览器宽度 1/5 === */
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; padding: 0 12px; }

.tile { background: #fff; border: 1px solid #e6e8ef; border-radius: 12px; overflow: hidden; cursor: pointer; transition: .15s; display: flex; flex-direction: column; }
.tile:hover { border-color: #4f46e5; box-shadow: 0 4px 14px rgba(79,70,229,.12); }
.tile.running { border-color: #f59e0b; }
.tile.done { border-color: #10b981; }
.tile.error { border-color: #ef4444; }

.tile-head { padding: 8px 12px; background: #f9fafb; border-bottom: 1px solid #eef0f6; display: flex; align-items: center; gap: 8px; }
.tile-title { font-weight: 700; color: #1f2330; }
.tile-status { margin-left: auto; font-size: 11px; padding: 2px 6px; border-radius: 4px; background: #eef0f6; color: #5a6378; }
.tile-status.running { background: #fef3c7; color: #92400e; }
.tile-status.done { background: #d1fae5; color: #065f46; }
.tile-status.error { background: #fee2e2; color: #991b1b; }

.tile-body { aspect-ratio: 16 / 9; background: #f3f4f6; display: flex; align-items: center; justify-content: center; padding: 8px; overflow: hidden; }
.tile-body img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.tile-body .prompt-text { font-size: 11px; line-height: 1.45; color: #4b5563; max-height: 100%; overflow: auto; padding: 4px 6px; }
.tile-body .spinner { width: 26px; height: 26px; border: 3px solid #e5e7eb; border-top-color: #4f46e5; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.tile-foot { padding: 6px 8px; background: #fff; border-top: 1px solid #eef0f6; font-size: 11px; line-height: 1.4; color: #4b5563; max-height: 80px; overflow: auto; }

.bottom-actions { display: flex; justify-content: center; padding: 24px 0; }

[hidden] { display: none !important; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1f2330; color: #fff; padding: 10px 18px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.18); font-size: 13px; }

.lightbox { position: fixed; inset: 0; background: rgba(15, 18, 30, .88); display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 100; padding: 32px; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 80vh; box-shadow: 0 18px 50px rgba(0,0,0,.5); border-radius: 8px; background: #fff; cursor: default; }
.lightbox-caption { color: #d7dbe8; font-size: 13px; max-width: 80vw; margin-top: 14px; line-height: 1.5; max-height: 12vh; overflow: auto; text-align: center; cursor: default; }
.lightbox-close { position: absolute; top: 18px; right: 22px; width: 38px; height: 38px; border-radius: 50%; border: none; background: rgba(255,255,255,.12); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.lightbox-close:hover { background: rgba(255,255,255,.22); }
.tile.done .tile-body { cursor: zoom-in; }
