/* ========================================
   FrameFlow — 序列帧动画工具
   设计语言：干净、专业、轻盈
   ======================================== */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #fafbfc;
  --surface:       #ffffff;
  --border:        #e5e7eb;
  --border-subtle: #f0f1f3;
  --text:          #1a1d23;
  --text-secondary:#6b7280;
  --text-muted:    #9ca3af;
  --accent:        #6366f1;
  --accent-hover:  #4f46e5;
  --accent-subtle: #eef2ff;
  --danger:        #ef4444;
  --success:       #10b981;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow-sm:     0 1px 2px rgba(0,0,0,.04);
  --shadow:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-lg:     0 4px 16px rgba(0,0,0,.08), 0 1px 4px rgba(0,0,0,.04);
  --transition:    150ms ease;
  --font:          -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* --- App Shell --- */
.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
}

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 24px;
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}
.brand-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
}
.pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--accent-subtle);
  color: var(--accent);
  font-weight: 500;
}

/* --- Layout --- */
.main-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

/* --- Sidebar --- */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--text);
}

/* --- Upload Zone --- */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.upload-icon {
  color: var(--accent);
  margin-bottom: 12px;
}
.upload-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
}
.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- File Selected --- */
.file-selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.file-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.file-icon { font-size: 20px; flex-shrink: 0; }
.file-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-size {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* --- Buttons --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-primary.full { width: 100%; }

.btn-text {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.btn-text:hover { background: var(--accent-subtle); }

/* --- Chips --- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 6px 14px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  background: var(--surface);
  transition: all var(--transition);
  user-select: none;
}
.chip:hover { border-color: var(--accent); }
.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Checkboxes --- */
.checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.checkbox-item:hover { border-color: var(--accent); }
.checkbox-item.checked {
  background: var(--accent-subtle);
  border-color: var(--accent);
}
.checkbox-dot {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}
.checkbox-item.checked .checkbox-dot {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-item.checked .checkbox-dot::after {
  content: "✓";
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* --- Settings --- */
.setting-group {
  margin-bottom: 16px;
}
.setting-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Status --- */
.status-bar {
  display: flex;
  align-items: center;
  gap: 12px;
}
.status-track {
  flex: 1;
  height: 4px;
  background: var(--border-subtle);
  border-radius: 4px;
  overflow: hidden;
}
.status-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.4s ease;
  animation: statusPulse 1.5s ease-in-out infinite;
}
@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}
.status-text {
  font-size: 12px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

/* --- Spinner --- */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Preview Area --- */
.preview-area {
  min-height: 400px;
}

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.empty-state h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 16px 0 8px;
}
.empty-icon {
  color: var(--text-muted);
}
.text-muted {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* --- Preview Stage --- */
.preview-stage {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preview-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 3px;
  border: 1px solid var(--border);
}
.preview-tab {
  flex: 1;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all var(--transition);
}
.preview-tab.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.preview-tab:hover:not(.active) { color: var(--text); }

.preview-panels { position: relative; }
.preview-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.preview-panel.active { display: block; }

/* --- Video Wrap --- */
.video-wrap {
  background: #0f0f0f;
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 480px;
}
.video-wrap video {
  width: 100%;
  max-height: 480px;
  object-fit: contain;
}

/* --- Result Wrap --- */
.result-wrap {
  padding: 0;
}
.result-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  /* 棋盘格背景 — 透明区域可见 */
  background-image:
    linear-gradient(45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(-45deg, #e0e0e0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e0e0e0 75%),
    linear-gradient(-45deg, transparent 75%, #e0e0e0 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}
.result-view img {
  max-width: 100%;
  max-height: 480px;
  object-fit: contain;
}
.result-info {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
}
.result-stats {
  display: flex;
  gap: 24px;
  justify-content: center;
}
.stat {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}
.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- Downloads --- */
.downloads {
  margin-top: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.download-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  color: var(--text);
}
.download-btn:hover {
  border-color: var(--accent);
  background: var(--accent-subtle);
}
.download-btn .dl-icon {
  font-size: 16px;
}
.download-btn .dl-label { font-weight: 500; }
.download-btn .dl-type {
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
}

/* --- Error --- */
.error-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.error-icon { font-size: 16px; flex-shrink: 0; }
.error-text { flex: 1; color: var(--danger); }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 24px;
  font-size: 13px;
  font-weight: 500;
  background: var(--text);
  color: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transition: opacity var(--transition), transform var(--transition);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast:not(.show) {
  opacity: 0;
  transform: translateX(-50%) translateY(8px);
}


/* --- Setting Group Extras --- */
.setting-hint {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 6px;
}
.setting-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.setting-label-row .setting-label { margin-bottom: 0; }
.sub-label {
  font-size: 11px;
  color: var(--text-muted);
  margin: 8px 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.auto-readout {
  font-size: 12px;
  color: var(--accent);
  background: var(--accent-subtle);
  border-radius: 6px;
  padding: 6px 10px;
  margin-top: 4px;
}

/* --- Size Input --- */
.size-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.size-input {
  width: 64px;
  padding: 6px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
}
.size-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}
.size-unit {
  font-size: 13px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.size-presets {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.size-preset {
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  background: var(--surface);
  color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}
.size-preset:hover { border-color: var(--accent); }
.size-preset.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* --- Toggle Mini (fps/quality auto mode) --- */
.toggle-mini {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
}
.toggle-mini input { display: none; }
.toggle-track {
  width: 34px;
  height: 18px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition);
}
.toggle-mini input:checked ~ .toggle-track {
  background: var(--accent);
}
.toggle-mini input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(16px);
}
.toggle-text { font-weight: 500; }

/* --- Advanced Panel --- */
.advanced {
  margin-top: 4px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.advanced > summary {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-secondary);
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.advanced > summary::-webkit-details-marker { display: none; }
.advanced > summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform var(--transition);
}
.advanced[open] > summary::before { transform: rotate(90deg); }
.advanced > summary:hover { background: var(--bg); }
.advanced-body {
  padding: 4px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.adv-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-secondary);
}
.adv-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.adv-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.adv-label {
  font-size: 12px;
  color: var(--text-muted);
  width: 80px;
  flex-shrink: 0;
}
.adv-field input[type="number"] {
  width: 72px;
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  color: var(--text);
}
.adv-field input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-subtle);
}
.adv-field input[type="color"] {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  background: var(--surface);
}
.adv-rgb {
  font-size: 12px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}
.adv-note {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 2px;
}


/* --- Disabled Chips --- */
.chips.disabled .chip {
  opacity: 0.35;
  pointer-events: none;
}

/* --- Download Size Tag --- */
.download-btn .dl-size {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 4px;
}

/* --- Responsive --- */
@media (max-width: 860px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
  .sidebar { order: 1; }
  .preview-area { order: 0; }
}
