.up-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  height: calc(100vh - 120px);
}

.up-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.up-title h2 { margin: 0 0 0.25rem; font-size: 1.5rem; }
.up-title p { margin: 0; color: #64748b; font-size: 0.95rem; }

.up-actions { display: flex; gap: 0.75rem; }

.up-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: 8px; font-weight: 600; cursor: pointer;
  border: none; font-size: 0.95rem; transition: 0.2s;
}
.up-btn.lg { padding: 0.7rem 1.4rem; font-size: 1rem; }
.up-btn.primary { background: #7c5cff; color: #fff; }
.up-btn.primary:hover { background: #6b4de0; }
.up-btn.primary:disabled { opacity: 0.5; cursor: not-allowed; }
.up-btn.secondary { background: #f1f5f9; color: #334155; }
.up-btn.secondary:hover { background: #e2e8f0; }

.up-workspace {
  flex: 1;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.04);
  border: 1px solid #e2e8f0;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Upload Zone */
.up-upload {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: #f8fafc;
}
.up-upload.dragover { background: #f1f5f9; border: 2px dashed #7c5cff; }
.up-upload-inner { text-align: center; max-width: 300px; }
.up-upload-inner svg { width: 48px; height: 48px; color: #94a3b8; margin-bottom: 1rem; }
.up-upload-inner h3 { margin: 0 0 0.5rem; font-size: 1.2rem; }
.up-upload-inner p { color: #64748b; margin: 0 0 1.5rem; }

/* Setup Zone (превью + контролы) */
.up-setup {
  flex: 1;
  display: flex;
  gap: 2rem;
  padding: 2rem;
  overflow: auto;
}
.up-setup-preview {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  background: #f1f5f9;
  border-radius: 12px;
  padding: 1.5rem;
  min-width: 0;
}
.up-setup-preview img {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  object-fit: contain;
}
.up-src-info { font-size: 0.9rem; color: #64748b; font-weight: 500; }

.up-setup-controls {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}
.up-field { display: flex; flex-direction: column; gap: 0.6rem; }
.up-field-label { font-size: 0.95rem; font-weight: 600; color: #334155; }
.up-val { color: #7c5cff; font-variant-numeric: tabular-nums; }

.up-engine { display: flex; flex-direction: column; gap: 0.6rem; }
.up-radio { cursor: pointer; }
.up-radio input { display: none; }
.up-radio-btn {
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.75rem 1rem; border-radius: 10px;
  border: 2px solid #e2e8f0; background: #fff; transition: 0.15s;
}
.up-radio-btn b { font-size: 0.95rem; color: #334155; }
.up-radio-btn small { font-size: 0.8rem; color: #94a3b8; line-height: 1.3; }
.up-radio input:checked + .up-radio-btn {
  border-color: #7c5cff; background: #f5f3ff;
}
.up-radio input:checked + .up-radio-btn b { color: #7c5cff; }

#factorInput { width: 100%; }
.up-target { font-size: 0.85rem; color: #64748b; font-variant-numeric: tabular-nums; }

.up-hint { font-size: 0.8rem; color: #94a3b8; line-height: 1.4; margin: 0; }

/* Loading Zone */
.up-loading {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: #fff; z-index: 10;
}
.up-loading .spinner {
  width: 40px; height: 40px; border: 4px solid #f1f5f9; border-top-color: #7c5cff;
  border-radius: 50%; animation: spin 1s linear infinite; margin-bottom: 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }
.up-loading h3 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.up-loading p { margin: 0; color: #64748b; font-size: 0.9rem; }

/* Result Zone */
.up-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}
.up-result-info {
  padding: 1rem;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
  color: #334155;
  font-weight: 500;
  background: #fdfdfd;
}
.up-result-view {
  flex: 1;
  overflow: auto;
  padding: 2rem;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: #f1f5f9;
}
canvas#resultCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  background: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  border-radius: 4px;
}

@media (max-width: 800px) {
  .up-setup { flex-direction: column; }
  .up-setup-controls { width: 100%; }
}
