:root {
  --bg: #0b0d12;
  --surface: #131720;
  --surface-2: #1c2230;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2f8;
  --text-muted: #8b95a7;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --emerald: #10b981;
  --emerald-bg: rgba(16, 185, 129, 0.12);
  --emerald-border: rgba(16, 185, 129, 0.34);
  --amber: #f59e0b;
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

.hidden { display: none !important; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* Header */
.topbar {
  min-height: 58px;
  padding: 8px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, #3b82f6, #10b981);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

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

.brand-title {
  font-weight: 700;
  font-size: 15px;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.privacy-pill:hover {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.55);
}

.pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--emerald);
  box-shadow: 0 0 8px var(--emerald);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
  color: var(--text);
  background: transparent;
  white-space: nowrap;
}

.btn-lg {
  padding: 10px 18px;
  font-size: 13.5px;
  border-radius: 10px;
}

.btn-xs {
  padding: 4px 9px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #252d3f; border-color: var(--border-strong); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.06); }

.lang-btn {
  border-color: var(--border);
  padding: 5px 9px;
  font-size: 11.5px;
  font-weight: 600;
}

.link-btn {
  background: none;
  border: none;
  color: #60a5fa;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

.link-btn:hover { text-decoration: underline; }

/* Status bar */
.status-bar {
  background: #131c2e;
  border-bottom: 1px solid rgba(59, 130, 246, 0.25);
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.status-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #bfdbfe;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(96, 165, 250, 0.25);
  border-top-color: #60a5fa;
  animation: spin 0.8s linear infinite;
}

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

.progress-track {
  width: 240px;
  height: 6px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #3b82f6, #10b981);
  transition: width 0.2s ease;
}

/* Main 3-column studio */
.studio {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 274px 1fr 292px;
}

.panel {
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.panel-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card {
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
}

.card-title {
  margin: 0 0 10px 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.card-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-head-row .card-title { margin-bottom: 0; }

/* Segmented controls */
.seg-group {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 4px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Sliders & Inputs */
.control-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}

.control-row:last-child { margin-bottom: 0; }

.control-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.control-head .val {
  color: #93c5fd;
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}

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

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  font-size: 12.5px;
  padding: 2px 0;
}

.switch-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.small-label { font-size: 11.5px; color: var(--text-muted); }

.select-input {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 12px;
}

.select-sm { width: auto; padding: 4px 8px; font-size: 11.5px; }

/* Center Stage & Privacy-First Empty State */
.stage {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 30%, #151c2a 0%, #0a0c11 75%);
  overflow-y: auto;
}

.empty-state {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 24px;
}

.drop-zone {
  max-width: 680px;
  width: 100%;
  padding: 34px 30px 26px;
  border-radius: 20px;
  border: 1.5px dashed rgba(255, 255, 255, 0.16);
  background: rgba(19, 23, 32, 0.78);
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
}

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

.hero-privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 99px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: #6ee7b7;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 14px;
}

.drop-zone h1 {
  margin: 0 0 10px 0;
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.2px;
}

.hero-desc {
  margin: 0 auto 20px;
  max-width: 540px;
  color: var(--text-muted);
  font-size: 13.5px;
  line-height: 1.6;
}

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

.trust-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  text-align: left;
}

.trust-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.trust-icon { font-size: 18px; margin-bottom: 6px; }
.trust-title { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; color: #e2e8f0; }
.trust-desc { font-size: 11.5px; color: var(--text-muted); line-height: 1.48; }

.drop-hint {
  margin-top: 16px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.desktop-tip {
  margin-top: 10px;
  font-size: 11.5px;
}

.desktop-tip a {
  color: #60a5fa;
  text-decoration: none;
}

.desktop-tip a:hover { text-decoration: underline; }

/* Active Canvas */
.canvas-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 10px 16px;
  gap: 8px;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.toolbar-group { display: flex; gap: 6px; }

.chip-btn {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 11px;
  border-radius: 99px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.chip-btn:hover { color: var(--text); }

.chip-btn.active {
  background: rgba(59, 130, 246, 0.18);
  border-color: rgba(96, 165, 250, 0.55);
  color: #93c5fd;
}

.toolbar-meta {
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
  font-size: 12px;
}

.viewport-wrap {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
}

.preview-frame {
  position: relative;
  max-height: 100%;
  max-width: 100%;
  height: 100%;
  aspect-ratio: 9 / 16;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.08);
  cursor: grab;
  user-select: none;
}

.preview-frame.dragging { cursor: grabbing; }

.preview-frame canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.onion-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.38;
  pointer-events: none;
  mix-blend-mode: screen;
}

.drag-hint {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.62);
  color: rgba(255, 255, 255, 0.85);
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 11px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.preview-frame:hover .drag-hint { opacity: 1; }

.stage-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.shortcut-hint { font-size: 11px; color: var(--text-muted); }

/* Right Inspector */
.muted-center {
  color: var(--text-muted);
  text-align: center;
  padding: 32px 12px;
  line-height: 1.5;
}

.inspector-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}

.item-title { font-weight: 600; font-size: 13px; word-break: break-all; }
.item-meta { margin-top: 3px; font-size: 11.5px; color: var(--text-muted); }

.toggle-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 11.5px;
  cursor: pointer;
  flex-shrink: 0;
}

.warning-box {
  margin-top: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fcd34d;
  font-size: 11.5px;
}

.badge {
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 99px;
  font-size: 11px;
}

.source-picker-wrap {
  position: relative;
  width: 100%;
  border-radius: 8px;
  overflow: hidden;
  background: #090b10;
  border: 1px solid var(--border);
}

.source-picker-wrap img { width: 100%; height: auto; display: block; }
.candidate-overlay { position: absolute; inset: 0; }

.cand-box {
  position: absolute;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 4px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.cand-box:hover { border-color: #60a5fa; background: rgba(59, 130, 246, 0.15); }
.cand-box.selected { border-color: var(--emerald); background: rgba(16, 185, 129, 0.12); }

.cand-tag {
  position: absolute;
  top: -1px;
  left: -1px;
  background: rgba(15, 23, 42, 0.85);
  color: #fff;
  font-size: 10px;
  padding: 1px 5px;
  border-bottom-right-radius: 4px;
  white-space: nowrap;
}

.cand-box.selected .cand-tag {
  background: var(--emerald);
  color: #032117;
  font-weight: 700;
}

.small-hint { font-size: 11px; color: var(--text-muted); line-height: 1.45; }

/* Bottom Filmstrip */
.filmstrip-bar {
  height: 138px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.filmstrip-head {
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.filmstrip-stats { font-size: 12px; color: var(--text-muted); }
.filmstrip-controls { display: flex; align-items: center; gap: 6px; }

.filmstrip-track {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  overflow-x: auto;
  overflow-y: hidden;
}

.thumb-card {
  position: relative;
  height: 86px;
  width: 60px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid transparent;
  background: #090b10;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s, opacity 0.15s;
}

.thumb-card:hover { transform: translateY(-2px); }
.thumb-card.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.35); }
.thumb-card.disabled { opacity: 0.35; filter: grayscale(0.8); }
.thumb-card canvas { width: 100%; height: 100%; display: block; object-fit: cover; }

.thumb-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.84));
  color: #fff;
  font-size: 9.5px;
  padding: 8px 4px 2px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.thumb-warn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--amber);
  color: #000;
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal {
  width: 480px;
  max-width: 92vw;
  max-height: 88vh;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-wide { width: 560px; }

.modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

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

.icon-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 6px;
}

.icon-close:hover { color: var(--text); }

.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-desc { margin: 0 0 14px 0; color: var(--text-muted); line-height: 1.55; }

.priv-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.priv-item {
  padding: 11px 13px;
  border-radius: 10px;
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.priv-item strong {
  display: block;
  color: #6ee7b7;
  margin-bottom: 3px;
  font-size: 13px;
}

.priv-item span {
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
}

.export-video-wrap {
  width: 100%;
  max-height: 52vh;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.export-video-wrap video { max-height: 52vh; max-width: 100%; }

.export-privacy-bar {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--emerald-bg);
  border: 1px solid var(--emerald-border);
  color: #6ee7b7;
  font-size: 12px;
}

.export-meta { margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.export-actions { margin-top: 14px; display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(255, 255, 255, 0.16);
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 12.5px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
  z-index: 200;
}

@media (max-width: 960px) {
  html, body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .studio { grid-template-columns: 1fr; }
  .panel { border: none; border-bottom: 1px solid var(--border); }
  .trust-grid { grid-template-columns: 1fr; }
  .viewport-wrap { min-height: 460px; }
  .preview-frame { height: 460px; }
}
