:root {
  --bg: #0b1120;
  --panel: #111827;
  --panel-border: rgba(255, 255, 255, 0.1);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #f59e0b;
  --primary-dark: #d97706;
  --green: #10b981;
  --blue: #3b82f6;
  --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, #1e1b4b 0%, var(--bg) 52%);
  color: var(--text);
}

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

.hidden {
  display: none !important;
}

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

/* 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.95);
  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: 7px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn-primary {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #0f172a;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.26);
}

.btn-secondary {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.btn-gold {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  width: 100%;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

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

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.85);
  border-bottom: 1px solid var(--panel-border);
}

.brand-title {
  margin: 0;
  font-size: 19px;
  font-weight: 800;
}

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

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

.nav-pill {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.38);
  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.28);
  border-color: rgba(96, 165, 250, 0.7);
}

.status-pill {
  font-size: 12px;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.status-pill.ready {
  border-color: rgba(52, 211, 153, 0.5);
  color: #a7f3d0;
}

/* Layout */
.studio-view {
  max-width: 1300px;
  margin: 0 auto;
  padding: 16px 20px 30px;
}

.drop-zone {
  min-height: 410px;
  border: 2px dashed rgba(251, 191, 36, 0.36);
  border-radius: 18px;
  background: rgba(17, 24, 39, 0.88);
  padding: 34px 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 13px;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.drop-zone.dragover {
  border-color: var(--primary);
  background: rgba(245, 158, 11, 0.09);
}

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

.drop-zone .btn-lg {
  width: auto;
  min-width: 230px;
}

.drop-icon {
  font-size: 44px;
}

.drop-title {
  font-size: 19px;
  font-weight: 800;
}

.drop-desc {
  font-size: 13.5px;
  color: var(--muted);
  max-width: 560px;
  line-height: 1.65;
}

.feature-highlights {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 820px;
}

.highlight-chip {
  text-align: left;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.highlight-chip strong {
  font-size: 13px;
  color: #fde68a;
}

.highlight-chip span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* Batch Bar & Progress */
.tag-progress-banner {
  background: rgba(17, 24, 39, 0.94);
  border: 1px solid rgba(245, 158, 11, 0.36);
  border-radius: 14px;
  padding: 12px 15px;
  margin-bottom: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.25);
}

.batch-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.batch-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 700;
}

.batch-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

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

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

.state-pill {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(59, 130, 246, 0.22);
  border: 1px solid rgba(96, 165, 250, 0.55);
  color: #bfdbfe;
}

.state-pill.done {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(52, 211, 153, 0.55);
  color: #a7f3d0;
}

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

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

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #f59e0b, #fbbf24);
  transition: width 0.15s ease;
}

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

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

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 355px;
  gap: 16px;
  align-items: start;
}

.stage-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.preview-header-block {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preview-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.preview-main-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

.stage-meta-pills {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kind-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(245, 158, 11, 0.18);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

.kind-pill.muted-pill {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

.preview-tools-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
}

.toggle-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.canvas-wrap {
  background: #020617;
  border: 1.5px solid rgba(251, 191, 36, 0.28);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.canvas-stage-inner {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  min-height: 220px;
}

.stage-canvas {
  max-width: 100%;
  max-height: 66vh;
  width: auto;
  height: auto;
  border-radius: 8px;
  touch-action: none;
  cursor: grab;
}

.stage-canvas.dragging {
  cursor: grabbing;
}

.video-controls {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.video-seek {
  flex: 1;
}

.video-time {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.stage-hint-chip {
  font-size: 12px;
  color: var(--muted);
  width: 100%;
  text-align: left;
  line-height: 1.5;
}

/* Thumbnail Strip */
.thumb-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px;
}

.thumb-item {
  flex: 0 0 auto;
  min-width: 112px;
  max-width: 146px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 7px 9px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--text);
  text-align: left;
}

.thumb-item.active {
  border-color: var(--primary);
  background: rgba(245, 158, 11, 0.14);
}

.thumb-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  color: #fde68a;
  font-weight: 700;
}

.thumb-name {
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.panel-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12.5px;
  color: #cbd5e1;
  font-weight: 600;
}

.text-input,
.select-input {
  width: 100%;
  background: rgba(2, 6, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
}

.text-input:focus,
.select-input:focus {
  border-color: var(--primary);
}

.preset-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11.5px;
  cursor: pointer;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: #fde68a;
}

.prefix-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  padding: 5px 10px;
  cursor: pointer;
}

.emoji-btn.active {
  border-color: var(--primary);
  background: rgba(245, 158, 11, 0.22);
  color: #fde68a;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.style-pill {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 8px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.style-pill.wide {
  grid-column: span 2;
}

.style-pill.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--primary);
  color: #fef3c7;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.color-swatches {
  display: flex;
  align-items: center;
  gap: 7px;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  cursor: pointer;
  padding: 0;
}

.swatch.active {
  border-color: #f59e0b;
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.45);
}

.color-input {
  width: 34px;
  height: 26px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
}

.split-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.segmented-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.seg-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--muted);
  border-radius: 8px;
  padding: 6px 4px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}

.seg-btn.active {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--primary);
  color: #fef3c7;
}

.anchor-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.anchor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.custom-anchor-hint {
  font-size: 11px;
  color: #38bdf8;
  font-weight: 600;
}

.anchor-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.anchor-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 7px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.anchor-btn.active {
  background: rgba(245, 158, 11, 0.22);
  border-color: var(--primary);
  color: #fef3c7;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-head {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}

.slider-val {
  color: #fde68a;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
}

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

.mini-actions-row .btn {
  flex: 1;
}

.export-inline-progress {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: 10px;
  padding: 10px;
}

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

.upload-terms-hint {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

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

/* SEO Cards */
.seo-guide-section {
  margin-top: 26px;
  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);
}

.app-footer {
  margin-top: 18px;
  padding: 8px 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.76);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  max-height: 86vh;
  overflow-y: auto;
  border-radius: 16px;
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

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

.modal-close-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: var(--text);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.6;
  color: #cbd5e1;
}

.terms-list {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.terms-list strong {
  color: var(--text);
}

.modal-foot {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

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

  .feature-highlights,
  .seo-guide-grid {
    grid-template-columns: 1fr;
  }

  .studio-view {
    padding: 12px;
  }

  .app-header {
    padding: 12px;
  }
}
