:root {
  --bg: #0b0c10;
  --panel: #13151c;
  --panel-2: #1a1d27;
  --border: rgba(255, 255, 255, 0.09);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #7c5cff;
  --accent-2: #22d3ee;
  --ppt: #f97316;
  --ok: #34d399;
  --danger: #f43f5e;
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 20% -10%, rgba(124, 92, 255, 0.16), transparent 45%),
    radial-gradient(circle at 80% 0%, rgba(34, 211, 238, 0.1), transparent 40%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 28px;
  border-bottom: 1px solid var(--border);
  background: rgba(11, 12, 16, 0.82);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
}

.brand-mark {
  color: var(--accent-2);
  font-size: 18px;
}

.badge {
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  background: rgba(124, 92, 255, 0.18);
  color: #c4b5fd;
  border: 1px solid rgba(124, 92, 255, 0.35);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-link {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 8px;
}

.nav-link:hover {
  color: var(--text);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
}

.credits-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

.user-email {
  font-size: 12px;
  color: var(--muted);
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  max-width: 1200px;
  margin: 0 auto;
  padding: 26px 20px 64px;
}

.hero {
  text-align: center;
  margin-bottom: 18px;
}

.hero h1 {
  margin: 0 0 10px;
  font-size: clamp(26px, 3.8vw, 40px);
  letter-spacing: -0.025em;
}

.hero h1 span {
  background: linear-gradient(90deg, #a78bfa, #22d3ee);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  margin: 0 auto;
  max-width: 680px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}

/* Instant samples bar */
.samples-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
}

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

.samples-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.sample-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.sample-pill:hover {
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.08);
}

.sample-pill small {
  color: var(--muted);
  font-size: 11px;
}

.controls-card,
.stage-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 20px;
}

.gpu-paused-banner {
  margin-bottom: 12px;
  padding: 9px 12px;
  border-radius: 9px;
  background: rgba(249, 115, 22, 0.12);
  border: 1px solid rgba(249, 115, 22, 0.35);
  color: #fed7aa;
  font-size: 12.5px;
  line-height: 1.45;
}

.otp-sent-hint {
  margin: 0 0 4px;
  font-size: 12.5px;
  color: #6ee7b7;
}

.dropzone {
  border: 1.5px dashed rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  padding: 22px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(255, 255, 255, 0.015);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 122px;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--accent);
  background: rgba(124, 92, 255, 0.08);
}

.drop-icon {
  font-size: 24px;
  margin-bottom: 6px;
  color: var(--accent-2);
}

.drop-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
}

.drop-hint {
  font-size: 12px;
  color: var(--muted);
}

.thumb-preview {
  max-height: 150px;
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

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

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

.mode-btn,
.tab-btn {
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  cursor: pointer;
}

.mode-btn.active,
.tab-btn.active {
  color: var(--text);
  border-color: rgba(124, 92, 255, 0.7);
  background: rgba(124, 92, 255, 0.18);
}

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

.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}

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

.btn-sm {
  padding: 6px 11px;
  font-size: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #7c5cff, #5b3df5);
  color: #fff;
}

.btn-accent {
  background: rgba(34, 211, 238, 0.16);
  border-color: rgba(34, 211, 238, 0.45);
  color: #a5f3fc;
}

.btn-ppt {
  background: rgba(249, 115, 22, 0.18);
  border-color: rgba(249, 115, 22, 0.5);
  color: #fed7aa;
}

.btn-ghost {
  background: var(--panel-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.16);
  border-color: rgba(244, 63, 94, 0.45);
  color: #fda4af;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel-2);
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.dot.streaming {
  background: var(--accent-2);
  box-shadow: 0 0 8px var(--accent-2);
}

.dot.done {
  background: var(--ok);
}

/* Theme recolor bar */
.theme-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
}

.theme-label {
  font-size: 12px;
  color: var(--muted);
}

.theme-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.theme-chip:hover {
  border-color: rgba(124, 92, 255, 0.6);
}

.theme-chip i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.inspector-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid rgba(34, 211, 238, 0.35);
}

.insp-tag {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(34, 211, 238, 0.15);
  color: #67e8f9;
}

.insp-field {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.insp-field input[type="text"] {
  width: 210px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
}

.insp-field input[type="number"] {
  width: 64px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
}

.insp-field input[type="color"] {
  width: 28px;
  height: 26px;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.insp-field input[type="range"] {
  width: 76px;
}

.stage-body {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.layers-panel {
  width: 205px;
  flex-shrink: 0;
  background: #0f1118;
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-height: 520px;
  overflow: hidden;
}

.layers-header {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.layers-list {
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.layer-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 7px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  border: 1px solid transparent;
}

.layer-item:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.layer-item.active {
  background: rgba(124, 92, 255, 0.18);
  border-color: rgba(124, 92, 255, 0.5);
  color: var(--text);
}

.layer-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-eye {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
}

.stage-canvas {
  flex: 1;
  min-width: 0;
  position: relative;
  border-radius: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  background:
    linear-gradient(45deg, #171922 25%, transparent 25%),
    linear-gradient(-45deg, #171922 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #171922 75%),
    linear-gradient(-45deg, transparent 75%, #171922 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
  background-color: #11131a;
  min-height: 500px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(11, 12, 16, 0.86);
  backdrop-filter: blur(6px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
}

.spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent-2);
  animation: spin 0.85s linear infinite;
}

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

.progress-title {
  font-size: 16px;
  font-weight: 600;
}

.progress-sub {
  max-width: 440px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.progress-timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--accent-2);
}

.compare-wrap {
  position: relative;
  width: 100%;
  height: 520px;
  overflow: hidden;
  transform-origin: center center;
  transition: transform 0.15s ease;
}

.layer {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.layer-original img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.layer-svg {
  clip-path: inset(0 0 0 50%);
}

.compare-wrap.svg-only .layer-original,
.compare-wrap.svg-only .compare-slider,
.compare-wrap.svg-only .slider-line,
.compare-wrap.svg-only .layer-tag {
  display: none;
}

.compare-wrap.svg-only .layer-svg {
  clip-path: none;
}

.svg-mount {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.svg-mount svg {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  background: #ffffff;
  border-radius: 8px;
}

.compare-wrap.svg-only .svg-mount svg [data-editable="1"]:hover {
  outline: 2px dashed rgba(34, 211, 238, 0.85);
  outline-offset: 2px;
  cursor: move;
}

.compare-wrap.svg-only .svg-mount svg [data-selected="1"] {
  outline: 2.5px solid #7c5cff !important;
  outline-offset: 2px;
}

.inline-text-input {
  position: absolute;
  z-index: 25;
  background: #0f172a;
  color: #ffffff;
  border: 2px solid var(--accent-2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 14px;
  min-width: 160px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.layer-tag {
  position: absolute;
  top: 12px;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(11, 12, 16, 0.75);
  border: 1px solid var(--border);
  pointer-events: none;
}

.tag-left {
  left: 12px;
}

.tag-right {
  right: 12px;
}

.compare-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  z-index: 5;
}

.slider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: var(--accent-2);
  pointer-events: none;
  z-index: 4;
}

.code-view {
  width: 100%;
  height: 520px;
  margin: 0;
  padding: 18px;
  overflow: auto;
  background: #0d0f15;
  color: #c4b5fd;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  line-height: 1.5;
}

.stage-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.edit-hint {
  color: #a5f3fc;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(0, 0, 0, 0.68);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 26px;
}

.modal-wide {
  max-width: 780px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
}

.modal-card h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.modal-desc {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: var(--muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.auth-form input {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
}

.modal-footnote {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.price-tier {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.price-tier.featured {
  border-color: rgba(124, 92, 255, 0.7);
  background: rgba(124, 92, 255, 0.1);
}

.tier-badge {
  position: absolute;
  top: -10px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}

.tier-name {
  font-weight: 600;
  font-size: 15px;
}

.tier-price {
  font-size: 28px;
  font-weight: 700;
}

.tier-price span {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
}

.price-tier ul {
  margin: 0;
  padding-left: 18px;
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2433;
  border: 1px solid rgba(34, 211, 238, 0.45);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 50;
}

@media (max-width: 780px) {
  .stage-body {
    flex-direction: column;
  }
  .layers-panel {
    width: 100%;
    max-height: 160px;
  }
}
