:root {
  --bg: #0b1120;
  --panel: #111827;
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #10b981;
  --blue: #3b82f6;
  --gold: #f59e0b;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
    "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at top right, #172554 0%, var(--bg) 52%);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--muted);
  font-size: 12.5px;
}

code {
  background: rgba(148, 163, 184, 0.16);
  padding: 1px 5px;
  border-radius: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
}

/* Toast */
.toast-container {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(15, 23, 42, 0.94);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.toast.error {
  background: rgba(127, 29, 29, 0.95);
  border-color: rgba(248, 113, 113, 0.7);
}

.toast.success {
  border-color: rgba(52, 211, 153, 0.65);
}

/* Buttons */
.btn {
  border: none;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: transform 0.1s ease, filter 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-lg {
  padding: 13px 20px;
  font-size: 15px;
  width: 100%;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.28);
}

.btn-secondary {
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #dbeafe;
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
}

.text-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #60a5fa;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Header */
.app-header {
  max-width: 1260px;
  margin: 0 auto;
  padding: 18px 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-sub {
  color: var(--muted);
  font-size: 13px;
  margin-top: 2px;
}

.header-pills {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.nav-pill {
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(96, 165, 250, 0.35);
  background: rgba(59, 130, 246, 0.14);
  color: #dbeafe;
  text-decoration: none;
  font-weight: 600;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.nav-pill:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(96, 165, 250, 0.65);
}

.status-pill {
  font-size: 12.5px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(15, 23, 42, 0.8);
}

.status-pill.ready {
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.12);
}

.status-pill.error {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.5);
}

/* Main container */
.studio-view {
  max-width: 1260px;
  margin: 0 auto;
  padding: 6px 20px 36px;
}

/* Batch Banner */
.batch-banner {
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px 18px;
  margin-bottom: 16px;
  backdrop-filter: blur(10px);
}

.batch-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.batch-summary {
  font-weight: 700;
  font-size: 14px;
}

.batch-actions {
  display: flex;
  gap: 8px;
}

.progress-banner-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13.5px;
}

.progress-title-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.state-pill {
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.state-pill.done {
  background: rgba(16, 185, 129, 0.16);
  color: #6ee7b7;
  border-color: rgba(16, 185, 129, 0.45);
}

.progress-pct {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.progress-track {
  height: 7px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  transition: width 0.2s ease;
  border-radius: 999px;
}

.progress-fill.green {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.progress-sub-text {
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(300px, 0.9fr);
  gap: 18px;
  align-items: start;
}

@media (max-width: 920px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.stage-panel,
.panel-card {
  background: rgba(17, 24, 39, 0.88);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 18px;
  backdrop-filter: blur(10px);
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed rgba(96, 165, 250, 0.35);
  border-radius: 14px;
  padding: 46px 24px;
  text-align: center;
  background: rgba(15, 23, 42, 0.55);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.drop-zone.drag-over {
  border-color: var(--primary);
  background: rgba(16, 185, 129, 0.08);
}

.drop-icon {
  font-size: 42px;
  margin-bottom: 10px;
}

.drop-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}

.drop-desc {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
  margin: 0 auto 20px;
  max-width: 560px;
}

.drop-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.upload-terms-hint {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--muted);
}

/* Preview Stage */
.preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.preview-main-title {
  margin: 0;
  font-size: 16.5px;
}

.item-status-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
  background: rgba(148, 163, 184, 0.16);
  color: #cbd5e1;
}

.item-status-pill.repaired {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.45);
}

.item-status-pill.intact {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.45);
}

.item-status-pill.error {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.45);
}

.diagnosis-box {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
  margin-bottom: 12px;
}

.preview-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.preview-current-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  justify-content: center;
}

.active-item-label {
  font-size: 12.5px;
  font-weight: 700;
  color: #93c5fd;
  white-space: nowrap;
}

.preview-file-name {
  font-size: 13px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

.preview-nav-right {
  display: flex;
  gap: 6px;
}

.preview-stage-box {
  position: relative;
  min-height: 300px;
  max-height: 520px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background-color: #090d16;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-video,
.preview-img,
.preview-canvas {
  max-width: 100%;
  max-height: 500px;
  display: block;
  object-fit: contain;
}

.stage-loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(9, 13, 22, 0.82);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.spinner-ring {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.stage-loading-text {
  font-size: 13.5px;
  color: #e2e8f0;
}

.fallback-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

/* Queue List */
.queue-section {
  margin-top: 16px;
}

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  margin-bottom: 8px;
}

.queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(15, 23, 42, 0.65);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}

.queue-item.active {
  border-color: rgba(59, 130, 246, 0.65);
  background: rgba(30, 58, 138, 0.25);
}

.queue-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.queue-icon {
  font-size: 18px;
}

.queue-meta {
  min-width: 0;
}

.queue-name {
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.queue-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.queue-item-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Right Control Panel */
.control-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card h3 {
  margin: 0 0 12px;
  font-size: 15.5px;
}

.field-group {
  margin-bottom: 14px;
}

.field-group:last-child {
  margin-bottom: 0;
}

.field-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.select-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13.5px;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
}

.template-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.export-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.export-note {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.55;
}

.app-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 400;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 18px 20px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.modal-head h3 {
  margin: 0;
  font-size: 16.5px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.terms-list {
  margin: 0;
  padding-left: 18px;
  color: #cbd5e1;
  font-size: 13.5px;
  line-height: 1.7;
}

.terms-list li + li {
  margin-top: 8px;
}

.modal-foot {
  margin-top: 16px;
  text-align: right;
}

/* SEO Guide & FAQ Section */
.seo-guide-section {
  margin-top: 28px;
  padding: 20px;
  background: rgba(17, 24, 39, 0.72);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
}

.seo-guide-head h2 {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
}

.seo-guide-head p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--muted);
}

.seo-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.seo-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 14px;
}

.seo-card h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #e2e8f0;
}

.seo-card p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--muted);
}

@media (max-width: 900px) {
  .seo-guide-grid {
    grid-template-columns: 1fr;
  }
}
